net.moioli.drawables
Class AbstractDrawableFunction

java.lang.Object
  extended by net.moioli.drawables.AbstractDrawableFunction
All Implemented Interfaces:
DrawableI, FunctionI
Direct Known Subclasses:
FunctionByPointsLines, ParsedFunction

public abstract class AbstractDrawableFunction
extends java.lang.Object
implements DrawableI, FunctionI

A general implementation of the DrawableI and FunctionI interfaces. Includes empirical minY() and maxY() methods.

Version:
2005/10/5
Author:
Silvio Moioli

Constructor Summary
AbstractDrawableFunction()
          Default constructor, does really nothing.
 
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.
abstract  double f(double x)
          Returns the y value associated to the specified x.
 double getMaximum(double minX, double maxX)
          Returns the point in which the function is maximum with an empirical algorithm.
 double getMinimum(double minX, double maxX)
          Returns the point in which the function is minimum with an empirical algorithm.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDrawableFunction

public AbstractDrawableFunction()
Default constructor, does really nothing.

Method Detail

f

public abstract double f(double x)
Description copied from interface: FunctionI
Returns the y value associated to the specified x.

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

getMinimum

public double getMinimum(double minX,
                         double maxX)
Returns the point in which the function is minimum with an empirical algorithm. While this method is accurate enough in most cases, it should be overridden whenever possible.

Parameters:
minX - the minimum x value to be represented
maxX - the maximum x value to be represented
Returns:
the abcissa in which the function has an absolute minimum

getMaximum

public double getMaximum(double minX,
                         double maxX)
Returns the point in which the function is maximum with an empirical algorithm. While this method is accurate enough in most cases, it should be overridden whenever possible.

Parameters:
minX - the minimum x value to be represented
maxX - the maximum x value to be represented
Returns:
the abcissa in which the function has an absolute maximum

minY

public double minY(double minX,
                   double maxX)
Description copied from interface: DrawableI
Returns the minimum y value that should be represented in the DefaultChart for this object to be drawn properly.
If the object will be drawn indipendently from the y values represented in the DefaultChart, this method should return Double.NaN.

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

maxY

public double maxY(double minX,
                   double maxX)
Description copied from interface: DrawableI
Returns the maximum y value that should be represented in the DefaultChart for this object to be drawn properly.
If the object will be drawn indipendently from the y values represented in the DefaultChart, this method should return Double.NaN.

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

drawMe

public void drawMe(GraphicsI g,
                   Scale s,
                   java.lang.Object c)
Description copied from interface: DrawableI
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
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)