edu.rit.numeric.plot.impl
Class XYPlot
- java.lang.Object
-
- edu.rit.numeric.plot.impl.XYPlot
-
- All Implemented Interfaces:
- Displayable, Drawable
public class XYPlot extends java.lang.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
Fields Modifier and Type Field and Description static java.awt.PaintDEFAULT_BACKGROUNDThe default background paint (white).static doubleDEFAULT_MARGINThe default margin (54).
-
Constructor Summary
Constructors Constructor and Description 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, java.awt.Paint theBackgroundPaint)Construct a new XY plot with the given axes, grid, margins, and background.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddLabel(Label theLabel)Add the given label to this XY plot.voidaddPlotSeries(PlotSeries thePlotSeries)Add the given plot series to this XY plot.voiddraw(java.awt.Graphics2D g2d)Draw this drawable object in the given graphics context.java.awt.PaintgetBackgroundPaint()Returns this displayable object's background paint.java.awt.geom.Rectangle2DgetBoundingBox()Returns this displayable object's bounding box.
-
-
-
Field Detail
-
DEFAULT_MARGIN
public static final double DEFAULT_MARGIN
The default margin (54).- See Also:
- Constant Field Values
-
DEFAULT_BACKGROUND
public static final java.awt.Paint DEFAULT_BACKGROUND
The default background paint (white).
-
-
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:
java.lang.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:
java.lang.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:
java.lang.NullPointerException- (unchecked exception) Thrown if theXAxis is null or theYAxis is null.java.lang.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:
java.lang.NullPointerException- (unchecked exception) Thrown if theXAxis is null or theYAxis is null.java.lang.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, java.awt.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:
java.lang.NullPointerException- (unchecked exception) Thrown if theXAxis is null, theYAxis is null, or theBackgroundPaint is null.java.lang.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:
java.lang.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:
java.lang.NullPointerException- (unchecked exception) Thrown if theLabel is null.
-
draw
public void draw(java.awt.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.
-
getBoundingBox
public java.awt.geom.Rectangle2D getBoundingBox()
Returns this displayable object's bounding box. This is the smallest rectangle that encloses all of this displayable object.- Specified by:
getBoundingBoxin interfaceDisplayable
-
getBackgroundPaint
public java.awt.Paint getBackgroundPaint()
Returns this displayable object's background paint.- Specified by:
getBackgroundPaintin interfaceDisplayable
-
-
DMelt 3.0 © DataMelt by jWork.ORG