org.generation5.util
Class Plot

java.lang.Object
  extended byorg.generation5.util.Plot
All Implemented Interfaces:
Visualizable
Direct Known Subclasses:
Plot2D, PlotGrid

public abstract class Plot
extends java.lang.Object
implements Visualizable

An abstract base class providing basic functionality for the plot classes.


Field Summary
protected  boolean drawAxes
          Draw the axes.
protected  double maxX
          Maximum X-range
protected  double maxY
          Maximum Y-range.
protected  double minX
          Minimum X-range
protected  double minY
          Minimum Y-range
protected  int[] plotTypes
          The type of plot for a given data series.
 
Constructor Summary
Plot()
          Creates a new instance of Plot
 
Method Summary
protected  void calculateRanges()
          Calculates the ranges for the X and Y coordinates.
protected  void drawAxes(java.awt.Graphics g, int width, int height)
          Draws the axes on the given graphics context.
 double getMaximumX()
          Return the maximum X-coordinate.
 double getMaximumY()
          Get the maximum Y-coordinate.
 double getMinimumX()
          Return the minimum X-coordinate.
 double getMinimumY()
          Return the minimum Y-coordinate.
 double getRangeX()
          Return the X-range.
 double getRangeY()
          Return the Y-range.
abstract  void render(java.awt.Graphics g, int width, int height)
          Render the plot on a graphics context.
 void setDrawAxes(boolean da)
          Allows the axes to be toggled on and off.
 void setMaximumX(double mx)
          Set the maximum X-coordinate.
 void setMaximumY(double my)
          Set the maximum Y-coordinate.
 void setMinimumX(double mx)
          Set the minimum X-coordinate.
 void setRange(double minX, double maxX, double minY, double maxY)
          Set the range covered by the plot.
 PlotPoint translateCoordinate(double x, double y, int width, int height)
          Translates a cartesian coordinate to absolute coordinates for the graphics context.
 PlotPoint translateCoordinate(PlotPoint point, int width, int height)
          Translates a cartesian coordinate to absolute coordinates for the graphics context.
 void writeImage(java.lang.String s, int width, int height)
          Write the plot to file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

plotTypes

protected int[] plotTypes
The type of plot for a given data series.


minX

protected double minX
Minimum X-range


maxX

protected double maxX
Maximum X-range


minY

protected double minY
Minimum Y-range


maxY

protected double maxY
Maximum Y-range.


drawAxes

protected boolean drawAxes
Draw the axes.

Constructor Detail

Plot

public Plot()
Creates a new instance of Plot

Method Detail

setDrawAxes

public void setDrawAxes(boolean da)
Allows the axes to be toggled on and off.

Parameters:
da - should the axes be drawn?

render

public abstract void render(java.awt.Graphics g,
                            int width,
                            int height)
Render the plot on a graphics context.

Specified by:
render in interface Visualizable
Parameters:
g - the graphics context.
width - the width of the context.
height - the height of the context.

writeImage

public void writeImage(java.lang.String s,
                       int width,
                       int height)
Write the plot to file.

Specified by:
writeImage in interface Visualizable
Parameters:
s - the image filename.
width - the width of the image.
height - the height of the image.

translateCoordinate

public PlotPoint translateCoordinate(double x,
                                     double y,
                                     int width,
                                     int height)
Translates a cartesian coordinate to absolute coordinates for the graphics context.

Parameters:
x - the x-position.
y - the y-position.
width - the width of the graphics context.
height - the height of the graphics context.
Returns:
a PlotPoint corresponding to the absolute coordinates.

translateCoordinate

public PlotPoint translateCoordinate(PlotPoint point,
                                     int width,
                                     int height)
Translates a cartesian coordinate to absolute coordinates for the graphics context.

Parameters:
point - the point to translate.
width - the width of the graphics context.
height - the height of the graphics context.
Returns:
a PlotPoint corresponding to the absolute coordinates.

calculateRanges

protected void calculateRanges()
Calculates the ranges for the X and Y coordinates. Required for correct rendering.


getRangeX

public double getRangeX()
Return the X-range.

Returns:
the range of the X-axis.

getRangeY

public double getRangeY()
Return the Y-range.

Returns:
the range of the Y-axis.

getMinimumX

public double getMinimumX()
Return the minimum X-coordinate.

Returns:
the minimum X-coordinate.

setMinimumX

public void setMinimumX(double mx)
Set the minimum X-coordinate.

Parameters:
mx - the new minimum X-coordinate.

getMaximumX

public double getMaximumX()
Return the maximum X-coordinate.

Returns:
the maximum X-coordinate.

setMaximumX

public void setMaximumX(double mx)
Set the maximum X-coordinate.

Parameters:
mx - the new maximum X-coordinate.

getMinimumY

public double getMinimumY()
Return the minimum Y-coordinate.

Returns:
the minimum Y-coordinate.

getMaximumY

public double getMaximumY()
Get the maximum Y-coordinate.

Returns:
the maximum Y-coordinate.

setMaximumY

public void setMaximumY(double my)
Set the maximum Y-coordinate.

Parameters:
my - the new maximum Y-coordinate.

setRange

public void setRange(double minX,
                     double maxX,
                     double minY,
                     double maxY)
Set the range covered by the plot.

Parameters:
minX - the minimum X-coordinate.
maxX - the maximum X-coordinate.
minY - the minimum Y-coordinate.
maxY - the maximum Y-coordinate.

drawAxes

protected void drawAxes(java.awt.Graphics g,
                        int width,
                        int height)
Draws the axes on the given graphics context.

Parameters:
g - the graphics context.
width - the width of the context.
height - the height of the context.

This documentation is part of the Generation5 JDK.