tidying
This commit is contained in:
parent
4a03c411fc
commit
fb748df4ae
|
@ -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);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -78,7 +78,6 @@ public class OutputPanel extends JTabbedPane
|
|||
public OutputPanel (MenuHandler menuHandler)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// this.menuHandler = mh;
|
||||
setTabPlacement (SwingConstants.BOTTOM);
|
||||
|
||||
formattedText = new JTextArea (10, TEXT_WIDTH);
|
||||
|
@ -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,23 +251,17 @@ 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 ());
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void setDebug (boolean value)
|
||||
|
@ -480,7 +469,6 @@ public class OutputPanel extends JTabbedPane
|
|||
{
|
||||
setSelectedIndex (0);
|
||||
setDataSource (event.getFileNode ());
|
||||
// FileNode node = event.getFileNode ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -105,14 +105,16 @@ public final class Utility
|
|||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
// 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;
|
||||
|
@ -137,12 +139,8 @@ 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);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int val = 0;
|
||||
for (int i = 3; i >= 0; i--)
|
||||
{
|
||||
|
@ -151,6 +149,12 @@ public final class Utility
|
|||
}
|
||||
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)
|
||||
|
@ -167,7 +171,8 @@ public final class Utility
|
|||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
// public static int getWordBigEndian (byte[] buffer, int ptr)
|
||||
// // ---------------------------------------------------------------------------------//
|
||||
// //
|
||||
// ---------------------------------------------------------------------------------//
|
||||
// {
|
||||
// int val = 0;
|
||||
// for (int i = 0; i < 2; i++)
|
||||
|
@ -182,25 +187,35 @@ public final class Utility
|
|||
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));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -298,7 +313,8 @@ public final class Utility
|
|||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
// public static int readShort (byte[] buffer, int ptr)
|
||||
// // ---------------------------------------------------------------------------------//
|
||||
// //
|
||||
// ---------------------------------------------------------------------------------//
|
||||
// {
|
||||
// return (buffer[ptr] & 0xFF) | (buffer[ptr + 1] & 0xFF) << 8;
|
||||
// }
|
||||
|
|
|
@ -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 ();
|
||||
|
|
|
@ -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?
|
||||
|
|
Loading…
Reference in New Issue