mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-22 02:29:03 +00:00
created ValueFunction
This commit is contained in:
parent
60d908b6d1
commit
36750a11e7
@ -1,29 +1,16 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Abs extends Function
|
||||
public class Abs extends ValueFunction
|
||||
{
|
||||
Abs (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@ABS(") : text;
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
void setValue ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.abs (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -1,29 +1,17 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Acos extends Function
|
||||
public class Acos extends ValueFunction
|
||||
{
|
||||
Acos (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@ACOS(") : text;
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
public void setValue ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.acos (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -1,29 +1,16 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Asin extends Function
|
||||
public class Asin extends ValueFunction
|
||||
{
|
||||
Asin (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@ASIN(") : text;
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
public void setValue ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.asin (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -1,29 +1,16 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Atan extends Function
|
||||
public class Atan extends ValueFunction
|
||||
{
|
||||
Atan (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@ATAN(") : text;
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
public void setValue ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.atan (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -1,29 +1,16 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Cos extends Function
|
||||
public class Cos extends ValueFunction
|
||||
{
|
||||
Cos (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@COS(") : text;
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
public void setValue ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.cos (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -1,29 +1,16 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Exp extends Function
|
||||
public class Exp extends ValueFunction
|
||||
{
|
||||
Exp (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@EXP(") : text;
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
public void setValue ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.exp (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -1,23 +1,16 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Int extends Function
|
||||
public class Int extends ValueFunction
|
||||
{
|
||||
Int (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@INT(") : text;
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
public void setValue ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
value = (int) source.getValue ();
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -1,15 +1,11 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
class IsError extends Function
|
||||
class IsError extends ValueFunction
|
||||
{
|
||||
public IsError (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@ISERROR(") : text;
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -19,11 +15,8 @@ class IsError extends Function
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
public void setValue ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
value = source.isValueType (ValueType.ERROR) ? 1 : 0;
|
||||
valueType = ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -1,15 +1,11 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class IsNa extends Function
|
||||
public class IsNa extends ValueFunction
|
||||
{
|
||||
IsNa (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@ISNA(") : text;
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -19,11 +15,8 @@ public class IsNa extends Function
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
public void setValue ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
value = source.isValueType (ValueType.NA) ? 1 : 0;
|
||||
valueType = source.getValueType ();
|
||||
}
|
||||
}
|
@ -1,29 +1,16 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Ln extends Function
|
||||
public class Ln extends ValueFunction
|
||||
{
|
||||
Ln (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@LN(") : text;
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
public void setValue ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.log (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -1,29 +1,16 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Log10 extends Function
|
||||
public class Log10 extends ValueFunction
|
||||
{
|
||||
Log10 (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@LOG10(") : text;
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
public void setValue ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.log10 (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -57,7 +57,6 @@ class Lookup extends Function
|
||||
{
|
||||
Address adjacentAddress = isVertical ? target.nextColumn () : target.nextRow ();
|
||||
|
||||
// Sheet parent = cell.getParent ();
|
||||
if (cell.cellExists (adjacentAddress))
|
||||
{
|
||||
value = cell.getCell (adjacentAddress).getValue ();
|
||||
|
@ -1,29 +1,16 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Sin extends Function
|
||||
public class Sin extends ValueFunction
|
||||
{
|
||||
Sin (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@SIN(") : text;
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
public void setValue ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.sin (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -1,29 +1,16 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Sqrt extends Function
|
||||
public class Sqrt extends ValueFunction
|
||||
{
|
||||
Sqrt (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@SQRT(") : text;
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
public void setValue ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.sqrt (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -1,29 +1,16 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Tan extends Function
|
||||
public class Tan extends ValueFunction
|
||||
{
|
||||
Tan (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@TAN(") : text;
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
public void setValue ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
value = Math.tan (source.getValue ());
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
}
|
30
src/com/bytezone/diskbrowser/visicalc/ValueFunction.java
Normal file
30
src/com/bytezone/diskbrowser/visicalc/ValueFunction.java
Normal file
@ -0,0 +1,30 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public abstract class ValueFunction extends Function
|
||||
{
|
||||
ValueFunction (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
source = cell.getExpressionValue (functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate ()
|
||||
{
|
||||
source.calculate ();
|
||||
|
||||
if (!source.isValueType (ValueType.VALUE))
|
||||
{
|
||||
valueType = source.getValueType ();
|
||||
return;
|
||||
}
|
||||
|
||||
// value = Math.abs (source.getValue ());
|
||||
setValue ();
|
||||
valueType = Double.isNaN (value) ? ValueType.ERROR : ValueType.VALUE;
|
||||
}
|
||||
|
||||
abstract void setValue ();
|
||||
}
|
@ -11,7 +11,6 @@ public class ValueList implements Iterable<Value>
|
||||
|
||||
public ValueList (Cell cell, String text)
|
||||
{
|
||||
// Sheet parent = cell.getParent ();
|
||||
String remainder = text;
|
||||
|
||||
while (true)
|
||||
|
Loading…
x
Reference in New Issue
Block a user