mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-07 11:30:39 +00:00
method header lines
This commit is contained in:
parent
6b3c7011d3
commit
846c975be6
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class Abs extends ValueFunction
|
public class Abs extends ValueFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Abs (Cell cell, String text)
|
Abs (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@ABS(") : text;
|
assert text.startsWith ("@ABS(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
double calculateValue ()
|
double calculateValue ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return Math.abs (source.getDouble ());
|
return Math.abs (source.getDouble ());
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class AbstractValue implements Value
|
// -----------------------------------------------------------------------------------//
|
||||||
|
abstract class AbstractValue implements Value
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
protected static final String FMT2 = "| %-9.9s : %-70.70s|%n";
|
protected static final String FMT2 = "| %-9.9s : %-70.70s|%n";
|
||||||
protected static final String FMT4 = "| %-9.9s : %-50.50s %-8.8s %-10.10s|%n";
|
protected static final String FMT4 = "| %-9.9s : %-50.50s %-8.8s %-10.10s|%n";
|
||||||
@ -22,69 +24,91 @@ public abstract class AbstractValue implements Value
|
|||||||
protected ValueResult valueResult = ValueResult.VALID;
|
protected ValueResult valueResult = ValueResult.VALID;
|
||||||
protected List<Value> values = new ArrayList<> ();
|
protected List<Value> values = new ArrayList<> ();
|
||||||
|
|
||||||
public AbstractValue (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
AbstractValue (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.cell = cell;
|
this.cell = cell;
|
||||||
this.fullText = text;
|
this.fullText = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getFullText ()
|
public String getFullText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return fullText;
|
return fullText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public ValueType getValueType ()
|
public ValueType getValueType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return valueType;
|
return valueType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public ValueResult getValueResult ()
|
public ValueResult getValueResult ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return valueResult;
|
return valueResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid ()
|
public boolean isValid ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return valueResult == ValueResult.VALID;
|
return valueResult == ValueResult.VALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public double getDouble ()
|
public double getDouble ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert valueType == ValueType.NUMBER;
|
assert valueType == ValueType.NUMBER;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean getBoolean ()
|
public boolean getBoolean ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert valueType == ValueType.BOOLEAN;
|
assert valueType == ValueType.BOOLEAN;
|
||||||
return bool;
|
return bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int size ()
|
public int size ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return values.size ();
|
return values.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getText ()
|
public String getText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return valueResult == ValueResult.VALID ? getValueText (this) : valueResult + "";
|
return valueResult == ValueResult.VALID ? getValueText (this) : valueResult + "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
// System.out.println ("calculate not overridden: " + cell);
|
// System.out.println ("calculate not overridden: " + cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
protected void attach (StringBuilder text, String title, String textValue, Value value)
|
protected void attach (StringBuilder text, String title, String textValue, Value value)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
text.append (String.format (FMT4, title, textValue, value.getValueType (),
|
text.append (String.format (FMT4, title, textValue, value.getValueType (),
|
||||||
getValueText (value)));
|
getValueText (value)));
|
||||||
@ -92,7 +116,9 @@ public abstract class AbstractValue implements Value
|
|||||||
text.append (v);
|
text.append (v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
protected String getValueText (Value value)
|
protected String getValueText (Value value)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (value.getValueType () == ValueType.NUMBER)
|
if (value.getValueType () == ValueType.NUMBER)
|
||||||
return value.getDouble () + "";
|
return value.getDouble () + "";
|
||||||
@ -101,8 +127,10 @@ public abstract class AbstractValue implements Value
|
|||||||
return "??*??";
|
return "??*??";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Value> iterator ()
|
public Iterator<Value> iterator ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return values.iterator ();
|
return values.iterator ();
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class Acos extends ValueFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Acos extends ValueFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Acos (Cell cell, String text)
|
Acos (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@ACOS(") : text;
|
assert text.startsWith ("@ACOS(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public double calculateValue ()
|
public double calculateValue ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return Math.acos (source.getDouble ());
|
return Math.acos (source.getDouble ());
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.visicalc;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class Address implements Comparable<Address>
|
class Address implements Comparable<Address>
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final int MAX_ROWS = 255;
|
private static final int MAX_ROWS = 255;
|
||||||
private static final int MAX_COLUMNS = 64;
|
private static final int MAX_COLUMNS = 64;
|
||||||
@ -12,12 +14,16 @@ class Address implements Comparable<Address>
|
|||||||
private int columnKey;
|
private int columnKey;
|
||||||
private String text;
|
private String text;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public Address (String column, String row)
|
public Address (String column, String row)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
set (column, row);
|
set (column, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public Address (int column, int row)
|
public Address (int column, int row)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert column <= MAX_COLUMNS;
|
assert column <= MAX_COLUMNS;
|
||||||
assert row <= MAX_ROWS;
|
assert row <= MAX_ROWS;
|
||||||
@ -34,7 +40,9 @@ class Address implements Comparable<Address>
|
|||||||
text = col + (row + 1);
|
text = col + (row + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public Address (String address)
|
public Address (String address)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert address.length () >= 2;
|
assert address.length () >= 2;
|
||||||
if (address.charAt (1) < 'A')
|
if (address.charAt (1) < 'A')
|
||||||
@ -43,13 +51,17 @@ class Address implements Comparable<Address>
|
|||||||
set (address.substring (0, 2), address.substring (2));
|
set (address.substring (0, 2), address.substring (2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public boolean matches (String addressText)
|
public boolean matches (String addressText)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Address address = new Address (addressText);
|
Address address = new Address (addressText);
|
||||||
return this.rowMatches (address) && this.columnMatches (address);
|
return this.rowMatches (address) && this.columnMatches (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void set (String sCol, String sRow)
|
private void set (String sCol, String sRow)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (sCol.length () == 1)
|
if (sCol.length () == 1)
|
||||||
column = sCol.charAt (0) - 'A';
|
column = sCol.charAt (0) - 'A';
|
||||||
@ -73,75 +85,101 @@ class Address implements Comparable<Address>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
boolean rowMatches (Address other)
|
boolean rowMatches (Address other)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return row == other.row;
|
return row == other.row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
boolean columnMatches (Address other)
|
boolean columnMatches (Address other)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return column == other.column;
|
return column == other.column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
int getRow ()
|
int getRow ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
int getColumn ()
|
int getColumn ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Address nextRow ()
|
Address nextRow ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Address next = new Address (column, row + 1);
|
Address next = new Address (column, row + 1);
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Address nextColumn ()
|
Address nextColumn ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Address next = new Address (column + 1, row);
|
Address next = new Address (column + 1, row);
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copied from Appleworks Cell
|
// copied from Appleworks Cell
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
static String getCellName (int row, int column)
|
static String getCellName (int row, int column)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
char c1 = (char) ('A' + column / 26 - 1);
|
char c1 = (char) ('A' + column / 26 - 1);
|
||||||
char c2 = (char) ('A' + column % 26);
|
char c2 = (char) ('A' + column % 26);
|
||||||
return "" + (c1 == '@' ? "" : c1) + c2 + row;
|
return "" + (c1 == '@' ? "" : c1) + c2 + row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public String getText ()
|
public String getText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
int getRowKey ()
|
int getRowKey ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return rowKey;
|
return rowKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
int getColumnKey ()
|
int getColumnKey ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return columnKey;
|
return columnKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public String getDetails ()
|
public String getDetails ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return String.format ("Row:%3d Col:%3d rKey:%5d cKey:%5d", row, column, rowKey,
|
return String.format ("Row:%3d Col:%3d rKey:%5d cKey:%5d", row, column, rowKey,
|
||||||
columnKey);
|
columnKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return String.format ("%-6s Row:%3d Col:%3d Key:%4d", text, row, column, rowKey);
|
return String.format ("%-6s Row:%3d Col:%3d Key:%4d", text, row, column, rowKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int compareTo (Address o)
|
public int compareTo (Address o)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return rowKey - o.rowKey;
|
return rowKey - o.rowKey;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class And extends ConditionListFunction
|
class And extends ConditionListFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public And (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
And (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@AND(") : text;
|
assert text.startsWith ("@AND(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
valueResult = ValueResult.VALID;
|
valueResult = ValueResult.VALID;
|
||||||
|
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class Asin extends ValueFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Asin extends ValueFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Asin (Cell cell, String text)
|
Asin (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@ASIN(") : text;
|
assert text.startsWith ("@ASIN(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public double calculateValue ()
|
public double calculateValue ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return Math.asin (source.getDouble ());
|
return Math.asin (source.getDouble ());
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class Atan extends ValueFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Atan extends ValueFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Atan (Cell cell, String text)
|
Atan (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@ATAN(") : text;
|
assert text.startsWith ("@ATAN(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public double calculateValue ()
|
public double calculateValue ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return Math.atan (source.getDouble ());
|
return Math.atan (source.getDouble ());
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,23 @@ package com.bytezone.diskbrowser.visicalc;
|
|||||||
|
|
||||||
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
|
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
|
||||||
|
|
||||||
public class Average extends ValueListFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Average extends ValueListFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public Average (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Average (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
assert text.startsWith ("@AVERAGE(") : text;
|
assert text.startsWith ("@AVERAGE(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
double total = 0.0;
|
double total = 0.0;
|
||||||
int totalChecked = 0;
|
int totalChecked = 0;
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class BooleanFunction extends Function
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class BooleanFunction extends Function
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
protected Value source;
|
protected Value source;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
BooleanFunction (Cell cell, String text)
|
BooleanFunction (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
@ -13,8 +17,10 @@ public class BooleanFunction extends Function
|
|||||||
valueType = ValueType.BOOLEAN;
|
valueType = ValueType.BOOLEAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getType ()
|
public String getType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return "BooleanFunction";
|
return "BooleanFunction";
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.visicalc;
|
|||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class Cell implements Value, Comparable<Cell>
|
class Cell implements Value, Comparable<Cell>
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final String empty = " ";
|
private static final String empty = " ";
|
||||||
|
|
||||||
@ -23,7 +25,9 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
LABEL, FILLER, VALUE, EMPTY
|
LABEL, FILLER, VALUE, EMPTY
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cell (Sheet parent, Address address)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Cell (Sheet parent, Address address)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
@ -31,7 +35,9 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
cellType = CellType.EMPTY;
|
cellType = CellType.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
void setFormat (String formatText)
|
void setFormat (String formatText)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (formatText.startsWith ("/T")) // lock titles
|
if (formatText.startsWith ("/T")) // lock titles
|
||||||
return;
|
return;
|
||||||
@ -57,7 +63,9 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
System.out.printf ("Unexpected format [%s]%n", formatText);
|
System.out.printf ("Unexpected format [%s]%n", formatText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
void setValue (String valueText)
|
void setValue (String valueText)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert cellType == CellType.EMPTY;
|
assert cellType == CellType.EMPTY;
|
||||||
|
|
||||||
@ -84,28 +92,38 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
setTestData (0);
|
setTestData (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
void reset ()
|
void reset ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
calculated = false;
|
calculated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Value getExpressionValue (String text)
|
Value getExpressionValue (String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return new Expression (this, text).reduce ();
|
return new Expression (this, text).reduce ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
boolean isCellType (CellType cellType)
|
boolean isCellType (CellType cellType)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return this.cellType == cellType;
|
return this.cellType == cellType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Address getAddress ()
|
Address getAddress ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
// format cell value for output
|
// format cell value for output
|
||||||
String getFormattedText (int colWidth, char globalFormat)
|
String getFormattedText (int colWidth, char globalFormat)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
char fmtChar = cellFormat != ' ' ? cellFormat : globalFormat;
|
char fmtChar = cellFormat != ' ' ? cellFormat : globalFormat;
|
||||||
|
|
||||||
@ -159,36 +177,46 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
// Sheet convenience methods
|
// Sheet convenience methods
|
||||||
// --------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Cell getCell (Address address)
|
Cell getCell (Address address)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return parent.getCell (address);
|
return parent.getCell (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Cell getCell (String addressText)
|
Cell getCell (String addressText)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return parent.getCell (addressText);
|
return parent.getCell (addressText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
boolean cellExists (Address address)
|
boolean cellExists (Address address)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return parent.cellExists (address);
|
return parent.cellExists (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Function getFunction (String text)
|
Function getFunction (String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return parent.getFunction (this, text);
|
return parent.getFunction (this, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
// Value interface methods
|
// Value interface methods
|
||||||
// --------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (cellType == CellType.VALUE && !calculated)
|
if (cellType == CellType.VALUE && !calculated)
|
||||||
{
|
{
|
||||||
@ -197,44 +225,58 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid ()
|
public boolean isValid ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return cellType == CellType.VALUE ? value.isValid () : true;
|
return cellType == CellType.VALUE ? value.isValid () : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public ValueType getValueType ()
|
public ValueType getValueType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return cellType == CellType.VALUE ? value.getValueType () : ValueType.NUMBER;
|
return cellType == CellType.VALUE ? value.getValueType () : ValueType.NUMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public ValueResult getValueResult ()
|
public ValueResult getValueResult ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return cellType == CellType.VALUE ? value.getValueResult () : ValueResult.VALID;
|
return cellType == CellType.VALUE ? value.getValueResult () : ValueResult.VALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public double getDouble ()
|
public double getDouble ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return cellType == CellType.VALUE ? value.getDouble () : 0;
|
return cellType == CellType.VALUE ? value.getDouble () : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean getBoolean ()
|
public boolean getBoolean ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return cellType == CellType.VALUE ? value.getBoolean () : false;
|
return cellType == CellType.VALUE ? value.getBoolean () : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getText ()
|
public String getText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return cellType == CellType.VALUE ? value.getText () : "???";
|
return cellType == CellType.VALUE ? value.getText () : "???";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getFullText ()
|
public String getFullText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
switch (cellType)
|
switch (cellType)
|
||||||
{
|
{
|
||||||
@ -251,29 +293,37 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getType ()
|
public String getType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return "Cell " + address.getText ();
|
return "Cell " + address.getText ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int size ()
|
public int size ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return cellType == CellType.VALUE ? value.size () : 0;
|
return cellType == CellType.VALUE ? value.size () : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Value> iterator ()
|
public Iterator<Value> iterator ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return cellType == CellType.VALUE ? value.iterator () : null;
|
return cellType == CellType.VALUE ? value.iterator () : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
// end of Value interface methods
|
// end of Value interface methods
|
||||||
// --------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void setTestData (int choice)
|
private void setTestData (int choice)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
// FUTURE.VC
|
// FUTURE.VC
|
||||||
if (choice == 1)
|
if (choice == 1)
|
||||||
@ -320,14 +370,18 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int compareTo (Cell o)
|
public int compareTo (Cell o)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return address.compareTo (o.address);
|
return address.compareTo (o.address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String contents = "";
|
String contents = "";
|
||||||
String contents2 = "";
|
String contents2 = "";
|
||||||
|
@ -2,17 +2,23 @@ package com.bytezone.diskbrowser.visicalc;
|
|||||||
|
|
||||||
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
|
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
|
||||||
|
|
||||||
public class Choose extends ValueListFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Choose extends ValueListFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Choose (Cell cell, String text)
|
Choose (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
assert text.startsWith ("@CHOOSE(") : text;
|
assert text.startsWith ("@CHOOSE(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Value source = list.get (0);
|
Value source = list.get (0);
|
||||||
valueResult = ValueResult.VALID;
|
valueResult = ValueResult.VALID;
|
||||||
|
@ -4,7 +4,9 @@ import java.util.Iterator;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
// Predicate
|
// Predicate
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class Condition extends AbstractValue implements Iterable<Value>
|
class Condition extends AbstractValue implements Iterable<Value>
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final Pattern cellAddress = Pattern.compile ("[A-B]?[A-Z][0-9]{1,3}");
|
private static final Pattern cellAddress = Pattern.compile ("[A-B]?[A-Z][0-9]{1,3}");
|
||||||
private static final String[] comparators = { "<>", "<=", ">=", "=", "<", ">" };
|
private static final String[] comparators = { "<>", "<=", ">=", "=", "<", ">" };
|
||||||
@ -16,7 +18,9 @@ class Condition extends AbstractValue implements Iterable<Value>
|
|||||||
private Value conditionExpression;
|
private Value conditionExpression;
|
||||||
private Value valueExpression;
|
private Value valueExpression;
|
||||||
|
|
||||||
public Condition (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Condition (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
@ -52,8 +56,10 @@ class Condition extends AbstractValue implements Iterable<Value>
|
|||||||
"No comparator and not a function or address: " + text);
|
"No comparator and not a function or address: " + text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
valueResult = ValueResult.VALID;
|
valueResult = ValueResult.VALID;
|
||||||
|
|
||||||
@ -97,19 +103,25 @@ class Condition extends AbstractValue implements Iterable<Value>
|
|||||||
System.out.printf ("Unexpected comparator result [%s]%n", comparator);
|
System.out.printf ("Unexpected comparator result [%s]%n", comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getFullText ()
|
public String getFullText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return fullText;
|
return fullText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getType ()
|
public String getType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return "Condition";
|
return "Condition";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
static boolean isCondition (String text)
|
static boolean isCondition (String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int ptr = 0;
|
int ptr = 0;
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
@ -129,14 +141,18 @@ class Condition extends AbstractValue implements Iterable<Value>
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Value> iterator ()
|
public Iterator<Value> iterator ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return values.iterator ();
|
return values.iterator ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
|
@ -4,11 +4,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ConditionList implements Iterable<Value>
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class ConditionList implements Iterable<Value>
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final List<Value> conditions = new ArrayList<> ();
|
private final List<Value> conditions = new ArrayList<> ();
|
||||||
|
|
||||||
public ConditionList (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
ConditionList (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String remainder = text;
|
String remainder = text;
|
||||||
|
|
||||||
@ -30,18 +34,24 @@ public class ConditionList implements Iterable<Value>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public Value get (int index)
|
public Value get (int index)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return conditions.get (index);
|
return conditions.get (index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public int size ()
|
public int size ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return conditions.size ();
|
return conditions.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Value> iterator ()
|
public Iterator<Value> iterator ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return conditions.iterator ();
|
return conditions.iterator ();
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class ConditionListFunction extends Function
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class ConditionListFunction extends Function
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
protected final ConditionList conditions;
|
protected final ConditionList conditions;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
ConditionListFunction (Cell cell, String text)
|
ConditionListFunction (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
@ -15,8 +19,10 @@ public class ConditionListFunction extends Function
|
|||||||
valueType = ValueType.BOOLEAN;
|
valueType = ValueType.BOOLEAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getType ()
|
public String getType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return "CLF";
|
return "CLF";
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public abstract class ConstantFunction extends Function
|
// -----------------------------------------------------------------------------------//
|
||||||
|
abstract class ConstantFunction extends Function
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public ConstantFunction (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
ConstantFunction (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getType ()
|
public String getType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return "ConstantFunction";
|
return "ConstantFunction";
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class Cos extends ValueFunction
|
// ---------------------------------------------------------------------------------//
|
||||||
|
class Cos extends ValueFunction
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Cos (Cell cell, String text)
|
Cos (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@COS(") : text;
|
assert text.startsWith ("@COS(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public double calculateValue ()
|
public double calculateValue ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return Math.cos (source.getDouble ());
|
return Math.cos (source.getDouble ());
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,23 @@ package com.bytezone.diskbrowser.visicalc;
|
|||||||
|
|
||||||
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
|
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class Count extends ValueListFunction
|
class Count extends ValueListFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public Count (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Count (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
assert text.startsWith ("@COUNT(") : text;
|
assert text.startsWith ("@COUNT(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
value = 0;
|
value = 0;
|
||||||
|
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class Error extends ConstantFunction
|
class Error extends ConstantFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public Error (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Error (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class Exp extends ValueFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Exp extends ValueFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Exp (Cell cell, String text)
|
Exp (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@EXP(") : text;
|
assert text.startsWith ("@EXP(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public double calculateValue ()
|
public double calculateValue ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return Math.exp (source.getDouble ());
|
return Math.exp (source.getDouble ());
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,16 @@ package com.bytezone.diskbrowser.visicalc;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class Expression extends AbstractValue
|
class Expression extends AbstractValue
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final List<String> operators = new ArrayList<> ();
|
private final List<String> operators = new ArrayList<> ();
|
||||||
private final List<String> signs = new ArrayList<> ();
|
private final List<String> signs = new ArrayList<> ();
|
||||||
|
|
||||||
public Expression (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Expression (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
@ -97,26 +101,34 @@ class Expression extends AbstractValue
|
|||||||
valueType = values.get (0).getValueType ();
|
valueType = values.get (0).getValueType ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Value reduce ()
|
Value reduce ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return values.size () == 1 && signs.get (0).equals ("(+)") ? values.get (0) : this;
|
return values.size () == 1 && signs.get (0).equals ("(+)") ? values.get (0) : this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Value get (int index)
|
Value get (int index)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (index < 0 || index >= values.size ())
|
if (index < 0 || index >= values.size ())
|
||||||
throw new IllegalArgumentException ();
|
throw new IllegalArgumentException ();
|
||||||
return values.get (index);
|
return values.get (index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getType ()
|
public String getType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return "Expression";
|
return "Expression";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert values.size () > 0;
|
assert values.size () > 0;
|
||||||
|
|
||||||
@ -191,7 +203,9 @@ class Expression extends AbstractValue
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private String balanceBrackets (String input)
|
private String balanceBrackets (String input)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String line = input.trim ();
|
String line = input.trim ();
|
||||||
|
|
||||||
@ -224,7 +238,9 @@ class Expression extends AbstractValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
// called for functions and expressions
|
// called for functions and expressions
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private String getBalancedText (String text)
|
private String getBalancedText (String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int ptr = text.indexOf ('('); // find first left parenthesis
|
int ptr = text.indexOf ('('); // find first left parenthesis
|
||||||
if (ptr < 0)
|
if (ptr < 0)
|
||||||
@ -248,7 +264,9 @@ class Expression extends AbstractValue
|
|||||||
|
|
||||||
// reads text up to the next comma that is not part of a function
|
// reads text up to the next comma that is not part of a function
|
||||||
// text does not include the outer brackets or calling function name
|
// text does not include the outer brackets or calling function name
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
static String getParameter (String text)
|
static String getParameter (String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
int ptr = 0;
|
int ptr = 0;
|
||||||
@ -269,7 +287,9 @@ class Expression extends AbstractValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
// receives a string starting with the function name
|
// receives a string starting with the function name
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private String getFunctionCall (String text)
|
private String getFunctionCall (String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (text.charAt (0) != '@')
|
if (text.charAt (0) != '@')
|
||||||
throw new IllegalArgumentException ("Bad function name: " + text);
|
throw new IllegalArgumentException ("Bad function name: " + text);
|
||||||
@ -285,7 +305,9 @@ class Expression extends AbstractValue
|
|||||||
throw new IllegalArgumentException ("Bad function name: " + text);
|
throw new IllegalArgumentException ("Bad function name: " + text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private String getNumberText (String text)
|
private String getNumberText (String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int ptr = 0;
|
int ptr = 0;
|
||||||
while (++ptr < text.length ())
|
while (++ptr < text.length ())
|
||||||
@ -297,7 +319,9 @@ class Expression extends AbstractValue
|
|||||||
return text.substring (0, ptr);
|
return text.substring (0, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private String getAddressText (String text)
|
private String getAddressText (String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int ptr = 0;
|
int ptr = 0;
|
||||||
while (++ptr < text.length ())
|
while (++ptr < text.length ())
|
||||||
@ -309,7 +333,9 @@ class Expression extends AbstractValue
|
|||||||
return text.substring (0, ptr);
|
return text.substring (0, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public String fullText ()
|
public String fullText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
@ -326,8 +352,10 @@ class Expression extends AbstractValue
|
|||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
text.append (String.format ("%s%n", LINE));
|
text.append (String.format ("%s%n", LINE));
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class False extends ConstantFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class False extends ConstantFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
False (Cell cell, String text)
|
False (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
|
@ -1,17 +1,23 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class Format
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Format
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final String OVERFLOW = ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
|
private static final String OVERFLOW = ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
|
||||||
private static final String HISTOGRAM = "***********************************";
|
private static final String HISTOGRAM = "***********************************";
|
||||||
private static final String UNKNOWN = "???????????????????????????????????";
|
private static final String UNKNOWN = "???????????????????????????????????";
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private Format ()
|
private Format ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
static String format (Value value, char formatChar, int colWidth)
|
static String format (Value value, char formatChar, int colWidth)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
double actualValue = value.getDouble ();
|
double actualValue = value.getDouble ();
|
||||||
if (actualValue == -0.0)
|
if (actualValue == -0.0)
|
||||||
@ -96,7 +102,9 @@ public class Format
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
static String justify (String text, int colWidth, char format)
|
static String justify (String text, int colWidth, char format)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
// right justify
|
// right justify
|
||||||
if (format == 'R' || format == '$' || format == 'I')
|
if (format == 'R' || format == '$' || format == 'I')
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
abstract class Function extends AbstractValue
|
abstract class Function extends AbstractValue
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
static final String[] functionList =
|
static final String[] functionList =
|
||||||
{ "@ABS(", "@ACOS(", "@AND(", "@ASIN(", "@ATAN(", "@AVERAGE(", "@COUNT(",
|
{ "@ABS(", "@ACOS(", "@AND(", "@ASIN(", "@ATAN(", "@AVERAGE(", "@COUNT(",
|
||||||
@ -11,7 +13,9 @@ abstract class Function extends AbstractValue
|
|||||||
protected final String functionName;
|
protected final String functionName;
|
||||||
protected final String functionText;
|
protected final String functionText;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Function (Cell cell, String text)
|
Function (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
@ -29,8 +33,10 @@ abstract class Function extends AbstractValue
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
text.append (String.format ("%s%n", LINE));
|
text.append (String.format ("%s%n", LINE));
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class If extends Function
|
class If extends Function
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final String conditionText;
|
private final String conditionText;
|
||||||
private final String textTrue;
|
private final String textTrue;
|
||||||
@ -10,7 +12,9 @@ class If extends Function
|
|||||||
private final Value expTrue;
|
private final Value expTrue;
|
||||||
private final Value expFalse;
|
private final Value expFalse;
|
||||||
|
|
||||||
public If (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
If (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
@ -42,8 +46,10 @@ class If extends Function
|
|||||||
valueType = expTrue.getValueType ();
|
valueType = expTrue.getValueType ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
valueResult = ValueResult.VALID;
|
valueResult = ValueResult.VALID;
|
||||||
|
|
||||||
@ -73,14 +79,18 @@ class If extends Function
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getType ()
|
public String getType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return "If";
|
return "If";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class Int extends ValueFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Int extends ValueFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Int (Cell cell, String text)
|
Int (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@INT(") : text;
|
assert text.startsWith ("@INT(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public double calculateValue ()
|
public double calculateValue ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return (int) source.getDouble ();
|
return (int) source.getDouble ();
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class IsError extends BooleanFunction
|
class IsError extends BooleanFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public IsError (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
IsError (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
assert text.startsWith ("@ISERROR(") : text;
|
assert text.startsWith ("@ISERROR(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
source.calculate ();
|
source.calculate ();
|
||||||
bool = source.getValueResult () == ValueResult.ERROR;
|
bool = source.getValueResult () == ValueResult.ERROR;
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class IsNa extends BooleanFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class IsNa extends BooleanFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
IsNa (Cell cell, String text)
|
IsNa (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
assert text.startsWith ("@ISNA(") : text;
|
assert text.startsWith ("@ISNA(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
source.calculate ();
|
source.calculate ();
|
||||||
bool = source.getValueResult () == ValueResult.NA;
|
bool = source.getValueResult () == ValueResult.NA;
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class Ln extends ValueFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Ln extends ValueFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Ln (Cell cell, String text)
|
Ln (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@LN(") : text;
|
assert text.startsWith ("@LN(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public double calculateValue ()
|
public double calculateValue ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return Math.log (source.getDouble ());
|
return Math.log (source.getDouble ());
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class Log10 extends ValueFunction
|
// ---------------------------------------------------------------------------------//
|
||||||
|
class Log10 extends ValueFunction
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Log10 (Cell cell, String text)
|
Log10 (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@LOG10(") : text;
|
assert text.startsWith ("@LOG10(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public double calculateValue ()
|
public double calculateValue ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return Math.log10 (source.getDouble ());
|
return Math.log10 (source.getDouble ());
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class Lookup extends ValueListFunction
|
class Lookup extends ValueListFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public Lookup (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Lookup (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
assert text.startsWith ("@LOOKUP(") : text;
|
assert text.startsWith ("@LOOKUP(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Value source = list.get (0); // first Value is the value to look up
|
Value source = list.get (0); // first Value is the value to look up
|
||||||
valueResult = ValueResult.VALID;
|
valueResult = ValueResult.VALID;
|
||||||
@ -55,7 +61,9 @@ class Lookup extends ValueListFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
// is the range horizontal or vertical?
|
// is the range horizontal or vertical?
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private boolean isVertical ()
|
private boolean isVertical ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Cell firstCell = (Cell) list.get (1);
|
Cell firstCell = (Cell) list.get (1);
|
||||||
Cell lastCell = (Cell) list.get (list.size () - 1);
|
Cell lastCell = (Cell) list.get (list.size () - 1);
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class Max extends ValueListFunction
|
class Max extends ValueListFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public Max (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Max (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
assert text.startsWith ("@MAX(") : text;
|
assert text.startsWith ("@MAX(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
value = Double.MIN_VALUE;
|
value = Double.MIN_VALUE;
|
||||||
int totalChecked = 0;
|
int totalChecked = 0;
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class Min extends ValueListFunction
|
class Min extends ValueListFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public Min (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Min (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
assert text.startsWith ("@MIN(") : text;
|
assert text.startsWith ("@MIN(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
value = Double.MAX_VALUE;
|
value = Double.MAX_VALUE;
|
||||||
int totalChecked = 0;
|
int totalChecked = 0;
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class Na extends ConstantFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Na extends ConstantFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public Na (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Na (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class Not extends BooleanFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Not extends BooleanFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Not (Cell cell, String text)
|
Not (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@NOT(") : text;
|
assert text.startsWith ("@NOT(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
source.calculate ();
|
source.calculate ();
|
||||||
|
|
||||||
|
@ -2,17 +2,23 @@ package com.bytezone.diskbrowser.visicalc;
|
|||||||
|
|
||||||
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
|
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
|
||||||
|
|
||||||
public class Npv extends ValueListFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Npv extends ValueListFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Npv (Cell cell, String text)
|
Npv (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
assert text.startsWith ("@NPV(") : text;
|
assert text.startsWith ("@NPV(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
value = 0;
|
value = 0;
|
||||||
valueResult = ValueResult.VALID;
|
valueResult = ValueResult.VALID;
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class Number extends AbstractValue
|
class Number extends AbstractValue
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public Number (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Number (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
@ -19,14 +23,18 @@ class Number extends AbstractValue
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getType ()
|
public String getType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return "Constant";
|
return "Constant";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
text.append (String.format ("%s%n", LINE));
|
text.append (String.format ("%s%n", LINE));
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class Or extends ConditionListFunction
|
class Or extends ConditionListFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public Or (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Or (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@OR(") : text;
|
assert text.startsWith ("@OR(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
valueResult = ValueResult.VALID;
|
valueResult = ValueResult.VALID;
|
||||||
|
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class Pi extends ConstantFunction
|
class Pi extends ConstantFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Pi (Cell cell, String text)
|
Pi (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
|
@ -6,7 +6,9 @@ import java.util.List;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class Range implements Iterable<Address>
|
class Range implements Iterable<Address>
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
// private static final Pattern cellAddress = Pattern.compile ("[A-B]?[A-Z][0-9]{1,3}");
|
// private static final Pattern cellAddress = Pattern.compile ("[A-B]?[A-Z][0-9]{1,3}");
|
||||||
private static final Pattern rangePattern =
|
private static final Pattern rangePattern =
|
||||||
@ -19,7 +21,9 @@ class Range implements Iterable<Address>
|
|||||||
|
|
||||||
private boolean isHorizontal;
|
private boolean isHorizontal;
|
||||||
|
|
||||||
public Range (Cell cell, String rangeText)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Range (Cell cell, String rangeText)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.cell = cell;
|
this.cell = cell;
|
||||||
|
|
||||||
@ -35,7 +39,9 @@ class Range implements Iterable<Address>
|
|||||||
throw new IllegalArgumentException (rangeText);
|
throw new IllegalArgumentException (rangeText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void populateRange ()
|
private void populateRange ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
range.add (from);
|
range.add (from);
|
||||||
cell.getCell (from);
|
cell.getCell (from);
|
||||||
@ -62,39 +68,53 @@ class Range implements Iterable<Address>
|
|||||||
from = tempFrom;
|
from = tempFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
static boolean isRange (String text)
|
static boolean isRange (String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return rangePattern.matcher (text).matches ();
|
return rangePattern.matcher (text).matches ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
boolean isHorizontal ()
|
boolean isHorizontal ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return isHorizontal;
|
return isHorizontal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
boolean isVertical ()
|
boolean isVertical ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return !isHorizontal;
|
return !isHorizontal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Address> iterator ()
|
public Iterator<Address> iterator ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return range.iterator ();
|
return range.iterator ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public int size ()
|
public int size ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return range.size ();
|
return range.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public Address get (int index)
|
public Address get (int index)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return index < 0 || index >= range.size () ? null : range.get (index);
|
return index < 0 || index >= range.size () ? null : range.get (index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (from == null || to == null)
|
if (from == null || to == null)
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,9 @@ import java.util.regex.Pattern;
|
|||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
|
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class Sheet
|
public class Sheet
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final Pattern addressPattern =
|
private static final Pattern addressPattern =
|
||||||
Pattern.compile ("([AB]?[A-Z])([0-9]{1,3}):");
|
Pattern.compile ("([AB]?[A-Z])([0-9]{1,3}):");
|
||||||
@ -146,7 +148,9 @@ public class Sheet
|
|||||||
|
|
||||||
// /X!/X>A3:>A7: A3:top-left cell in window, A7:cell to place cursor
|
// /X!/X>A3:>A7: A3:top-left cell in window, A7:cell to place cursor
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public Sheet (byte[] buffer)
|
public Sheet (byte[] buffer)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int last = buffer.length;
|
int last = buffer.length;
|
||||||
while (buffer[--last] == 0) // ignore trailing zeroes
|
while (buffer[--last] == 0) // ignore trailing zeroes
|
||||||
@ -182,7 +186,9 @@ public class Sheet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void calculate (char order)
|
private void calculate (char order)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Map<Integer, Cell> cells = order == 'R' ? rowOrderCells : columnOrderCells;
|
Map<Integer, Cell> cells = order == 'R' ? rowOrderCells : columnOrderCells;
|
||||||
for (Cell cell : cells.values ())
|
for (Cell cell : cells.values ())
|
||||||
@ -190,7 +196,9 @@ public class Sheet
|
|||||||
cell.calculate ();
|
cell.calculate ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private int getLineLength (byte[] buffer, int offset)
|
private int getLineLength (byte[] buffer, int offset)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int ptr = offset;
|
int ptr = offset;
|
||||||
while (buffer[ptr] != END_OF_LINE_TOKEN)
|
while (buffer[ptr] != END_OF_LINE_TOKEN)
|
||||||
@ -198,7 +206,9 @@ public class Sheet
|
|||||||
return ptr - offset;
|
return ptr - offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void processLine (String line)
|
private void processLine (String line)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Cell currentCell = null;
|
Cell currentCell = null;
|
||||||
|
|
||||||
@ -259,7 +269,9 @@ public class Sheet
|
|||||||
currentCell.setValue (line); // expression
|
currentCell.setValue (line); // expression
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void addCell (Cell cell)
|
private void addCell (Cell cell)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
rowOrderCells.put (cell.getAddress ().getRowKey (), cell);
|
rowOrderCells.put (cell.getAddress ().getRowKey (), cell);
|
||||||
columnOrderCells.put (cell.getAddress ().getColumnKey (), cell);
|
columnOrderCells.put (cell.getAddress ().getColumnKey (), cell);
|
||||||
@ -271,12 +283,16 @@ public class Sheet
|
|||||||
maxColumn = Math.max (maxColumn, cell.getAddress ().getColumn ());
|
maxColumn = Math.max (maxColumn, cell.getAddress ().getColumn ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Cell getCell (String addressText)
|
Cell getCell (String addressText)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return getCell (new Address (addressText));
|
return getCell (new Address (addressText));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Cell getCell (Address address)
|
Cell getCell (Address address)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Cell cell = rowOrderCells.get (address.getRowKey ());
|
Cell cell = rowOrderCells.get (address.getRowKey ());
|
||||||
if (cell == null)
|
if (cell == null)
|
||||||
@ -287,17 +303,23 @@ public class Sheet
|
|||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
boolean cellExists (Address address)
|
boolean cellExists (Address address)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return rowOrderCells.get (address.getRowKey ()) != null;
|
return rowOrderCells.get (address.getRowKey ()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public int size ()
|
public int size ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return rowOrderCells.size ();
|
return rowOrderCells.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void doFormat (String line)
|
private void doFormat (String line)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
switch (line.charAt (1))
|
switch (line.charAt (1))
|
||||||
{
|
{
|
||||||
@ -313,7 +335,9 @@ public class Sheet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void setGlobal (String line)
|
private void setGlobal (String line)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
switch (line.charAt (2))
|
switch (line.charAt (2))
|
||||||
{
|
{
|
||||||
@ -338,7 +362,9 @@ public class Sheet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public String getTextDisplay (boolean debug)
|
public String getTextDisplay (boolean debug)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
String longLine;
|
String longLine;
|
||||||
@ -497,7 +523,9 @@ public class Sheet
|
|||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Function getFunction (Cell cell, String text)
|
Function getFunction (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int functionId = -1;
|
int functionId = -1;
|
||||||
for (int i = 0; i < Function.functionList.length; i++)
|
for (int i = 0; i < Function.functionList.length; i++)
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class Sin extends ValueFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Sin extends ValueFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Sin (Cell cell, String text)
|
Sin (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@SIN(") : text;
|
assert text.startsWith ("@SIN(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public double calculateValue ()
|
public double calculateValue ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return Math.sin (source.getDouble ());
|
return Math.sin (source.getDouble ());
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class Sqrt extends ValueFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Sqrt extends ValueFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Sqrt (Cell cell, String text)
|
Sqrt (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@SQRT(") : text;
|
assert text.startsWith ("@SQRT(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public double calculateValue ()
|
public double calculateValue ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return Math.sqrt (source.getDouble ());
|
return Math.sqrt (source.getDouble ());
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
class Sum extends ValueListFunction
|
class Sum extends ValueListFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public Sum (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Sum (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
assert text.startsWith ("@SUM(") : text;
|
assert text.startsWith ("@SUM(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
value = 0;
|
value = 0;
|
||||||
valueResult = ValueResult.VALID;
|
valueResult = ValueResult.VALID;
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class Tan extends ValueFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class Tan extends ValueFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
Tan (Cell cell, String text)
|
Tan (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
assert text.startsWith ("@TAN(") : text;
|
assert text.startsWith ("@TAN(") : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public double calculateValue ()
|
public double calculateValue ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return Math.tan (source.getDouble ());
|
return Math.tan (source.getDouble ());
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public class True extends ConstantFunction
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class True extends ConstantFunction
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
True (Cell cell, String text)
|
True (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
interface Value extends Iterable<Value>
|
interface Value extends Iterable<Value>
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
enum ValueType
|
enum ValueType
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public abstract class ValueFunction extends Function
|
// -----------------------------------------------------------------------------------//
|
||||||
|
abstract class ValueFunction extends Function
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
protected Value source;
|
protected Value source;
|
||||||
|
|
||||||
abstract double calculateValue ();
|
abstract double calculateValue ();
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
ValueFunction (Cell cell, String text)
|
ValueFunction (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
@ -15,8 +19,10 @@ public abstract class ValueFunction extends Function
|
|||||||
valueType = ValueType.NUMBER;
|
valueType = ValueType.NUMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void calculate ()
|
public void calculate ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
valueResult = ValueResult.VALID;
|
valueResult = ValueResult.VALID;
|
||||||
|
|
||||||
@ -34,8 +40,10 @@ public abstract class ValueFunction extends Function
|
|||||||
valueResult = ValueResult.ERROR;
|
valueResult = ValueResult.ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getType ()
|
public String getType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return "ValueFunction";
|
return "ValueFunction";
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,16 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ValueList implements Iterable<Value>
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class ValueList implements Iterable<Value>
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final List<Value> values = new ArrayList<> ();
|
private final List<Value> values = new ArrayList<> ();
|
||||||
private boolean hasRange;
|
private boolean hasRange;
|
||||||
|
|
||||||
public ValueList (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
ValueList (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String remainder = text;
|
String remainder = text;
|
||||||
|
|
||||||
@ -33,23 +37,31 @@ public class ValueList implements Iterable<Value>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public boolean hasRange ()
|
public boolean hasRange ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return hasRange;
|
return hasRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public Value get (int index)
|
public Value get (int index)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return values.get (index);
|
return values.get (index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public int size ()
|
public int size ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return values.size ();
|
return values.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Value> iterator ()
|
public Iterator<Value> iterator ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return values.iterator ();
|
return values.iterator ();
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
public abstract class ValueListFunction extends Function
|
// -----------------------------------------------------------------------------------//
|
||||||
|
abstract class ValueListFunction extends Function
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
protected final ValueList list;
|
protected final ValueList list;
|
||||||
protected final boolean isRange;
|
protected final boolean isRange;
|
||||||
|
|
||||||
public ValueListFunction (Cell cell, String text)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
ValueListFunction (Cell cell, String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (cell, text);
|
super (cell, text);
|
||||||
|
|
||||||
@ -17,8 +21,10 @@ public abstract class ValueListFunction extends Function
|
|||||||
values.add (v);
|
values.add (v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getType ()
|
public String getType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return "ValueListFunction";
|
return "ValueListFunction";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user