|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.jrefinery.chart.Plot | +--com.jrefinery.chart.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
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_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 |
addAnnotation(Annotation annotation)
Adds an annotation to the plot. |
void |
addDomainMarker(Marker marker)
Adds a marker for the domain axis. |
void |
addHorizontalLine(java.lang.Number value)
Deprecated. Use addRangeMarker(...). |
void |
addHorizontalLine(java.lang.Number location,
java.awt.Paint color)
Deprecated. Use addRangeMarker(...). |
void |
addRangeMarker(Marker marker)
Adds a marker for the range axis. |
void |
addVerticalLine(java.lang.Number location)
Deprecated. Use addDomainMarker(...). |
void |
addVerticalLine(java.lang.Number location,
java.awt.Paint color)
Deprecated. Use addDomainMarker(...). |
void |
clearAnnotations()
Clears all the annotations. |
void |
clearDomainMarkers()
Clears all the domain markers. |
void |
clearRangeMarkers()
Clears all the range markers. |
void |
datasetChanged(DatasetChangeEvent event)
Receives notification of a change to the plot's dataset. |
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). |
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 |
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). |
ValueAxis |
getDomainAxis()
Returns the domain axis for the plot. |
HorizontalAxis |
getHorizontalAxis()
Returns the horizontal axis. |
Range |
getHorizontalDataRange()
Returns the range for the horizontal axis. |
ValueAxis |
getHorizontalValueAxis()
Returns the horizontal axis. |
XYItemRenderer |
getItemRenderer()
Deprecated. Use getRenderer(). |
java.util.List |
getLegendItemLabels()
Returns an array of labels to be displayed by the legend. |
LegendItemCollection |
getLegendItems()
Returns the legend items for the plot. |
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. |
XYItemRenderer |
getRenderer()
Returns the item renderer. |
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 vertical axis. |
ValueAxis |
getVerticalValueAxis()
Returns the vertical axis. |
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... |
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. |
void |
propertyChange(java.beans.PropertyChangeEvent event)
Notifies all registered listeners of a property change. |
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 |
setRenderer(XYItemRenderer renderer)
Sets the item renderer, and notifies all listeners of a change to the plot. |
void |
setWeight(int weight)
Sets the weight for the plot. |
void |
setXYItemRenderer(XYItemRenderer renderer)
Deprecated. Use setRenderer(...). |
void |
zoom(double percent)
Zooms the axis ranges by the specified percentage about the anchor point. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XYPlot(XYDataset data, ValueAxis domainAxis, ValueAxis rangeAxis)
data
- The dataset.domainAxis
- The domain axis.rangeAxis
- The range axis.public XYPlot(XYDataset data, ValueAxis domainAxis, ValueAxis rangeAxis, XYItemRenderer renderer)
data
- the dataset.domainAxis
- the domain axis.rangeAxis
- the range axis.renderer
- the rendererpublic 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)
data
- the dataset.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 Plot getParent()
public void setParent(XYPlot parent)
parent
- The parent plot.public boolean isSubplot()
isSubplot
in class Plot
true
if this plot is part of a combined plot structure.public int getSeriesCount()
public java.util.List getLegendItemLabels()
getLegendItemLabels
in class Plot
public LegendItemCollection getLegendItems()
getLegendItems
in class Plot
public int getWeight()
public void setWeight(int weight)
weight
- The weight.public XYItemRenderer getRenderer()
public void setRenderer(XYItemRenderer renderer)
If the renderer is set to null, no chart will be drawn.
renderer
- The new renderer (null permitted).public XYDataset getXYDataset()
public ValueAxis getDomainAxis()
public void setDomainAxis(ValueAxis axis) throws AxisNotCompatibleException
axis
- The new axis.AxisNotCompatibleException
- if the axis is not compatible.public ValueAxis getRangeAxis()
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
- if the axis is not compatible.public void addDomainMarker(Marker marker)
Typically a marker will be drawn by the renderer as a line perpendicular to the range axis, however this is entirely up to the renderer.
marker
- the marker.public void clearDomainMarkers()
public void addRangeMarker(Marker marker)
Typically a marker will be drawn by the renderer as a line perpendicular to the range axis, however this is entirely up to the renderer.
marker
- The marker.public void clearRangeMarkers()
public void addAnnotation(Annotation annotation)
annotation
- the annotation.public void clearAnnotations()
public boolean isCompatibleDomainAxis(ValueAxis axis)
axis
- The proposed axis.true
if the axis is compatible with the plot.public boolean isCompatibleRangeAxis(ValueAxis axis)
axis
- The proposed axis.true
if the axis is compatible with the plot.public 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 Plot
g2
- 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)
The info
and crosshairInfo
arguments may be null
.
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)
g2
- The graphics device.dataArea
- The data area.value
- The coordinate, where to draw the line.stroke
- The stroke to use.paint
- The paint to use.protected void drawHorizontalLine(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, double value, java.awt.Stroke stroke, java.awt.Paint paint)
g2
- The graphics device.dataArea
- The data area.value
- The coordinate, where to draw the line.stroke
- The stroke to use.paint
- The paint to use.public void handleClick(int x, int y, ChartRenderingInfo info)
handleClick
in class Plot
x
- x-coordinate, where the click occured.y
- y-coordinate, where the click occured.info
- An object for collection dimension information.public void zoom(double percent)
zoom
in class Plot
percent
- The amount of the zoom.public java.lang.String getPlotType()
getPlotType
in class Plot
public Range getHorizontalDataRange()
getHorizontalDataRange
in interface HorizontalValuePlot
public Range getVerticalDataRange()
getVerticalDataRange
in interface VerticalValuePlot
public void propertyChange(java.beans.PropertyChangeEvent event)
One source of property change events is the plot's renderer.
propertyChange
in interface java.beans.PropertyChangeListener
event
- Information about the property change.public void datasetChanged(DatasetChangeEvent event)
The chart reacts by passing on a chart change event to all registered listeners.
datasetChanged
in class Plot
event
- Information about the event (not used here).public HorizontalAxis getHorizontalAxis()
public ValueAxis getHorizontalValueAxis()
This method is part of the HorizontalValuePlot interface.
getHorizontalValueAxis
in interface HorizontalValuePlot
public VerticalAxis getVerticalAxis()
public ValueAxis getVerticalValueAxis()
This method is part of the VerticalValuePlot interface.
getVerticalValueAxis
in interface VerticalValuePlot
public XYItemRenderer getItemRenderer()
public void setXYItemRenderer(XYItemRenderer renderer)
renderer
- the renderer.public void addHorizontalLine(java.lang.Number value)
value
- The data value.public void addHorizontalLine(java.lang.Number location, java.awt.Paint color)
location
- The location.color
- The line color.public void addVerticalLine(java.lang.Number location)
location
- The location.public void addVerticalLine(java.lang.Number location, java.awt.Paint color)
location
- The location.color
- The color to use.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |