This commit is contained in:
Denis Molony 2021-09-19 17:09:34 +10:00
parent 4a03c411fc
commit fb748df4ae
6 changed files with 94 additions and 90 deletions

View File

@ -89,9 +89,9 @@ class CatalogPanel extends JTabbedPane implements RedoListener, SectorSelectionL
{
if (evt.getPropertyName ().equals ("RootDirectory"))
rootDirectoryChanged ((File) evt.getOldValue (), (File) evt.getNewValue ());
// else
// closeCurrentTab ();
// System.out.println (evt.getPropertyName ());
// else
// closeCurrentTab ();
// System.out.println (evt.getPropertyName ());
}
// ---------------------------------------------------------------------------------//
@ -158,8 +158,8 @@ class CatalogPanel extends JTabbedPane implements RedoListener, SectorSelectionL
tab.refresh ();
// Any newly created disk needs to appear in the FileSystemTab's tree
if (tab instanceof AppleDiskTab)
fileTab.replaceDisk (((AppleDiskTab) tab).disk);
if (tab instanceof AppleDiskTab appleDiskTab)
fileTab.replaceDisk (appleDiskTab.disk);
}
// ---------------------------------------------------------------------------------//
@ -221,8 +221,8 @@ class CatalogPanel extends JTabbedPane implements RedoListener, SectorSelectionL
FormattedDisk fd = ((AppleDiskTab) selectedTab).disk;
prefs.put (prefsLastDiskUsed, fd.getAbsolutePath ());
if (fd instanceof HybridDisk)
prefs.putInt (prefsLastDosUsed, ((HybridDisk) fd).getCurrentDiskNo ());
if (fd instanceof HybridDisk hybridDisk)
prefs.putInt (prefsLastDosUsed, hybridDisk.getCurrentDiskNo ());
else
prefs.putInt (prefsLastDosUsed, -1);
@ -231,16 +231,16 @@ class CatalogPanel extends JTabbedPane implements RedoListener, SectorSelectionL
{
EventObject event = redoEvent.value;
if (event instanceof FileSelectedEvent)
if (event instanceof FileSelectedEvent fileSelectedEvent)
{
AppleFileSource afs = ((FileSelectedEvent) event).appleFileSource;
AppleFileSource afs = fileSelectedEvent.appleFileSource;
prefs.put (prefsLastFileUsed, afs == null ? "" : afs.getUniqueName ());
prefs.put (prefsLastSectorsUsed, "");
}
else if (event instanceof SectorSelectedEvent)
else if (event instanceof SectorSelectedEvent sectorSelectedEvent)
{
prefs.put (prefsLastFileUsed, "");
prefs.put (prefsLastSectorsUsed, ((SectorSelectedEvent) event).toText ());
prefs.put (prefsLastSectorsUsed, sectorSelectedEvent.toText ());
}
}
}
@ -273,8 +273,8 @@ class CatalogPanel extends JTabbedPane implements RedoListener, SectorSelectionL
if (diskEvent != null)
{
fd1 = diskEvent.getFormattedDisk ();
if (lastDosUsed >= 0 && fd1 instanceof HybridDisk)
((HybridDisk) fd1).setCurrentDiskNo (lastDosUsed);
if (lastDosUsed >= 0 && fd1 instanceof HybridDisk hybridDisk)
hybridDisk.setCurrentDiskNo (lastDosUsed);
}
}
else
@ -399,13 +399,13 @@ class CatalogPanel extends JTabbedPane implements RedoListener, SectorSelectionL
{
case "DiskEvent":
case "FileNodeEvent":
if (tab instanceof FileSystemTab)
((FileSystemTab) tab).redoEvent (event);
if (tab instanceof FileSystemTab fileSystemTab)
fileSystemTab.redoEvent (event);
break;
case "FileEvent":
if (tab instanceof AppleDiskTab)
((AppleDiskTab) tab).redoEvent (event);
if (tab instanceof AppleDiskTab appleDiskTab)
appleDiskTab.redoEvent (event);
break;
case "SectorEvent":
@ -426,8 +426,8 @@ class CatalogPanel extends JTabbedPane implements RedoListener, SectorSelectionL
{
// user has clicked in the DiskLayoutPanel, so turn off any current file selection
Tab tab = (Tab) getSelectedComponent ();
if (tab instanceof AppleDiskTab)
((AppleDiskTab) tab).tree.setSelectionPath (null);
if (tab instanceof AppleDiskTab appleDiskTab)
appleDiskTab.tree.setSelectionPath (null);
}
// ---------------------------------------------------------------------------------//
@ -462,7 +462,7 @@ class CatalogPanel extends JTabbedPane implements RedoListener, SectorSelectionL
FileNode node = (FileNode) selectedNode.getUserObject ();
if (node.file.isDirectory ())
{
// lister.catalogLister.setNode (selectedNode);
// lister.catalogLister.setNode (selectedNode);
}
else if (e.getClickCount () == 2)
addDiskPanel (node.getFormattedDisk (), true);

View File

@ -262,8 +262,8 @@ class DiskLayoutPanel extends JPanel implements DiskSelectionListener,
private void checkCorrectDisk (FormattedDisk newDisk)
{
if (newDisk instanceof HybridDisk)
newDisk = ((HybridDisk) newDisk).getCurrentDisk (); // never set to a hybrid disk
if (newDisk instanceof HybridDisk hybridDisk)
newDisk = hybridDisk.getCurrentDisk (); // never set to a hybrid disk
if (newDisk != diskLayoutImage.getDisk ())
{
LayoutDetails layout = new LayoutDetails (newDisk);

View File

@ -43,7 +43,7 @@ public class OutputPanel extends JTabbedPane
{
private static final int TEXT_WIDTH = 65;
// final MenuHandler menuHandler;
// final MenuHandler menuHandler;
private final JTextArea formattedText;
private final JTextArea hexText;
private final JTextArea disassemblyText;
@ -78,12 +78,11 @@ public class OutputPanel extends JTabbedPane
public OutputPanel (MenuHandler menuHandler)
// ---------------------------------------------------------------------------------//
{
// this.menuHandler = mh;
setTabPlacement (SwingConstants.BOTTOM);
formattedText = new JTextArea (10, TEXT_WIDTH);
formattedPane = setPanel (formattedText, "Formatted");
// formattedText.setLineWrap (prefs.getBoolean (MenuHandler.PREFS_LINE_WRAP, true));
// formattedText.setLineWrap (prefs.getBoolean (MenuHandler.PREFS_LINE_WRAP, true));
formattedText.setText ("Please use the 'File->Set HOME folder...' command to "
+ "\ntell DiskBrowser where your Apple disks are located."
+ "\n\nTo see the contents of a disk in more detail, double-click"
@ -183,9 +182,8 @@ public class OutputPanel extends JTabbedPane
// ---------------------------------------------------------------------------------//
{
HiResImage.getPaletteFactory ().setCurrentPalette (palette);
if (currentDataSource instanceof HiResImage)
if (currentDataSource instanceof HiResImage image)
{
HiResImage image = (HiResImage) currentDataSource;
image.setPalette ();
imagePanel.setImage (image.getImage ());
}
@ -196,9 +194,8 @@ public class OutputPanel extends JTabbedPane
// ---------------------------------------------------------------------------------//
{
Palette palette = HiResImage.getPaletteFactory ().cyclePalette (direction);
if (currentDataSource instanceof HiResImage)
if (currentDataSource instanceof HiResImage image)
{
HiResImage image = (HiResImage) currentDataSource;
image.setPalette ();
imagePanel.setImage (image.getImage ());
}
@ -231,9 +228,8 @@ public class OutputPanel extends JTabbedPane
public void setColourQuirks (boolean value)
// ---------------------------------------------------------------------------------//
{
if (currentDataSource instanceof HiResImage)
if (currentDataSource instanceof HiResImage image)
{
HiResImage image = (HiResImage) currentDataSource;
image.setColourQuirks (value);
imagePanel.setImage (image.getImage ());
}
@ -243,9 +239,8 @@ public class OutputPanel extends JTabbedPane
public void setMonochrome (boolean value)
// ---------------------------------------------------------------------------------//
{
if (currentDataSource instanceof HiResImage)
if (currentDataSource instanceof HiResImage image)
{
HiResImage image = (HiResImage) currentDataSource;
image.setMonochrome (value);
imagePanel.setImage (image.getImage ());
}
@ -256,22 +251,16 @@ public class OutputPanel extends JTabbedPane
// ---------------------------------------------------------------------------------//
{
imagePanel.setScale (scale);
if (currentDataSource instanceof HiResImage)
{
HiResImage image = (HiResImage) currentDataSource;
if (currentDataSource instanceof HiResImage image)
imagePanel.setImage (image.getImage ());
}
}
// ---------------------------------------------------------------------------------//
public void update ()
// ---------------------------------------------------------------------------------//
{
if (currentDataSource instanceof HiResImage)
{
HiResImage image = (HiResImage) currentDataSource;
if (currentDataSource instanceof HiResImage image)
imagePanel.setImage (image.getImage ());
}
}
// ---------------------------------------------------------------------------------//
@ -480,7 +469,6 @@ public class OutputPanel extends JTabbedPane
{
setSelectedIndex (0);
setDataSource (event.getFileNode ());
// FileNode node = event.getFileNode ();
}
// ---------------------------------------------------------------------------------//

View File

@ -104,20 +104,22 @@ public final class Utility
}
// ---------------------------------------------------------------------------------//
// public static int getLong (byte[] buffer, int ptr)
// // ---------------------------------------------------------------------------------//
// {
// return getWord (buffer, ptr) + getWord (buffer, ptr + 2) * 0x10000;
// }
// public static int getLong (byte[] buffer, int ptr)
// //
// ---------------------------------------------------------------------------------//
// {
// return getWord (buffer, ptr) + getWord (buffer, ptr + 2) * 0x10000;
// }
// ---------------------------------------------------------------------------------//
// public static int getWord (byte[] buffer, int ptr)
// // ---------------------------------------------------------------------------------//
// {
// int a = (buffer[ptr + 1] & 0xFF) << 8;
// int b = buffer[ptr] & 0xFF;
// return a + b;
// }
// public static int getWord (byte[] buffer, int ptr)
// //
// ---------------------------------------------------------------------------------//
// {
// int a = (buffer[ptr + 1] & 0xFF) << 8;
// int b = buffer[ptr] & 0xFF;
// return a + b;
// }
// ---------------------------------------------------------------------------------//
public static int intValue (byte b1, byte b2)
@ -137,19 +139,21 @@ public final class Utility
public static int getLong (byte[] buffer, int ptr)
// ---------------------------------------------------------------------------------//
{
if (ptr >= buffer.length)
try
{
System.out.printf ("Index out of range (getLong): %08X%n", ptr);
int val = 0;
for (int i = 3; i >= 0; i--)
{
val <<= 8;
val += buffer[ptr + i] & 0xFF;
}
return val;
}
catch (ArrayIndexOutOfBoundsException e)
{
System.out.printf ("Index out of range (getLong): %08X %<d%n", ptr);
return 0;
}
int val = 0;
for (int i = 3; i >= 0; i--)
{
val <<= 8;
val += buffer[ptr + i] & 0xFF;
}
return val;
}
// ---------------------------------------------------------------------------------//
@ -166,41 +170,52 @@ public final class Utility
}
// ---------------------------------------------------------------------------------//
// public static int getWordBigEndian (byte[] buffer, int ptr)
// // ---------------------------------------------------------------------------------//
// {
// int val = 0;
// for (int i = 0; i < 2; i++)
// {
// val <<= 8;
// val += buffer[ptr + i] & 0xFF;
// }
// return val;
// }
// public static int getWordBigEndian (byte[] buffer, int ptr)
// //
// ---------------------------------------------------------------------------------//
// {
// int val = 0;
// for (int i = 0; i < 2; i++)
// {
// val <<= 8;
// val += buffer[ptr + i] & 0xFF;
// }
// return val;
// }
// ---------------------------------------------------------------------------------//
public static int getShort (byte[] buffer, int ptr)
// ---------------------------------------------------------------------------------//
{
if (ptr >= buffer.length)
try
{
System.out.printf ("Index out of range (getShort): %04X%n", ptr);
return (buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8);
}
catch (ArrayIndexOutOfBoundsException e)
{
System.out.printf ("Index out of range (getShort): %04X %<d%n", ptr);
return 0;
}
return (buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8);
}
// ---------------------------------------------------------------------------------//
public static int signedShort (byte[] buffer, int ptr)
// ---------------------------------------------------------------------------------//
{
if (ptr >= buffer.length)
// if (ptr >= buffer.length)
// {
// System.out.println ("Index out of range (signed short): " + ptr);
// return 0;
// }
try
{
System.out.println ("Index out of range (signed short): " + ptr);
return (short) ((buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8));
}
catch (ArrayIndexOutOfBoundsException e)
{
System.out.printf ("Index out of range (signedShort): %04X %<d%n", ptr);
return 0;
}
return (short) ((buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8));
}
// ---------------------------------------------------------------------------------//
@ -220,7 +235,7 @@ public final class Utility
public static LocalDateTime getAppleDate (byte[] buffer, int offset)
// ---------------------------------------------------------------------------------//
{
// int yymmdd = readShort (buffer, offset);
// int yymmdd = readShort (buffer, offset);
int yymmdd = getShort (buffer, offset);
if (yymmdd != 0)
{
@ -297,11 +312,12 @@ public final class Utility
}
// ---------------------------------------------------------------------------------//
// public static int readShort (byte[] buffer, int ptr)
// // ---------------------------------------------------------------------------------//
// {
// return (buffer[ptr] & 0xFF) | (buffer[ptr + 1] & 0xFF) << 8;
// }
// public static int readShort (byte[] buffer, int ptr)
// //
// ---------------------------------------------------------------------------------//
// {
// return (buffer[ptr] & 0xFF) | (buffer[ptr + 1] & 0xFF) << 8;
// }
// ---------------------------------------------------------------------------------//
public static int readTriple (byte[] buffer, int ptr)

View File

@ -26,7 +26,7 @@ class Average extends ValueListFunction
for (Value v : list)
{
if (v instanceof Cell && ((Cell) v).isCellType (CellType.EMPTY))
if (v instanceof Cell cell && cell.isCellType (CellType.EMPTY))
continue;
v.calculate ();

View File

@ -27,7 +27,7 @@ class Count extends ValueListFunction
else
for (Value v : list)
{
if (v instanceof Cell && ((Cell) v).isCellType (CellType.EMPTY))
if (v instanceof Cell cell && cell.isCellType (CellType.EMPTY))
continue;
v.calculate (); // is this required?