mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-29 11:49:29 +00:00
replaced retina test with one that works
This commit is contained in:
parent
3a4db5fc31
commit
2bec5a83f6
@ -6,6 +6,7 @@ import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
@ -31,6 +32,7 @@ class DiskLayoutImage extends JPanel implements Scrollable, RedoListener
|
||||
private boolean showFreeSectors;
|
||||
private final DiskLayoutSelection selectionHandler = new DiskLayoutSelection ();
|
||||
private boolean redo;
|
||||
private boolean retinaTest;
|
||||
|
||||
// set defaults (used until a real disk is set)
|
||||
private int bw = 30;
|
||||
@ -38,7 +40,7 @@ class DiskLayoutImage extends JPanel implements Scrollable, RedoListener
|
||||
private int gw = 8;
|
||||
private int gh = 35;
|
||||
|
||||
private boolean retina;
|
||||
// private boolean retina;
|
||||
|
||||
public DiskLayoutImage ()
|
||||
{
|
||||
@ -64,6 +66,10 @@ class DiskLayoutImage extends JPanel implements Scrollable, RedoListener
|
||||
setPreferredSize (new Dimension (gw * bw + 1, gh * bh + 1));
|
||||
selectionHandler.setSelection (null);
|
||||
|
||||
Graphics2D g = (Graphics2D) this.getGraphics ();
|
||||
retinaTest = g.getFontRenderContext ().getTransform ()
|
||||
.equals (AffineTransform.getScaleInstance (2.0, 2.0));
|
||||
|
||||
repaint ();
|
||||
}
|
||||
|
||||
@ -78,11 +84,11 @@ class DiskLayoutImage extends JPanel implements Scrollable, RedoListener
|
||||
repaint ();
|
||||
}
|
||||
|
||||
public void setRetina (boolean value)
|
||||
{
|
||||
retina = value;
|
||||
repaint ();
|
||||
}
|
||||
// public void setRetina (boolean value)
|
||||
// {
|
||||
// retina = value;
|
||||
// repaint ();
|
||||
// }
|
||||
|
||||
void setSelection (List<DiskAddress> sectors)
|
||||
{
|
||||
@ -155,7 +161,7 @@ class DiskLayoutImage extends JPanel implements Scrollable, RedoListener
|
||||
g.setColor (type.colour);
|
||||
// this is weird, the retina OSX screen needs the second fillRect
|
||||
// see also DiskLegendPanel.paint()
|
||||
if (retina)
|
||||
if (retinaTest)
|
||||
g.fillRect (rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2);
|
||||
else
|
||||
g.fillRect (rect.x + 2, rect.y + 2, rect.width - 3, rect.height - 3);
|
||||
|
@ -31,7 +31,7 @@ class DiskLayoutPanel extends JPanel
|
||||
//, FontChangeListener
|
||||
{
|
||||
private static final int SIZE = 15; // basic unit of a display block
|
||||
private static final String PREFS_RETINA = "retina";
|
||||
// private static final String PREFS_RETINA = "retina";
|
||||
|
||||
private final Preferences prefs;
|
||||
private final MenuHandler mh;
|
||||
@ -73,7 +73,7 @@ class DiskLayoutPanel extends JPanel
|
||||
add (sp, BorderLayout.CENTER);
|
||||
add (legendPanel, BorderLayout.SOUTH);
|
||||
|
||||
mh.retinaItem.setAction (new RetinaAction (this));
|
||||
// mh.retinaItem.setAction (new RetinaAction (this));
|
||||
}
|
||||
|
||||
// public DiskLayoutPanel (FormattedDisk disk)
|
||||
@ -122,11 +122,11 @@ class DiskLayoutPanel extends JPanel
|
||||
repaint ();
|
||||
}
|
||||
|
||||
public void setRetina (boolean value)
|
||||
{
|
||||
image.setRetina (value);
|
||||
legendPanel.setRetina (value);
|
||||
}
|
||||
// public void setRetina (boolean value)
|
||||
// {
|
||||
// image.setRetina (value);
|
||||
// legendPanel.setRetina (value);
|
||||
// }
|
||||
|
||||
public void setHex (boolean hex)
|
||||
{
|
||||
@ -257,14 +257,14 @@ class DiskLayoutPanel extends JPanel
|
||||
@Override
|
||||
public void quit (Preferences arg0)
|
||||
{
|
||||
prefs.putBoolean (PREFS_RETINA, mh.retinaItem.isSelected ());
|
||||
// prefs.putBoolean (PREFS_RETINA, mh.retinaItem.isSelected ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restore (Preferences arg0)
|
||||
{
|
||||
mh.retinaItem.setSelected (prefs.getBoolean (PREFS_RETINA, false));
|
||||
setRetina (mh.retinaItem.isSelected ());
|
||||
// mh.retinaItem.setSelected (prefs.getBoolean (PREFS_RETINA, false));
|
||||
// setRetina (mh.retinaItem.isSelected ());
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
@ -4,6 +4,8 @@ import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
@ -13,6 +15,7 @@ import com.bytezone.common.Platform.FontType;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
import com.bytezone.diskbrowser.disk.SectorType;
|
||||
import com.bytezone.diskbrowser.gui.DiskLayoutPanel.LayoutDetails;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
class DiskLegendPanel extends JPanel
|
||||
{
|
||||
@ -22,7 +25,8 @@ class DiskLegendPanel extends JPanel
|
||||
private FormattedDisk disk;
|
||||
private LayoutDetails layoutDetails;
|
||||
private final Font font;
|
||||
private boolean retina;
|
||||
// private boolean retina;
|
||||
private boolean retinaTest;
|
||||
|
||||
public DiskLegendPanel ()
|
||||
{
|
||||
@ -34,14 +38,19 @@ class DiskLegendPanel extends JPanel
|
||||
{
|
||||
this.disk = disk;
|
||||
layoutDetails = details;
|
||||
|
||||
Graphics2D g = (Graphics2D) this.getGraphics ();
|
||||
retinaTest = g.getFontRenderContext ().getTransform ()
|
||||
.equals (AffineTransform.getScaleInstance (2.0, 2.0));
|
||||
|
||||
repaint ();
|
||||
}
|
||||
|
||||
public void setRetina (boolean value)
|
||||
{
|
||||
retina = value;
|
||||
repaint ();
|
||||
}
|
||||
// public void setRetina (boolean value)
|
||||
// {
|
||||
// retina = value;
|
||||
// repaint ();
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize ()
|
||||
@ -61,6 +70,7 @@ class DiskLegendPanel extends JPanel
|
||||
|
||||
int count = 0;
|
||||
int lineHeight = 20;
|
||||
System.out.println (Utility.test ((Graphics2D) g));
|
||||
|
||||
for (SectorType type : disk.getSectorTypeList ())
|
||||
{
|
||||
@ -73,7 +83,7 @@ class DiskLegendPanel extends JPanel
|
||||
|
||||
// draw the colour
|
||||
g.setColor (type.colour);
|
||||
if (retina)
|
||||
if (retinaTest)
|
||||
g.fillRect (x + 1, y + 1, layoutDetails.block.width - 2,
|
||||
layoutDetails.block.height - 2);
|
||||
else
|
||||
|
@ -64,7 +64,7 @@ public class MenuHandler
|
||||
JMenuItem colourQuirksItem = new JCheckBoxMenuItem ("Colour quirks");
|
||||
JMenuItem monochromeItem = new JCheckBoxMenuItem ("Monochrome");
|
||||
JMenuItem debuggingItem = new JCheckBoxMenuItem ("Debugging");
|
||||
JMenuItem retinaItem = new JCheckBoxMenuItem ("Retina display");
|
||||
// JMenuItem retinaItem = new JCheckBoxMenuItem ("Retina display");
|
||||
|
||||
public MenuHandler (Preferences prefs)
|
||||
{
|
||||
@ -123,7 +123,7 @@ public class MenuHandler
|
||||
formatMenu.add (colourQuirksItem);
|
||||
formatMenu.add (monochromeItem);
|
||||
formatMenu.add (debuggingItem);
|
||||
formatMenu.add (retinaItem);
|
||||
// formatMenu.add (retinaItem);
|
||||
|
||||
helpMenu.add (new JMenuItem (new EnvironmentAction ()));
|
||||
|
||||
|
@ -1,27 +0,0 @@
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JMenuItem;
|
||||
|
||||
public class RetinaAction extends AbstractAction
|
||||
{
|
||||
private final DiskLayoutPanel owner;
|
||||
|
||||
public RetinaAction (DiskLayoutPanel owner)
|
||||
{
|
||||
super ("Retina display");
|
||||
putValue (Action.SHORT_DESCRIPTION, "use hi resolution graphics");
|
||||
// putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt G"));
|
||||
// putValue (Action.MNEMONIC_KEY, KeyEvent.VK_G);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
owner.setRetina (((JMenuItem) e.getSource ()).isSelected ());
|
||||
}
|
||||
}
|
@ -1,9 +1,12 @@
|
||||
package com.bytezone.diskbrowser.utilities;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
public class Utility
|
||||
{
|
||||
// not used - it doesn't work with Oracle's JDK
|
||||
public static boolean hasRetinaDisplay ()
|
||||
{
|
||||
Object obj =
|
||||
@ -16,4 +19,10 @@ public class Utility
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean test (Graphics2D g)
|
||||
{
|
||||
return g.getFontRenderContext ().getTransform ()
|
||||
.equals (AffineTransform.getScaleInstance (2.0, 2.0));
|
||||
}
|
||||
}
|
@ -117,7 +117,7 @@ class Cell implements Comparable<Cell>, Value
|
||||
switch (type)
|
||||
{
|
||||
case LABEL:
|
||||
return justify (label, colWidth, format);
|
||||
return justify (label, colWidth, cellFormat);
|
||||
|
||||
case REPEATING_CHARACTER:
|
||||
return justify (repeat, colWidth, format);
|
||||
|
Loading…
Reference in New Issue
Block a user