|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jfree.chart.plot.Plot | +--org.jfree.chart.plot.XYPlot
A general class for plotting data in the form of (x, y) pairs. This plot can
use data from any class that implements the XYDataset
interface.
XYPlot
makes use of an XYItemRenderer
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.
Field Summary | |
static java.awt.Paint |
DEFAULT_CROSSHAIR_PAINT
The default crosshair paint. |
static java.awt.Stroke |
DEFAULT_CROSSHAIR_STROKE
The default crosshair stroke. |
static boolean |
DEFAULT_CROSSHAIR_VISIBLE
The default crosshair visibility. |
static java.awt.Paint |
DEFAULT_GRIDLINE_PAINT
The default grid line paint. |
static java.awt.Stroke |
DEFAULT_GRIDLINE_STROKE
The default grid line stroke. |
Fields inherited from class org.jfree.chart.plot.Plot |
DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_FOREGROUND_ALPHA, DEFAULT_INSETS, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, MINIMUM_HEIGHT_TO_DRAW, MINIMUM_WIDTH_TO_DRAW, ZERO |
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,
XYItemRenderer renderer)
Constructs an XYPlot with the specified axes and renderer (other attributes take default values). |
Method Summary | |
void |
addAnnotation(XYAnnotation annotation)
Adds an annotation to the plot. |
void |
addDomainMarker(Marker marker)
Adds a marker for the domain axis. |
void |
addRangeMarker(Marker marker)
Adds a marker for the range axis. |
void |
addSecondaryRangeMarker(Marker marker)
Adds a secondary marker for the range axis. |
void |
clearAnnotations()
Clears all the annotations. |
void |
clearDomainMarkers()
Clears all the domain markers. |
void |
clearRangeMarkers()
Clears all the range markers. |
void |
clearSecondaryRangeMarkers()
Clears all the secondary 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). |
boolean |
equals(java.lang.Object obj)
Tests this plot for equality with another object. |
ValueAxis |
getDomainAxis()
Returns the domain axis for the plot. |
int |
getDomainAxisLocation()
Returns the location of the domain axis. |
java.awt.Paint |
getDomainCrosshairPaint()
Returns the domain crosshair color. |
java.awt.Stroke |
getDomainCrosshairStroke()
Returns the Stroke used to draw the crosshair (if visible). |
double |
getDomainCrosshairValue()
Returns the domain crosshair value. |
java.awt.Paint |
getDomainGridlinePaint()
Returns the paint for the grid lines (if any) plotted against the domain axis. |
java.awt.Stroke |
getDomainGridlineStroke()
Returns the stroke for the grid-lines (if any) plotted against the domain axis. |
HorizontalAxis |
getHorizontalAxis()
Returns the horizontal axis. |
Range |
getHorizontalDataRange(ValueAxis axis)
Returns the range for the horizontal axis. |
ValueAxis |
getHorizontalValueAxis()
Returns the horizontal axis. |
LegendItemCollection |
getLegendItems()
Returns the legend items for the plot. |
java.lang.String |
getPlotType()
Returns the plot type as a string. |
ValueAxis |
getRangeAxis()
Returns the range axis for the plot. |
int |
getRangeAxisLocation()
Returns the location of the range axis. |
java.awt.Paint |
getRangeCrosshairPaint()
Returns the range crosshair color. |
java.awt.Stroke |
getRangeCrosshairStroke()
Returns the Stroke used to draw the crosshair (if visible). |
double |
getRangeCrosshairValue()
Returns the range crosshair value. |
java.awt.Paint |
getRangeGridlinePaint()
Returns the paint for the grid lines (if any) plotted against the range axis. |
java.awt.Stroke |
getRangeGridlineStroke()
Returns the stroke for the grid lines (if any) plotted against the range axis. |
XYItemRenderer |
getRenderer()
Returns the item renderer. |
ValueAxis |
getSecondaryRangeAxis()
Returns the secondary range axis. |
XYItemRenderer |
getSecondaryRenderer()
Returns the secondary item renderer. |
XYDataset |
getSecondaryXYDataset()
Returns the secondary dataset (possibly null), cast as an XYDataset. |
int |
getSeriesCount()
Returns the number of series in the dataset for this plot. |
VerticalAxis |
getVerticalAxis()
Returns the vertical axis. |
Range |
getVerticalDataRange(ValueAxis axis)
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 |
isDomainCrosshairLockedOnData()
Returns a flag indicating whether or not the crosshair should "lock-on" to actual data values. |
boolean |
isDomainCrosshairVisible()
Returns a flag indicating whether or not the domain crosshair is visible. |
boolean |
isDomainGridlinesVisible()
Returns true if the domain gridlines are visible, and false |
boolean |
isRangeCrosshairLockedOnData()
Returns a flag indicating whether or not the crosshair should "lock-on" to actual data values. |
boolean |
isRangeCrosshairVisible()
Returns a flag indicating whether or not the range crosshair is visible. |
boolean |
isRangeGridlinesVisible()
Returns true if the range axis grid is visible, and false |
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 |
render2(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 |
setDomainAxisLocation(int location)
Sets the location of the domain axis. |
void |
setDomainAxisLocation(int location,
boolean notify)
Sets the location of the domain axis. |
void |
setDomainCrosshairLockedOnData(boolean flag)
Sets the flag indicating whether or not the domain crosshair should "lock-on" to actual data values. |
void |
setDomainCrosshairPaint(java.awt.Paint paint)
Sets the Paint used to color the crosshairs (if visible) and notifies registered listeners that the axis has been modified. |
void |
setDomainCrosshairStroke(java.awt.Stroke stroke)
Sets the Stroke used to draw the crosshairs (if visible) and notifies registered listeners that the axis has been modified. |
void |
setDomainCrosshairValue(double value)
Sets the domain crosshair value. |
void |
setDomainCrosshairValue(double value,
boolean notify)
Sets the domain crosshair value. |
void |
setDomainCrosshairVisible(boolean flag)
Sets the flag indicating whether or not the domain crosshair is visible. |
void |
setDomainGridlinePaint(java.awt.Paint paint)
Sets the paint for the grid lines plotted against the domain axis. |
void |
setDomainGridlineStroke(java.awt.Stroke stroke)
Sets the stroke for the grid lines plotted against the domain axis. |
void |
setDomainGridlinesVisible(boolean visible)
Sets the flag that controls whether or not the domain grid-lines are visible. |
void |
setRangeAxis(ValueAxis axis)
Sets the range axis for the plot. |
void |
setRangeAxisLocation(int location)
Sets the location of the range axis. |
void |
setRangeAxisLocation(int location,
boolean notify)
Sets the location of the range axis. |
void |
setRangeCrosshairLockedOnData(boolean flag)
Sets the flag indicating whether or not the range crosshair should "lock-on" to actual data values. |
void |
setRangeCrosshairPaint(java.awt.Paint paint)
Sets the Paint used to color the crosshairs (if visible) and notifies registered listeners that the axis has been modified. |
void |
setRangeCrosshairStroke(java.awt.Stroke stroke)
Sets the Stroke used to draw the crosshairs (if visible) and notifies registered listeners that the axis has been modified. |
void |
setRangeCrosshairValue(double value)
Sets the domain crosshair value. |
void |
setRangeCrosshairValue(double value,
boolean notify)
Sets the range crosshair value. |
void |
setRangeCrosshairVisible(boolean flag)
Sets the flag indicating whether or not the range crosshair is visible. |
void |
setRangeGridlinePaint(java.awt.Paint paint)
Sets the paint for the grid lines plotted against the range axis. |
void |
setRangeGridlineStroke(java.awt.Stroke stroke)
Sets the stroke for the grid lines plotted against the range axis. |
void |
setRangeGridlinesVisible(boolean visible)
Sets the flag that controls whether or not the range axis grid lines are visible. |
void |
setRenderer(XYItemRenderer renderer)
Sets the item renderer, and notifies all listeners of a change to the plot. |
void |
setSecondaryRangeAxis(ValueAxis axis)
Sets the secondary range axis for the plot. |
void |
setSecondaryRenderer(XYItemRenderer renderer)
Sets the secondary item renderer. |
void |
setWeight(int weight)
Sets the weight for the plot. |
void |
zoom(double percent)
Zooms the axis ranges by the specified percentage about the anchor point. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.awt.Stroke DEFAULT_GRIDLINE_STROKE
public static final java.awt.Paint DEFAULT_GRIDLINE_PAINT
public static final boolean DEFAULT_CROSSHAIR_VISIBLE
public static final java.awt.Stroke DEFAULT_CROSSHAIR_STROKE
public static final java.awt.Paint DEFAULT_CROSSHAIR_PAINT
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 rendererMethod Detail |
public int getSeriesCount()
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 XYItemRenderer getSecondaryRenderer()
public void setSecondaryRenderer(XYItemRenderer renderer)
You can set this renderer to null
, in which case the primary renderer
is used instead.
renderer
- the new renderer (null
permitted).public ValueAxis getSecondaryRangeAxis()
public void setSecondaryRangeAxis(ValueAxis axis)
axis
- the axis.public XYDataset getXYDataset()
public XYDataset getSecondaryXYDataset()
public ValueAxis getDomainAxis()
public void setDomainAxis(ValueAxis axis) throws AxisNotCompatibleException
axis
- the new axis.
AxisNotCompatibleException
- if the axis is not compatible.public int getDomainAxisLocation()
public void setDomainAxisLocation(int location)
Use one of the constants LEFT
, RIGHT
, TOP
or
BOTTOM
.
location
- the axis location.public void setDomainAxisLocation(int location, boolean notify)
Use one of the constants LEFT
, RIGHT
, TOP
or
BOTTOM
.
location
- the axis location.notify
- a flag that controls whether listeners are notified.public boolean isDomainGridlinesVisible()
true
if the domain gridlines are visible, and false
otherwise.
- Returns:
true
or false
.
public void setDomainGridlinesVisible(boolean visible)
If the flag value is changed, a PlotChangeEvent
is sent to all registered listeners.
visible
- the new value of the flag.public java.awt.Stroke getDomainGridlineStroke()
public void setDomainGridlineStroke(java.awt.Stroke stroke)
If you set this to null
, no grid lines will be drawn.
stroke
- the stroke (null
permitted).public java.awt.Paint getDomainGridlinePaint()
public void setDomainGridlinePaint(java.awt.Paint paint)
If you set this to null
, no grid lines will be drawn.
paint
- the paint (null
permitted).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 int getRangeAxisLocation()
public void setRangeAxisLocation(int location)
Use one of the constants LEFT, RIGHT, TOP or BOTTOM.
location
- the location.public void setRangeAxisLocation(int location, boolean notify)
Use one of the constants LEFT, RIGHT, TOP or BOTTOM.
location
- the location.notify
- a flag that controls whether listeners are notified.public boolean isRangeGridlinesVisible()
true
if the range axis grid is visible, and false
otherwise.
- Returns:
true
or false
.
public void setRangeGridlinesVisible(boolean visible)
If the flag value is changed, a PlotChangeEvent
is sent to all registered listeners.
visible
- the new value of the flag.public java.awt.Stroke getRangeGridlineStroke()
public void setRangeGridlineStroke(java.awt.Stroke stroke)
If you set this to null
, no grid lines will be drawn.
stroke
- the stroke (null
permitted).public java.awt.Paint getRangeGridlinePaint()
public void setRangeGridlinePaint(java.awt.Paint paint)
If you set this to null
, no grid lines will be drawn.
paint
- the paint (null
permitted).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 addSecondaryRangeMarker(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 clearSecondaryRangeMarkers()
public void addAnnotation(XYAnnotation 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.public void render2(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(ValueAxis axis)
getHorizontalDataRange
in interface HorizontalValuePlot
axis
- the axis.
public Range getVerticalDataRange(ValueAxis axis)
getVerticalDataRange
in interface VerticalValuePlot
axis
- the axis.
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 axis ranges are updated if necessary.
datasetChanged
in interface DatasetChangeListener
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 boolean isDomainCrosshairVisible()
public void setDomainCrosshairVisible(boolean flag)
flag
- the new value of the flag.public boolean isDomainCrosshairLockedOnData()
public void setDomainCrosshairLockedOnData(boolean flag)
flag
- the flag.public double getDomainCrosshairValue()
public void setDomainCrosshairValue(double value)
Registered listeners are notified that the plot has been modified, but only if the crosshair is visible.
value
- the new value.public void setDomainCrosshairValue(double value, boolean notify)
Registered listeners are notified that the axis has been modified, but only if the crosshair is visible.
value
- the new value.notify
- a flag that controls whether or not listeners are notified.public java.awt.Stroke getDomainCrosshairStroke()
public void setDomainCrosshairStroke(java.awt.Stroke stroke)
stroke
- the new crosshair stroke.public java.awt.Paint getDomainCrosshairPaint()
public void setDomainCrosshairPaint(java.awt.Paint paint)
paint
- the new crosshair paint.public boolean isRangeCrosshairVisible()
public void setRangeCrosshairVisible(boolean flag)
flag
- the new value of the flag.public boolean isRangeCrosshairLockedOnData()
public void setRangeCrosshairLockedOnData(boolean flag)
flag
- the flag.public double getRangeCrosshairValue()
public void setRangeCrosshairValue(double value)
Registered listeners are notified that the plot has been modified, but only if the crosshair is visible.
value
- the new value.public void setRangeCrosshairValue(double value, boolean notify)
Registered listeners are notified that the axis has been modified, but only if the crosshair is visible.
value
- the new value.notify
- a flag that controls whether or not listeners are notified.public java.awt.Stroke getRangeCrosshairStroke()
public void setRangeCrosshairStroke(java.awt.Stroke stroke)
stroke
- the new crosshair stroke.public java.awt.Paint getRangeCrosshairPaint()
public void setRangeCrosshairPaint(java.awt.Paint paint)
paint
- the new crosshair paint.public boolean equals(java.lang.Object obj)
equals
in class Plot
obj
- the object.
true
or false
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |