org.generation5.util
Class Plot2D

java.lang.Object
  extended byorg.generation5.util.Plot
      extended byorg.generation5.util.Plot2D
All Implemented Interfaces:
Visualizable

public class Plot2D
extends Plot

Plot2D is a simple utility class designed to plot data. The class provides the necessary render functions to plot points, line or histogram data.


Field Summary
protected  java.awt.Color[] datasetColors
          The colours to use for the different data-sets.
static int HISTOGRAM
          Draw the data-series as a histogram
static int LINES
          Draw the data-series as lines.
static int NONE
          Don't draw the data series.
protected  java.util.LinkedList[] plotData
          The data to plot.
static int POINTS
          Draw the data-series as points.
 
Fields inherited from class org.generation5.util.Plot
drawAxes, maxX, maxY, minX, minY, plotTypes
 
Constructor Summary
Plot2D()
          Creates a new instance of Plot2D
Plot2D(int dataSets)
          Create a new instance of Plot2D, with a given number of data sets.
 
Method Summary
 void render(java.awt.Graphics g, int width, int height)
          Render the plot on a graphics context.
protected  void renderHistogram(java.awt.Graphics g, int dataSeries, int width, int height)
          Render the data as a histogram.
protected  void renderLines(java.awt.Graphics g, int dataSeries, int width, int height)
          Render the data as lines.
protected  void renderPoint(java.awt.Graphics g, double x, double y, int width, int height)
          Render a point.
protected  void renderPoints(java.awt.Graphics g, int dataSeries, int width, int height)
          Render the data series as points.
 void setData(int dataSeries, double[] pd)
          Set the data for a given series.
 void setData(int dataSeries, double[][] pd)
          Set the data for a given series.
 void setData(int dataSeries, java.util.LinkedList pd)
          Set the data for a given series.
 void setData(int dataSeries, long[] pd)
          Set the data from an array of longs.
 void setDataSets(int dataSets)
          Set the number of the datasets.
 void setPlotColor(int dataSeries, java.awt.Color plotColor)
          Set the plot colour for a given data series.
 void setPlotType(int dataSeries, int plotType)
          Sets the plot type for a given data series.
 
Methods inherited from class org.generation5.util.Plot
calculateRanges, drawAxes, getMaximumX, getMaximumY, getMinimumX, getMinimumY, getRangeX, getRangeY, setDrawAxes, setMaximumX, setMaximumY, setMinimumX, setRange, translateCoordinate, translateCoordinate, writeImage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

datasetColors

protected java.awt.Color[] datasetColors
The colours to use for the different data-sets.


plotData

protected java.util.LinkedList[] plotData
The data to plot. The data is stored as an array of linked lists.


POINTS

public static final int POINTS
Draw the data-series as points.

See Also:
Constant Field Values

LINES

public static final int LINES
Draw the data-series as lines.

See Also:
Constant Field Values

HISTOGRAM

public static final int HISTOGRAM
Draw the data-series as a histogram

See Also:
Constant Field Values

NONE

public static final int NONE
Don't draw the data series.

See Also:
Constant Field Values
Constructor Detail

Plot2D

public Plot2D()
Creates a new instance of Plot2D


Plot2D

public Plot2D(int dataSets)
Create a new instance of Plot2D, with a given number of data sets.

Parameters:
dataSets - the number of data sets in this plot.
Method Detail

setDataSets

public void setDataSets(int dataSets)
Set the number of the datasets.

Parameters:
dataSets - the number of data sets present.

setPlotType

public void setPlotType(int dataSeries,
                        int plotType)
Sets the plot type for a given data series.

Parameters:
dataSeries - the series number.
plotType - the plot type to use (see POINTS, LINES, FILLED).

setPlotColor

public void setPlotColor(int dataSeries,
                         java.awt.Color plotColor)
Set the plot colour for a given data series.

Parameters:
dataSeries - the data series.
plotColor - the new plot colour.

setData

public void setData(int dataSeries,
                    double[] pd)
Set the data for a given series. Note that this function creates a linked list: plotData[dataSeries] = new LinkedList(); for (int i=0; i

Parameters:
dataSeries - the data series.
pd - a one-dimensional double array specifying the y-coordinates of the data.

setData

public void setData(int dataSeries,
                    long[] pd)
Set the data from an array of longs.

Parameters:
dataSeries - the data series to set.
pd - a one-dimensional long array specifying the y-coordinates of the data.

setData

public void setData(int dataSeries,
                    double[][] pd)
Set the data for a given series. Note that this function creates a linked list: plotData[dataSeries] = new LinkedList(); for (int i=0; i

Parameters:
dataSeries - the data series.
pd - a two-dimensional array specifying the x and y coordinates of the data.

setData

public void setData(int dataSeries,
                    java.util.LinkedList pd)
Set the data for a given series. Note the linked list must stored objects of type PlotPoint.

Parameters:
dataSeries - the data series.
pd - the linked list of plot data.

render

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

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

renderLines

protected void renderLines(java.awt.Graphics g,
                           int dataSeries,
                           int width,
                           int height)
Render the data as lines.

Parameters:
g - the graphics context.
dataSeries - the data series to render.
width - the width of the context.
height - the height of the context.

renderHistogram

protected void renderHistogram(java.awt.Graphics g,
                               int dataSeries,
                               int width,
                               int height)
Render the data as a histogram.

Parameters:
g - the graphics context.
dataSeries - the data series to plot.
width - the width of the context.
height - the height of the context.

renderPoints

protected void renderPoints(java.awt.Graphics g,
                            int dataSeries,
                            int width,
                            int height)
Render the data series as points.

Parameters:
g - the graphics context.
dataSeries - the data series to render.
width - the width of the context.
height - the height of the context.

renderPoint

protected void renderPoint(java.awt.Graphics g,
                           double x,
                           double y,
                           int width,
                           int height)
Render a point.

Parameters:
g - the graphics context.
x - the x-coordinate.
y - the y-coordinate.
width - the width of the context.
height - the height of the context.

This documentation is part of the Generation5 JDK.