mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-12-01 09:50:32 +00:00
tidying
This commit is contained in:
parent
93186f2b6d
commit
b7e8c470f7
@ -25,9 +25,6 @@ public class CharacterRom extends CharacterList
|
||||
super (name, buffer, charsX, charsY, HEADER_LENGTH);
|
||||
|
||||
description = HexFormatter.getCString (buffer, 16);
|
||||
|
||||
assert sizeX == (buffer[5] & 0xFF);
|
||||
assert sizeY == (buffer[6] & 0xFF);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -17,7 +17,7 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
||||
private final int iBlkID;
|
||||
private final int iBlkPath;
|
||||
private final String iBlkName;
|
||||
private final List<Icon> icons = new ArrayList<IconFile.Icon> ();
|
||||
private final List<Icon> icons = new ArrayList<> ();
|
||||
private final boolean debug = false;
|
||||
|
||||
public IconFile (String name, byte[] buffer)
|
||||
@ -60,8 +60,8 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
||||
int rows = (icons.size () - 1) / columns + 1;
|
||||
|
||||
image = new BufferedImage ( //
|
||||
columns * maxWidth + 2 * base + (columns - 1) * gap, //
|
||||
rows * maxHeight + 2 * base + (rows - 1) * gap, //
|
||||
dimension (columns, base, maxWidth, gap), //
|
||||
dimension (rows, base, maxHeight, gap), //
|
||||
BufferedImage.TYPE_INT_RGB);
|
||||
|
||||
Graphics2D graphics = image.createGraphics ();
|
||||
@ -87,6 +87,13 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
||||
graphics.dispose ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int dimension (int chars, int border, int size, int gap)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return border * 2 + chars * (size + gap) - gap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText ()
|
||||
{
|
||||
@ -197,6 +204,10 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
||||
System.out.println ();
|
||||
}
|
||||
|
||||
if (iconWidth == 0 || iconHeight == 0)
|
||||
throw new InvalidImageException (
|
||||
String.format ("Invalid icon: Height: %d, Width: %d", iconHeight, iconWidth));
|
||||
|
||||
if (iconType != 0 && iconType != 0x8000 && iconType != 0xFFFF && iconType != 0x00FF)
|
||||
throw new InvalidImageException (String.format ("Bad icon type: %04X", iconType));
|
||||
|
||||
|
@ -14,20 +14,6 @@ public class Utility
|
||||
public static final List<String> suffixes =
|
||||
Arrays.asList ("po", "dsk", "do", "hdv", "2mg", "v2d", "d13", "sdk", "woz");
|
||||
|
||||
// not used - it doesn't work with Oracle's JDK
|
||||
// private static boolean hasRetinaDisplay ()
|
||||
// {
|
||||
// Object obj =
|
||||
// Toolkit.getDefaultToolkit ().getDesktopProperty ("apple.awt.contentScaleFactor");
|
||||
// if (obj instanceof Float)
|
||||
// {
|
||||
// Float f = (Float) obj;
|
||||
// int scale = f.intValue ();
|
||||
// return (scale == 2); // 1 indicates a regular mac display.
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static boolean test (Graphics2D g)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -57,19 +43,27 @@ public class Utility
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (int i = 0; i < buffer.length; i++)
|
||||
{
|
||||
if (buffer[i] == key[0])
|
||||
{
|
||||
if (matches (buffer, i, key))
|
||||
{
|
||||
System.out.printf ("Matches at %04X%n", i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static boolean matches (byte[] buffer, int offset, byte[] key)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int ptr = 0;
|
||||
while (offset < buffer.length && ptr < key.length)
|
||||
if (buffer[offset++] != key[ptr++])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static LocalDateTime getDateTime (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -90,18 +84,6 @@ public class Utility
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static boolean matches (byte[] buffer, int offset, byte[] key)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int ptr = 0;
|
||||
while (offset < buffer.length && ptr < key.length)
|
||||
if (buffer[offset++] != key[ptr++])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int getSuffixNo (String filename)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
Loading…
Reference in New Issue
Block a user