org.jfree.chart.plot
Class CategoryPlot

java.lang.Object
  extended byorg.jfree.chart.plot.Plot
      extended byorg.jfree.chart.plot.CategoryPlot
All Implemented Interfaces:
AxisChangeListener, java.lang.Cloneable, DatasetChangeListener, java.util.EventListener, LegendItemSource, RendererChangeListener, java.io.Serializable, ValueAxisPlot, Zoomable
Direct Known Subclasses:
CombinedDomainCategoryPlot, CombinedRangeCategoryPlot

public class CategoryPlot
extends Plot
implements ValueAxisPlot, Zoomable, RendererChangeListener, java.lang.Cloneable, java.io.Serializable

A general plotting class that uses data from a CategoryDataset and renders each data item using a CategoryItemRenderer.

See Also:
Serialized Form

Field Summary
static boolean DEFAULT_DOMAIN_GRIDLINES_VISIBLE
          The default visibility of the grid lines plotted against the domain axis.
static java.awt.Paint DEFAULT_GRIDLINE_PAINT
          The default grid line paint.
static java.awt.Stroke DEFAULT_GRIDLINE_STROKE
          The default grid line stroke.
static boolean DEFAULT_RANGE_GRIDLINES_VISIBLE
          The default visibility of the grid lines plotted against the range axis.
static java.awt.Font DEFAULT_VALUE_LABEL_FONT
          The default value label font.
protected static java.util.ResourceBundle localizationResources
          The resourceBundle for the localization.
 
Fields inherited from class org.jfree.chart.plot.Plot
DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_FOREGROUND_ALPHA, DEFAULT_INSETS, DEFAULT_LEGEND_ITEM_BOX, DEFAULT_LEGEND_ITEM_CIRCLE, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, MINIMUM_HEIGHT_TO_DRAW, MINIMUM_WIDTH_TO_DRAW, ZERO
 
Constructor Summary
CategoryPlot()
          Default constructor.
CategoryPlot(CategoryDataset dataset, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryItemRenderer renderer)
          Creates a new plot.
 
Method Summary
 void addAnnotation(CategoryAnnotation annotation)
          Adds an annotation to the plot.
 void addRangeMarker(int index, Marker marker, Layer layer)
          Adds a marker for display by a particular renderer.
 void addRangeMarker(Marker marker)
          Adds a marker for display (in the foreground) against the range axis and sends a PlotChangeEvent to all registered listeners.
 void addRangeMarker(Marker marker, Layer layer)
          Adds a marker for display against the range axis and sends a PlotChangeEvent to all registered listeners.
protected  AxisSpace calculateAxisSpace(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea)
          Calculates the space required for the axes.
protected  AxisSpace calculateDomainAxisSpace(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, AxisSpace space)
          Calculates the space required for the domain axis/axes.
protected  AxisSpace calculateRangeAxisSpace(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, AxisSpace space)
          Calculates the space required for the range axis/axes.
 void clearDomainAxes()
          Clears the domain axes from the plot and sends a PlotChangeEvent to all registered listeners.
 void clearRangeAxes()
          Clears the range axes from the plot and sends a PlotChangeEvent to all registered listeners.
 void clearRangeMarkers()
          Clears all the range markers for the plot and sends a PlotChangeEvent to all registered listeners.
 void clearRangeMarkers(int index)
          Clears all the range markers for the specified renderer.
 java.lang.Object clone()
          Returns a clone of the plot.
 void configureDomainAxes()
          Configures the domain axes.
 void configureRangeAxes()
          Configures the range axes.
 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, PlotState parentState, PlotRenderingInfo state)
          Draws the plot on a Java 2D graphics device (such as the screen or a printer).
protected  void drawAnnotations(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea)
          Draws the annotations...
protected  java.util.Map drawAxes(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, PlotRenderingInfo plotState)
          A utility method for drawing the plot's axes.
protected  void drawDomainGridlines(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea)
          Draws the gridlines for the plot.
protected  void drawRangeGridlines(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, java.util.List ticks)
          Draws the gridlines for the plot.
protected  void drawRangeLine(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, double value, java.awt.Stroke stroke, java.awt.Paint paint)
          Utility method for drawing a line perpendicular to the range axis (used for crosshairs).
protected  void drawRangeMarkers(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, int index, Layer layer)
          Draws the range markers (if any) for an axis and layer.
protected  void drawRangeMarkers(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, Layer layer)
          Draws the range markers (if any) for the specified layer.
 boolean equals(java.lang.Object obj)
          Tests the plot for equality with an arbitrary object.
 double getAnchorValue()
          Returns the anchor value.
 java.util.List getAnnotations()
          Returns the list of annotations.
 RectangleInsets getAxisOffset()
          Returns the axis offset.
 java.util.List getCategories()
          Returns a list of the categories for the plot.
 SortOrder getColumnRenderingOrder()
          Returns the order in which the columns are rendered.
 Range getDataRange(ValueAxis axis)
          Returns the range of data values that will be plotted against the range axis.
 CategoryDataset getDataset()
          Returns the primary dataset for the plot.
 CategoryDataset getDataset(int index)
          Returns the dataset at the given index.
 DatasetRenderingOrder getDatasetRenderingOrder()
          Returns the dataset rendering order.
 CategoryAxis getDomainAxis()
          Returns the domain axis for the plot.
 CategoryAxis getDomainAxis(int index)
          Returns a domain axis.
 RectangleEdge getDomainAxisEdge()
          Returns the domain axis edge.
 RectangleEdge getDomainAxisEdge(int index)
          Returns the edge for a domain axis.
 CategoryAxis getDomainAxisForDataset(int index)
          Returns the domain axis for a dataset.
 AxisLocation getDomainAxisLocation()
          Returns the domain axis location.
 AxisLocation getDomainAxisLocation(int index)
          Returns the location for a domain axis.
 java.awt.Paint getDomainGridlinePaint()
          Returns the paint used to draw grid-lines against the domain axis.
 CategoryAnchor getDomainGridlinePosition()
          Returns the position used for the domain gridlines.
 java.awt.Stroke getDomainGridlineStroke()
          Returns the stroke used to draw grid-lines against the domain axis.
 boolean getDrawSharedDomainAxis()
          Returns the flag that controls whether or not the shared domain axis is drawn for each subplot.
 AxisSpace getFixedDomainAxisSpace()
          Returns the fixed domain axis space.
 LegendItemCollection getFixedLegendItems()
          Returns the fixed legend items, if any.
 AxisSpace getFixedRangeAxisSpace()
          Returns the fixed range axis space.
 int getIndexOf(CategoryItemRenderer renderer)
          Returns the index of the specified renderer, or -1 if the renderer is not assigned to this plot.
 LegendItemCollection getLegendItems()
          Returns the legend items for the plot.
 PlotOrientation getOrientation()
          Returns the orientation of the plot.
 java.lang.String getPlotType()
          Returns a string describing the type of plot.
 ValueAxis getRangeAxis()
          Returns the range axis for the plot.
 ValueAxis getRangeAxis(int index)
          Returns a range axis.
 RectangleEdge getRangeAxisEdge()
          Returns the edge where the primary range axis is located.
 RectangleEdge getRangeAxisEdge(int index)
          Returns the edge for a range axis.
 ValueAxis getRangeAxisForDataset(int index)
          Returns the range axis for a dataset.
 AxisLocation getRangeAxisLocation()
          Returns the range axis location.
 AxisLocation getRangeAxisLocation(int index)
          Returns the location for a range axis.
 java.awt.Paint getRangeCrosshairPaint()
          Returns the range crosshair color.
 java.awt.Stroke getRangeCrosshairStroke()
          Returns the pen-style (Stroke) used to draw the crosshair (if visible).
 double getRangeCrosshairValue()
          Returns the range crosshair value.
 java.awt.Paint getRangeGridlinePaint()
          Returns the paint used to draw the grid-lines against the range axis.
 java.awt.Stroke getRangeGridlineStroke()
          Returns the stroke used to draw the grid-lines against the range axis.
 java.util.Collection getRangeMarkers(int index, Layer layer)
          Returns a collection of range markers for a particular renderer and layer.
 java.util.Collection getRangeMarkers(Layer layer)
          Returns the list of range markers (read only) for the specified layer.
 CategoryItemRenderer getRenderer()
          Returns a reference to the renderer for the plot.
 CategoryItemRenderer getRenderer(int index)
          Returns the renderer at the given index.
 CategoryItemRenderer getRendererForDataset(CategoryDataset dataset)
          Returns the renderer for the specified dataset.
 SortOrder getRowRenderingOrder()
          Returns the order in which the rows should be rendered.
 int getWeight()
          Returns the weight for this plot when it is used as a subplot within a combined plot.
 void handleClick(int x, int y, PlotRenderingInfo info)
          Handles a 'click' on the plot by updating the anchor value.
 boolean isDomainGridlinesVisible()
          Returns the flag that controls whether the domain grid-lines are visible.
 boolean isDomainZoomable()
          Returns 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 the flag that controls whether the range grid-lines are visible.
 boolean isRangeZoomable()
          Returns false.
 void mapDatasetToDomainAxis(int index, int axisIndex)
          Maps a dataset to a particular domain axis.
 void mapDatasetToRangeAxis(int index, int axisIndex)
          Maps a dataset to a particular range axis.
 boolean render(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, int index, PlotRenderingInfo info)
          Draws a representation of a dataset within the dataArea region using the appropriate renderer.
 void rendererChanged(RendererChangeEvent event)
          Receives notification of a renderer change event.
 void setAnchorValue(double value)
          Sets the anchor value.
 void setAnchorValue(double value, boolean notify)
          Sets the anchor value.
 void setAxisOffset(RectangleInsets offset)
          Sets the axis offsets (gap between the data area and the axes).
 void setColumnRenderingOrder(SortOrder order)
          Sets the order in which the columns should be rendered.
 void setDataset(CategoryDataset dataset)
          Sets the dataset for the plot, replacing the existing dataset, if there is one.
 void setDataset(int index, CategoryDataset dataset)
          Sets a dataset for the plot.
 void setDatasetRenderingOrder(DatasetRenderingOrder order)
          Sets the rendering order and sends a PlotChangeEvent to all registered listeners.
 void setDomainAxis(CategoryAxis axis)
          Sets the domain axis for the plot and sends a PlotChangeEvent to all registered listeners.
 void setDomainAxis(int index, CategoryAxis axis)
          Sets a domain axis.
 void setDomainAxisLocation(AxisLocation location)
          Sets the location of the domain axis and sends a PlotChangeEvent to all registered listeners.
 void setDomainAxisLocation(AxisLocation location, boolean notify)
          Sets the location of the domain axis.
 void setDomainAxisLocation(int index, AxisLocation location)
          Sets the location for a domain axis and sends a PlotChangeEvent to all registered listeners.
 void setDomainGridlinePaint(java.awt.Paint paint)
          Sets the paint used to draw the grid-lines (if any) against the domain axis.
 void setDomainGridlinePosition(CategoryAnchor position)
          Sets the position used for the domain gridlines.
 void setDomainGridlineStroke(java.awt.Stroke stroke)
          Sets the stroke used to draw grid-lines against the domain axis.
 void setDomainGridlinesVisible(boolean visible)
          Sets the flag that controls whether or not grid-lines are drawn against the domain axis.
 void setDrawSharedDomainAxis(boolean draw)
          Sets the flag that controls whether the shared domain axis is drawn when this plot is being used as a subplot.
 void setFixedDomainAxisSpace(AxisSpace space)
          Sets the fixed domain axis space.
 void setFixedLegendItems(LegendItemCollection items)
          Sets the fixed legend items for the plot.
 void setFixedRangeAxisSpace(AxisSpace space)
          Sets the fixed range axis space.
 void setOrientation(PlotOrientation orientation)
          Sets the orientation for the plot and sends a PlotChangeEvent to all registered listeners.
 void setRangeAxis(int index, ValueAxis axis)
          Sets a range axis.
 void setRangeAxis(ValueAxis axis)
          Sets the range axis for the plot and sends a PlotChangeEvent to all registered listeners.
 void setRangeAxisLocation(AxisLocation location)
          Sets the location of the range axis and sends a PlotChangeEvent to all registered listeners.
 void setRangeAxisLocation(AxisLocation location, boolean notify)
          Sets the location of the range axis and, if requested, sends a PlotChangeEvent to all registered listeners.
 void setRangeAxisLocation(int index, AxisLocation location)
          Sets the location for a range axis and sends a PlotChangeEvent to all registered listeners.
 void setRangeAxisLocation(int index, AxisLocation location, boolean notify)
          Sets the location for a range axis and sends a PlotChangeEvent to all registered listeners.
 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 pen-style (Stroke) used to draw the crosshairs (if visible).
 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 used to draw the grid lines against the range axis.
 void setRangeGridlineStroke(java.awt.Stroke stroke)
          Sets the stroke used to draw the grid-lines against the range axis.
 void setRangeGridlinesVisible(boolean visible)
          Sets the flag that controls whether or not grid-lines are drawn against the range axis.
 void setRenderer(CategoryItemRenderer renderer)
          Sets the renderer at index 0 (sometimes referred to as the "primary" renderer) and sends a PlotChangeEvent to all registered listeners.
 void setRenderer(CategoryItemRenderer renderer, boolean notify)
          Sets the renderer at index 0 (sometimes referred to as the "primary" renderer) and, if requested, sends a PlotChangeEvent to all registered listeners.
 void setRenderer(int index, CategoryItemRenderer renderer)
          Sets the renderer at the specified index and sends a PlotChangeEvent to all registered listeners.
 void setRenderer(int index, CategoryItemRenderer renderer, boolean notify)
          Sets a renderer.
 void setRowRenderingOrder(SortOrder order)
          Sets the order in which the rows should be rendered.
 void setWeight(int weight)
          Sets the weight for the plot.
 void zoom(double percent)
          Zooms (in or out) on the plot's value axis.
 void zoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, java.awt.geom.Point2D source)
          This method does nothing, because CategoryPlot doesn't support zooming on the domain.
 void zoomDomainAxes(double factor, PlotRenderingInfo state, java.awt.geom.Point2D source)
          This method does nothing, because CategoryPlot doesn't support zooming on the domain.
 void zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, java.awt.geom.Point2D source)
          Zooms in on the range axes.
 void zoomRangeAxes(double factor, PlotRenderingInfo state, java.awt.geom.Point2D source)
          Multiplies the range on the range axis/axes by the specified factor.
 
Methods inherited from class org.jfree.chart.plot.Plot
addChangeListener, axisChanged, draw, drawBackground, drawBackgroundImage, drawNoDataMessage, drawOutline, fillBackground, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundPaint, getDataAreaRatio, getDatasetGroup, getDrawingSupplier, getForegroundAlpha, getInsets, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getOutlinePaint, getOutlineStroke, getParent, getRectX, getRectY, getRootPlot, isSubplot, notifyListeners, removeChangeListener, resolveDomainAxisLocation, resolveRangeAxisLocation, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundPaint, setDataAreaRatio, setDatasetGroup, setDrawingSupplier, setForegroundAlpha, setInsets, setInsets, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setOutlinePaint, setOutlineStroke, setParent
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DOMAIN_GRIDLINES_VISIBLE

public static final boolean DEFAULT_DOMAIN_GRIDLINES_VISIBLE
The default visibility of the grid lines plotted against the domain axis.

See Also:
Constant Field Values

DEFAULT_RANGE_GRIDLINES_VISIBLE

public static final boolean DEFAULT_RANGE_GRIDLINES_VISIBLE
The default visibility of the grid lines plotted against the range axis.

See Also:
Constant Field Values

DEFAULT_GRIDLINE_STROKE

public static final java.awt.Stroke DEFAULT_GRIDLINE_STROKE
The default grid line stroke.


DEFAULT_GRIDLINE_PAINT

public static final java.awt.Paint DEFAULT_GRIDLINE_PAINT
The default grid line paint.


DEFAULT_VALUE_LABEL_FONT

public static final java.awt.Font DEFAULT_VALUE_LABEL_FONT
The default value label font.


localizationResources

protected static java.util.ResourceBundle localizationResources
The resourceBundle for the localization.

Constructor Detail

CategoryPlot

public CategoryPlot()
Default constructor.


CategoryPlot

public CategoryPlot(CategoryDataset dataset,
                    CategoryAxis domainAxis,
                    ValueAxis rangeAxis,
                    CategoryItemRenderer renderer)
Creates a new plot.

Parameters:
dataset - the dataset (null permitted).
domainAxis - the domain axis (null permitted).
rangeAxis - the range axis (null permitted).
renderer - the item renderer (null permitted).
Method Detail

getPlotType

public java.lang.String getPlotType()
Returns a string describing the type of plot.

Specified by:
getPlotType in class Plot
Returns:
The type.

getOrientation

public PlotOrientation getOrientation()
Returns the orientation of the plot.

Specified by:
getOrientation in interface Zoomable
Returns:
The orientation of the plot.

setOrientation

public void setOrientation(PlotOrientation orientation)
Sets the orientation for the plot and sends a PlotChangeEvent to all registered listeners.

Parameters:
orientation - the orientation (null not permitted).

getAxisOffset

public RectangleInsets getAxisOffset()
Returns the axis offset.

Returns:
The axis offset (never null).

setAxisOffset

public void setAxisOffset(RectangleInsets offset)
Sets the axis offsets (gap between the data area and the axes).

Parameters:
offset - the offset (null not permitted).

getDomainAxis

public CategoryAxis getDomainAxis()
Returns the domain axis for the plot. If the domain axis for this plot is null, then the method will return the parent plot's domain axis (if there is a parent plot).

Returns:
The domain axis (null permitted).

getDomainAxis

public CategoryAxis getDomainAxis(int index)
Returns a domain axis.

Parameters:
index - the axis index.
Returns:
The axis (null possible).

setDomainAxis

public void setDomainAxis(CategoryAxis axis)
Sets the domain axis for the plot and sends a PlotChangeEvent to all registered listeners.

Parameters:
axis - the axis (null permitted).

setDomainAxis

public void setDomainAxis(int index,
                          CategoryAxis axis)
Sets a domain axis.

Parameters:
index - the axis index.
axis - the axis.

getDomainAxisLocation

public AxisLocation getDomainAxisLocation()
Returns the domain axis location.

Returns:
The location (never null).

getDomainAxisLocation

public AxisLocation getDomainAxisLocation(int index)
Returns the location for a domain axis.

Parameters:
index - the axis index.
Returns:
The location.

setDomainAxisLocation

public void setDomainAxisLocation(AxisLocation location)
Sets the location of the domain axis and sends a PlotChangeEvent to all registered listeners.

Parameters:
location - the axis location (null not permitted).

setDomainAxisLocation

public void setDomainAxisLocation(AxisLocation location,
                                  boolean notify)
Sets the location of the domain axis.

Parameters:
location - the axis location (null not permitted).
notify - a flag that controls whether listeners are notified.

setDomainAxisLocation

public void setDomainAxisLocation(int index,
                                  AxisLocation location)
Sets the location for a domain axis and sends a PlotChangeEvent to all registered listeners.

Parameters:
index - the axis index.
location - the location.

getDomainAxisEdge

public RectangleEdge getDomainAxisEdge()
Returns the domain axis edge. This is derived from the axis location and the plot orientation.

Returns:
The edge (never null).

getDomainAxisEdge

public RectangleEdge getDomainAxisEdge(int index)
Returns the edge for a domain axis.

Parameters:
index - the axis index.
Returns:
The edge (never null).

clearDomainAxes

public void clearDomainAxes()
Clears the domain axes from the plot and sends a PlotChangeEvent to all registered listeners.


configureDomainAxes

public void configureDomainAxes()
Configures the domain axes.


getRangeAxis

public ValueAxis getRangeAxis()
Returns the range axis for the plot. If the range axis for this plot is null, then the method will return the parent plot's range axis (if there is a parent plot).

Returns:
The range axis (possibly null).

getRangeAxis

public ValueAxis getRangeAxis(int index)
Returns a range axis.

Parameters:
index - the axis index.
Returns:
The axis (null possible).

setRangeAxis

public void setRangeAxis(ValueAxis axis)
Sets the range axis for the plot and sends a PlotChangeEvent to all registered listeners.

Parameters:
axis - the axis (null permitted).

setRangeAxis

public void setRangeAxis(int index,
                         ValueAxis axis)
Sets a range axis.

Parameters:
index - the axis index.
axis - the axis.

getRangeAxisLocation

public AxisLocation getRangeAxisLocation()
Returns the range axis location.

Returns:
the location (never null).

getRangeAxisLocation

public AxisLocation getRangeAxisLocation(int index)
Returns the location for a range axis.

Parameters:
index - the axis index.
Returns:
The location.

setRangeAxisLocation

public void setRangeAxisLocation(AxisLocation location)
Sets the location of the range axis and sends a PlotChangeEvent to all registered listeners.

Parameters:
location - the location (null not permitted).

setRangeAxisLocation

public void setRangeAxisLocation(AxisLocation location,
                                 boolean notify)
Sets the location of the range axis and, if requested, sends a PlotChangeEvent to all registered listeners.

Parameters:
location - the location (null not permitted).
notify - notify listeners?

setRangeAxisLocation

public void setRangeAxisLocation(int index,
                                 AxisLocation location)
Sets the location for a range axis and sends a PlotChangeEvent to all registered listeners.

Parameters:
index - the axis index.
location - the location.

setRangeAxisLocation

public void setRangeAxisLocation(int index,
                                 AxisLocation location,
                                 boolean notify)
Sets the location for a range axis and sends a PlotChangeEvent to all registered listeners.

Parameters:
index - the axis index.
location - the location.
notify - notify listeners?

getRangeAxisEdge

public RectangleEdge getRangeAxisEdge()
Returns the edge where the primary range axis is located.

Returns:
The edge (never null).

getRangeAxisEdge

public RectangleEdge getRangeAxisEdge(int index)
Returns the edge for a range axis.

Parameters:
index - the axis index.
Returns:
The edge.

clearRangeAxes

public void clearRangeAxes()
Clears the range axes from the plot and sends a PlotChangeEvent to all registered listeners.


configureRangeAxes

public void configureRangeAxes()
Configures the range axes.


getDataset

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

Returns:
The primary dataset (possibly null).

getDataset

public CategoryDataset getDataset(int index)
Returns the dataset at the given index.

Parameters:
index - the dataset index.
Returns:
The dataset (possibly null).

setDataset

public void setDataset(CategoryDataset dataset)
Sets the dataset for the plot, replacing the existing dataset, if there is one. This method also calls the datasetChanged(DatasetChangeEvent) method, which adjusts the axis ranges if necessary and sends a PlotChangeEvent to all registered listeners.

Parameters:
dataset - the dataset (null permitted).

setDataset

public void setDataset(int index,
                       CategoryDataset dataset)
Sets a dataset for the plot.

Parameters:
index - the dataset index.
dataset - the dataset (null permitted).

mapDatasetToDomainAxis

public void mapDatasetToDomainAxis(int index,
                                   int axisIndex)
Maps a dataset to a particular domain axis.

Parameters:
index - the dataset index (zero-based).
axisIndex - the axis index (zero-based).

getDomainAxisForDataset

public CategoryAxis getDomainAxisForDataset(int index)
Returns the domain axis for a dataset. You can change the axis for a dataset using the mapDatasetToDomainAxis(int, int) method.

Parameters:
index - the dataset index.
Returns:
The domain axis.

mapDatasetToRangeAxis

public void mapDatasetToRangeAxis(int index,
                                  int axisIndex)
Maps a dataset to a particular range axis.

Parameters:
index - the dataset index (zero-based).
axisIndex - the axis index (zero-based).

getRangeAxisForDataset

public ValueAxis getRangeAxisForDataset(int index)
Returns the range axis for a dataset. You can change the axis for a dataset using the mapDatasetToRangeAxis(int, int) method.

Parameters:
index - the dataset index.
Returns:
The range axis.

getRenderer

public CategoryItemRenderer getRenderer()
Returns a reference to the renderer for the plot.

Returns:
The renderer.

getRenderer

public CategoryItemRenderer getRenderer(int index)
Returns the renderer at the given index.

Parameters:
index - the renderer index.
Returns:
The renderer (possibly null).

setRenderer

public void setRenderer(CategoryItemRenderer renderer)
Sets the renderer at index 0 (sometimes referred to as the "primary" renderer) and sends a PlotChangeEvent to all registered listeners.

Parameters:
renderer - the renderer (null permitted.

setRenderer

public void setRenderer(CategoryItemRenderer renderer,
                        boolean notify)
Sets the renderer at index 0 (sometimes referred to as the "primary" renderer) and, if requested, sends a PlotChangeEvent to all registered listeners.

You can set the renderer to null, but this is not recommended because:

Parameters:
renderer - the renderer (null permitted).
notify - notify listeners?

setRenderer

public void setRenderer(int index,
                        CategoryItemRenderer renderer)
Sets the renderer at the specified index and sends a PlotChangeEvent to all registered listeners.

Parameters:
index - the index.
renderer - the renderer (null permitted).

setRenderer

public void setRenderer(int index,
                        CategoryItemRenderer renderer,
                        boolean notify)
Sets a renderer. A PlotChangeEvent is sent to all registered listeners.

Parameters:
index - the index.
renderer - the renderer (null permitted).
notify - notify listeners?

getRendererForDataset

public CategoryItemRenderer getRendererForDataset(CategoryDataset dataset)
Returns the renderer for the specified dataset. If the dataset doesn't belong to the plot, this method will return null.

Parameters:
dataset - the dataset (null permitted).
Returns:
The renderer (possibly null).

getIndexOf

public int getIndexOf(CategoryItemRenderer renderer)
Returns the index of the specified renderer, or -1 if the renderer is not assigned to this plot.

Parameters:
renderer - the renderer (null permitted).
Returns:
The renderer index.

getDatasetRenderingOrder

public DatasetRenderingOrder getDatasetRenderingOrder()
Returns the dataset rendering order.

Returns:
The order (never null).

setDatasetRenderingOrder

public void setDatasetRenderingOrder(DatasetRenderingOrder order)
Sets the rendering order and sends a PlotChangeEvent to all registered listeners. By default, the plot renders the primary dataset last (so that the primary dataset overlays the secondary datasets). You can reverse this if you want to.

Parameters:
order - the rendering order (null not permitted).

getColumnRenderingOrder

public SortOrder getColumnRenderingOrder()
Returns the order in which the columns are rendered.

Returns:
The order.

setColumnRenderingOrder

public void setColumnRenderingOrder(SortOrder order)
Sets the order in which the columns should be rendered.

Parameters:
order - the order.

getRowRenderingOrder

public SortOrder getRowRenderingOrder()
Returns the order in which the rows should be rendered.

Returns:
the order (never null).

setRowRenderingOrder

public void setRowRenderingOrder(SortOrder order)
Sets the order in which the rows should be rendered.

Parameters:
order - the order (null not allowed).

isDomainGridlinesVisible

public boolean isDomainGridlinesVisible()
Returns the flag that controls whether the domain grid-lines are visible.

Returns:
the true or false.

setDomainGridlinesVisible

public void setDomainGridlinesVisible(boolean visible)
Sets the flag that controls whether or not grid-lines are drawn against the domain axis.

If the flag value changes, a PlotChangeEvent is sent to all registered listeners.

Parameters:
visible - the new value of the flag.

getDomainGridlinePosition

public CategoryAnchor getDomainGridlinePosition()
Returns the position used for the domain gridlines.

Returns:
The gridline position.

setDomainGridlinePosition

public void setDomainGridlinePosition(CategoryAnchor position)
Sets the position used for the domain gridlines.

Parameters:
position - the position.

getDomainGridlineStroke

public java.awt.Stroke getDomainGridlineStroke()
Returns the stroke used to draw grid-lines against the domain axis.

Returns:
the stroke.

setDomainGridlineStroke

public void setDomainGridlineStroke(java.awt.Stroke stroke)
Sets the stroke used to draw grid-lines against the domain axis. A PlotChangeEvent is sent to all registered listeners.

Parameters:
stroke - the stroke.

getDomainGridlinePaint

public java.awt.Paint getDomainGridlinePaint()
Returns the paint used to draw grid-lines against the domain axis.

Returns:
the paint.

setDomainGridlinePaint

public void setDomainGridlinePaint(java.awt.Paint paint)
Sets the paint used to draw the grid-lines (if any) against the domain axis. A PlotChangeEvent is sent to all registered listeners.

Parameters:
paint - the paint.

isRangeGridlinesVisible

public boolean isRangeGridlinesVisible()
Returns the flag that controls whether the range grid-lines are visible.

Returns:
the flag.

setRangeGridlinesVisible

public void setRangeGridlinesVisible(boolean visible)
Sets the flag that controls whether or not grid-lines are drawn against the range axis. If the flag changes value, a PlotChangeEvent is sent to all registered listeners.

Parameters:
visible - the new value of the flag.

getRangeGridlineStroke

public java.awt.Stroke getRangeGridlineStroke()
Returns the stroke used to draw the grid-lines against the range axis.

Returns:
the stroke.

setRangeGridlineStroke

public void setRangeGridlineStroke(java.awt.Stroke stroke)
Sets the stroke used to draw the grid-lines against the range axis. A PlotChangeEvent is sent to all registered listeners.

Parameters:
stroke - the stroke.

getRangeGridlinePaint

public java.awt.Paint getRangeGridlinePaint()
Returns the paint used to draw the grid-lines against the range axis.

Returns:
the paint.

setRangeGridlinePaint

public void setRangeGridlinePaint(java.awt.Paint paint)
Sets the paint used to draw the grid lines against the range axis. A PlotChangeEvent is sent to all registered listeners.

Parameters:
paint - the paint.

getFixedLegendItems

public LegendItemCollection getFixedLegendItems()
Returns the fixed legend items, if any.

Returns:
The legend items (possibly null).

setFixedLegendItems

public void setFixedLegendItems(LegendItemCollection items)
Sets the fixed legend items for the plot. Leave this set to null if you prefer the legend items to be created automatically.

Parameters:
items - the legend items (null permitted).

getLegendItems

public LegendItemCollection getLegendItems()
Returns the legend items for the plot. By default, this method creates a legend item for each series in each of the datasets. You can change this behaviour by overriding this method.

Specified by:
getLegendItems in interface LegendItemSource
Overrides:
getLegendItems in class Plot
Returns:
The legend items.

handleClick

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

Overrides:
handleClick in class Plot
Parameters:
x - x-coordinate of the click (in Java2D space).
y - y-coordinate of the click (in Java2D space).
info - information about the plot's dimensions.

zoom

public void zoom(double percent)
Zooms (in or out) on the plot's value axis.

If the value 0.0 is passed in as the zoom percent, the auto-range calculation for the axis is restored (which sets the range to include the minimum and maximum data values, thus displaying all the data).

Overrides:
zoom in class Plot
Parameters:
percent - the zoom amount.

datasetChanged

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

The range axis bounds will be recalculated if necessary.

Specified by:
datasetChanged in interface DatasetChangeListener
Overrides:
datasetChanged in class Plot
Parameters:
event - information about the event (not used here).

rendererChanged

public void rendererChanged(RendererChangeEvent event)
Receives notification of a renderer change event.

Specified by:
rendererChanged in interface RendererChangeListener
Parameters:
event - the event.

addRangeMarker

public void addRangeMarker(Marker marker)
Adds a marker for display (in the foreground) against the range axis and sends a PlotChangeEvent to all registered listeners. 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 (null not permitted).

addRangeMarker

public void addRangeMarker(Marker marker,
                           Layer layer)
Adds a marker for display against the range axis and sends a PlotChangeEvent to all registered listeners. 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 (null not permitted).
layer - the layer (foreground or background) (null not permitted).

addRangeMarker

public void addRangeMarker(int index,
                           Marker marker,
                           Layer layer)
Adds a marker for display by a particular renderer.

Typically a marker will be drawn by the renderer as a line perpendicular to a range axis, however this is entirely up to the renderer.

Parameters:
index - the renderer index.
marker - the marker.
layer - the layer.

clearRangeMarkers

public void clearRangeMarkers()
Clears all the range markers for the plot and sends a PlotChangeEvent to all registered listeners.


getRangeMarkers

public java.util.Collection getRangeMarkers(Layer layer)
Returns the list of range markers (read only) for the specified layer.

Parameters:
layer - the layer (foreground or background).
Returns:
The list of range markers.

getRangeMarkers

public java.util.Collection getRangeMarkers(int index,
                                            Layer layer)
Returns a collection of range markers for a particular renderer and layer.

Parameters:
index - the renderer index.
layer - the layer.
Returns:
A collection of markers (possibly null).

clearRangeMarkers

public void clearRangeMarkers(int index)
Clears all the range markers for the specified renderer.

Parameters:
index - the renderer index.

isRangeCrosshairVisible

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

Returns:
The flag.

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.

isRangeCrosshairLockedOnData

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

Returns:
the flag.

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.

getRangeCrosshairValue

public double getRangeCrosshairValue()
Returns the range crosshair value.

Returns:
The value.

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.

getRangeCrosshairStroke

public java.awt.Stroke getRangeCrosshairStroke()
Returns the pen-style (Stroke) used to draw the crosshair (if visible).

Returns:
the crosshair stroke.

setRangeCrosshairStroke

public void setRangeCrosshairStroke(java.awt.Stroke stroke)
Sets the pen-style (Stroke) used to draw the crosshairs (if visible). A PlotChangeEvent is sent to all registered listeners.

Parameters:
stroke - the new crosshair stroke.

getRangeCrosshairPaint

public java.awt.Paint getRangeCrosshairPaint()
Returns the range crosshair color.

Returns:
The crosshair color.

setRangeCrosshairPaint

public 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.

Parameters:
paint - the new crosshair paint.

getAnnotations

public java.util.List getAnnotations()
Returns the list of annotations.

Returns:
The list of annotations.

addAnnotation

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

Parameters:
annotation - the annotation.

calculateDomainAxisSpace

protected AxisSpace calculateDomainAxisSpace(java.awt.Graphics2D g2,
                                             java.awt.geom.Rectangle2D plotArea,
                                             AxisSpace space)
Calculates the space required for the domain axis/axes.

Parameters:
g2 - the graphics device.
plotArea - the plot area.
space - a carrier for the result (null permitted).
Returns:
The required space.

calculateRangeAxisSpace

protected AxisSpace calculateRangeAxisSpace(java.awt.Graphics2D g2,
                                            java.awt.geom.Rectangle2D plotArea,
                                            AxisSpace space)
Calculates the space required for the range axis/axes.

Parameters:
g2 - the graphics device.
plotArea - the plot area.
space - a carrier for the result (null permitted).
Returns:
The required space.

calculateAxisSpace

protected AxisSpace calculateAxisSpace(java.awt.Graphics2D g2,
                                       java.awt.geom.Rectangle2D plotArea)
Calculates the space required for the axes.

Parameters:
g2 - the graphics device.
plotArea - the plot area.
Returns:
The space required for the axes.

draw

public void draw(java.awt.Graphics2D g2,
                 java.awt.geom.Rectangle2D plotArea,
                 PlotState parentState,
                 PlotRenderingInfo state)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).

At your option, you may supply an instance of PlotRenderingInfo. If you do, it will be populated with information about the drawing, including various plot dimensions and tooltip info.

Specified by:
draw in class Plot
Parameters:
g2 - the graphics device.
plotArea - the area within which the plot (including axes) should be drawn.
parentState - the state from the parent plot, if there is one.
state - collects info as the chart is drawn (possibly null).

drawAxes

protected java.util.Map drawAxes(java.awt.Graphics2D g2,
                                 java.awt.geom.Rectangle2D plotArea,
                                 java.awt.geom.Rectangle2D dataArea,
                                 PlotRenderingInfo plotState)
A utility method for drawing the plot's axes.

Parameters:
g2 - the graphics device.
plotArea - the plot area.
dataArea - the data area.
plotState - collects information about the plot (null permitted).
Returns:
A map containing the axis states.

render

public boolean render(java.awt.Graphics2D g2,
                      java.awt.geom.Rectangle2D dataArea,
                      int index,
                      PlotRenderingInfo info)
Draws a representation of a dataset within the dataArea region using the appropriate renderer.

Parameters:
g2 - the graphics device.
dataArea - the region in which the data is to be drawn.
index - the dataset and renderer index.
info - an optional object for collection dimension information.
Returns:
A boolean that indicates whether or not real data was found.

drawDomainGridlines

protected void drawDomainGridlines(java.awt.Graphics2D g2,
                                   java.awt.geom.Rectangle2D dataArea)
Draws the gridlines for the plot.

Parameters:
g2 - the graphics device.
dataArea - the area inside the axes.

drawRangeGridlines

protected void drawRangeGridlines(java.awt.Graphics2D g2,
                                  java.awt.geom.Rectangle2D dataArea,
                                  java.util.List ticks)
Draws the gridlines for the plot.

Parameters:
g2 - the graphics device.
dataArea - the area inside the axes.
ticks - the ticks.

drawAnnotations

protected void drawAnnotations(java.awt.Graphics2D g2,
                               java.awt.geom.Rectangle2D dataArea)
Draws the annotations...

Parameters:
g2 - the graphics device.
dataArea - the data area.

drawRangeMarkers

protected void drawRangeMarkers(java.awt.Graphics2D g2,
                                java.awt.geom.Rectangle2D dataArea,
                                Layer layer)
Draws the range markers (if any) for the specified layer. This method is typically called from within the draw() method.

Parameters:
g2 - the graphics device.
dataArea - the data area.
layer - the layer (foreground or background).

drawRangeMarkers

protected void drawRangeMarkers(java.awt.Graphics2D g2,
                                java.awt.geom.Rectangle2D dataArea,
                                int index,
                                Layer layer)
Draws the range markers (if any) for an axis and layer. This method is typically called from within the draw() method.

Parameters:
g2 - the graphics device.
dataArea - the data area.
index - the renderer index.
layer - the layer (foreground or background).

drawRangeLine

protected void drawRangeLine(java.awt.Graphics2D g2,
                             java.awt.geom.Rectangle2D dataArea,
                             double value,
                             java.awt.Stroke stroke,
                             java.awt.Paint paint)
Utility method for drawing a line perpendicular to the range axis (used for crosshairs).

Parameters:
g2 - the graphics device.
dataArea - the area defined by the axes.
value - the data value.
stroke - the line stroke.
paint - the line paint.

getDataRange

public Range getDataRange(ValueAxis axis)
Returns the range of data values that will be plotted against the range axis. If the dataset is null, this method returns null.

Specified by:
getDataRange in interface ValueAxisPlot
Parameters:
axis - the axis.
Returns:
The data range.

getWeight

public int getWeight()
Returns the weight for this plot when it is used as a subplot within a combined plot.

Returns:
the weight.

setWeight

public void setWeight(int weight)
Sets the weight for the plot.

Parameters:
weight - the weight.

getFixedDomainAxisSpace

public AxisSpace getFixedDomainAxisSpace()
Returns the fixed domain axis space.

Returns:
The fixed domain axis space (possibly null).

setFixedDomainAxisSpace

public void setFixedDomainAxisSpace(AxisSpace space)
Sets the fixed domain axis space.

Parameters:
space - the space (null permitted).

getFixedRangeAxisSpace

public AxisSpace getFixedRangeAxisSpace()
Returns the fixed range axis space.

Returns:
The fixed range axis space (possibly null).

setFixedRangeAxisSpace

public void setFixedRangeAxisSpace(AxisSpace space)
Sets the fixed range axis space.

Parameters:
space - the space (null permitted).

getCategories

public java.util.List getCategories()
Returns a list of the categories for the plot.

Returns:
A list of the categories for the plot.

getDrawSharedDomainAxis

public boolean getDrawSharedDomainAxis()
Returns the flag that controls whether or not the shared domain axis is drawn for each subplot.

Returns:
A boolean.

setDrawSharedDomainAxis

public void setDrawSharedDomainAxis(boolean draw)
Sets the flag that controls whether the shared domain axis is drawn when this plot is being used as a subplot.

Parameters:
draw - a boolean.

isDomainZoomable

public boolean isDomainZoomable()
Returns false.

Specified by:
isDomainZoomable in interface Zoomable
Returns:
A boolean.

isRangeZoomable

public boolean isRangeZoomable()
Returns false.

Specified by:
isRangeZoomable in interface Zoomable
Returns:
A boolean.

zoomDomainAxes

public void zoomDomainAxes(double factor,
                           PlotRenderingInfo state,
                           java.awt.geom.Point2D source)
This method does nothing, because CategoryPlot doesn't support zooming on the domain.

Specified by:
zoomDomainAxes in interface Zoomable
Parameters:
factor - the zoom factor.
state - the plot state.
source - the source point (in Java2D space) for the zoom.

zoomDomainAxes

public void zoomDomainAxes(double lowerPercent,
                           double upperPercent,
                           PlotRenderingInfo state,
                           java.awt.geom.Point2D source)
This method does nothing, because CategoryPlot doesn't support zooming on the domain.

Specified by:
zoomDomainAxes in interface Zoomable
Parameters:
lowerPercent - the lower bound.
upperPercent - the upper bound.
state - the plot state.
source - the source point (in Java2D space) for the zoom.

zoomRangeAxes

public void zoomRangeAxes(double factor,
                          PlotRenderingInfo state,
                          java.awt.geom.Point2D source)
Multiplies the range on the range axis/axes by the specified factor.

Specified by:
zoomRangeAxes in interface Zoomable
Parameters:
factor - the zoom factor.
state - the plot state.
source - the source point (in Java2D space) for the zoom.

zoomRangeAxes

public void zoomRangeAxes(double lowerPercent,
                          double upperPercent,
                          PlotRenderingInfo state,
                          java.awt.geom.Point2D source)
Zooms in on the range axes.

Specified by:
zoomRangeAxes in interface Zoomable
Parameters:
lowerPercent - the lower bound.
upperPercent - the upper bound.
state - the plot state.
source - the source point (in Java2D space) for the zoom.

getAnchorValue

public double getAnchorValue()
Returns the anchor value.

Returns:
The anchor value.

setAnchorValue

public void setAnchorValue(double value)
Sets the anchor value.

Parameters:
value - the anchor value.

setAnchorValue

public void setAnchorValue(double value,
                           boolean notify)
Sets the anchor value.

Parameters:
value - the value.
notify - notify listeners?

equals

public boolean equals(java.lang.Object obj)
Tests the plot for equality with an arbitrary object.

Overrides:
equals in class Plot
Parameters:
obj - the object to test against (null permitted).
Returns:
A boolean.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns a clone of the plot.

Overrides:
clone in class Plot
Returns:
A clone.
Throws:
java.lang.CloneNotSupportedException - if the cloning is not supported.