mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-08-14 17:27:22 +00:00
more functions
This commit is contained in:
@@ -68,7 +68,7 @@ class CatalogPanel extends JTabbedPane
|
|||||||
selector.addDiskSelectionListener (lister.diskLister);
|
selector.addDiskSelectionListener (lister.diskLister);
|
||||||
|
|
||||||
setTabPlacement (SwingConstants.BOTTOM);
|
setTabPlacement (SwingConstants.BOTTOM);
|
||||||
setPreferredSize (new Dimension (360, 802)); // width, height
|
setPreferredSize (new Dimension (360, 802)); // width, height
|
||||||
// setPreferredSize (new Dimension (360, 523)); // width, height
|
// setPreferredSize (new Dimension (360, 523)); // width, height
|
||||||
|
|
||||||
createTabs (prefs);
|
createTabs (prefs);
|
||||||
|
@@ -16,7 +16,8 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
|||||||
{
|
{
|
||||||
private static final String windowTitle = "Apple ][ Disk Browser";
|
private static final String windowTitle = "Apple ][ Disk Browser";
|
||||||
private static final String PREFS_FULL_SCREEN = "full screen";
|
private static final String PREFS_FULL_SCREEN = "full screen";
|
||||||
Preferences prefs = Preferences.userNodeForPackage (this.getClass ());
|
private final Preferences prefs = Preferences.userNodeForPackage (this.getClass ());
|
||||||
|
private WindowSaver windowSaver;
|
||||||
|
|
||||||
public DiskBrowser ()
|
public DiskBrowser ()
|
||||||
{
|
{
|
||||||
@@ -157,6 +158,19 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
|||||||
: e.getFormattedDisk ().getName ());
|
: e.getFormattedDisk ().getName ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void quit (Preferences preferences)
|
||||||
|
{
|
||||||
|
windowSaver.saveWindow ();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restore (Preferences preferences)
|
||||||
|
{
|
||||||
|
windowSaver = new WindowSaver (prefs, this, "DiskBrowser");
|
||||||
|
windowSaver.restoreWindow ();
|
||||||
|
}
|
||||||
|
|
||||||
public static void main (String[] args)
|
public static void main (String[] args)
|
||||||
{
|
{
|
||||||
EventQueue.invokeLater (new Runnable ()
|
EventQueue.invokeLater (new Runnable ()
|
||||||
@@ -169,32 +183,4 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void quit (Preferences preferences)
|
|
||||||
{
|
|
||||||
prefs.putBoolean (PREFS_FULL_SCREEN, getExtendedState () == MAXIMIZED_BOTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void restore (Preferences preferences)
|
|
||||||
{
|
|
||||||
if (true)
|
|
||||||
{
|
|
||||||
setLocationRelativeTo (null); // centre
|
|
||||||
|
|
||||||
// if we are on a smallish screen, just go fullscreen width
|
|
||||||
if (Platform.toolkit.getScreenSize ().width <= 1280)
|
|
||||||
setExtendedState (MAXIMIZED_HORIZ);
|
|
||||||
|
|
||||||
// restore window if it was previously at full screen
|
|
||||||
if (prefs.getBoolean (PREFS_FULL_SCREEN, false))
|
|
||||||
setExtendedState (MAXIMIZED_BOTH);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setLocation (10, 10);
|
|
||||||
setSize (1200, 812);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
51
src/com/bytezone/diskbrowser/gui/WindowSaver.java
Normal file
51
src/com/bytezone/diskbrowser/gui/WindowSaver.java
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
public class WindowSaver
|
||||||
|
{
|
||||||
|
private final Preferences prefs;
|
||||||
|
private final JFrame frame;
|
||||||
|
private final String key;
|
||||||
|
|
||||||
|
public WindowSaver (Preferences prefs, JFrame frame, String key)
|
||||||
|
{
|
||||||
|
this.prefs = prefs;
|
||||||
|
this.frame = frame;
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveWindow ()
|
||||||
|
{
|
||||||
|
prefs.putInt (key + "X", frame.getX ());
|
||||||
|
prefs.putInt (key + "Y", frame.getY ());
|
||||||
|
prefs.putInt (key + "Height", frame.getHeight ());
|
||||||
|
prefs.putInt (key + "Width", frame.getWidth ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean restoreWindow ()
|
||||||
|
{
|
||||||
|
int x = prefs.getInt (key + "X", -1);
|
||||||
|
int y = prefs.getInt (key + "Y", -1);
|
||||||
|
int height = prefs.getInt (key + "Height", -1);
|
||||||
|
int width = prefs.getInt (key + "Width", -1);
|
||||||
|
|
||||||
|
if (width < 0) // nothing to restore
|
||||||
|
{
|
||||||
|
frame.setLocationRelativeTo (null); // centre
|
||||||
|
// frame.centerOnScreen ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// frame.setX (x);
|
||||||
|
// frame.setY (y);
|
||||||
|
// frame.setHeight (height);
|
||||||
|
// frame.setWidth (width);
|
||||||
|
frame.setLocation (x, y);
|
||||||
|
frame.setSize (width, height);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
16
src/com/bytezone/diskbrowser/visicalc/Abs.java
Normal file
16
src/com/bytezone/diskbrowser/visicalc/Abs.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
public class Abs extends Function
|
||||||
|
{
|
||||||
|
|
||||||
|
Abs (Sheet parent, String text)
|
||||||
|
{
|
||||||
|
super (parent, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getValue ()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
@@ -7,6 +7,18 @@ class Error extends Function
|
|||||||
super (parent, text);
|
super (parent, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasValue ()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getError ()
|
||||||
|
{
|
||||||
|
return "@Error";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getValue ()
|
public double getValue ()
|
||||||
{
|
{
|
||||||
|
@@ -60,17 +60,32 @@ abstract class Function implements Value
|
|||||||
if (text.startsWith ("@AND("))
|
if (text.startsWith ("@AND("))
|
||||||
return new And (parent, text);
|
return new And (parent, text);
|
||||||
|
|
||||||
|
if (text.startsWith ("@NPV("))
|
||||||
|
return new Npv (parent, text);
|
||||||
|
|
||||||
|
if (text.startsWith ("@ABS("))
|
||||||
|
return new Abs (parent, text);
|
||||||
|
|
||||||
|
if (text.startsWith ("@INT("))
|
||||||
|
return new Int (parent, text);
|
||||||
|
|
||||||
if (text.startsWith ("@ISERROR("))
|
if (text.startsWith ("@ISERROR("))
|
||||||
return new IsError (parent, text);
|
return new IsError (parent, text);
|
||||||
|
|
||||||
if (text.startsWith ("@ERROR("))
|
if (text.startsWith ("@ISNA("))
|
||||||
|
return new IsNa (parent, text);
|
||||||
|
|
||||||
|
if (text.startsWith ("@PI"))
|
||||||
|
return new Pi (parent, text);
|
||||||
|
|
||||||
|
if (text.startsWith ("@ERROR"))
|
||||||
return new Error (parent, text);
|
return new Error (parent, text);
|
||||||
|
|
||||||
if (text.equals ("@NA"))
|
if (text.equals ("@NA"))
|
||||||
return new Error (parent, text);
|
return new Na (parent, text);
|
||||||
|
|
||||||
System.out.printf ("Unknown function: [%s]%n", text);
|
System.out.printf ("Unknown function: [%s]%n", text);
|
||||||
return new Error (parent, "@ERROR()");
|
return new Error (parent, "@ERROR");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function (Sheet parent, String text)
|
Function (Sheet parent, String text)
|
||||||
|
16
src/com/bytezone/diskbrowser/visicalc/Int.java
Normal file
16
src/com/bytezone/diskbrowser/visicalc/Int.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
public class Int extends Function
|
||||||
|
{
|
||||||
|
|
||||||
|
Int (Sheet parent, String text)
|
||||||
|
{
|
||||||
|
super (parent, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getValue ()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
16
src/com/bytezone/diskbrowser/visicalc/IsNa.java
Normal file
16
src/com/bytezone/diskbrowser/visicalc/IsNa.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
public class IsNa extends Function
|
||||||
|
{
|
||||||
|
|
||||||
|
IsNa (Sheet parent, String text)
|
||||||
|
{
|
||||||
|
super (parent, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getValue ()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
27
src/com/bytezone/diskbrowser/visicalc/Na.java
Normal file
27
src/com/bytezone/diskbrowser/visicalc/Na.java
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
public class Na extends Function
|
||||||
|
{
|
||||||
|
public Na (Sheet parent, String text)
|
||||||
|
{
|
||||||
|
super (parent, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasValue ()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getError ()
|
||||||
|
{
|
||||||
|
return "@NA";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getValue ()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
55
src/com/bytezone/diskbrowser/visicalc/Npv.java
Normal file
55
src/com/bytezone/diskbrowser/visicalc/Npv.java
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
public class Npv extends Function
|
||||||
|
{
|
||||||
|
private final String valueText;
|
||||||
|
private final String rangeText;
|
||||||
|
|
||||||
|
private final Expression valueExp;
|
||||||
|
private final Range range;
|
||||||
|
|
||||||
|
private boolean hasChecked;
|
||||||
|
private final double value = 0;
|
||||||
|
|
||||||
|
Npv (Sheet parent, String text)
|
||||||
|
{
|
||||||
|
super (parent, text);
|
||||||
|
|
||||||
|
int pos = text.indexOf (',');
|
||||||
|
valueText = text.substring (8, pos);
|
||||||
|
rangeText = text.substring (pos + 1, text.length () - 1);
|
||||||
|
|
||||||
|
valueExp = new Expression (parent, valueText);
|
||||||
|
range = getRange (rangeText);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasValue ()
|
||||||
|
{
|
||||||
|
if (!hasChecked)
|
||||||
|
calculate ();
|
||||||
|
return hasValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getValue ()
|
||||||
|
{
|
||||||
|
return hasValue () ? value : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculate ()
|
||||||
|
{
|
||||||
|
hasChecked = true;
|
||||||
|
hasValue = false;
|
||||||
|
|
||||||
|
for (Address address : range)
|
||||||
|
{
|
||||||
|
Cell cell = parent.getCell (address);
|
||||||
|
if (cell != null && cell.hasValue ())
|
||||||
|
{
|
||||||
|
hasValue = true;
|
||||||
|
// calculate something
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -10,6 +10,6 @@ class Pi extends Function
|
|||||||
@Override
|
@Override
|
||||||
public double getValue ()
|
public double getValue ()
|
||||||
{
|
{
|
||||||
return 3.14159265;
|
return 3.1415926536;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user