net.moioli.drawables
Class ParsedPlaneCurve

java.lang.Object
  extended by net.moioli.drawables.AbstractPlaneCurve
      extended by net.moioli.drawables.ParsedPlaneCurve
All Implemented Interfaces:
DrawableI, PlaneCurveI

public class ParsedPlaneCurve
extends AbstractPlaneCurve

This class provides a quick way to implement mathematical curves: parsing them from strings. Just pass a string like "x^2+sin(x)" and "3y" to the constructor and you'll get a drawable curve to add to your DefaultChart.
The parsing is done with the JEP parser, so strings should follow JEP's syntax.

Version:
2005/10/5
Author:
Silvio Moioli
See Also:
JEP

Constructor Summary
ParsedPlaneCurve(java.lang.String xFunction, java.lang.String yFunction, double maxT)
          Constructs a new function with the given strings (any point in this function has coordinates (x(t),y(t)).
 
Method Summary
 java.lang.String toString()
          Returns a string describing this function.
 double x(double t)
          Returns the x value corresponding to the specified t (any point in this function has coordinates (x(t),y(t)).
 double y(double t)
          Returns the y value corresponding to the specified t (any point in this function has coordinates (x(t),y(t)).
 
Methods inherited from class net.moioli.drawables.AbstractPlaneCurve
drawMe, getMaxT, getXMaximum, getXMinimum, getYMaximum, getYMinimum, maxX, maxY, minX, minY, setMaxT
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParsedPlaneCurve

public ParsedPlaneCurve(java.lang.String xFunction,
                        java.lang.String yFunction,
                        double maxT)
                 throws org.nfunk.jep.ParseException
Constructs a new function with the given strings (any point in this function has coordinates (x(t),y(t)). The string should follow JEP's syntax.

Parameters:
xFunction - the string to be parsed corresponting to x(t)
yFunction - the string to be parsed corresponting to y(t)
maxT - the maximum parameter value
Throws:
org.nfunk.jep.ParseException - if the string cannot be parsed by JEP
See Also:
JEP
Method Detail

x

public double x(double t)
Description copied from interface: PlaneCurveI
Returns the x value corresponding to the specified t (any point in this function has coordinates (x(t),y(t)).

Specified by:
x in interface PlaneCurveI
Specified by:
x in class AbstractPlaneCurve
Parameters:
t - the parameter's value
Returns:
the point's abscissa
See Also:
PlaneCurveI.x(double)

y

public double y(double t)
Description copied from interface: PlaneCurveI
Returns the y value corresponding to the specified t (any point in this function has coordinates (x(t),y(t)).

Specified by:
y in interface PlaneCurveI
Specified by:
y in class AbstractPlaneCurve
Parameters:
t - the parameter's value
Returns:
the point's ordinate
See Also:
PlaneCurveI.y(double)

toString

public java.lang.String toString()
Returns a string describing this function.

Overrides:
toString in class java.lang.Object
Returns:
a string describing this function