edu.swri.swiftvis
Class BooleanFormula

java.lang.Object
  extended by edu.swri.swiftvis.BooleanFormula
All Implemented Interfaces:
java.io.Serializable

public class BooleanFormula
extends java.lang.Object
implements java.io.Serializable

This class is intended to allow uses to type in formulas that use parameters or values from elements that evaluate to boolean values. This is mainly used for selecting certain elements. The operators that are understood by this class are the following logical operators: =, <, >, <=, >=, &, and, |, or, ^, xor, !, not. Note that for the booleans operators you can use C-ish characters or full names. Also note that the characters are single, unlike in C, but they are short circuit. Also note that equality is a single '='. All formulas can use parentheses to specify order of operation. Without them the comparisons have highest precidence, followed by and, or, and xor in that order. At the same level they all go left to right as one would expect. The comparisons compare two numerical expressions. Those expressions should conform to that used by the DataFormula class.

See Also:
Serialized Form

Nested Class Summary
private  class BooleanFormula.AndNode
           
private static interface BooleanFormula.BoolNode
           
private  class BooleanFormula.EqualsNode
           
private  class BooleanFormula.GTENode
           
private  class BooleanFormula.GTNode
           
static interface BooleanFormula.Listener
           
private  class BooleanFormula.LTENode
           
private  class BooleanFormula.LTNode
           
private  class BooleanFormula.NotNode
           
private  class BooleanFormula.OrNode
           
private  class BooleanFormula.XorNode
           
 
Field Summary
private  java.lang.String equ
           
private  boolean errorHandling
           
private  DataFormula.GroupInformation groupInfo
           
private  javax.swing.JTextField inputField
           
private  BooleanFormula.Listener listener
           
private  BooleanFormula.BoolNode root
           
private static long serialVersionUID
           
 
Constructor Summary
private BooleanFormula()
           
  BooleanFormula(BooleanFormula c)
           
  BooleanFormula(java.lang.String equation)
           
 
Method Summary
 boolean equals(java.lang.Object o)
           
private  void formulaChanged()
           
 java.lang.String getFormula()
           
 int[] getSafeElementRange(DataSink sink)
          Returns the smallest and largest element numbers that are safe to use with this formula.
 javax.swing.JTextField getTextField(BooleanFormula.Listener dfl)
          This method returns a text field that can be put into a GUI to edit this formula.
static void main(java.lang.String[] args)
           
private  void parse(java.lang.String equation)
           
private  BooleanFormula.BoolNode parseToTree(java.lang.String e)
           
 void setFormula(java.lang.String equation)
           
 boolean valueOf(DataSink sink, int elem)
          Returns the value of the given expression using the provided DataSink, primary element.
 boolean valueOf(DataSink sink, int elem, int[] specialElem)
          Returns the value of the given expression using the provided DataSink, primary element, and special elements.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

equ

private java.lang.String equ

root

private BooleanFormula.BoolNode root

groupInfo

private DataFormula.GroupInformation groupInfo

inputField

private transient javax.swing.JTextField inputField

listener

private transient BooleanFormula.Listener listener

errorHandling

private transient boolean errorHandling

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

BooleanFormula

public BooleanFormula(java.lang.String equation)

BooleanFormula

private BooleanFormula()

BooleanFormula

public BooleanFormula(BooleanFormula c)
Method Detail

main

public static void main(java.lang.String[] args)

parse

private void parse(java.lang.String equation)

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getFormula

public java.lang.String getFormula()

setFormula

public void setFormula(java.lang.String equation)

valueOf

public boolean valueOf(DataSink sink,
                       int elem)
Returns the value of the given expression using the provided DataSink, primary element. Special elements will be calculated using the "local" setting will be used.

Throws:
java.lang.ArithmeticException - This means that it tried an undefinied operation.
NoSuchElementException - A provided subscript was out of bounds.

valueOf

public boolean valueOf(DataSink sink,
                       int elem,
                       int[] specialElem)
Returns the value of the given expression using the provided DataSink, primary element, and special elements. Special elements can be null in which case the "local" setting will be used.

Throws:
java.lang.ArithmeticException - This means that it tried an undefinied operation.
NoSuchElementException - A provided subscript was out of bounds.

getSafeElementRange

public int[] getSafeElementRange(DataSink sink)
Returns the smallest and largest element numbers that are safe to use with this formula. This only checks the various data sources used and the offsets in them.


getTextField

public javax.swing.JTextField getTextField(BooleanFormula.Listener dfl)
This method returns a text field that can be put into a GUI to edit this formula. If the formula hasn't created one yet, it will create it. This field has listeners attached to it that will update the formula on action or focus loss. The provided DataFormulaListener will be notified when the formula is altered. It can be null.


parseToTree

private BooleanFormula.BoolNode parseToTree(java.lang.String e)

formulaChanged

private void formulaChanged()