net.sourceforge.webcompmath.draw.beans
Class WCMMouseVariableBean

java.lang.Object
  extended by net.sourceforge.webcompmath.data.Constant
      extended by net.sourceforge.webcompmath.data.Variable
          extended by net.sourceforge.webcompmath.draw.beans.WCMMouseVariableBean
All Implemented Interfaces:
java.io.Serializable, Tieable, ParserMathObject, Expression, ExpressionCommand, MathObject, Value

public class WCMMouseVariableBean
extends Variable
implements Tieable, Value, ParserMathObject

This class is a convenience class used when creating applications via a GUI builder. After dropping a WCMMouseTrackerBean or a WCMDraggablePointBean on a canvas, you can access it's x and y variables by creating a WCMMouseVariableBean and setting its Mouse property (and optionally it's AxisDirection property, which defaults to the x axis). Once set up, you can use this anywhere you would normally use a variable. The implementation just gets the appropriate variable from the mouse tracker or draggable point, saves it, and then passes appropriate method calls on to the variable.

Author:
Tom Downey
See Also:
Serialized Form

Field Summary
static int X_AXIS
          Indicates that the variable should track the mouse's x position
static int Y_AXIS
          Indicates that the variable should track the mouse's y position
 
Fields inherited from class net.sourceforge.webcompmath.data.Constant
value
 
Constructor Summary
WCMMouseVariableBean()
          Default constructor
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Just pass through to the support class
 void appendOutputString(ExpressionProgram prog, int myIndex, java.lang.StringBuffer buffer)
          Passed through to the MouseVar variable.
 void apply(StackOfDouble stack, Cases cases)
          Passed through to the MouseVar variable.
 void compileDerivative(ExpressionProgram prog, int myIndex, ExpressionProgram deriv, Variable wrt)
          Passed through to the MouseVar variable.
 boolean dependsOn(Variable x)
          Passed through to the MouseVar variable.
 Expression derivative(Variable wrt)
          Passed through to the MouseVar variable.
 int extent(ExpressionProgram prog, int myIndex)
          Passed through to the MouseVar variable.
 int getAxisDirection()
          Get whether this variable represents the x or y position of the mouse.
 MathObject getMathObject()
          Just return the variable.
 MouseVar getMouse()
          Get the MouseTracker or DraggablePoint being referenced
 java.lang.String getName()
          Passed through to the MouseVar variable.
 long getSerialNumber()
          Passed through to the MouseVar variable.
 double getVal()
          Passed through to the MouseVar variable.
 double getValueWithCases(Cases cases)
          Passed through to the MouseVar variable.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          just pass through to the support class )
 void setAxisDirection(int d)
          Set whether this variable represents the x or y position of the mouse.
 void setMouse(MouseVar m)
          Set the MouseTracker or DraggablePoint to use when getting a position variable
 void setName(java.lang.String name)
          Passed through to the MouseVar variable.
 void setVal(double value)
          Passed through to the MouseVar variable.
 void sync(Tie tie, Tieable newest)
          Passed through to the MouseVar variable.
 java.lang.String toString()
          Passed through to the MouseVar variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

X_AXIS

public static final int X_AXIS
Indicates that the variable should track the mouse's x position

See Also:
Constant Field Values

Y_AXIS

public static final int Y_AXIS
Indicates that the variable should track the mouse's y position

See Also:
Constant Field Values
Constructor Detail

WCMMouseVariableBean

public WCMMouseVariableBean()
Default constructor

Method Detail

setMouse

public void setMouse(MouseVar m)
Set the MouseTracker or DraggablePoint to use when getting a position variable

Parameters:
m - the mouse tracker or draggable point

getMouse

public MouseVar getMouse()
Get the MouseTracker or DraggablePoint being referenced

Returns:
the MouseTracker or DraggablePoint

setName

public void setName(java.lang.String name)
Passed through to the MouseVar variable.

Specified by:
setName in interface MathObject
Overrides:
setName in class Constant
Parameters:
name - name of the constant
See Also:
Constant.setName(java.lang.String)

getName

public java.lang.String getName()
Passed through to the MouseVar variable.

Specified by:
getName in interface MathObject
Overrides:
getName in class Constant
Returns:
name of the constant
See Also:
Constant.getName()

setAxisDirection

public void setAxisDirection(int d)
Set whether this variable represents the x or y position of the mouse.

Parameters:
d - the desired position, either X_AXIS or Y_AXIS

getAxisDirection

public int getAxisDirection()
Get whether this variable represents the x or y position of the mouse.

Returns:
either X_AXIS or Y_AXIS

setVal

public void setVal(double value)
Passed through to the MouseVar variable.

Overrides:
setVal in class Variable
Parameters:
value - value to set variable to
See Also:
Variable.setVal(double)

derivative

public Expression derivative(Variable wrt)
Passed through to the MouseVar variable.

Specified by:
derivative in interface Expression
Overrides:
derivative in class Variable
Parameters:
wrt - "with respect to", i.e., the variable with respect to which to take the derivative.
Returns:
a constant: 1 if wrt is this Variable, 0 otherwise.
See Also:
Variable.derivative(net.sourceforge.webcompmath.data.Variable)

compileDerivative

public void compileDerivative(ExpressionProgram prog,
                              int myIndex,
                              ExpressionProgram deriv,
                              Variable wrt)
Passed through to the MouseVar variable.

Specified by:
compileDerivative in interface ExpressionCommand
Overrides:
compileDerivative in class Variable
Parameters:
prog - expression program
myIndex - location in program
deriv - the derivative
wrt - variable with respect to
See Also:
Variable.compileDerivative(net.sourceforge.webcompmath.data.ExpressionProgram, int, net.sourceforge.webcompmath.data.ExpressionProgram, net.sourceforge.webcompmath.data.Variable)

dependsOn

public boolean dependsOn(Variable x)
Passed through to the MouseVar variable.

Specified by:
dependsOn in interface Expression
Specified by:
dependsOn in interface ExpressionCommand
Overrides:
dependsOn in class Variable
Parameters:
x - variable to check
Returns:
true or false
See Also:
Variable.dependsOn(net.sourceforge.webcompmath.data.Variable)

toString

public java.lang.String toString()
Passed through to the MouseVar variable.

Specified by:
toString in interface Expression
Overrides:
toString in class Variable
Returns:
string representation of the variable
See Also:
Variable.toString()

getVal

public double getVal()
Passed through to the MouseVar variable.

Specified by:
getVal in interface Value
Overrides:
getVal in class Constant
Returns:
value of the constant
See Also:
Constant.getVal()

getValueWithCases

public double getValueWithCases(Cases cases)
Passed through to the MouseVar variable.

Specified by:
getValueWithCases in interface Expression
Overrides:
getValueWithCases in class Constant
Parameters:
cases - the cases to use
Returns:
value of the constant
See Also:
Constant.getValueWithCases(net.sourceforge.webcompmath.data.Cases)

apply

public void apply(StackOfDouble stack,
                  Cases cases)
Passed through to the MouseVar variable.

Specified by:
apply in interface ExpressionCommand
Overrides:
apply in class Constant
Parameters:
stack - the stack to use
cases - the cases to use
See Also:
Constant.apply(net.sourceforge.webcompmath.data.StackOfDouble, net.sourceforge.webcompmath.data.Cases)

extent

public int extent(ExpressionProgram prog,
                  int myIndex)
Passed through to the MouseVar variable.

Specified by:
extent in interface ExpressionCommand
Overrides:
extent in class Constant
Parameters:
prog - program containing the constant
myIndex - location of the constant
Returns:
number of locations
See Also:
Constant.extent(net.sourceforge.webcompmath.data.ExpressionProgram, int)

appendOutputString

public void appendOutputString(ExpressionProgram prog,
                               int myIndex,
                               java.lang.StringBuffer buffer)
Passed through to the MouseVar variable.

Specified by:
appendOutputString in interface ExpressionCommand
Overrides:
appendOutputString in class Constant
Parameters:
prog - program containing the constant
myIndex - location of the constant
buffer - string to append
See Also:
Constant.appendOutputString(net.sourceforge.webcompmath.data.ExpressionProgram, int, java.lang.StringBuffer)

getSerialNumber

public long getSerialNumber()
Passed through to the MouseVar variable.

Specified by:
getSerialNumber in interface Tieable
Returns:
the serial number
See Also:
Tieable.getSerialNumber()

sync

public void sync(Tie tie,
                 Tieable newest)
Passed through to the MouseVar variable.

Specified by:
sync in interface Tieable
Parameters:
tie - the tie connecting the objects
newest - the object to notify
See Also:
Tieable.sync(net.sourceforge.webcompmath.awt.Tie, net.sourceforge.webcompmath.awt.Tieable)

getMathObject

public MathObject getMathObject()
Just return the variable.

Specified by:
getMathObject in interface ParserMathObject
Returns:
the MathObject that will be added to a parser
See Also:
ParserMathObject.getMathObject()

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Just pass through to the support class

Specified by:
addPropertyChangeListener in interface ParserMathObject
See Also:
ParserMathObject.addPropertyChangeListener(java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
just pass through to the support class )

Specified by:
removePropertyChangeListener in interface ParserMathObject
See Also:
ParserMathObject.removePropertyChangeListener(java.beans.PropertyChangeListener)