|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.jrefinery.chart.Plot
com.jrefinery.chart.XYPlot
public class XYPlot
A general class for plotting data in the form of (x, y) pairs. XYPlot can use data from any class that implements the XYDataset interface (in the com.jrefinery.data package).
XYPlot makes use of a renderer to draw each point on the plot. By using different renderers, various chart types can be produced. The ChartFactory class contains static methods for creating pre-configured charts.
ChartFactory,
Plot,
XYDataset| Field Summary | |
|---|---|
protected ValueAxis |
domainAxis
The domain axis (used for the x-values). |
protected java.util.List |
horizontalColors
The colors for the horizontal lines. |
protected java.util.List |
horizontalLines
A list of horizontal lines that will be overlaid on the plot. |
protected XYPlot |
parent
The parent plot (used only when this plot is part of a combined plot). |
protected ValueAxis |
rangeAxis
The range axis (used for the y-values). |
protected XYItemRenderer |
renderer
Object responsible for drawing the visual representation of each point on the plot. |
protected java.util.List |
verticalColors
The colors for the vertical lines. |
protected java.util.List |
verticalLines
A list of (optional) vertical lines that will be overlaid on the plot. |
protected int |
weight
The weight for this plot in a combined plot. |
| Fields inherited from class com.jrefinery.chart.Plot |
|---|
backgroundAlpha, backgroundImage, backgroundPaint, dataset, DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_FOREGROUND_ALPHA, DEFAULT_INSETS, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, firstSeriesIndex, foregroundAlpha, insets, listeners, MINIMUM_HEIGHT_TO_DRAW, MINIMUM_WIDTH_TO_DRAW, outlinePaint, outlineStroke, seriesOutlinePaint, seriesOutlineStroke, seriesPaint, seriesStroke, shapeFactory, ZERO |
| Fields inherited from interface com.jrefinery.chart.AxisConstants |
|---|
DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, DEFAULT_TICK_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_STROKE |
| Constructor Summary | |
|---|---|
XYPlot(XYDataset data,
ValueAxis domainAxis,
ValueAxis rangeAxis)
Constructs an XYPlot with the specified axes (other attributes take default values). |
|
XYPlot(XYDataset data,
ValueAxis domainAxis,
ValueAxis rangeAxis,
java.awt.Insets insets,
java.awt.Paint backgroundPaint,
java.awt.Image backgroundImage,
float backgroundAlpha,
java.awt.Stroke outlineStroke,
java.awt.Paint outlinePaint,
float alpha,
XYItemRenderer renderer)
Constructs a new XY plot. |
|
XYPlot(XYDataset data,
ValueAxis domainAxis,
ValueAxis rangeAxis,
XYItemRenderer renderer)
Constructs an XYPlot with the specified axes and renderer (other attributes take default values). |
|
| Method Summary | |
|---|---|
void |
addHorizontalLine(java.lang.Number value)
Adds a horizontal line at the specified data value, using the default color red. |
void |
addHorizontalLine(java.lang.Number location,
java.awt.Paint color)
Adds a horizontal line at the specified data value, using the specified color. |
void |
addVerticalLine(java.lang.Number location)
Adds a vertical line at location with default color blue. |
void |
addVerticalLine(java.lang.Number location,
java.awt.Paint color)
Adds a vertical of the given color at location with the given color. |
void |
datasetChanged(DatasetChangeEvent event)
Receives notification of a change to the plot's dataset. |
void |
draw(boolean error,
java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D plotArea,
ChartRenderingInfo info)
|
protected void |
draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D plotArea,
ChartRenderingInfo info)
Draws the XY plot on a Java 2D graphics device (such as the screen or a printer). |
void |
draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D plotArea,
ChartRenderingInfo info,
Dataset dataset)
|
protected void |
drawHorizontalLine(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D dataArea,
double value,
java.awt.Stroke stroke,
java.awt.Paint paint)
Utility method for drawing a crosshair on the chart (if required). |
protected void |
drawHorizontalLines(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D dataArea)
Support method for the draw(...) method. |
protected void |
drawVerticalLine(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D dataArea,
double value,
java.awt.Stroke stroke,
java.awt.Paint paint)
Utility method for drawing a crosshair on the chart (if required). |
protected void |
drawVerticalLines(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D dataArea)
Support method for the draw(...) method. |
ValueAxis |
getDomainAxis()
Returns the domain axis for the plot. |
HorizontalAxis |
getHorizontalAxis()
Returns the horizontal axis. |
Range |
getHorizontalDataRange()
Returns the range of data values to be plotted along the horizontal axis. |
ValueAxis |
getHorizontalValueAxis()
|
XYItemRenderer |
getItemRenderer()
Returns the item renderer. |
java.util.List |
getLegendItemLabels()
Returns an array of labels to be displayed by the legend. |
Plot |
getParent()
Returns the parent plot (or null if this plot is not part of a combined plot). |
java.lang.String |
getPlotType()
Returns the plot type as a string. |
ValueAxis |
getRangeAxis()
Returns the range axis for the plot. |
int |
getSeriesCount()
Returns the number of series in the dataset for this plot. |
VerticalAxis |
getVerticalAxis()
Returns the vertical axis. |
Range |
getVerticalDataRange()
Returns the range for the data to be plotted against the vertical axis. |
ValueAxis |
getVerticalValueAxis()
|
int |
getWeight()
Returns the weight for this plot when it is used as a subplot within a combined plot. |
XYDataset |
getXYDataset()
A convenience method that returns the dataset for the plot, cast as an XYDataset. |
void |
handleClick(int x,
int y,
ChartRenderingInfo info)
Handles a 'click' on the plot by updating the anchor values... |
void |
handleClick(int x,
int y,
java.awt.geom.Rectangle2D plotArea)
|
boolean |
isCompatibleDomainAxis(ValueAxis axis)
Checks the compatibility of a domain axis, returning true if the axis is compatible with the plot, and false otherwise. |
boolean |
isCompatibleRangeAxis(ValueAxis axis)
Checks the compatibility of a range axis, returning true if the axis is compatible with the plot, and false otherwise. |
boolean |
isSubplot()
Returns true if this plot is part of a combined plot structure, and false otherwise. |
void |
propertyChange(java.beans.PropertyChangeEvent event)
|
void |
render(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D dataArea,
ChartRenderingInfo info,
CrosshairInfo crosshairInfo)
Draws a representation of the data within the dataArea region, using the current renderer. |
void |
setDomainAxis(ValueAxis axis)
Sets the domain axis for the plot (this must be compatible with the plot type or an exception is thrown). |
void |
setParent(XYPlot parent)
Sets the parent plot. |
void |
setRangeAxis(ValueAxis axis)
Sets the range axis for the plot. |
void |
setWeight(int weight)
Sets the weight for the plot. |
void |
setXYItemRenderer(XYItemRenderer renderer)
Sets the item renderer, and notifies all listeners of a change to the plot. |
void |
zoom(double percent)
Performs a zoom on the plot. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected XYPlot parent
protected int weight
protected ValueAxis domainAxis
protected ValueAxis rangeAxis
protected XYItemRenderer renderer
protected java.util.List verticalLines
protected java.util.List verticalColors
protected java.util.List horizontalLines
protected java.util.List horizontalColors
| Constructor Detail |
|---|
public XYPlot(XYDataset data,
ValueAxis domainAxis,
ValueAxis rangeAxis)
domainAxis - The domain axis.rangeAxis - The range axis.
public XYPlot(XYDataset data,
ValueAxis domainAxis,
ValueAxis rangeAxis,
XYItemRenderer renderer)
domainAxis - The domain axis.rangeAxis - The range axis.renderer - The renderer
public XYPlot(XYDataset data,
ValueAxis domainAxis,
ValueAxis rangeAxis,
java.awt.Insets insets,
java.awt.Paint backgroundPaint,
java.awt.Image backgroundImage,
float backgroundAlpha,
java.awt.Stroke outlineStroke,
java.awt.Paint outlinePaint,
float alpha,
XYItemRenderer renderer)
domainAxis - The domain axis.rangeAxis - The range axis.insets - Amount of blank space around the plot area.backgroundPaint - An optional color for the plot's background.backgroundImage - An optional image for the plot's background.backgroundAlpha - Alpha-transparency for the plot's background.outlineStroke - The Stroke used to draw an outline around the plot.outlinePaint - The color used to draw the plot outline.alpha - The alpha-transparency.renderer - The renderer.| Method Detail |
|---|
public boolean isSubplot()
isSubplot in class Plotpublic Plot getParent()
public void setParent(XYPlot parent)
parent - The parent plot.public int getSeriesCount()
public java.util.List getLegendItemLabels()
getLegendItemLabels in class Plotpublic int getWeight()
public void setWeight(int weight)
The - weight.public XYItemRenderer getItemRenderer()
public void setXYItemRenderer(XYItemRenderer renderer)
renderer - The new renderer.public XYDataset getXYDataset()
public void addVerticalLine(java.lang.Number location)
public void addVerticalLine(java.lang.Number location,
java.awt.Paint color)
public void addHorizontalLine(java.lang.Number value)
value - The data value.
public void addHorizontalLine(java.lang.Number location,
java.awt.Paint color)
value - The data value.color - The line color.public ValueAxis getDomainAxis()
public ValueAxis getRangeAxis()
public boolean isCompatibleDomainAxis(ValueAxis axis)
axis - The proposed axis.
public boolean isCompatibleRangeAxis(ValueAxis axis)
axis - The proposed axis.
public void draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D plotArea,
ChartRenderingInfo info,
Dataset dataset)
public void draw(boolean error,
java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D plotArea,
ChartRenderingInfo info)
protected void draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D plotArea,
ChartRenderingInfo info)
XYPlot relies on an XYItemRenderer to draw each item in the plot. This allows the visual representation of the data to be changed easily.
The optional info argument collects information about the rendering of the plot (dimensions, tooltip information etc). Just pass in null if you do not need this information.
draw in class Plotg2 - The graphics device.plotArea - The area within which the plot (including axis labels) should be drawn.info - Collects chart drawing information (null permitted).
public void render(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D dataArea,
ChartRenderingInfo info,
CrosshairInfo crosshairInfo)
g2 - The graphics device.dataArea - The region in which the data is to be drawn.info - An optional object for collection dimension information.crosshairInfo - An optional object for collecting crosshair info.
protected void drawVerticalLine(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D dataArea,
double value,
java.awt.Stroke stroke,
java.awt.Paint paint)
protected void drawHorizontalLine(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D dataArea,
double value,
java.awt.Stroke stroke,
java.awt.Paint paint)
protected void drawVerticalLines(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D dataArea)
protected void drawHorizontalLines(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D dataArea)
public void handleClick(int x,
int y,
ChartRenderingInfo info)
handleClick in class Plotx - The x coordinate.y - The y coordinate.
public void handleClick(int x,
int y,
java.awt.geom.Rectangle2D plotArea)
public void zoom(double percent)
Plot
zoom in class Plotpublic java.lang.String getPlotType()
getPlotType in class Plotpublic Range getHorizontalDataRange()
HorizontalValuePlot
getHorizontalDataRange in interface HorizontalValuePlotpublic Range getVerticalDataRange()
VerticalValuePlot
getVerticalDataRange in interface VerticalValuePlotpublic void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange in interface java.beans.PropertyChangeListenerpublic void datasetChanged(DatasetChangeEvent event)
The chart reacts by passing on a chart change event to all registered listeners.
datasetChanged in interface DatasetChangeListenerdatasetChanged in class Plotevent - Information about the event (not used here).public HorizontalAxis getHorizontalAxis()
public ValueAxis getHorizontalValueAxis()
getHorizontalValueAxis in interface HorizontalValuePlotpublic VerticalAxis getVerticalAxis()
public ValueAxis getVerticalValueAxis()
getVerticalValueAxis in interface VerticalValuePlot
public void setDomainAxis(ValueAxis axis)
throws AxisNotCompatibleException
axis - The new axis.
AxisNotCompatibleException
public void setRangeAxis(ValueAxis axis)
throws AxisNotCompatibleException
An exception is thrown if the new axis and the plot are not mutually compatible.
axis - The new axis (null permitted).
AxisNotCompatibleException
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||