net.moioli.drawables
Class FunctionByPointsLines

java.lang.Object
  extended by net.moioli.drawables.AbstractDrawableFunction
      extended by net.moioli.drawables.FunctionByPointsLines
All Implemented Interfaces:
DrawableI, FunctionByPointsI, FunctionI

public class FunctionByPointsLines
extends AbstractDrawableFunction
implements FunctionByPointsI

A function which is defined (empirically) from a set of points, and interpolated/ extrapolated with lines.

Version:
2005/10/5
Author:
Silvio Moioli

Constructor Summary
FunctionByPointsLines()
          Default constructor (y=x)
FunctionByPointsLines(java.util.Collection points)
          Standard constructor.
 
Method Summary
 void drawMe(GraphicsI g, Scale s, java.lang.Object c)
          This method is automatically called by DefaultChart to draw the objects it contains, so end users should never call drawMe directly.
 double f(double x)
          Returns the y value corresponding to the specified x.
 double[] getAscissae()
          Returns an array with the ascissae of the points that define this function.
 double[] getOrdinate()
          Returns an array with the ordinate of the points that define this function.
 double maxY(double minX, double maxX)
          Returns the maximum y value that should be represented in the DefaultChart for this object to be drawn properly.
 double minY(double minX, double maxX)
          Returns the minimum y value that should be represented in the DefaultChart for this object to be drawn properly.
 void setAscissae(double[] ascissae)
          Changes the ascissae of the points that define this function.
 void setOrdinate(double[] ordinate)
          Changes the ordinate of the points that define this function.
 
Methods inherited from class net.moioli.drawables.AbstractDrawableFunction
getMaximum, getMinimum
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionByPointsLines

public FunctionByPointsLines()
Default constructor (y=x)


FunctionByPointsLines

public FunctionByPointsLines(java.util.Collection points)
Standard constructor.

Parameters:
points - a DoublePoint Collection.
Method Detail

f

public double f(double x)
Returns the y value corresponding to the specified x.

Specified by:
f in interface FunctionI
Specified by:
f in class AbstractDrawableFunction
Parameters:
x - the abscissa
Returns:
the ordinate
See Also:
FunctionI.f(double)

drawMe

public void drawMe(GraphicsI g,
                   Scale s,
                   java.lang.Object c)
This method is automatically called by DefaultChart to draw the objects it contains, so end users should never call drawMe directly. Inside this method there must be all the code to draw the object on a DefaultChart, and all the operations which involve scaling should be done via the passed Scale object.

Specified by:
drawMe in interface DrawableI
Overrides:
drawMe in class AbstractDrawableFunction
Parameters:
g - the surface where this object will be drawn
s - the DefaultChart's Scale object
c - the color to be used for drawing
See Also:
DrawableI.drawMe(GraphicsI, Scale, Object)

minY

public double minY(double minX,
                   double maxX)
Returns the minimum y value that should be represented in the DefaultChart for this object to be drawn properly.

Specified by:
minY in interface DrawableI
Overrides:
minY in class AbstractDrawableFunction
Parameters:
minX - the minimum x value represented in this DefaultChart
maxX - the maximum x value represented in this DefaultChart
Returns:
the minimum y value
See Also:
DrawableI.minY(double, double)

maxY

public double maxY(double minX,
                   double maxX)
Returns the maximum y value that should be represented in the DefaultChart for this object to be drawn properly.

Specified by:
maxY in interface DrawableI
Overrides:
maxY in class AbstractDrawableFunction
Parameters:
minX - the minimum x value represented in this DefaultChart
maxX - the maximum x value represented in this DefaultChart
Returns:
the maximum y value
See Also:
DrawableI.maxY(double, double)

getAscissae

public double[] getAscissae()
Returns an array with the ascissae of the points that define this function.

Specified by:
getAscissae in interface FunctionByPointsI
Returns:
an array of double

setAscissae

public void setAscissae(double[] ascissae)
Changes the ascissae of the points that define this function.

Specified by:
setAscissae in interface FunctionByPointsI
Parameters:
ascissae - the ascissae to set.

getOrdinate

public double[] getOrdinate()
Returns an array with the ordinate of the points that define this function.

Specified by:
getOrdinate in interface FunctionByPointsI
Returns:
an array of double

setOrdinate

public void setOrdinate(double[] ordinate)
Changes the ordinate of the points that define this function.

Specified by:
setOrdinate in interface FunctionByPointsI
Parameters:
ordinate - the ascissae to set.