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

@ -158,8 +158,8 @@ class CatalogPanel extends JTabbedPane implements RedoListener, SectorSelectionL
tab.refresh (); tab.refresh ();
// Any newly created disk needs to appear in the FileSystemTab's tree // Any newly created disk needs to appear in the FileSystemTab's tree
if (tab instanceof AppleDiskTab) if (tab instanceof AppleDiskTab appleDiskTab)
fileTab.replaceDisk (((AppleDiskTab) tab).disk); fileTab.replaceDisk (appleDiskTab.disk);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -221,8 +221,8 @@ class CatalogPanel extends JTabbedPane implements RedoListener, SectorSelectionL
FormattedDisk fd = ((AppleDiskTab) selectedTab).disk; FormattedDisk fd = ((AppleDiskTab) selectedTab).disk;
prefs.put (prefsLastDiskUsed, fd.getAbsolutePath ()); prefs.put (prefsLastDiskUsed, fd.getAbsolutePath ());
if (fd instanceof HybridDisk) if (fd instanceof HybridDisk hybridDisk)
prefs.putInt (prefsLastDosUsed, ((HybridDisk) fd).getCurrentDiskNo ()); prefs.putInt (prefsLastDosUsed, hybridDisk.getCurrentDiskNo ());
else else
prefs.putInt (prefsLastDosUsed, -1); prefs.putInt (prefsLastDosUsed, -1);
@ -231,16 +231,16 @@ class CatalogPanel extends JTabbedPane implements RedoListener, SectorSelectionL
{ {
EventObject event = redoEvent.value; 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 (prefsLastFileUsed, afs == null ? "" : afs.getUniqueName ());
prefs.put (prefsLastSectorsUsed, ""); prefs.put (prefsLastSectorsUsed, "");
} }
else if (event instanceof SectorSelectedEvent) else if (event instanceof SectorSelectedEvent sectorSelectedEvent)
{ {
prefs.put (prefsLastFileUsed, ""); 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) if (diskEvent != null)
{ {
fd1 = diskEvent.getFormattedDisk (); fd1 = diskEvent.getFormattedDisk ();
if (lastDosUsed >= 0 && fd1 instanceof HybridDisk) if (lastDosUsed >= 0 && fd1 instanceof HybridDisk hybridDisk)
((HybridDisk) fd1).setCurrentDiskNo (lastDosUsed); hybridDisk.setCurrentDiskNo (lastDosUsed);
} }
} }
else else
@ -399,13 +399,13 @@ class CatalogPanel extends JTabbedPane implements RedoListener, SectorSelectionL
{ {
case "DiskEvent": case "DiskEvent":
case "FileNodeEvent": case "FileNodeEvent":
if (tab instanceof FileSystemTab) if (tab instanceof FileSystemTab fileSystemTab)
((FileSystemTab) tab).redoEvent (event); fileSystemTab.redoEvent (event);
break; break;
case "FileEvent": case "FileEvent":
if (tab instanceof AppleDiskTab) if (tab instanceof AppleDiskTab appleDiskTab)
((AppleDiskTab) tab).redoEvent (event); appleDiskTab.redoEvent (event);
break; break;
case "SectorEvent": 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 // user has clicked in the DiskLayoutPanel, so turn off any current file selection
Tab tab = (Tab) getSelectedComponent (); Tab tab = (Tab) getSelectedComponent ();
if (tab instanceof AppleDiskTab) if (tab instanceof AppleDiskTab appleDiskTab)
((AppleDiskTab) tab).tree.setSelectionPath (null); appleDiskTab.tree.setSelectionPath (null);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//

View File

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

View File

@ -78,7 +78,6 @@ public class OutputPanel extends JTabbedPane
public OutputPanel (MenuHandler menuHandler) public OutputPanel (MenuHandler menuHandler)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
// this.menuHandler = mh;
setTabPlacement (SwingConstants.BOTTOM); setTabPlacement (SwingConstants.BOTTOM);
formattedText = new JTextArea (10, TEXT_WIDTH); formattedText = new JTextArea (10, TEXT_WIDTH);
@ -183,9 +182,8 @@ public class OutputPanel extends JTabbedPane
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
HiResImage.getPaletteFactory ().setCurrentPalette (palette); HiResImage.getPaletteFactory ().setCurrentPalette (palette);
if (currentDataSource instanceof HiResImage) if (currentDataSource instanceof HiResImage image)
{ {
HiResImage image = (HiResImage) currentDataSource;
image.setPalette (); image.setPalette ();
imagePanel.setImage (image.getImage ()); imagePanel.setImage (image.getImage ());
} }
@ -196,9 +194,8 @@ public class OutputPanel extends JTabbedPane
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
Palette palette = HiResImage.getPaletteFactory ().cyclePalette (direction); Palette palette = HiResImage.getPaletteFactory ().cyclePalette (direction);
if (currentDataSource instanceof HiResImage) if (currentDataSource instanceof HiResImage image)
{ {
HiResImage image = (HiResImage) currentDataSource;
image.setPalette (); image.setPalette ();
imagePanel.setImage (image.getImage ()); imagePanel.setImage (image.getImage ());
} }
@ -231,9 +228,8 @@ public class OutputPanel extends JTabbedPane
public void setColourQuirks (boolean value) public void setColourQuirks (boolean value)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
if (currentDataSource instanceof HiResImage) if (currentDataSource instanceof HiResImage image)
{ {
HiResImage image = (HiResImage) currentDataSource;
image.setColourQuirks (value); image.setColourQuirks (value);
imagePanel.setImage (image.getImage ()); imagePanel.setImage (image.getImage ());
} }
@ -243,9 +239,8 @@ public class OutputPanel extends JTabbedPane
public void setMonochrome (boolean value) public void setMonochrome (boolean value)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
if (currentDataSource instanceof HiResImage) if (currentDataSource instanceof HiResImage image)
{ {
HiResImage image = (HiResImage) currentDataSource;
image.setMonochrome (value); image.setMonochrome (value);
imagePanel.setImage (image.getImage ()); imagePanel.setImage (image.getImage ());
} }
@ -256,23 +251,17 @@ public class OutputPanel extends JTabbedPane
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
imagePanel.setScale (scale); imagePanel.setScale (scale);
if (currentDataSource instanceof HiResImage) if (currentDataSource instanceof HiResImage image)
{
HiResImage image = (HiResImage) currentDataSource;
imagePanel.setImage (image.getImage ()); imagePanel.setImage (image.getImage ());
} }
}
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public void update () public void update ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
if (currentDataSource instanceof HiResImage) if (currentDataSource instanceof HiResImage image)
{
HiResImage image = (HiResImage) currentDataSource;
imagePanel.setImage (image.getImage ()); imagePanel.setImage (image.getImage ());
} }
}
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public void setDebug (boolean value) public void setDebug (boolean value)
@ -480,7 +469,6 @@ public class OutputPanel extends JTabbedPane
{ {
setSelectedIndex (0); setSelectedIndex (0);
setDataSource (event.getFileNode ()); setDataSource (event.getFileNode ());
// FileNode node = event.getFileNode ();
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//

View File

@ -105,14 +105,16 @@ public final class Utility
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
// public static int getLong (byte[] buffer, int ptr) // public static int getLong (byte[] buffer, int ptr)
// // ---------------------------------------------------------------------------------// // //
// ---------------------------------------------------------------------------------//
// { // {
// return getWord (buffer, ptr) + getWord (buffer, ptr + 2) * 0x10000; // return getWord (buffer, ptr) + getWord (buffer, ptr + 2) * 0x10000;
// } // }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
// public static int getWord (byte[] buffer, int ptr) // public static int getWord (byte[] buffer, int ptr)
// // ---------------------------------------------------------------------------------// // //
// ---------------------------------------------------------------------------------//
// { // {
// int a = (buffer[ptr + 1] & 0xFF) << 8; // int a = (buffer[ptr + 1] & 0xFF) << 8;
// int b = buffer[ptr] & 0xFF; // int b = buffer[ptr] & 0xFF;
@ -137,12 +139,8 @@ public final class Utility
public static int getLong (byte[] buffer, int ptr) public static int getLong (byte[] buffer, int ptr)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
if (ptr >= buffer.length) try
{ {
System.out.printf ("Index out of range (getLong): %08X%n", ptr);
return 0;
}
int val = 0; int val = 0;
for (int i = 3; i >= 0; i--) for (int i = 3; i >= 0; i--)
{ {
@ -151,6 +149,12 @@ public final class Utility
} }
return val; return val;
} }
catch (ArrayIndexOutOfBoundsException e)
{
System.out.printf ("Index out of range (getLong): %08X %<d%n", ptr);
return 0;
}
}
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public static int getLongBigEndian (byte[] buffer, int ptr) public static int getLongBigEndian (byte[] buffer, int ptr)
@ -167,7 +171,8 @@ public final class Utility
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
// public static int getWordBigEndian (byte[] buffer, int ptr) // public static int getWordBigEndian (byte[] buffer, int ptr)
// // ---------------------------------------------------------------------------------// // //
// ---------------------------------------------------------------------------------//
// { // {
// int val = 0; // int val = 0;
// for (int i = 0; i < 2; i++) // for (int i = 0; i < 2; i++)
@ -182,25 +187,35 @@ public final class Utility
public static int getShort (byte[] buffer, int ptr) 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 0;
} }
return (buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public static int signedShort (byte[] buffer, int ptr) 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 0;
} }
return (short) ((buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8));
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -298,7 +313,8 @@ public final class Utility
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
// public static int readShort (byte[] buffer, int ptr) // public static int readShort (byte[] buffer, int ptr)
// // ---------------------------------------------------------------------------------// // //
// ---------------------------------------------------------------------------------//
// { // {
// return (buffer[ptr] & 0xFF) | (buffer[ptr + 1] & 0xFF) << 8; // return (buffer[ptr] & 0xFF) | (buffer[ptr + 1] & 0xFF) << 8;
// } // }

View File

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

View File

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