mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-26 23:51:57 +00:00
DiskLayout problem drawing boxes
This commit is contained in:
parent
e502d2cfae
commit
12b8db6bdc
@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Mon Jun 01 19:29:14 AEST 2015
|
#Tue Jun 02 11:34:38 AEST 2015
|
||||||
build.number=627
|
build.number=629
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Color;
|
||||||
|
import java.awt.Cursor;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
import java.awt.event.InputEvent;
|
import java.awt.event.InputEvent;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.Scrollable;
|
import javax.swing.Scrollable;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
@ -17,7 +23,7 @@ import com.bytezone.diskbrowser.disk.SectorType;
|
|||||||
import com.bytezone.diskbrowser.gui.DiskLayoutPanel.LayoutDetails;
|
import com.bytezone.diskbrowser.gui.DiskLayoutPanel.LayoutDetails;
|
||||||
import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent;
|
import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent;
|
||||||
|
|
||||||
class DiskLayoutImage extends JComponent implements Scrollable
|
class DiskLayoutImage extends JPanel implements Scrollable
|
||||||
{
|
{
|
||||||
static final Cursor crosshairCursor = new Cursor (Cursor.CROSSHAIR_CURSOR);
|
static final Cursor crosshairCursor = new Cursor (Cursor.CROSSHAIR_CURSOR);
|
||||||
FormattedDisk disk;
|
FormattedDisk disk;
|
||||||
@ -82,8 +88,8 @@ class DiskLayoutImage extends JComponent implements Scrollable
|
|||||||
super.paintComponent (g);
|
super.paintComponent (g);
|
||||||
|
|
||||||
// why doesn't linux do this?
|
// why doesn't linux do this?
|
||||||
g.setColor (Color.WHITE);
|
// g.setColor (Color.WHITE);
|
||||||
g.fillRect (0, 0, getWidth (), getHeight ());
|
// g.fillRect (0, 0, getWidth (), getHeight ());
|
||||||
|
|
||||||
if (disk == null)
|
if (disk == null)
|
||||||
return;
|
return;
|
||||||
@ -128,7 +134,6 @@ class DiskLayoutImage extends JComponent implements Scrollable
|
|||||||
SectorType type = disk.getSectorType (blockNo);
|
SectorType type = disk.getSectorType (blockNo);
|
||||||
int offset = (bw - 4) / 2 + 1;
|
int offset = (bw - 4) / 2 + 1;
|
||||||
|
|
||||||
// Rectangle rect = new Rectangle (x, y, bw, bh);
|
|
||||||
Rectangle rect = new Rectangle (x, y, bw, bh);
|
Rectangle rect = new Rectangle (x, y, bw, bh);
|
||||||
// System.out.printf ("Rect: %4d %4d %4d %4d%n", x, y, bw, bh);
|
// System.out.printf ("Rect: %4d %4d %4d %4d%n", x, y, bw, bh);
|
||||||
|
|
||||||
@ -144,7 +149,12 @@ class DiskLayoutImage extends JComponent implements Scrollable
|
|||||||
if (type.colour != Color.WHITE)
|
if (type.colour != Color.WHITE)
|
||||||
{
|
{
|
||||||
g.setColor (type.colour);
|
g.setColor (type.colour);
|
||||||
|
// this is weird, the retina OSX screen needs the second fillRect
|
||||||
|
// see also DiskLegendPanel.paint()
|
||||||
|
if (false)
|
||||||
g.fillRect (rect.x + 2, rect.y + 2, rect.width - 3, rect.height - 3);
|
g.fillRect (rect.x + 2, rect.y + 2, rect.width - 3, rect.height - 3);
|
||||||
|
else
|
||||||
|
g.fillRect (rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw an indicator in free blocks
|
// draw an indicator in free blocks
|
||||||
@ -164,8 +174,9 @@ class DiskLayoutImage extends JComponent implements Scrollable
|
|||||||
|
|
||||||
private Color getContrastColor (SectorType type)
|
private Color getContrastColor (SectorType type)
|
||||||
{
|
{
|
||||||
if (type.colour == Color.WHITE || type.colour == Color.YELLOW || type.colour == Color.PINK
|
if (type.colour == Color.WHITE || type.colour == Color.YELLOW
|
||||||
|| type.colour == Color.CYAN || type.colour == Color.ORANGE)
|
|| type.colour == Color.PINK || type.colour == Color.CYAN
|
||||||
|
|| type.colour == Color.ORANGE)
|
||||||
return Color.BLACK;
|
return Color.BLACK;
|
||||||
return Color.WHITE;
|
return Color.WHITE;
|
||||||
}
|
}
|
||||||
@ -177,15 +188,15 @@ class DiskLayoutImage extends JComponent implements Scrollable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int
|
public int getScrollableUnitIncrement (Rectangle visibleRect, int orientation,
|
||||||
getScrollableUnitIncrement (Rectangle visibleRect, int orientation, int direction)
|
int direction)
|
||||||
{
|
{
|
||||||
return orientation == SwingConstants.HORIZONTAL ? bw : bh;
|
return orientation == SwingConstants.HORIZONTAL ? bw : bh;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int
|
public int getScrollableBlockIncrement (Rectangle visibleRect, int orientation,
|
||||||
getScrollableBlockIncrement (Rectangle visibleRect, int orientation, int direction)
|
int direction)
|
||||||
{
|
{
|
||||||
return orientation == SwingConstants.HORIZONTAL ? bw * 4 : bh * 10;
|
return orientation == SwingConstants.HORIZONTAL ? bw * 4 : bh * 10;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,12 @@ class DiskLegendPanel extends JPanel
|
|||||||
|
|
||||||
// draw the colour
|
// draw the colour
|
||||||
g.setColor (type.colour);
|
g.setColor (type.colour);
|
||||||
g.fillRect (x + 2, y + 2, layoutDetails.block.width - 3, layoutDetails.block.height - 3);
|
if (false)
|
||||||
|
g.fillRect (x + 2, y + 2, layoutDetails.block.width - 3,
|
||||||
|
layoutDetails.block.height - 3);
|
||||||
|
else
|
||||||
|
g.fillRect (x + 1, y + 1, layoutDetails.block.width - 2,
|
||||||
|
layoutDetails.block.height - 2);
|
||||||
|
|
||||||
// draw the text
|
// draw the text
|
||||||
g.setColor (Color.BLACK);
|
g.setColor (Color.BLACK);
|
||||||
@ -84,13 +89,13 @@ class DiskLegendPanel extends JPanel
|
|||||||
int val = disk.falseNegativeBlocks ();
|
int val = disk.falseNegativeBlocks ();
|
||||||
if (val > 0)
|
if (val > 0)
|
||||||
{
|
{
|
||||||
g.drawString (val + " empty sector" + (val == 1 ? "" : "s") + " marked as unavailable",
|
g.drawString (val + " empty sector" + (val == 1 ? "" : "s")
|
||||||
10, y);
|
+ " marked as unavailable", 10, y);
|
||||||
y += lineHeight;
|
y += lineHeight;
|
||||||
}
|
}
|
||||||
val = disk.falsePositiveBlocks ();
|
val = disk.falsePositiveBlocks ();
|
||||||
if (val > 0)
|
if (val > 0)
|
||||||
g.drawString (val + " used sector" + (val == 1 ? "" : "s") + " marked as available", 10,
|
g.drawString (val + " used sector" + (val == 1 ? "" : "s") + " marked as available",
|
||||||
y);
|
10, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user