mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-12-23 01:30:25 +00:00
consistency
This commit is contained in:
parent
eff78e0108
commit
cf8d3729d4
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Abs extends Function
|
||||
{
|
||||
private final Expression source;
|
||||
private final Value source;
|
||||
|
||||
Abs (Cell cell, String text)
|
||||
{
|
||||
@ -10,7 +10,7 @@ public class Abs extends Function
|
||||
|
||||
assert text.startsWith ("@ABS(") : text;
|
||||
|
||||
source = new Expression (parent, cell, functionText);
|
||||
source = new Expression (parent, cell, functionText).reduce ();
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@ -19,7 +19,13 @@ public class Abs extends Function
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.abs (source.getValue ());
|
||||
valueType = source.getValueType ();
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Acos extends Function
|
||||
{
|
||||
Value v;
|
||||
private final Value source;
|
||||
|
||||
Acos (Cell cell, String text)
|
||||
{
|
||||
@ -10,23 +10,22 @@ public class Acos extends Function
|
||||
|
||||
assert text.startsWith ("@ACOS(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
source = new Expression (parent, cell, functionText).reduce ();
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
{
|
||||
v.calculate ();
|
||||
if (!v.isValueType (ValueType.VALUE))
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = v.getValueType ();
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.acos (v.getValue ());
|
||||
|
||||
if (Double.isNaN (value))
|
||||
valueType = ValueType.ERROR;
|
||||
value = Math.acos (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -17,10 +17,7 @@ class And extends Function
|
||||
while (true)
|
||||
{
|
||||
String parameter = Expression.getParameter (remainder);
|
||||
// System.out.printf ("cond: [%s]%n", parameter);
|
||||
conditions.add (new Condition (parent, cell, parameter));
|
||||
// System.out.printf (" [%s]%n", remainder);
|
||||
// System.out.printf (" [%s]%n", parameter);
|
||||
if (remainder.length () == parameter.length ())
|
||||
break;
|
||||
remainder = remainder.substring (parameter.length () + 1);
|
||||
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Asin extends Function
|
||||
{
|
||||
Value v;
|
||||
private final Value source;
|
||||
|
||||
Asin (Cell cell, String text)
|
||||
{
|
||||
@ -10,23 +10,22 @@ public class Asin extends Function
|
||||
|
||||
assert text.startsWith ("@ASIN(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
source = new Expression (parent, cell, functionText).reduce ();
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
{
|
||||
v.calculate ();
|
||||
if (!v.isValueType (ValueType.VALUE))
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = v.getValueType ();
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.asin (v.getValue ());
|
||||
|
||||
if (Double.isNaN (value))
|
||||
valueType = ValueType.ERROR;
|
||||
value = Math.asin (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Atan extends Function
|
||||
{
|
||||
Value v;
|
||||
private final Value source;
|
||||
|
||||
Atan (Cell cell, String text)
|
||||
{
|
||||
@ -10,23 +10,22 @@ public class Atan extends Function
|
||||
|
||||
assert text.startsWith ("@ATAN(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
source = new Expression (parent, cell, functionText).reduce ();
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
{
|
||||
v.calculate ();
|
||||
if (!v.isValueType (ValueType.VALUE))
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = v.getValueType ();
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.atan (v.getValue ());
|
||||
|
||||
if (Double.isNaN (value))
|
||||
valueType = ValueType.ERROR;
|
||||
value = Math.atan (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -13,8 +13,11 @@ public class Average extends Function
|
||||
|
||||
assert text.startsWith ("@AVERAGE(") : text;
|
||||
|
||||
list = new ValueList (parent, cell, functionText);
|
||||
list = new ValueList (cell, functionText);
|
||||
isRange = functionText.indexOf ("...") > 0;
|
||||
|
||||
for (Value v : list)
|
||||
values.add (v);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,10 +2,11 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Choose extends Function
|
||||
{
|
||||
private final Range range;
|
||||
private final String sourceText;
|
||||
private final String rangeText;
|
||||
|
||||
private final Value source;
|
||||
private final Range range;
|
||||
|
||||
Choose (Cell cell, String text)
|
||||
{
|
||||
@ -13,8 +14,6 @@ public class Choose extends Function
|
||||
|
||||
assert text.startsWith ("@CHOOSE(") : text;
|
||||
|
||||
// int pos = functionText.indexOf (',');
|
||||
// sourceText = functionText.substring (0, pos);
|
||||
sourceText = Expression.getParameter (functionText);
|
||||
source = new Expression (parent, cell, sourceText).reduce ();
|
||||
values.add (source);
|
||||
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Cos extends Function
|
||||
{
|
||||
Value v;
|
||||
private final Value source;
|
||||
|
||||
Cos (Cell cell, String text)
|
||||
{
|
||||
@ -10,20 +10,22 @@ public class Cos extends Function
|
||||
|
||||
assert text.startsWith ("@COS(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
source = new Expression (parent, cell, functionText).reduce ();
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
{
|
||||
v.calculate ();
|
||||
if (!v.isValueType (ValueType.VALUE))
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = v.getValueType ();
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.cos (v.getValue ());
|
||||
value = Math.cos (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -13,8 +13,11 @@ class Count extends Function
|
||||
|
||||
assert text.startsWith ("@COUNT(") : text;
|
||||
|
||||
list = new ValueList (parent, cell, functionText);
|
||||
list = new ValueList (cell, functionText);
|
||||
isRange = functionText.indexOf ("...") > 0;
|
||||
|
||||
for (Value v : list)
|
||||
values.add (v);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Exp extends Function
|
||||
{
|
||||
Value v;
|
||||
private final Value source;
|
||||
|
||||
Exp (Cell cell, String text)
|
||||
{
|
||||
@ -10,23 +10,22 @@ public class Exp extends Function
|
||||
|
||||
assert text.startsWith ("@EXP(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
source = new Expression (parent, cell, functionText).reduce ();
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
{
|
||||
v.calculate ();
|
||||
if (!v.isValueType (ValueType.VALUE))
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = v.getValueType ();
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.exp (v.getValue ());
|
||||
|
||||
if (Double.isNaN (value))
|
||||
valueType = ValueType.ERROR;
|
||||
value = Math.exp (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Int extends Function
|
||||
{
|
||||
Expression source;
|
||||
private final Value source;
|
||||
|
||||
Int (Cell cell, String text)
|
||||
{
|
||||
@ -10,7 +10,7 @@ public class Int extends Function
|
||||
|
||||
assert text.startsWith ("@INT(") : text;
|
||||
|
||||
source = new Expression (parent, cell, functionText);
|
||||
source = new Expression (parent, cell, functionText).reduce ();
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@ -18,7 +18,8 @@ public class Int extends Function
|
||||
public void calculate ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
value = (int) source.getValue ();
|
||||
valueType = source.getValueType ();
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
class IsError extends Function
|
||||
{
|
||||
Value expression;
|
||||
private final Value source;
|
||||
|
||||
public IsError (Cell cell, String text)
|
||||
{
|
||||
@ -10,14 +10,16 @@ class IsError extends Function
|
||||
|
||||
assert text.startsWith ("@ISERROR(") : text;
|
||||
|
||||
expression = new Expression (parent, cell, functionText).reduce ();
|
||||
source = new Expression (parent, cell, functionText).reduce ();
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
{
|
||||
expression.calculate ();
|
||||
value = expression.isValueType (ValueType.ERROR) ? 1 : 0;
|
||||
source.calculate ();
|
||||
|
||||
value = source.isValueType (ValueType.ERROR) ? 1 : 0;
|
||||
valueType = ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class IsNa extends Function
|
||||
{
|
||||
Value expression;
|
||||
private final Value source;
|
||||
|
||||
IsNa (Cell cell, String text)
|
||||
{
|
||||
@ -10,14 +10,16 @@ public class IsNa extends Function
|
||||
|
||||
assert text.startsWith ("@ISNA(") : text;
|
||||
|
||||
expression = new Expression (parent, cell, functionText).reduce ();
|
||||
source = new Expression (parent, cell, functionText).reduce ();
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
{
|
||||
expression.calculate ();
|
||||
value = expression.isValueType (ValueType.NA) ? 1 : 0;
|
||||
valueType = expression.getValueType ();
|
||||
source.calculate ();
|
||||
|
||||
value = source.isValueType (ValueType.NA) ? 1 : 0;
|
||||
valueType = source.getValueType ();
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Ln extends Function
|
||||
{
|
||||
Value v;
|
||||
private final Value source;
|
||||
|
||||
Ln (Cell cell, String text)
|
||||
{
|
||||
@ -10,20 +10,22 @@ public class Ln extends Function
|
||||
|
||||
assert text.startsWith ("@LN(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
source = new Expression (parent, cell, functionText).reduce ();
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
{
|
||||
v.calculate ();
|
||||
if (!v.isValueType (ValueType.VALUE))
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = v.getValueType ();
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.log (v.getValue ());
|
||||
value = Math.log (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Log10 extends Function
|
||||
{
|
||||
Value v;
|
||||
private final Value source;
|
||||
|
||||
Log10 (Cell cell, String text)
|
||||
{
|
||||
@ -10,20 +10,22 @@ public class Log10 extends Function
|
||||
|
||||
assert text.startsWith ("@LOG10(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
source = new Expression (parent, cell, functionText).reduce ();
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
{
|
||||
v.calculate ();
|
||||
if (!v.isValueType (ValueType.VALUE))
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = v.getValueType ();
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.log10 (v.getValue ());
|
||||
value = Math.log10 (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -4,7 +4,8 @@ class Lookup extends Function
|
||||
{
|
||||
private final String sourceText;
|
||||
private final String rangeText;
|
||||
private final Expression source;
|
||||
|
||||
private final Value source;
|
||||
private final Range range;
|
||||
|
||||
public Lookup (Cell cell, String text)
|
||||
@ -14,7 +15,7 @@ class Lookup extends Function
|
||||
assert text.startsWith ("@LOOKUP(") : text;
|
||||
|
||||
sourceText = Expression.getParameter (functionText);
|
||||
source = new Expression (parent, cell, sourceText);
|
||||
source = new Expression (parent, cell, sourceText).reduce ();
|
||||
values.add (source);
|
||||
|
||||
rangeText = functionText.substring (sourceText.length () + 1);
|
||||
@ -29,7 +30,6 @@ class Lookup extends Function
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = source.getValueType ();
|
||||
// valueType = ValueType.NA;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -45,12 +45,6 @@ class Lookup extends Function
|
||||
for (Address address : range)
|
||||
{
|
||||
Cell cell = parent.getCell (address);
|
||||
// if (cell.isValueType (ValueType.NA))
|
||||
// {
|
||||
// // System.out.println ("NA1");
|
||||
// break;
|
||||
// // continue;
|
||||
// }
|
||||
if (cell.getValue () > sourceValue) // past the value
|
||||
break;
|
||||
target = address;
|
||||
@ -59,7 +53,6 @@ class Lookup extends Function
|
||||
if (target == null)
|
||||
{
|
||||
valueType = ValueType.NA;
|
||||
// System.out.println ("NA2");
|
||||
value = 0;
|
||||
}
|
||||
else
|
||||
|
@ -10,7 +10,10 @@ class Max extends Function
|
||||
|
||||
assert text.startsWith ("@MAX(") : text;
|
||||
|
||||
list = new ValueList (parent, cell, functionText);
|
||||
list = new ValueList (cell, functionText);
|
||||
|
||||
for (Value v : list)
|
||||
values.add (v);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,7 +10,10 @@ class Min extends Function
|
||||
|
||||
assert text.startsWith ("@MIN(") : text;
|
||||
|
||||
list = new ValueList (parent, cell, functionText);
|
||||
list = new ValueList (cell, functionText);
|
||||
|
||||
for (Value v : list)
|
||||
values.add (v);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,10 +4,10 @@ import com.bytezone.diskbrowser.visicalc.Cell.CellType;
|
||||
|
||||
public class Npv extends Function
|
||||
{
|
||||
private final String valueText;
|
||||
private final String sourceText;
|
||||
private final String rangeText;
|
||||
|
||||
private final Expression rateExp;
|
||||
private final Value source;
|
||||
private final Range range;
|
||||
|
||||
Npv (Cell cell, String text)
|
||||
@ -16,11 +16,11 @@ public class Npv extends Function
|
||||
|
||||
assert text.startsWith ("@NPV(") : text;
|
||||
|
||||
valueText = Expression.getParameter (functionText);
|
||||
rateExp = new Expression (parent, cell, valueText);
|
||||
values.add (rateExp);
|
||||
sourceText = Expression.getParameter (functionText);
|
||||
source = new Expression (parent, cell, sourceText).reduce ();
|
||||
values.add (source);
|
||||
|
||||
rangeText = functionText.substring (valueText.length () + 1);
|
||||
rangeText = functionText.substring (sourceText.length () + 1);
|
||||
range = new Range (parent, cell, rangeText);
|
||||
}
|
||||
|
||||
@ -30,14 +30,14 @@ public class Npv extends Function
|
||||
value = 0;
|
||||
valueType = ValueType.VALUE;
|
||||
|
||||
rateExp.calculate ();
|
||||
if (!rateExp.isValueType (ValueType.VALUE))
|
||||
source.calculate ();
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = rateExp.getValueType ();
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
double rate = 1 + rateExp.getValue ();
|
||||
double rate = 1 + source.getValue ();
|
||||
|
||||
int period = 0;
|
||||
for (Address address : range)
|
||||
|
@ -393,12 +393,13 @@ public class Sheet
|
||||
String name = Function.functionList[i];
|
||||
if (name.endsWith ("("))
|
||||
name = name.substring (0, name.length () - 1);
|
||||
counts.add (String.format ("%-10s %d", name, functionTotals[i]));
|
||||
counts.add (String.format ("%-10s%d", name, functionTotals[i]));
|
||||
}
|
||||
|
||||
while (counts.size () < 18)
|
||||
counts.add ("");
|
||||
|
||||
text.append (String.format ("%-85.85s%n", underline));
|
||||
text.append (String.format ("Global format : %-18s %-18s %-18s %s%n", globalFormat,
|
||||
counts.get (0), counts.get (6), counts.get (12)));
|
||||
text.append (String.format ("Column width : %-2d %-15s %-18s %-18s %s%n",
|
||||
@ -412,13 +413,11 @@ public class Sheet
|
||||
text.append (String.format ("Cells : %-5d %-11s %-18s %-18s %s%n", size (),
|
||||
"", counts.get (4), counts.get (10), counts.get (16)));
|
||||
|
||||
if (size () > 0)
|
||||
text.append (String.format ("Range : %-18s %-18s %-18s %s%n%n",
|
||||
Address.getCellName (minRow + 1, minColumn) + ":"
|
||||
+ Address.getCellName (maxRow + 1, maxColumn),
|
||||
counts.get (5), counts.get (11), counts.get (17)));
|
||||
else
|
||||
text.append ("\n\n");
|
||||
String rangeText = size () > 0 ? Address.getCellName (minRow + 1, minColumn) + ":"
|
||||
+ Address.getCellName (maxRow + 1, maxColumn) : "";
|
||||
text.append (String.format ("Range : %-18s %-18s %-18s %s%n", rangeText,
|
||||
counts.get (5), counts.get (11), counts.get (17)));
|
||||
text.append (String.format ("%-85.85s%n", underline));
|
||||
|
||||
if (debug)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Sin extends Function
|
||||
{
|
||||
Value v;
|
||||
private final Value source;
|
||||
|
||||
Sin (Cell cell, String text)
|
||||
{
|
||||
@ -10,20 +10,22 @@ public class Sin extends Function
|
||||
|
||||
assert text.startsWith ("@SIN(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
source = new Expression (parent, cell, functionText).reduce ();
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
{
|
||||
v.calculate ();
|
||||
if (!v.isValueType (ValueType.VALUE))
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = v.getValueType ();
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.sin (v.getValue ());
|
||||
value = Math.sin (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Sqrt extends Function
|
||||
{
|
||||
private final Expression source;
|
||||
private final Value source;
|
||||
|
||||
Sqrt (Cell cell, String text)
|
||||
{
|
||||
@ -10,7 +10,7 @@ public class Sqrt extends Function
|
||||
|
||||
assert text.startsWith ("@SQRT(") : text;
|
||||
|
||||
source = new Expression (parent, cell, functionText);
|
||||
source = new Expression (parent, cell, functionText).reduce ();
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@ -26,6 +26,6 @@ public class Sqrt extends Function
|
||||
}
|
||||
|
||||
value = Math.sqrt (source.getValue ());
|
||||
valueType = ValueType.VALUE;
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -10,7 +10,10 @@ class Sum extends Function
|
||||
|
||||
assert text.startsWith ("@SUM(") : text;
|
||||
|
||||
list = new ValueList (parent, cell, functionText);
|
||||
list = new ValueList (cell, functionText);
|
||||
|
||||
for (Value v : list)
|
||||
values.add (v);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,7 +2,7 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Tan extends Function
|
||||
{
|
||||
Value v;
|
||||
private final Value source;
|
||||
|
||||
Tan (Cell cell, String text)
|
||||
{
|
||||
@ -10,20 +10,22 @@ public class Tan extends Function
|
||||
|
||||
assert text.startsWith ("@TAN(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
source = new Expression (parent, cell, functionText).reduce ();
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
{
|
||||
v.calculate ();
|
||||
if (!v.isValueType (ValueType.VALUE))
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = v.getValueType ();
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.tan (v.getValue ());
|
||||
value = Math.tan (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -8,9 +8,11 @@ public class ValueList implements Iterable<Value>
|
||||
{
|
||||
protected List<Value> values = new ArrayList<Value> ();
|
||||
|
||||
public ValueList (Sheet parent, Cell cell, String text)
|
||||
public ValueList (Cell cell, String text)
|
||||
{
|
||||
Sheet parent = cell.getParent ();
|
||||
String remainder = text;
|
||||
|
||||
while (true)
|
||||
{
|
||||
String parameter = Expression.getParameter (remainder);
|
||||
@ -23,6 +25,7 @@ public class ValueList implements Iterable<Value>
|
||||
|
||||
if (remainder.length () == parameter.length ())
|
||||
break;
|
||||
|
||||
remainder = remainder.substring (parameter.length () + 1);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user