mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-29 11:49:29 +00:00
tidying
This commit is contained in:
parent
7b649380d3
commit
7e0dda6c7e
@ -9,38 +9,60 @@ import java.util.List;
|
||||
|
||||
public class FontFile extends AbstractFile
|
||||
{
|
||||
private static final int borderX = 3;
|
||||
private static final int borderY = 3;
|
||||
private static final int gapX = 3;
|
||||
private static final int gapY = 3;
|
||||
private static final int charsX = 8;
|
||||
private static final int charsY = 12;
|
||||
|
||||
private static final int sizeX = 7;
|
||||
private static final int sizeY = 8;
|
||||
private static final int charBytes = 8;
|
||||
|
||||
List<Character> characters = new ArrayList<Character> ();
|
||||
|
||||
public FontFile (String name, byte[] buffer)
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
image = new BufferedImage (8 * (7 + 4), 12 * (8 + 4), BufferedImage.TYPE_BYTE_GRAY);
|
||||
image = new BufferedImage ( //
|
||||
dimension (charsX, borderX, sizeX, gapX), //
|
||||
dimension (charsY, borderY, sizeY, gapY), //
|
||||
BufferedImage.TYPE_BYTE_GRAY);
|
||||
|
||||
Graphics2D g2d = image.createGraphics ();
|
||||
g2d.setComposite (AlphaComposite.getInstance (AlphaComposite.SRC_OVER, (float) 1.0));
|
||||
|
||||
int ptr = 0;
|
||||
int x = 2;
|
||||
int y = 2;
|
||||
int x = borderX;
|
||||
int y = borderY;
|
||||
int count = 0;
|
||||
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
Character c = new Character (buffer, ptr);
|
||||
ptr += 8;
|
||||
characters.add (c);
|
||||
ptr += charBytes;
|
||||
|
||||
g2d.drawImage (c.image, x, y, null);
|
||||
x += 7 + 4;
|
||||
if (++count % 8 == 0)
|
||||
if (++count % charBytes == 0)
|
||||
{
|
||||
x = 2;
|
||||
y += 8 + 4;
|
||||
x = borderX;
|
||||
y += sizeY + gapY;
|
||||
}
|
||||
else
|
||||
x += sizeX + gapX;
|
||||
}
|
||||
|
||||
g2d.dispose ();
|
||||
}
|
||||
|
||||
private int dimension (int chars, int border, int size, int gap)
|
||||
{
|
||||
return border * 2 + chars * (size + gap) - gap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText ()
|
||||
{
|
||||
@ -84,11 +106,11 @@ public class FontFile extends AbstractFile
|
||||
public Character (byte[] buffer, int ptr)
|
||||
{
|
||||
// draw the image
|
||||
image = new BufferedImage (7, 8, BufferedImage.TYPE_BYTE_GRAY);
|
||||
image = new BufferedImage (sizeX, sizeY, BufferedImage.TYPE_BYTE_GRAY);
|
||||
DataBuffer dataBuffer = image.getRaster ().getDataBuffer ();
|
||||
int element = 0;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
for (int i = 0; i < charBytes; i++)
|
||||
{
|
||||
int b = buffer[ptr + i] & 0xFF;
|
||||
String s = "0000000" + Integer.toString (b, 2);
|
||||
|
@ -11,7 +11,7 @@ import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
|
||||
class AttributeManager extends AbstractFile
|
||||
{
|
||||
List<Statistic> list = new ArrayList<Statistic> ();
|
||||
List<Statistic> list = new ArrayList<> ();
|
||||
Header header;
|
||||
|
||||
public AttributeManager (String name, byte[] buffer, Header header)
|
||||
@ -53,7 +53,7 @@ class AttributeManager extends AbstractFile
|
||||
private class Statistic
|
||||
{
|
||||
int id;
|
||||
List<ZObject> list = new ArrayList<ZObject> ();
|
||||
List<ZObject> list = new ArrayList<> ();
|
||||
|
||||
public Statistic (int id)
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ class CodeManager extends AbstractFile
|
||||
{
|
||||
private final Header header;
|
||||
private int codeSize;
|
||||
private final Map<Integer, Routine> routines = new TreeMap<Integer, Routine> ();
|
||||
private final Map<Integer, Routine> routines = new TreeMap<> ();
|
||||
|
||||
public CodeManager (Header header)
|
||||
{
|
||||
@ -50,7 +50,7 @@ class CodeManager extends AbstractFile
|
||||
{
|
||||
int blockNo = routine.startPtr / 256 + 48;
|
||||
int size = routine.length;
|
||||
List<DiskAddress> blocks = new ArrayList<DiskAddress> ();
|
||||
List<DiskAddress> blocks = new ArrayList<> ();
|
||||
|
||||
while (size > 0)
|
||||
{
|
||||
|
@ -16,14 +16,14 @@ class Dictionary extends AbstractFile
|
||||
private final int dictionaryPtr, dictionarySize;
|
||||
private final int entryLength;
|
||||
|
||||
Map<Integer, List<WordEntry>> synonymList = new TreeMap<Integer, List<WordEntry>> ();
|
||||
Map<Integer, List<WordEntry>> synonymList = new TreeMap<> ();
|
||||
|
||||
public Dictionary (Header header)
|
||||
{
|
||||
super ("Dictionary", header.buffer);
|
||||
|
||||
dictionaryPtr = header.dictionaryOffset;
|
||||
dictionary = new TreeMap<Integer, ZString> ();
|
||||
dictionary = new TreeMap<> ();
|
||||
|
||||
totalSeparators = buffer[dictionaryPtr] & 0xFF;
|
||||
int ptr = dictionaryPtr + totalSeparators + 1;
|
||||
|
@ -17,12 +17,11 @@ class Grammar extends InfocomAbstractFile
|
||||
private final int totalPrepositions;
|
||||
private final int padding;
|
||||
|
||||
private final List<SentenceGroup> sentenceGroups = new ArrayList<SentenceGroup> ();
|
||||
private final Map<Integer, List<Sentence>> actionList =
|
||||
new TreeMap<Integer, List<Sentence>> ();
|
||||
private final List<SentenceGroup> sentenceGroups = new ArrayList<> ();
|
||||
private final Map<Integer, List<Sentence>> actionList = new TreeMap<> ();
|
||||
|
||||
private final List<Integer> actionRoutines = new ArrayList<Integer> ();
|
||||
private final List<Integer> preActionRoutines = new ArrayList<Integer> ();
|
||||
private final List<Integer> actionRoutines = new ArrayList<> ();
|
||||
private final List<Integer> preActionRoutines = new ArrayList<> ();
|
||||
|
||||
Grammar (String name, byte[] buffer, Header header)
|
||||
{
|
||||
@ -135,7 +134,7 @@ class Grammar extends InfocomAbstractFile
|
||||
|
||||
public List<Integer> getActionRoutines ()
|
||||
{
|
||||
List<Integer> routines = new ArrayList<Integer> ();
|
||||
List<Integer> routines = new ArrayList<> ();
|
||||
routines.addAll (actionRoutines);
|
||||
routines.addAll (preActionRoutines);
|
||||
return routines;
|
||||
@ -202,7 +201,7 @@ class Grammar extends InfocomAbstractFile
|
||||
|
||||
private List<Sentence> getSentences (int routine)
|
||||
{
|
||||
List<Sentence> sentences = new ArrayList<Sentence> ();
|
||||
List<Sentence> sentences = new ArrayList<> ();
|
||||
|
||||
for (SentenceGroup sg : sentenceGroups)
|
||||
for (Sentence s : sg.sentences)
|
||||
@ -232,7 +231,7 @@ class Grammar extends InfocomAbstractFile
|
||||
{
|
||||
int startPtr;
|
||||
int id;
|
||||
List<Sentence> sentences = new ArrayList<Sentence> ();
|
||||
List<Sentence> sentences = new ArrayList<> ();
|
||||
String verbString; // list of synonyms inside []
|
||||
|
||||
public SentenceGroup (int id, int ptr)
|
||||
|
@ -21,7 +21,7 @@ abstract class CatalogEntry implements AppleFileSource
|
||||
protected int fileType;
|
||||
protected GregorianCalendar date;
|
||||
protected int bytesUsedInLastBlock;
|
||||
protected final List<DiskAddress> blocks = new ArrayList<DiskAddress> ();
|
||||
protected final List<DiskAddress> blocks = new ArrayList<> ();
|
||||
|
||||
public CatalogEntry (PascalDisk parent, byte[] buffer)
|
||||
{
|
||||
@ -29,7 +29,6 @@ abstract class CatalogEntry implements AppleFileSource
|
||||
|
||||
firstBlock = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
lastBlock = HexFormatter.intValue (buffer[2], buffer[3]);
|
||||
// fileType = HexFormatter.intValue (buffer[4], buffer[5]);
|
||||
fileType = buffer[4] & 0xFF;
|
||||
name = HexFormatter.getPascalString (buffer, 6);
|
||||
bytesUsedInLastBlock = HexFormatter.intValue (buffer[16], buffer[17]);
|
||||
@ -52,7 +51,7 @@ abstract class CatalogEntry implements AppleFileSource
|
||||
@Override
|
||||
public List<DiskAddress> getSectors ()
|
||||
{
|
||||
List<DiskAddress> sectors = new ArrayList<DiskAddress> (blocks);
|
||||
List<DiskAddress> sectors = new ArrayList<> (blocks);
|
||||
return sectors;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,6 @@ public class FileEntry extends CatalogEntry
|
||||
{
|
||||
byte[] buffer = parent.getDisk ().readSectors (blocks);
|
||||
byte[] exactBuffer;
|
||||
// System.out.println (HexFormatter.format (buffer));
|
||||
|
||||
if (buffer.length > 0 && bytesUsedInLastBlock < 512)
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ class PascalCatalogSector extends AbstractSector
|
||||
|
||||
public PascalCatalogSector (Disk disk, byte[] buffer, List<DiskAddress> diskAddress)
|
||||
{
|
||||
super (disk, buffer);//, diskAddress);
|
||||
super (disk, buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,13 +15,12 @@ class PascalCodeObject implements AppleFileSource
|
||||
{
|
||||
private final PascalDisk parent;
|
||||
private final AbstractFile segment;
|
||||
private final List<DiskAddress> blocks;
|
||||
private final List<DiskAddress> blocks = new ArrayList<> ();
|
||||
|
||||
public PascalCodeObject (PascalDisk parent, PascalSegment segment, int firstBlock)
|
||||
{
|
||||
this.parent = parent;
|
||||
this.segment = segment;
|
||||
this.blocks = new ArrayList<DiskAddress> ();
|
||||
|
||||
int lo = firstBlock + segment.blockNo;
|
||||
int hi = lo + (segment.size - 1) / 512;
|
||||
|
@ -76,7 +76,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||
DefaultMutableTreeNode volumeNode = new DefaultMutableTreeNode (volumeEntry);
|
||||
root.add (volumeNode);
|
||||
|
||||
List<DiskAddress> sectors = new ArrayList<DiskAddress> ();
|
||||
List<DiskAddress> sectors = new ArrayList<> ();
|
||||
int max = Math.min (volumeEntry.lastBlock, disk.getTotalBlocks ());
|
||||
for (int i = 2; i < max; i++)
|
||||
{
|
||||
@ -91,7 +91,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||
new PascalCatalogSector (disk, disk.readSectors (sectors), sectors);
|
||||
|
||||
// read the catalog
|
||||
List<DiskAddress> addresses = new ArrayList<DiskAddress> ();
|
||||
List<DiskAddress> addresses = new ArrayList<> ();
|
||||
for (int i = 2; i < max; i++)
|
||||
addresses.add (disk.getDiskAddress (i));
|
||||
buffer = disk.readSectors (addresses);
|
||||
@ -130,7 +130,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||
disk.setInterleave (1); // should only ever be Prodos
|
||||
if (checkFormat (disk, debug))
|
||||
return true;
|
||||
disk.setInterleave (0); // SANE Disk 2.po
|
||||
disk.setInterleave (0); // see SANE Disk 2.po
|
||||
if (checkFormat (disk, debug))
|
||||
return true;
|
||||
return false;
|
||||
@ -170,7 +170,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||
// return false;
|
||||
}
|
||||
|
||||
List<DiskAddress> addresses = new ArrayList<DiskAddress> ();
|
||||
List<DiskAddress> addresses = new ArrayList<> ();
|
||||
for (int i = 2; i < to; i++)
|
||||
addresses.add (disk.getDiskAddress (i));
|
||||
buffer = disk.readSectors (addresses);
|
||||
|
@ -20,7 +20,7 @@ abstract class CatalogEntry implements AppleFileSource
|
||||
int version;
|
||||
int minVersion;
|
||||
int access;
|
||||
List<DiskAddress> dataBlocks = new ArrayList<DiskAddress> ();
|
||||
List<DiskAddress> dataBlocks = new ArrayList<> ();
|
||||
Disk disk;
|
||||
|
||||
public CatalogEntry (ProdosDisk parentDisk, byte[] entryBuffer)
|
||||
|
@ -29,7 +29,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
private final DiskAddress catalogBlock;
|
||||
|
||||
private DiskAddress masterIndexBlock;
|
||||
private final List<DiskAddress> indexBlocks = new ArrayList<DiskAddress> ();
|
||||
private final List<DiskAddress> indexBlocks = new ArrayList<> ();
|
||||
|
||||
private boolean invalid;
|
||||
private FileEntry link;
|
||||
@ -250,6 +250,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
file = new SHRPictureFile2 (name, exactBuffer, 0xC0, 99, endOfFile);
|
||||
else if (name.endsWith (".FNT") && FontFile.isFont (exactBuffer))
|
||||
file = new FontFile (name, exactBuffer);
|
||||
else if (name.endsWith (".FONT") && FontFile.isFont (exactBuffer))
|
||||
file = new FontFile (name, exactBuffer);
|
||||
else if (ShapeTable.isShapeTable (exactBuffer))
|
||||
file = new ShapeTable (name, exactBuffer);
|
||||
else if (link != null)
|
||||
@ -477,8 +479,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
|
||||
private DataSource getTreeTextFile ()
|
||||
{
|
||||
List<TextBuffer> buffers = new ArrayList<TextBuffer> ();
|
||||
List<DiskAddress> addresses = new ArrayList<DiskAddress> ();
|
||||
List<TextBuffer> buffers = new ArrayList<> ();
|
||||
List<DiskAddress> addresses = new ArrayList<> ();
|
||||
int logicalBlock = 0;
|
||||
|
||||
byte[] mainIndexBuffer = disk.readSector (keyPtr);
|
||||
@ -508,8 +510,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
|
||||
private DataSource getSaplingTextFile ()
|
||||
{
|
||||
List<TextBuffer> buffers = new ArrayList<TextBuffer> ();
|
||||
List<DiskAddress> addresses = new ArrayList<DiskAddress> ();
|
||||
List<TextBuffer> buffers = new ArrayList<> ();
|
||||
List<DiskAddress> addresses = new ArrayList<> ();
|
||||
readIndexBlock (keyPtr, addresses, buffers, 0);
|
||||
|
||||
if (buffers.size () == 1 && name.endsWith (".S"))
|
||||
@ -590,7 +592,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
@Override
|
||||
public List<DiskAddress> getSectors ()
|
||||
{
|
||||
List<DiskAddress> sectors = new ArrayList<DiskAddress> ();
|
||||
List<DiskAddress> sectors = new ArrayList<> ();
|
||||
sectors.add (catalogBlock);
|
||||
if (masterIndexBlock != null)
|
||||
sectors.add (masterIndexBlock);
|
||||
|
@ -91,7 +91,7 @@ class VolumeDirectoryHeader extends DirectoryHeader
|
||||
@Override
|
||||
public DataSource getDataSource ()
|
||||
{
|
||||
List<byte[]> blockList = new ArrayList<byte[]> ();
|
||||
List<byte[]> blockList = new ArrayList<> ();
|
||||
int block = 2;
|
||||
do
|
||||
{
|
||||
@ -114,7 +114,7 @@ class VolumeDirectoryHeader extends DirectoryHeader
|
||||
@Override
|
||||
public List<DiskAddress> getSectors ()
|
||||
{
|
||||
List<DiskAddress> sectors = new ArrayList<DiskAddress> ();
|
||||
List<DiskAddress> sectors = new ArrayList<> ();
|
||||
sectors.addAll (dataBlocks);
|
||||
return sectors;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user