windows changes

This commit is contained in:
Denis Molony 2018-08-16 10:09:26 +10:00
parent 462744dce1
commit aa7b57dca8
6 changed files with 18 additions and 34 deletions

View File

@ -122,8 +122,6 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
menuHandler.duplicateItem.setAction (duplicateAction); menuHandler.duplicateItem.setAction (duplicateAction);
menuHandler.closeTabItem.setAction (closeTabAction); menuHandler.closeTabItem.setAction (closeTabAction);
// final QuitAction quitAction = Platform.setQuit (this, prefs, menuHandler.fileMenu);
addQuitListener (menuHandler); addQuitListener (menuHandler);
addQuitListener (catalogPanel); addQuitListener (catalogPanel);
addQuitListener (this); addQuitListener (this);
@ -131,18 +129,12 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
if (Desktop.isDesktopSupported ()) if (Desktop.isDesktopSupported ())
{ {
Desktop desktop = Desktop.getDesktop (); Desktop desktop = Desktop.getDesktop ();
if (false)
{
System.out.println ("Enums:");
for (Desktop.Action a : Desktop.Action.values ())
System.out.printf ("%s is%s supported%n", a.toString (),
(desktop.isSupported (a) ? "" : " not"));
}
if (desktop.isSupported (Desktop.Action.APP_ABOUT)) if (desktop.isSupported (Desktop.Action.APP_ABOUT))
desktop.setAboutHandler (e -> JOptionPane.showMessageDialog (null, desktop.setAboutHandler (e -> JOptionPane.showMessageDialog (null,
"Author - Denis Molony\nGitHub - https://github.com/dmolony/DiskBrowser", "Author - Denis Molony\nGitHub - https://github.com/dmolony/DiskBrowser",
"About DiskBrowser", JOptionPane.INFORMATION_MESSAGE)); "About DiskBrowser", JOptionPane.INFORMATION_MESSAGE));
if (desktop.isSupported (Desktop.Action.APP_QUIT_HANDLER)) if (desktop.isSupported (Desktop.Action.APP_QUIT_HANDLER))
desktop.setQuitHandler ( (e, r) -> fireQuitEvent ()); desktop.setQuitHandler ( (e, r) -> fireQuitEvent ());
else else
@ -182,7 +174,6 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
{ {
JPanel panel = new JPanel (new BorderLayout ()); JPanel panel = new JPanel (new BorderLayout ());
panel.setBackground (Color.WHITE); panel.setBackground (Color.WHITE);
// panel.setOpaque (true);
panel.setBorder (BorderFactory.createTitledBorder (title)); panel.setBorder (BorderFactory.createTitledBorder (title));
panel.add (pane); panel.add (pane);
add (panel, location); add (panel, location);
@ -199,7 +190,6 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
@Override @Override
public void quit (Preferences preferences) public void quit (Preferences preferences)
{ {
// windowSaver = new WindowSaver (prefs, this, "DiskBrowser");
windowSaver.saveWindow (); windowSaver.saveWindow ();
} }

View File

@ -38,7 +38,9 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
setPreferredSize (new Dimension (240 + 1, 525 + 1)); setPreferredSize (new Dimension (240 + 1, 525 + 1));
addMouseListener (new MyMouseListener ()); addMouseListener (new MyMouseListener ());
setBackground (backgroundColor); setBackground (backgroundColor);
setOpaque (true);
// setOpaque (true);
// https://stackoverflow.com/questions/2451990/setopaquetrue-false-java
addKeyListener (new MyKeyListener ()); addKeyListener (new MyKeyListener ());
} }
@ -131,9 +133,8 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
private void drawBlock (Graphics2D g, SectorType type, int x, int y, boolean flagFree, private void drawBlock (Graphics2D g, SectorType type, int x, int y, boolean flagFree,
boolean selected) boolean selected)
{ {
// draw block
g.setColor (type.colour); g.setColor (type.colour);
g.fillRect (x + offset, y + offset, width, height); g.fillRect (x + 1, y + 1, blockWidth - 1, blockHeight - 1);
if (flagFree || selected) if (flagFree || selected)
{ {

View File

@ -47,12 +47,10 @@ class DiskLayoutPanel extends JPanel
legendPanel = new DiskLegendPanel (); legendPanel = new DiskLegendPanel ();
setBackground (Color.WHITE); setBackground (Color.WHITE);
setOpaque (true);
sp = new JScrollPane (diskLayoutImage, VERTICAL_SCROLLBAR_ALWAYS, sp = new JScrollPane (diskLayoutImage, VERTICAL_SCROLLBAR_ALWAYS,
HORIZONTAL_SCROLLBAR_ALWAYS); HORIZONTAL_SCROLLBAR_ALWAYS);
sp.setBackground (Color.WHITE); sp.setBackground (Color.WHITE);
sp.setOpaque (true);
sp.setColumnHeaderView (horizontalRuler); sp.setColumnHeaderView (horizontalRuler);
sp.setRowHeaderView (verticalRuler); sp.setRowHeaderView (verticalRuler);
sp.setBorder (null); sp.setBorder (null);

View File

@ -64,7 +64,7 @@ class DiskLegendPanel extends DiskPanel
// draw block // draw block
g.setColor (type.colour); g.setColor (type.colour);
g.fillRect (x + offset, y + offset, width, height); g.fillRect (x + 1, y + 1, blockWidth - 1, blockHeight - 1);
// draw text // draw text
g.setColor (Color.BLACK); g.setColor (Color.BLACK);

View File

@ -1,8 +1,6 @@
package com.bytezone.diskbrowser.gui; package com.bytezone.diskbrowser.gui;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -13,12 +11,10 @@ public class DiskPanel extends JPanel
{ {
FormattedDisk formattedDisk; FormattedDisk formattedDisk;
LayoutDetails layoutDetails; LayoutDetails layoutDetails;
boolean isRetina; // boolean isRetina;
int blockWidth = 30; // default int blockWidth = 30; // default
int blockHeight = 15; // default int blockHeight = 15; // default
int width; // int offset;
int height;
int offset;
int centerOffset; int centerOffset;
Color backgroundColor = new Color (0xE0, 0xE0, 0xE0); Color backgroundColor = new Color (0xE0, 0xE0, 0xE0);
@ -30,15 +26,14 @@ public class DiskPanel extends JPanel
blockWidth = layoutDetails.block.width; blockWidth = layoutDetails.block.width;
blockHeight = layoutDetails.block.height; blockHeight = layoutDetails.block.height;
Graphics2D g = (Graphics2D) this.getGraphics ();
if (g != null) // panel might not be showing
isRetina = g.getFontRenderContext ().getTransform ()
.equals (AffineTransform.getScaleInstance (2.0, 2.0));
width = blockWidth - (isRetina ? 2 : 3) + 1;
height = blockHeight - (isRetina ? 2 : 3) + 1;
offset = isRetina ? 1 : 2;
centerOffset = (blockWidth - 4) / 2 + 1; centerOffset = (blockWidth - 4) / 2 + 1;
// Graphics2D g = (Graphics2D) this.getGraphics ();
// if (g != null) // panel might not be showing
// isRetina = g.getFontRenderContext ().getTransform ()
// .equals (AffineTransform.getScaleInstance (2.0, 2.0));
// offset = isRetina ? 1 : 2;
// centerOffset = (blockWidth - 4) / 2 + 1;
} }
} }

View File

@ -36,7 +36,7 @@ class ScrollRuler extends JComponent
// set defaults until setLayout is called // set defaults until setLayout is called
if (orientation == HORIZONTAL) if (orientation == HORIZONTAL)
setPreferredSize (new Dimension (0, HEIGHT)); // width/height setPreferredSize (new Dimension (0, HEIGHT)); // width/height
else else
setPreferredSize (new Dimension (WIDTH, 0)); setPreferredSize (new Dimension (WIDTH, 0));
} }
@ -96,7 +96,7 @@ class ScrollRuler extends JComponent
String format; String format;
int offset; int offset;
if (layoutDetails.block.width <= 15) if (layoutDetails.block.width <= 16)
{ {
format = isHex ? "%1X" : "%1d"; format = isHex ? "%1X" : "%1d";
offset = isHex ? 4 : 0; offset = isHex ? 4 : 0;