mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-01-23 06:32:12 +00:00
cosmetic changes
This commit is contained in:
parent
b281bd0cec
commit
08da529ca3
@ -1,12 +1,23 @@
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Insets;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.List;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
@ -15,10 +26,10 @@ import com.bytezone.common.FontAction.FontChangeListener;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.disk.SectorList;
|
||||
|
||||
class DataPanel extends JTabbedPane implements DiskSelectionListener, FileSelectionListener,
|
||||
SectorSelectionListener,
|
||||
// PreferenceChangeListener,
|
||||
FileNodeSelectionListener, FontChangeListener
|
||||
class DataPanel extends JTabbedPane
|
||||
implements DiskSelectionListener, FileSelectionListener, SectorSelectionListener,
|
||||
// PreferenceChangeListener,
|
||||
FileNodeSelectionListener, FontChangeListener
|
||||
{
|
||||
private static final int TEXT_WIDTH = 65;
|
||||
|
||||
@ -30,7 +41,7 @@ class DataPanel extends JTabbedPane implements DiskSelectionListener, FileSelect
|
||||
JScrollPane imagePane;
|
||||
|
||||
JTextArea formattedText;
|
||||
ImagePanel imagePanel; // internal class
|
||||
ImagePanel imagePanel;// internal class
|
||||
|
||||
boolean imageVisible = false;
|
||||
|
||||
@ -58,11 +69,10 @@ class DataPanel extends JTabbedPane implements DiskSelectionListener, FileSelect
|
||||
formattedText = new JTextArea (10, TEXT_WIDTH);
|
||||
formattedPane = setPanel (formattedText, "Formatted");
|
||||
formattedText.setLineWrap (mh.lineWrapItem.isSelected ());
|
||||
formattedText
|
||||
.setText ("Please use the 'File->Set root folder' command to "
|
||||
+ "\ntell DiskBrowser where your Apple disks are located."
|
||||
+ "\n\nTo see the contents of a disk in more detail, double-click"
|
||||
+ "\nthe disk. You will then be able to select individual files to view completely.");
|
||||
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"
|
||||
+ "\nthe disk. You will then be able to select individual files to view completely.");
|
||||
|
||||
hexText = new JTextArea (10, TEXT_WIDTH);
|
||||
setPanel (hexText, "Hex dump");
|
||||
@ -72,9 +82,9 @@ class DataPanel extends JTabbedPane implements DiskSelectionListener, FileSelect
|
||||
|
||||
imagePanel = new ImagePanel ();
|
||||
imagePane =
|
||||
new JScrollPane (imagePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
// imagePane.getVerticalScrollBar ().setUnitIncrement (font.getSize ());
|
||||
new JScrollPane (imagePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
// imagePane.getVerticalScrollBar ().setUnitIncrement (font.getSize ());
|
||||
|
||||
// setTabsFont (font);
|
||||
// this.setMinimumSize (new Dimension (800, 200));
|
||||
@ -136,8 +146,8 @@ class DataPanel extends JTabbedPane implements DiskSelectionListener, FileSelect
|
||||
public String getCurrentText ()
|
||||
{
|
||||
int index = getSelectedIndex ();
|
||||
return index == 0 ? formattedText.getText () : index == 1 ? hexText.getText ()
|
||||
: disassemblyText.getText ();
|
||||
return index == 0 ? formattedText.getText ()
|
||||
: index == 1 ? hexText.getText () : disassemblyText.getText ();
|
||||
}
|
||||
|
||||
private JScrollPane setPanel (JTextArea outputPanel, String tabName)
|
||||
@ -146,9 +156,9 @@ class DataPanel extends JTabbedPane implements DiskSelectionListener, FileSelect
|
||||
outputPanel.setMargin (new Insets (5, 5, 5, 5));
|
||||
|
||||
JScrollPane outputScrollPane =
|
||||
new JScrollPane (outputPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
outputScrollPane.setBorder (null); // remove the ugly default border
|
||||
new JScrollPane (outputPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
outputScrollPane.setBorder (null);// remove the ugly default border
|
||||
add (outputScrollPane, tabName);
|
||||
return outputScrollPane;
|
||||
}
|
||||
@ -274,7 +284,8 @@ class DataPanel extends JTabbedPane implements DiskSelectionListener, FileSelect
|
||||
{
|
||||
Graphics2D g2 = ((Graphics2D) g);
|
||||
g2.transform (AffineTransform.getScaleInstance (scale, scale));
|
||||
g2.drawImage (image, (getWidth () - image.getWidth () * scale) / 2 / scale, 4, this);
|
||||
g2.drawImage (image, (getWidth () - image.getWidth () * scale) / 2 / scale, 4,
|
||||
this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,14 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.Checksum;
|
||||
|
||||
@ -25,8 +32,8 @@ public class TreeBuilder
|
||||
{
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat ("dd MMM yyyy");
|
||||
private static final boolean FULL_TREE = false;
|
||||
private static final List<String> suffixes = Arrays.asList ("po", "dsk", "do", "hdv", "2mg",
|
||||
"d13", "sdk", "gz");
|
||||
private static final List<String> suffixes =
|
||||
Arrays.asList ("po", "dsk", "do", "hdv", "2mg", "d13", "sdk", "gz");
|
||||
|
||||
FileComparator fc = new FileComparator ();
|
||||
JTree tree;
|
||||
@ -35,14 +42,15 @@ public class TreeBuilder
|
||||
|
||||
Map<String, Integer> totalFiles = new TreeMap<String, Integer> ();
|
||||
|
||||
Map<String, List<DiskDetails>> duplicateDisks = new TreeMap<String, List<DiskDetails>> ();
|
||||
Map<String, List<DiskDetails>> duplicateDisks =
|
||||
new TreeMap<String, List<DiskDetails>> ();
|
||||
Map<String, File> diskNames = new HashMap<String, File> ();
|
||||
Map<Long, List<File>> dosMap = new TreeMap<Long, List<File>> ();
|
||||
|
||||
public TreeBuilder (File folder)
|
||||
{
|
||||
assert (folder.exists ());
|
||||
assert (folder.isDirectory ());
|
||||
assert(folder.exists ());
|
||||
assert(folder.isDirectory ());
|
||||
|
||||
long start = System.currentTimeMillis ();
|
||||
|
||||
@ -54,12 +62,12 @@ public class TreeBuilder
|
||||
tree = new JTree (treeModel);
|
||||
|
||||
long duration = System.currentTimeMillis () - start;
|
||||
System.out
|
||||
.printf ("Tree building took %,d milliseconds for %,d disk%s and %,d folder%s%n",
|
||||
duration, totalDisks, (totalDisks == 1 ? "" : "s"), totalFolders,
|
||||
(totalFolders == 1 ? "" : "s"));
|
||||
System.out.printf (
|
||||
"Tree building took %,d milliseconds for %,d disk%s and %,d folder%s%n",
|
||||
duration, totalDisks, (totalDisks == 1 ? "" : "s"), totalFolders,
|
||||
(totalFolders == 1 ? "" : "s"));
|
||||
|
||||
treeModel.setAsksAllowsChildren (true); // allows empty nodes to appear as folders
|
||||
treeModel.setAsksAllowsChildren (true);// allows empty nodes to appear as folders
|
||||
setDiskIcon ("/com/bytezone/diskbrowser/icons/disk.png");
|
||||
((FileNode) root.getUserObject ()).disks = totalDisks;
|
||||
|
||||
@ -102,7 +110,7 @@ public class TreeBuilder
|
||||
totalFolders++;
|
||||
|
||||
if (FULL_TREE)
|
||||
addFiles (newNode, file); // recursion!
|
||||
addFiles (newNode, file);// recursion!
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -123,7 +131,7 @@ public class TreeBuilder
|
||||
}
|
||||
|
||||
if (file.length () != 143360 && file.length () != 116480 && file.length () != 819264
|
||||
&& file.length () < 200000)
|
||||
&& file.length () < 200000)
|
||||
{
|
||||
String name = file.getName ().toLowerCase ();
|
||||
if (!name.endsWith (".sdk") && !name.endsWith (".dsk.gz"))
|
||||
@ -179,9 +187,9 @@ public class TreeBuilder
|
||||
{
|
||||
diskList = new ArrayList<DiskDetails> ();
|
||||
duplicateDisks.put (file.getName (), diskList);
|
||||
diskList.add (new DiskDetails (diskNames.get (file.getName ()))); // add the original
|
||||
diskList.add (new DiskDetails (diskNames.get (file.getName ())));// add the original
|
||||
}
|
||||
diskList.add (new DiskDetails (file)); // add the duplicate
|
||||
diskList.add (new DiskDetails (file));// add the duplicate
|
||||
}
|
||||
else
|
||||
diskNames.put (file.getName (), file);
|
||||
@ -203,7 +211,8 @@ public class TreeBuilder
|
||||
if (url != null)
|
||||
{
|
||||
ImageIcon icon = new ImageIcon (url);
|
||||
DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer ();
|
||||
DefaultTreeCellRenderer renderer =
|
||||
(DefaultTreeCellRenderer) tree.getCellRenderer ();
|
||||
renderer.setLeafIcon (icon);
|
||||
tree.setCellRenderer (renderer);
|
||||
tree.setRowHeight (18);
|
||||
@ -273,9 +282,8 @@ public class TreeBuilder
|
||||
{
|
||||
String name = file.getName ();
|
||||
if (name.length () > MAX_NAME_LENGTH)
|
||||
name =
|
||||
name.substring (0, PREFIX_LENGTH) + "..."
|
||||
+ name.substring (name.length () - SUFFIX_LENGTH);
|
||||
name = name.substring (0, PREFIX_LENGTH) + "..."
|
||||
+ name.substring (name.length () - SUFFIX_LENGTH);
|
||||
if (showDisks && disks > 0)
|
||||
return String.format ("%s (%,d)", name, disks);
|
||||
return name;
|
||||
@ -288,9 +296,9 @@ public class TreeBuilder
|
||||
|
||||
text.append ("Directory : " + file.getAbsolutePath () + "\n\n");
|
||||
text.append ("D File names "
|
||||
+ " Date Size Type\n");
|
||||
+ " Date Size Type\n");
|
||||
text.append ("- ----------------------------------------"
|
||||
+ " ----------- -------------- ---------\n");
|
||||
+ " ----------- -------------- ---------\n");
|
||||
for (File f : file.listFiles ())
|
||||
{
|
||||
String name = f.getName ();
|
||||
@ -301,8 +309,9 @@ public class TreeBuilder
|
||||
int pos = name.lastIndexOf ('.');
|
||||
String type = pos > 0 && !f.isDirectory () ? name.substring (pos) : "";
|
||||
String size = f.isDirectory () ? "" : String.format ("%,14d", f.length ());
|
||||
text.append (String.format ("%s %-40.40s %s %-14s %s%n", f.isDirectory () ? "D"
|
||||
: " ", name, sdf.format (d), size, type));
|
||||
text.append (String.format ("%s %-40.40s %s %-14s %s%n",
|
||||
f.isDirectory () ? "D" : " ", name, sdf.format (d),
|
||||
size, type));
|
||||
}
|
||||
if (text.length () > 0)
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user