edu.rit.numeric.plot.impl
Class XYPlot

java.lang.Object
  extended by edu.rit.numeric.plot.impl.XYPlot
All Implemented Interfaces:
Displayable, Drawable

public class XYPlot
extends Object
implements Displayable

Class XYPlot provides an XY plot. The plot has an X axis, a Y axis, and one or more plot series (type PlotSeries). The plot may optionally have a Grid. Labels (class Label) may be added to a plot and are drawn after drawing all the plot series.


Field Summary
static Paint DEFAULT_BACKGROUND
          The default background paint (white).
static double DEFAULT_MARGIN
          The default margin (54).
protected  Paint myBackgroundPaint
          Background paint.
protected  double myBottomMargin
          Bottom margin.
protected  Rectangle2D.Double myBoundingBox
          Bounding box.
protected  Grid myGrid
          Grid.
protected  double myHeight
          Height.
protected  ArrayList<Label> myLabels
          List of labels.
protected  double myLeftMargin
          Left margin.
protected  ArrayList<PlotSeries> myPlotSeries
          List of plot series.
protected  double myRightMargin
          Right margin.
protected  double myTopMargin
          Top margin.
protected  double myWidth
          Width.
protected  NumericalAxis myXAxis
          X axis.
protected  NumericalAxis myYAxis
          Y axis.
 
Constructor Summary
XYPlot(NumericalAxis theXAxis, NumericalAxis theYAxis)
          Construct a new XY plot with the given axes.
XYPlot(NumericalAxis theXAxis, NumericalAxis theYAxis, Grid theGrid)
          Construct a new XY plot with the given axes and grid.
XYPlot(NumericalAxis theXAxis, NumericalAxis theYAxis, Grid theGrid, double theMargin)
          Construct a new XY plot with the given axes, grid, and margin.
XYPlot(NumericalAxis theXAxis, NumericalAxis theYAxis, Grid theGrid, double theLeftMargin, double theTopMargin, double theRightMargin, double theBottomMargin)
          Construct a new XY plot with the given axes, grid, and margins.
XYPlot(NumericalAxis theXAxis, NumericalAxis theYAxis, Grid theGrid, double theLeftMargin, double theTopMargin, double theRightMargin, double theBottomMargin, Paint theBackgroundPaint)
          Construct a new XY plot with the given axes, grid, margins, and background.
 
Method Summary
 void addLabel(Label theLabel)
          Add the given label to this XY plot.
 void addPlotSeries(PlotSeries thePlotSeries)
          Add the given plot series to this XY plot.
 void draw(Graphics2D g2d)
          Draw this drawable object in the given graphics context.
 Paint getBackgroundPaint()
          Returns this displayable object's background paint.
 Rectangle2D getBoundingBox()
          Returns this displayable object's bounding box.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MARGIN

public static final double DEFAULT_MARGIN
The default margin (54).

See Also:
Constant Field Values

DEFAULT_BACKGROUND

public static final Paint DEFAULT_BACKGROUND
The default background paint (white).


myXAxis

protected NumericalAxis myXAxis
X axis.


myYAxis

protected NumericalAxis myYAxis
Y axis.


myGrid

protected Grid myGrid
Grid.


myPlotSeries

protected ArrayList<PlotSeries> myPlotSeries
List of plot series.


myLabels

protected ArrayList<Label> myLabels
List of labels.


myLeftMargin

protected double myLeftMargin
Left margin.


myTopMargin

protected double myTopMargin
Top margin.


myRightMargin

protected double myRightMargin
Right margin.


myBottomMargin

protected double myBottomMargin
Bottom margin.


myWidth

protected double myWidth
Width.


myHeight

protected double myHeight
Height.


myBoundingBox

protected Rectangle2D.Double myBoundingBox
Bounding box.


myBackgroundPaint

protected Paint myBackgroundPaint
Background paint.

Constructor Detail

XYPlot

public XYPlot(NumericalAxis theXAxis,
              NumericalAxis theYAxis)
Construct a new XY plot with the given axes. The plot has no grid. The plot uses the default margin (54) on all sides. The plot uses the default background (white).

Parameters:
theXAxis - X axis.
theYAxis - Y axis.
Throws:
NullPointerException - (unchecked exception) Thrown if theXAxis is null or theYAxis is null.

XYPlot

public XYPlot(NumericalAxis theXAxis,
              NumericalAxis theYAxis,
              Grid theGrid)
Construct a new XY plot with the given axes and grid. The plot uses the default margin (54) on all sides. The plot uses the default background (white).

Parameters:
theXAxis - X axis.
theYAxis - Y axis.
theGrid - Grid, or null for no grid.
Throws:
NullPointerException - (unchecked exception) Thrown if theXAxis is null or theYAxis is null.

XYPlot

public XYPlot(NumericalAxis theXAxis,
              NumericalAxis theYAxis,
              Grid theGrid,
              double theMargin)
Construct a new XY plot with the given axes, grid, and margin. The plot uses the same margin on all sides. The plot uses the default background (white).

Parameters:
theXAxis - X axis.
theYAxis - Y axis.
theGrid - Grid, or null for no grid.
theMargin - Margin.
Throws:
NullPointerException - (unchecked exception) Thrown if theXAxis is null or theYAxis is null.
IllegalArgumentException - (unchecked exception) Thrown if theMargin is less than 0.

XYPlot

public XYPlot(NumericalAxis theXAxis,
              NumericalAxis theYAxis,
              Grid theGrid,
              double theLeftMargin,
              double theTopMargin,
              double theRightMargin,
              double theBottomMargin)
Construct a new XY plot with the given axes, grid, and margins. The plot uses the default background (white).

Parameters:
theXAxis - X axis.
theYAxis - Y axis.
theGrid - Grid, or null for no grid.
theLeftMargin - Left margin.
theTopMargin - Top margin.
theRightMargin - Right margin.
theBottomMargin - Left margin.
Throws:
NullPointerException - (unchecked exception) Thrown if theXAxis is null or theYAxis is null.
IllegalArgumentException - (unchecked exception) Thrown if any margin is less than 0.

XYPlot

public XYPlot(NumericalAxis theXAxis,
              NumericalAxis theYAxis,
              Grid theGrid,
              double theLeftMargin,
              double theTopMargin,
              double theRightMargin,
              double theBottomMargin,
              Paint theBackgroundPaint)
Construct a new XY plot with the given axes, grid, margins, and background.

Parameters:
theXAxis - X axis.
theYAxis - Y axis.
theGrid - Grid, or null for no grid.
theLeftMargin - Left margin.
theTopMargin - Top margin.
theRightMargin - Right margin.
theBottomMargin - Left margin.
theBackgroundPaint - Background paint.
Throws:
NullPointerException - (unchecked exception) Thrown if theXAxis is null, theYAxis is null, or theBackgroundPaint is null.
IllegalArgumentException - (unchecked exception) Thrown if any margin is less than 0.
Method Detail

addPlotSeries

public void addPlotSeries(PlotSeries thePlotSeries)
Add the given plot series to this XY plot. When this XY plot is drawn, the plot series are drawn in the order they were added; that is, last added plot series on top.

Parameters:
thePlotSeries - Plot series.
Throws:
NullPointerException - (unchecked exception) Thrown if thePlotSeries is null.

addLabel

public void addLabel(Label theLabel)
Add the given label to this XY plot. When this XY plot is drawn, the labels are drawn after the plot series, and the labels are drawn in the order they were added; that is, last added label on top.

Parameters:
theLabel - Label.
Throws:
NullPointerException - (unchecked exception) Thrown if theLabel is null.

draw

public void draw(Graphics2D g2d)
Draw this drawable object in the given graphics context. Upon return from this method, the given graphics context's state (color, font, transform, clip, and so on) is the same as it was upon entry to this method.

This XY plot is drawn so that the upper left corner (including the margins) is located at the display coordinates (0, 0) in the graphics context.

Specified by:
draw in interface Drawable
Parameters:
g2d - 2-D graphics context.

getBoundingBox

public Rectangle2D getBoundingBox()
Returns this displayable object's bounding box. This is the smallest rectangle that encloses all of this displayable object.

Specified by:
getBoundingBox in interface Displayable

getBackgroundPaint

public Paint getBackgroundPaint()
Returns this displayable object's background paint.

Specified by:
getBackgroundPaint in interface Displayable


Copyright © 2005-2012 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.