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