info.bioinfweb.treegraph.document.undo.edit
Class CalculateColumnEdit
java.lang.Object
info.bioinfweb.treegraph.document.undo.DocumentEdit
info.bioinfweb.treegraph.document.undo.NodeBranchDataEdit
info.bioinfweb.treegraph.document.undo.edit.CalculateColumnEdit
- All Implemented Interfaces:
- javax.swing.undo.UndoableEdit
public class CalculateColumnEdit
- extends NodeBranchDataEdit
Calculates a node/branch data column as specified by the passed expression.
- Since:
- 2.0.24
- Author:
- Ben Stöver
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CURRENT_VALUE_VAR
public static final java.lang.String CURRENT_VALUE_VAR
- See Also:
- Constant Field Values
UNIQUE_NODE_NAMES_VAR
public static final java.lang.String UNIQUE_NODE_NAMES_VAR
- See Also:
- Constant Field Values
NODE_NAMES_VAR
public static final java.lang.String NODE_NAMES_VAR
- See Also:
- Constant Field Values
BRANCH_LENGTH_VAR
public static final java.lang.String BRANCH_LENGTH_VAR
- See Also:
- Constant Field Values
GET_VALUE_FUNC
public static final java.lang.String GET_VALUE_FUNC
- See Also:
- Constant Field Values
HAS_VALUE_FUNC
public static final java.lang.String HAS_VALUE_FUNC
- See Also:
- Constant Field Values
expression
private java.lang.String expression
parser
private org.nfunk.jep.JEP parser
adapterMap
private java.util.Map<java.lang.String,NodeBranchDataAdapter> adapterMap
isEvaluating
private boolean isEvaluating
isEvaluatingDecimal
private boolean isEvaluatingDecimal
position
private Node position
errors
private java.util.List<java.lang.String> errors
CalculateColumnEdit
public CalculateColumnEdit(Document document,
NodeBranchDataAdapter targetAdapter,
java.lang.String expression)
createParser
private org.nfunk.jep.JEP createParser()
createAdapterMap
private java.util.HashMap<java.lang.String,NodeBranchDataAdapter> createAdapterMap()
evaluationStep
private java.lang.String evaluationStep(java.lang.Object defaultValue)
- Evaluates the expression with one set of variable values.
- Parameters:
defaultValue - - either a string or a double value
- Returns:
- the error information or
null if no error occurred.
evaluate
public boolean evaluate()
- Evaluates the expression of this instance. Error can be obtined by calling
getErrors().
- Returns:
true if the expression contained no errors.
getCurrentValue
private java.lang.Object getCurrentValue(NodeBranchDataAdapter adapter)
- Returns the value of the specified column in the current line
(specified by
position).
- Parameters:
adapter - - defined the column to use
- Returns:
- a value of type
Double or String
getIDValue
private java.lang.Object getIDValue(java.lang.String id)
throws org.nfunk.jep.ParseException
- Returns the value of the current line in the column specified the passed id present.
- Parameters:
id - - the ID of the node/branch data column
- Returns:
- the value (as
Double, String) or null if the specified column
does not contain any value at the current position or a Double with the value 1 if
isEvaluating is true
- Throws:
UndefinedIDException - - if no column with the specified ID exists
org.nfunk.jep.ParseException
calculateSubtree
private void calculateSubtree(Node root)
redo
public void redo()
throws javax.swing.undo.CannotRedoException
- Specified by:
redo in interface javax.swing.undo.UndoableEdit- Overrides:
redo in class DocumentEdit
- Throws:
javax.swing.undo.CannotRedoException
getPresentationName
public java.lang.String getPresentationName()
getErrors
public java.lang.String[] getErrors()
- Returns a description of the errors that occured during the last call of
redo() or evaluate().
- Returns: