org.jfree.chart.plot

Class ContourPlot

public class ContourPlot extends Plot implements ContourValuePlot, ValueAxisPlot, PropertyChangeListener, Serializable, Cloneable

Deprecated: This plot is no longer supported, please use XYPlot with an XYBlockRenderer.

A class for creating shaded contours.
Field Summary
protected static RectangleInsetsDEFAULT_INSETS
The default insets.
protected static ResourceBundlelocalizationResources
The resourceBundle for the localization.
Constructor Summary
ContourPlot()
Creates a new plot with no dataset or axes.
ContourPlot(ContourDataset dataset, ValueAxis domainAxis, ValueAxis rangeAxis, ColorBar colorBar)
Constructs a contour plot with the specified axes (other attributes take default values).
Method Summary
voidaddAnnotation(XYAnnotation annotation)
Adds an annotation to the plot.
voidaddDomainMarker(Marker marker)
Adds a marker for the domain axis.
voidaddRangeMarker(Marker marker)
Adds a marker for the range axis.
voidaxisChanged(AxisChangeEvent event)
Receives notification of a change to one of the plot's axes.
voidclearAnnotations()
Clears all the annotations.
voidclearDomainMarkers()
Clears all the domain markers.
voidclearRangeMarkers()
Clears all the range markers.
Objectclone()
Extends plot cloning to this plot type
voidcontourRenderer(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, ContourPlot plot, ValueAxis horizontalAxis, ValueAxis verticalAxis, ColorBar colorBar, ContourDataset data, CrosshairState crosshairState)
Fills the plot.
voiddatasetChanged(DatasetChangeEvent event)
Receives notification of a change to the plot's dataset.
voiddraw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).
voiddrawDomainMarker(Graphics2D g2, ContourPlot plot, ValueAxis domainAxis, Marker marker, Rectangle2D dataArea)
Draws a vertical line on the chart to represent a 'range marker'.
protected voiddrawHorizontalLine(Graphics2D g2, Rectangle2D dataArea, double value, Stroke stroke, Paint paint)
Utility method for drawing a crosshair on the chart (if required).
voiddrawRangeMarker(Graphics2D g2, ContourPlot plot, ValueAxis rangeAxis, Marker marker, Rectangle2D dataArea)
Draws a horizontal line across the chart to represent a 'range marker'.
protected voiddrawVerticalLine(Graphics2D g2, Rectangle2D dataArea, double value, Stroke stroke, Paint paint)
Utility method for drawing a crosshair on the chart (if required).
ClipPathgetClipPath()
Returns the clipPath.
ColorBargetColorBar()
Returns the colorbar.
RectangleEdgegetColorBarLocation()
Returns the color bar location.
RangegetContourDataRange()
Returns the range for the Contours.
doublegetDataAreaRatio()
Returns the data area ratio.
RangegetDataRange(ValueAxis axis)
Returns the range for an axis.
ContourDatasetgetDataset()
Returns the primary dataset for the plot.
ValueAxisgetDomainAxis()
Returns the domain axis for the plot.
PaintgetDomainCrosshairPaint()
Returns the domain crosshair color.
StrokegetDomainCrosshairStroke()
Returns the Stroke used to draw the crosshair (if visible).
doublegetDomainCrosshairValue()
Returns the domain crosshair value.
PaintgetMissingPaint()
Returns the missingPaint.
StringgetPlotType()
Returns the plot type as a string.
doublegetPtSizePct()
Returns the ptSizePct.
ValueAxisgetRangeAxis()
Returns the range axis for the plot.
PaintgetRangeCrosshairPaint()
Returns the range crosshair color.
StrokegetRangeCrosshairStroke()
Returns the Stroke used to draw the crosshair (if visible).
doublegetRangeCrosshairValue()
Returns the range crosshair value.
ContourToolTipGeneratorgetToolTipGenerator()
Returns the tool tip generator.
XYURLGeneratorgetURLGenerator()
Returns the URL generator for HTML image maps.
voidhandleClick(int x, int y, PlotRenderingInfo info)
Handles a 'click' on the plot by updating the anchor values...
booleanisCompatibleDomainAxis(ValueAxis axis)
Checks the compatibility of a domain axis, returning true if the axis is compatible with the plot, and false otherwise.
booleanisDomainCrosshairLockedOnData()
Returns a flag indicating whether or not the crosshair should "lock-on" to actual data values.
booleanisDomainCrosshairVisible()
Returns a flag indicating whether or not the domain crosshair is visible.
booleanisDomainZoomable()
Returns false.
booleanisRangeCrosshairLockedOnData()
Returns a flag indicating whether or not the crosshair should "lock-on" to actual data values.
booleanisRangeCrosshairVisible()
Returns a flag indicating whether or not the range crosshair is visible.
booleanisRangeZoomable()
Returns false.
booleanisRenderAsPoints()
Returns the renderAsPoints.
voidpointRenderer(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, ContourPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, ColorBar colorBar, ContourDataset data, CrosshairState crosshairState)
Draws the visual representation of a single data item.
voidpropertyChange(PropertyChangeEvent event)
Notifies all registered listeners of a property change.
voidrender(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, CrosshairState crosshairState)
Draws a representation of the data within the dataArea region, using the current renderer.
voidsetClipPath(ClipPath clipPath)
Sets the clipPath.
voidsetColorBarAxis(ColorBar axis)
Sets the colorbar for the plot.
voidsetColorBarLocation(RectangleEdge edge)
Sets the color bar location and sends a PlotChangeEvent to all registered listeners.
voidsetDataAreaRatio(double ratio)
Sets the data area ratio.
voidsetDataset(ContourDataset dataset)
Sets the dataset for the plot, replacing the existing dataset if there is one.
voidsetDomainAxis(ValueAxis axis)
Sets the domain axis for the plot (this must be compatible with the plot type or an exception is thrown).
voidsetDomainCrosshairLockedOnData(boolean flag)
Sets the flag indicating whether or not the domain crosshair should "lock-on" to actual data values.
voidsetDomainCrosshairPaint(Paint paint)
Sets the Paint used to color the crosshairs (if visible) and notifies registered listeners that the axis has been modified.
voidsetDomainCrosshairStroke(Stroke stroke)
Sets the Stroke used to draw the crosshairs (if visible) and notifies registered listeners that the axis has been modified.
voidsetDomainCrosshairValue(double value)
Sets the domain crosshair value.
voidsetDomainCrosshairValue(double value, boolean notify)
Sets the domain crosshair value.
voidsetDomainCrosshairVisible(boolean flag)
Sets the flag indicating whether or not the domain crosshair is visible.
voidsetMissingPaint(Paint paint)
Sets the missingPaint.
voidsetPtSizePct(double ptSizePct)
Sets the ptSizePct.
voidsetRangeAxis(ValueAxis axis)
Sets the range axis for the plot.
voidsetRangeCrosshairLockedOnData(boolean flag)
Sets the flag indicating whether or not the range crosshair should "lock-on" to actual data values.
voidsetRangeCrosshairPaint(Paint paint)
Sets the Paint used to color the crosshairs (if visible) and notifies registered listeners that the axis has been modified.
voidsetRangeCrosshairStroke(Stroke stroke)
Sets the Stroke used to draw the crosshairs (if visible) and notifies registered listeners that the axis has been modified.
voidsetRangeCrosshairValue(double value)
Sets the domain crosshair value.
voidsetRangeCrosshairValue(double value, boolean notify)
Sets the range crosshair value.
voidsetRangeCrosshairVisible(boolean flag)
Sets the flag indicating whether or not the range crosshair is visible.
voidsetRenderAsPoints(boolean renderAsPoints)
Sets the renderAsPoints.
voidsetToolTipGenerator(ContourToolTipGenerator generator)
Sets the tool tip generator.
voidsetURLGenerator(XYURLGenerator urlGenerator)
Sets the URL generator for HTML image maps.
RangevisibleRange(ContourDataset data, Range x, Range y)
Returns the visible z-range.
voidzoom(double percent)
Zooms the axis ranges by the specified percentage about the anchor point.
voidzoomDomainAxes(double x, double y, double factor)
Multiplies the range on the domain axis/axes by the specified factor (to be implemented).
voidzoomDomainAxes(double x, double y, double lowerPercent, double upperPercent)
Zooms the domain axes (not yet implemented).
voidzoomRangeAxes(double x, double y, double factor)
Multiplies the range on the range axis/axes by the specified factor.
voidzoomRangeAxes(double x, double y, double lowerPercent, double upperPercent)
Zooms the range axes (not yet implemented).

Field Detail

DEFAULT_INSETS

protected static final RectangleInsets DEFAULT_INSETS
The default insets.

localizationResources

protected static ResourceBundle localizationResources
The resourceBundle for the localization.

Constructor Detail

ContourPlot

public ContourPlot()
Creates a new plot with no dataset or axes.

ContourPlot

public ContourPlot(ContourDataset dataset, ValueAxis domainAxis, ValueAxis rangeAxis, ColorBar colorBar)
Constructs a contour plot with the specified axes (other attributes take default values).

Parameters: dataset The dataset. domainAxis The domain axis. rangeAxis The range axis. colorBar The z-axis axis.

Method Detail

addAnnotation

public void addAnnotation(XYAnnotation annotation)
Adds an annotation to the plot.

Parameters: annotation the annotation.

addDomainMarker

public void addDomainMarker(Marker marker)
Adds a marker for the domain axis.

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.

Parameters: marker the marker.

addRangeMarker

public void addRangeMarker(Marker marker)
Adds a marker for the range axis.

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.

Parameters: marker The marker.

axisChanged

public void axisChanged(AxisChangeEvent event)
Receives notification of a change to one of the plot's axes.

Parameters: event information about the event.

clearAnnotations

public void clearAnnotations()
Clears all the annotations.

clearDomainMarkers

public void clearDomainMarkers()
Clears all the domain markers.

clearRangeMarkers

public void clearRangeMarkers()
Clears all the range markers.

clone

public Object clone()
Extends plot cloning to this plot type

See Also: clone

contourRenderer

public void contourRenderer(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, ContourPlot plot, ValueAxis horizontalAxis, ValueAxis verticalAxis, ColorBar colorBar, ContourDataset data, CrosshairState crosshairState)
Fills the plot.

Parameters: g2 the graphics device. dataArea the area within which the data is being drawn. info collects information about the drawing. plot the plot (can be used to obtain standard color information etc). horizontalAxis the domain (horizontal) axis. verticalAxis the range (vertical) axis. colorBar the color bar axis. data the dataset. crosshairState information about crosshairs on a plot.

datasetChanged

public void datasetChanged(DatasetChangeEvent event)
Receives notification of a change to the plot's dataset.

The chart reacts by passing on a chart change event to all registered listeners.

Parameters: event Information about the event (not used here).

draw

public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).

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.

Parameters: g2 the graphics device. area the area within which the plot (including axis labels) should be drawn. anchor the anchor point (null permitted). parentState the state from the parent plot, if there is one. info collects chart drawing information (null permitted).

drawDomainMarker

public void drawDomainMarker(Graphics2D g2, ContourPlot plot, ValueAxis domainAxis, Marker marker, Rectangle2D dataArea)
Draws a vertical line on the chart to represent a 'range marker'.

Parameters: g2 the graphics device. plot the plot. domainAxis the domain axis. marker the marker line. dataArea the axis data area.

drawHorizontalLine

protected void drawHorizontalLine(Graphics2D g2, Rectangle2D dataArea, double value, Stroke stroke, Paint paint)
Utility method for drawing a crosshair on the chart (if required).

Parameters: 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.

drawRangeMarker

public void drawRangeMarker(Graphics2D g2, ContourPlot plot, ValueAxis rangeAxis, Marker marker, Rectangle2D dataArea)
Draws a horizontal line across the chart to represent a 'range marker'.

Parameters: g2 the graphics device. plot the plot. rangeAxis the range axis. marker the marker line. dataArea the axis data area.

drawVerticalLine

protected void drawVerticalLine(Graphics2D g2, Rectangle2D dataArea, double value, Stroke stroke, Paint paint)
Utility method for drawing a crosshair on the chart (if required).

Parameters: 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.

getClipPath

public ClipPath getClipPath()
Returns the clipPath.

Returns: ClipPath

getColorBar

public ColorBar getColorBar()
Returns the colorbar.

Returns: The colorbar.

getColorBarLocation

public RectangleEdge getColorBarLocation()
Returns the color bar location.

Returns: The color bar location.

getContourDataRange

public Range getContourDataRange()
Returns the range for the Contours.

Returns: The range for the Contours (z-axis).

getDataAreaRatio

public double getDataAreaRatio()
Returns the data area ratio.

Returns: The ratio.

getDataRange

public Range getDataRange(ValueAxis axis)
Returns the range for an axis.

Parameters: axis the axis.

Returns: The range for an axis.

getDataset

public ContourDataset getDataset()
Returns the primary dataset for the plot.

Returns: The primary dataset (possibly null).

getDomainAxis

public ValueAxis getDomainAxis()
Returns the domain axis for the plot.

Returns: The domain axis.

getDomainCrosshairPaint

public Paint getDomainCrosshairPaint()
Returns the domain crosshair color.

Returns: The crosshair color.

getDomainCrosshairStroke

public Stroke getDomainCrosshairStroke()
Returns the Stroke used to draw the crosshair (if visible).

Returns: The crosshair stroke.

getDomainCrosshairValue

public double getDomainCrosshairValue()
Returns the domain crosshair value.

Returns: The value.

getMissingPaint

public Paint getMissingPaint()
Returns the missingPaint.

Returns: Paint

getPlotType

public String getPlotType()
Returns the plot type as a string.

Returns: A short string describing the type of plot.

getPtSizePct

public double getPtSizePct()
Returns the ptSizePct.

Returns: double

getRangeAxis

public ValueAxis getRangeAxis()
Returns the range axis for the plot.

Returns: The range axis.

getRangeCrosshairPaint

public Paint getRangeCrosshairPaint()
Returns the range crosshair color.

Returns: The crosshair color.

getRangeCrosshairStroke

public Stroke getRangeCrosshairStroke()
Returns the Stroke used to draw the crosshair (if visible).

Returns: The crosshair stroke.

getRangeCrosshairValue

public double getRangeCrosshairValue()
Returns the range crosshair value.

Returns: The value.

getToolTipGenerator

public ContourToolTipGenerator getToolTipGenerator()
Returns the tool tip generator.

Returns: The tool tip generator (possibly null).

getURLGenerator

public XYURLGenerator getURLGenerator()
Returns the URL generator for HTML image maps.

Returns: The URL generator (possibly null).

handleClick

public void handleClick(int x, int y, PlotRenderingInfo info)
Handles a 'click' on the plot by updating the anchor values...

Parameters: x x-coordinate, where the click occured. y y-coordinate, where the click occured. info An object for collection dimension information.

isCompatibleDomainAxis

public boolean isCompatibleDomainAxis(ValueAxis axis)
Checks the compatibility of a domain axis, returning true if the axis is compatible with the plot, and false otherwise.

Parameters: axis The proposed axis.

Returns: true if the axis is compatible with the plot.

isDomainCrosshairLockedOnData

public boolean isDomainCrosshairLockedOnData()
Returns a flag indicating whether or not the crosshair should "lock-on" to actual data values.

Returns: The flag.

isDomainCrosshairVisible

public boolean isDomainCrosshairVisible()
Returns a flag indicating whether or not the domain crosshair is visible.

Returns: The flag.

isDomainZoomable

public boolean isDomainZoomable()
Returns false.

Returns: A boolean.

isRangeCrosshairLockedOnData

public boolean isRangeCrosshairLockedOnData()
Returns a flag indicating whether or not the crosshair should "lock-on" to actual data values.

Returns: The flag.

isRangeCrosshairVisible

public boolean isRangeCrosshairVisible()
Returns a flag indicating whether or not the range crosshair is visible.

Returns: The flag.

isRangeZoomable

public boolean isRangeZoomable()
Returns false.

Returns: A boolean.

isRenderAsPoints

public boolean isRenderAsPoints()
Returns the renderAsPoints.

Returns: boolean

pointRenderer

public void pointRenderer(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, ContourPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, ColorBar colorBar, ContourDataset data, CrosshairState crosshairState)
Draws the visual representation of a single data item.

Parameters: g2 the graphics device. dataArea the area within which the data is being drawn. info collects information about the drawing. plot the plot (can be used to obtain standard color information etc). domainAxis the domain (horizontal) axis. rangeAxis the range (vertical) axis. colorBar the color bar axis. data the dataset. crosshairState information about crosshairs on a plot.

propertyChange

public void propertyChange(PropertyChangeEvent event)
Notifies all registered listeners of a property change.

One source of property change events is the plot's renderer.

Parameters: event Information about the property change.

render

public void render(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, CrosshairState crosshairState)
Draws a representation of the data within the dataArea region, using the current renderer.

The info and crosshairState arguments may be null.

Parameters: g2 the graphics device. dataArea the region in which the data is to be drawn. info an optional object for collection dimension information. crosshairState an optional object for collecting crosshair info.

setClipPath

public void setClipPath(ClipPath clipPath)
Sets the clipPath.

Parameters: clipPath The clipPath to set

setColorBarAxis

public void setColorBarAxis(ColorBar axis)
Sets the colorbar for the plot.

Parameters: axis The new axis (null permitted).

setColorBarLocation

public void setColorBarLocation(RectangleEdge edge)
Sets the color bar location and sends a PlotChangeEvent to all registered listeners.

Parameters: edge the location.

setDataAreaRatio

public void setDataAreaRatio(double ratio)
Sets the data area ratio.

Parameters: ratio the ratio.

setDataset

public void setDataset(ContourDataset dataset)
Sets the dataset for the plot, replacing the existing dataset if there is one.

Parameters: dataset the dataset (null permitted).

setDomainAxis

public void setDomainAxis(ValueAxis axis)
Sets the domain axis for the plot (this must be compatible with the plot type or an exception is thrown).

Parameters: axis The new axis.

setDomainCrosshairLockedOnData

public void setDomainCrosshairLockedOnData(boolean flag)
Sets the flag indicating whether or not the domain crosshair should "lock-on" to actual data values.

Parameters: flag the flag.

setDomainCrosshairPaint

public void setDomainCrosshairPaint(Paint paint)
Sets the Paint used to color the crosshairs (if visible) and notifies registered listeners that the axis has been modified.

Parameters: paint the new crosshair paint.

setDomainCrosshairStroke

public void setDomainCrosshairStroke(Stroke stroke)
Sets the Stroke used to draw the crosshairs (if visible) and notifies registered listeners that the axis has been modified.

Parameters: stroke the new crosshair stroke.

setDomainCrosshairValue

public void setDomainCrosshairValue(double value)
Sets the domain crosshair value.

Registered listeners are notified that the plot has been modified, but only if the crosshair is visible.

Parameters: value the new value.

setDomainCrosshairValue

public void setDomainCrosshairValue(double value, boolean notify)
Sets the domain crosshair value.

Registered listeners are notified that the axis has been modified, but only if the crosshair is visible.

Parameters: value the new value. notify a flag that controls whether or not listeners are notified.

setDomainCrosshairVisible

public void setDomainCrosshairVisible(boolean flag)
Sets the flag indicating whether or not the domain crosshair is visible.

Parameters: flag the new value of the flag.

setMissingPaint

public void setMissingPaint(Paint paint)
Sets the missingPaint.

Parameters: paint the missingPaint to set.

setPtSizePct

public void setPtSizePct(double ptSizePct)
Sets the ptSizePct.

Parameters: ptSizePct The ptSizePct to set

setRangeAxis

public void setRangeAxis(ValueAxis axis)
Sets the range axis for the plot.

An exception is thrown if the new axis and the plot are not mutually compatible.

Parameters: axis The new axis (null permitted).

setRangeCrosshairLockedOnData

public void setRangeCrosshairLockedOnData(boolean flag)
Sets the flag indicating whether or not the range crosshair should "lock-on" to actual data values.

Parameters: flag the flag.

setRangeCrosshairPaint

public void setRangeCrosshairPaint(Paint paint)
Sets the Paint used to color the crosshairs (if visible) and notifies registered listeners that the axis has been modified.

Parameters: paint the new crosshair paint.

setRangeCrosshairStroke

public void setRangeCrosshairStroke(Stroke stroke)
Sets the Stroke used to draw the crosshairs (if visible) and notifies registered listeners that the axis has been modified.

Parameters: stroke the new crosshair stroke.

setRangeCrosshairValue

public void setRangeCrosshairValue(double value)
Sets the domain crosshair value.

Registered listeners are notified that the plot has been modified, but only if the crosshair is visible.

Parameters: value the new value.

setRangeCrosshairValue

public void setRangeCrosshairValue(double value, boolean notify)
Sets the range crosshair value.

Registered listeners are notified that the axis has been modified, but only if the crosshair is visible.

Parameters: value the new value. notify a flag that controls whether or not listeners are notified.

setRangeCrosshairVisible

public void setRangeCrosshairVisible(boolean flag)
Sets the flag indicating whether or not the range crosshair is visible.

Parameters: flag the new value of the flag.

setRenderAsPoints

public void setRenderAsPoints(boolean renderAsPoints)
Sets the renderAsPoints.

Parameters: renderAsPoints The renderAsPoints to set

setToolTipGenerator

public void setToolTipGenerator(ContourToolTipGenerator generator)
Sets the tool tip generator.

Parameters: generator the tool tip generator (null permitted).

setURLGenerator

public void setURLGenerator(XYURLGenerator urlGenerator)
Sets the URL generator for HTML image maps.

Parameters: urlGenerator the URL generator (null permitted).

visibleRange

public Range visibleRange(ContourDataset data, Range x, Range y)
Returns the visible z-range.

Parameters: data the dataset. x the x range. y the y range.

Returns: The range.

zoom

public void zoom(double percent)
Zooms the axis ranges by the specified percentage about the anchor point.

Parameters: percent The amount of the zoom.

zoomDomainAxes

public void zoomDomainAxes(double x, double y, double factor)
Multiplies the range on the domain axis/axes by the specified factor (to be implemented).

Parameters: x the x-coordinate (in Java2D space). y the y-coordinate (in Java2D space). factor the zoom factor.

zoomDomainAxes

public void zoomDomainAxes(double x, double y, double lowerPercent, double upperPercent)
Zooms the domain axes (not yet implemented).

Parameters: x the x-coordinate (in Java2D space). y the y-coordinate (in Java2D space). lowerPercent the new lower bound. upperPercent the new upper bound.

zoomRangeAxes

public void zoomRangeAxes(double x, double y, double factor)
Multiplies the range on the range axis/axes by the specified factor.

Parameters: x the x-coordinate (in Java2D space). y the y-coordinate (in Java2D space). factor the zoom factor.

zoomRangeAxes

public void zoomRangeAxes(double x, double y, double lowerPercent, double upperPercent)
Zooms the range axes (not yet implemented).

Parameters: x the x-coordinate (in Java2D space). y the y-coordinate (in Java2D space). lowerPercent the new lower bound. upperPercent the new upper bound.