org.jfree.chart.renderer.category

Class AbstractCategoryItemRenderer

public abstract class AbstractCategoryItemRenderer extends AbstractRenderer implements CategoryItemRenderer, Cloneable, PublicCloneable, Serializable

An abstract base class that you can use to implement a new CategoryItemRenderer. When you create a new CategoryItemRenderer you are not required to extend this class, but it makes the job easier.
Constructor Summary
protected AbstractCategoryItemRenderer()
Creates a new renderer with no tool tip generator and no URL generator.
Method Summary
protected voidaddItemEntity(EntityCollection entities, CategoryDataset dataset, int row, int column, Shape hotspot)
Adds an entity with the specified hotspot.
protected Point2DcalculateDomainMarkerTextAnchorPoint(Graphics2D g2, PlotOrientation orientation, Rectangle2D dataArea, Rectangle2D markerArea, RectangleInsets markerOffset, LengthAdjustmentType labelOffsetType, RectangleAnchor anchor)
Calculates the (x, y) coordinates for drawing the label for a marker on the range axis.
protected Point2DcalculateRangeMarkerTextAnchorPoint(Graphics2D g2, PlotOrientation orientation, Rectangle2D dataArea, Rectangle2D markerArea, RectangleInsets markerOffset, LengthAdjustmentType labelOffsetType, RectangleAnchor anchor)
Calculates the (x, y) coordinates for drawing a marker label.
Objectclone()
Returns an independent copy of the renderer.
protected CategoryItemRendererStatecreateState(PlotRenderingInfo info)
Creates a new state instance---this method is called from the AbstractCategoryItemRenderer method.
voiddrawBackground(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea)
Draws a background for the data area.
voiddrawDomainGridline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, double value)
Draws a grid line against the domain axis.
voiddrawDomainMarker(Graphics2D g2, CategoryPlot plot, CategoryAxis axis, CategoryMarker marker, Rectangle2D dataArea)
Draws a marker for the domain axis.
protected voiddrawItemLabel(Graphics2D g2, PlotOrientation orientation, CategoryDataset dataset, int row, int column, double x, double y, boolean negative)
Draws an item label.
voiddrawOutline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea)
Draws an outline for the data area.
voiddrawRangeGridline(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Rectangle2D dataArea, double value)
Draws a grid line against the range axis.
voiddrawRangeMarker(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Marker marker, Rectangle2D dataArea)
Draws a marker for the range axis.
booleanequals(Object obj)
Tests this renderer for equality with another object.
RangefindRangeBounds(CategoryDataset dataset)
Returns the range of values the renderer requires to display all the items from the specified dataset.
CategoryItemLabelGeneratorgetBaseItemLabelGenerator()
Returns the base item label generator.
CategoryURLGeneratorgetBaseItemURLGenerator()
Returns the base item URL generator.
CategoryToolTipGeneratorgetBaseToolTipGenerator()
Returns the base tool tip generator (the "layer 2" generator).
intgetColumnCount()
Returns the number of columns in the dataset.
protected CategoryAxisgetDomainAxis(CategoryPlot plot, int index)
Returns a domain axis for a plot.
DrawingSuppliergetDrawingSupplier()
Returns the drawing supplier from the plot.
CategoryItemLabelGeneratorgetItemLabelGenerator(int row, int column)
Returns the item label generator for a data item.
CategoryURLGeneratorgetItemURLGenerator(int row, int column)
Returns the URL generator for a data item.
LegendItemgetLegendItem(int datasetIndex, int series)
Returns a legend item for a series.
CategorySeriesLabelGeneratorgetLegendItemLabelGenerator()
Returns the legend item label generator.
LegendItemCollectiongetLegendItems()
Returns a (possibly empty) collection of legend items for the series that this renderer is responsible for drawing.
CategorySeriesLabelGeneratorgetLegendItemToolTipGenerator()
Returns the legend item tool tip generator.
CategorySeriesLabelGeneratorgetLegendItemURLGenerator()
Returns the legend item URL generator.
intgetPassCount()
Returns the number of passes through the dataset required by the renderer.
CategoryPlotgetPlot()
Returns the plot that the renderer has been assigned to (where null indicates that the renderer is not currently assigned to a plot).
protected ValueAxisgetRangeAxis(CategoryPlot plot, int index)
Returns a range axis for a plot.
intgetRowCount()
Returns the number of rows in the dataset.
CategoryItemLabelGeneratorgetSeriesItemLabelGenerator(int series)
Returns the item label generator for a series.
CategoryURLGeneratorgetSeriesItemURLGenerator(int series)
Returns the URL generator for a series.
CategoryToolTipGeneratorgetSeriesToolTipGenerator(int series)
Returns the tool tip generator for the specified series (a "layer 1" generator).
CategoryToolTipGeneratorgetToolTipGenerator(int row, int column)
Returns the tool tip generator that should be used for the specified item.
CategoryToolTipGeneratorgetToolTipGenerator()
Returns the tool tip generator that will be used for ALL items in the dataset (the "layer 0" generator).
inthashCode()
Returns a hash code for the renderer.
CategoryItemRendererStateinitialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info)
Initialises the renderer and returns a state object that will be used for the remainder of the drawing process for a single chart.
voidsetBaseItemLabelGenerator(CategoryItemLabelGenerator generator)
Sets the base item label generator and sends a RendererChangeEvent to all registered listeners.
voidsetBaseItemURLGenerator(CategoryURLGenerator generator)
Sets the base item URL generator.
voidsetBaseToolTipGenerator(CategoryToolTipGenerator generator)
Sets the base tool tip generator and sends a RendererChangeEvent to all registered listeners.
voidsetItemLabelGenerator(CategoryItemLabelGenerator generator)
Sets the item label generator for ALL series and sends a RendererChangeEvent to all registered listeners.
voidsetItemURLGenerator(CategoryURLGenerator generator)
Sets the item URL generator for ALL series.
voidsetLegendItemLabelGenerator(CategorySeriesLabelGenerator generator)
Sets the legend item label generator and sends a RendererChangeEvent to all registered listeners.
voidsetLegendItemToolTipGenerator(CategorySeriesLabelGenerator generator)
Sets the legend item tool tip generator and sends a RendererChangeEvent to all registered listeners.
voidsetLegendItemURLGenerator(CategorySeriesLabelGenerator generator)
Sets the legend item URL generator and sends a RendererChangeEvent to all registered listeners.
voidsetPlot(CategoryPlot plot)
Sets the plot that the renderer has been assigned to.
voidsetSeriesItemLabelGenerator(int series, CategoryItemLabelGenerator generator)
Sets the item label generator for a series and sends a RendererChangeEvent to all registered listeners.
voidsetSeriesItemURLGenerator(int series, CategoryURLGenerator generator)
Sets the URL generator for a series.
voidsetSeriesToolTipGenerator(int series, CategoryToolTipGenerator generator)
Sets the tool tip generator for a series and sends a RendererChangeEvent to all registered listeners.
voidsetToolTipGenerator(CategoryToolTipGenerator generator)
Sets the tool tip generator for ALL series and sends a RendererChangeEvent to all registered listeners.

Constructor Detail

AbstractCategoryItemRenderer

protected AbstractCategoryItemRenderer()
Creates a new renderer with no tool tip generator and no URL generator. The defaults (no tool tip or URL generators) have been chosen to minimise the processing required to generate a default chart. If you require tool tips or URLs, then you can easily add the required generators.

Method Detail

addItemEntity

protected void addItemEntity(EntityCollection entities, CategoryDataset dataset, int row, int column, Shape hotspot)
Adds an entity with the specified hotspot.

Parameters: entities the entity collection. dataset the dataset. row the row index. column the column index. hotspot the hotspot.

calculateDomainMarkerTextAnchorPoint

protected Point2D calculateDomainMarkerTextAnchorPoint(Graphics2D g2, PlotOrientation orientation, Rectangle2D dataArea, Rectangle2D markerArea, RectangleInsets markerOffset, LengthAdjustmentType labelOffsetType, RectangleAnchor anchor)
Calculates the (x, y) coordinates for drawing the label for a marker on the range axis.

Parameters: g2 the graphics device. orientation the plot orientation. dataArea the data area. markerArea the rectangle surrounding the marker. markerOffset the marker offset. labelOffsetType the label offset type. anchor the label anchor.

Returns: The coordinates for drawing the marker label.

calculateRangeMarkerTextAnchorPoint

protected Point2D calculateRangeMarkerTextAnchorPoint(Graphics2D g2, PlotOrientation orientation, Rectangle2D dataArea, Rectangle2D markerArea, RectangleInsets markerOffset, LengthAdjustmentType labelOffsetType, RectangleAnchor anchor)
Calculates the (x, y) coordinates for drawing a marker label.

Parameters: g2 the graphics device. orientation the plot orientation. dataArea the data area. markerArea the rectangle surrounding the marker. markerOffset the marker offset. labelOffsetType the label offset type. anchor the label anchor.

Returns: The coordinates for drawing the marker label.

clone

public Object clone()
Returns an independent copy of the renderer. The plot reference is shallow copied.

Returns: A clone.

Throws: CloneNotSupportedException can be thrown if one of the objects belonging to the renderer does not support cloning (for example, an item label generator).

createState

protected CategoryItemRendererState createState(PlotRenderingInfo info)
Creates a new state instance---this method is called from the AbstractCategoryItemRenderer method. Subclasses can override this method if they need to use a subclass of CategoryItemRendererState.

Parameters: info collects plot rendering info (null permitted).

Returns: The new state instance (never null).

Since: 1.0.5

drawBackground

public void drawBackground(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea)
Draws a background for the data area. The default implementation just gets the plot to draw the outline, but some renderers will override this behaviour.

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

drawDomainGridline

public void drawDomainGridline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, double value)
Draws a grid line against the domain axis.

Note that this default implementation assumes that the horizontal axis is the domain axis. If this is not the case, you will need to override this method.

Parameters: g2 the graphics device. plot the plot. dataArea the area for plotting data (not yet adjusted for any 3D effect). value the Java2D value at which the grid line should be drawn.

See Also: AbstractCategoryItemRenderer

drawDomainMarker

public void drawDomainMarker(Graphics2D g2, CategoryPlot plot, CategoryAxis axis, CategoryMarker marker, Rectangle2D dataArea)
Draws a marker for the domain axis.

Parameters: g2 the graphics device (not null). plot the plot (not null). axis the range axis (not null). marker the marker to be drawn (not null). dataArea the area inside the axes (not null).

See Also: AbstractCategoryItemRenderer

drawItemLabel

protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation, CategoryDataset dataset, int row, int column, double x, double y, boolean negative)
Draws an item label.

Parameters: g2 the graphics device. orientation the orientation. dataset the dataset. row the row. column the column. x the x coordinate (in Java2D space). y the y coordinate (in Java2D space). negative indicates a negative value (which affects the item label position).

drawOutline

public void drawOutline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea)
Draws an outline for the data area. The default implementation just gets the plot to draw the outline, but some renderers will override this behaviour.

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

drawRangeGridline

public void drawRangeGridline(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Rectangle2D dataArea, double value)
Draws a grid line against the range axis.

Parameters: g2 the graphics device. plot the plot. axis the value axis. dataArea the area for plotting data (not yet adjusted for any 3D effect). value the value at which the grid line should be drawn.

See Also:

drawRangeMarker

public void drawRangeMarker(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Marker marker, Rectangle2D dataArea)
Draws a marker for the range axis.

Parameters: g2 the graphics device (not null). plot the plot (not null). axis the range axis (not null). marker the marker to be drawn (not null). dataArea the area inside the axes (not null).

See Also: AbstractCategoryItemRenderer

equals

public boolean equals(Object obj)
Tests this renderer for equality with another object.

Parameters: obj the object.

Returns: true or false.

findRangeBounds

public Range findRangeBounds(CategoryDataset dataset)
Returns the range of values the renderer requires to display all the items from the specified dataset.

Parameters: dataset the dataset (null permitted).

Returns: The range (or null if the dataset is null or empty).

getBaseItemLabelGenerator

public CategoryItemLabelGenerator getBaseItemLabelGenerator()
Returns the base item label generator.

Returns: The generator (possibly null).

See Also: setBaseItemLabelGenerator

getBaseItemURLGenerator

public CategoryURLGenerator getBaseItemURLGenerator()
Returns the base item URL generator.

Returns: The item URL generator.

See Also: setBaseItemURLGenerator

getBaseToolTipGenerator

public CategoryToolTipGenerator getBaseToolTipGenerator()
Returns the base tool tip generator (the "layer 2" generator).

Returns: The tool tip generator (possibly null).

See Also: setBaseToolTipGenerator

getColumnCount

public int getColumnCount()
Returns the number of columns in the dataset. This value is updated in the AbstractCategoryItemRenderer method.

Returns: The column count.

getDomainAxis

protected CategoryAxis getDomainAxis(CategoryPlot plot, int index)
Returns a domain axis for a plot.

Parameters: plot the plot. index the axis index.

Returns: A domain axis.

getDrawingSupplier

public DrawingSupplier getDrawingSupplier()
Returns the drawing supplier from the plot.

Returns: The drawing supplier (possibly null).

getItemLabelGenerator

public CategoryItemLabelGenerator getItemLabelGenerator(int row, int column)
Returns the item label generator for a data item. This implementation simply passes control to the AbstractCategoryItemRenderer method. If, for some reason, you want a different generator for individual items, you can override this method.

Parameters: row the row index (zero based). column the column index (zero based).

Returns: The generator (possibly null).

getItemURLGenerator

public CategoryURLGenerator getItemURLGenerator(int row, int column)
Returns the URL generator for a data item. This method just calls the getSeriesItemURLGenerator method, but you can override this behaviour if you want to.

Parameters: row the row index (zero based). column the column index (zero based).

Returns: The URL generator.

getLegendItem

public LegendItem getLegendItem(int datasetIndex, int series)
Returns a legend item for a series.

Parameters: datasetIndex the dataset index (zero-based). series the series index (zero-based).

Returns: The legend item.

See Also: getLegendItems

getLegendItemLabelGenerator

public CategorySeriesLabelGenerator getLegendItemLabelGenerator()
Returns the legend item label generator.

Returns: The label generator (never null).

See Also: setLegendItemLabelGenerator

getLegendItems

public LegendItemCollection getLegendItems()
Returns a (possibly empty) collection of legend items for the series that this renderer is responsible for drawing.

Returns: The legend item collection (never null).

See Also: AbstractCategoryItemRenderer

getLegendItemToolTipGenerator

public CategorySeriesLabelGenerator getLegendItemToolTipGenerator()
Returns the legend item tool tip generator.

Returns: The tool tip generator (possibly null).

See Also: setLegendItemToolTipGenerator

getLegendItemURLGenerator

public CategorySeriesLabelGenerator getLegendItemURLGenerator()
Returns the legend item URL generator.

Returns: The URL generator (possibly null).

See Also: setLegendItemURLGenerator

getPassCount

public int getPassCount()
Returns the number of passes through the dataset required by the renderer. This method returns 1, subclasses should override if they need more passes.

Returns: The pass count.

getPlot

public CategoryPlot getPlot()
Returns the plot that the renderer has been assigned to (where null indicates that the renderer is not currently assigned to a plot).

Returns: The plot (possibly null).

See Also: setPlot

getRangeAxis

protected ValueAxis getRangeAxis(CategoryPlot plot, int index)
Returns a range axis for a plot.

Parameters: plot the plot. index the axis index.

Returns: A range axis.

getRowCount

public int getRowCount()
Returns the number of rows in the dataset. This value is updated in the AbstractCategoryItemRenderer method.

Returns: The row count.

getSeriesItemLabelGenerator

public CategoryItemLabelGenerator getSeriesItemLabelGenerator(int series)
Returns the item label generator for a series.

Parameters: series the series index (zero based).

Returns: The generator (possibly null).

See Also: AbstractCategoryItemRenderer

getSeriesItemURLGenerator

public CategoryURLGenerator getSeriesItemURLGenerator(int series)
Returns the URL generator for a series.

Parameters: series the series index (zero based).

Returns: The URL generator for the series.

See Also: AbstractCategoryItemRenderer

getSeriesToolTipGenerator

public CategoryToolTipGenerator getSeriesToolTipGenerator(int series)
Returns the tool tip generator for the specified series (a "layer 1" generator).

Parameters: series the series index (zero-based).

Returns: The tool tip generator (possibly null).

See Also: AbstractCategoryItemRenderer

getToolTipGenerator

public CategoryToolTipGenerator getToolTipGenerator(int row, int column)
Returns the tool tip generator that should be used for the specified item. This method looks up the generator using the "three-layer" approach outlined in the general description of this interface. You can override this method if you want to return a different generator per item.

Parameters: row the row index (zero-based). column the column index (zero-based).

Returns: The generator (possibly null).

getToolTipGenerator

public CategoryToolTipGenerator getToolTipGenerator()
Returns the tool tip generator that will be used for ALL items in the dataset (the "layer 0" generator).

Returns: A tool tip generator (possibly null).

See Also: setToolTipGenerator

hashCode

public int hashCode()
Returns a hash code for the renderer.

Returns: The hash code.

initialise

public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info)
Initialises the renderer and returns a state object that will be used for the remainder of the drawing process for a single chart. The state object allows for the fact that the renderer may be used simultaneously by multiple threads (each thread will work with a separate state object).

Parameters: g2 the graphics device. dataArea the data area. plot the plot. rendererIndex the renderer index. info an object for returning information about the structure of the plot (null permitted).

Returns: The renderer state.

setBaseItemLabelGenerator

public void setBaseItemLabelGenerator(CategoryItemLabelGenerator generator)
Sets the base item label generator and sends a RendererChangeEvent to all registered listeners.

Parameters: generator the generator (null permitted).

See Also: getBaseItemLabelGenerator

setBaseItemURLGenerator

public void setBaseItemURLGenerator(CategoryURLGenerator generator)
Sets the base item URL generator.

Parameters: generator the item URL generator.

See Also: getBaseItemURLGenerator

setBaseToolTipGenerator

public void setBaseToolTipGenerator(CategoryToolTipGenerator generator)
Sets the base tool tip generator and sends a RendererChangeEvent to all registered listeners.

Parameters: generator the generator (null permitted).

See Also: getBaseToolTipGenerator

setItemLabelGenerator

public void setItemLabelGenerator(CategoryItemLabelGenerator generator)
Sets the item label generator for ALL series and sends a RendererChangeEvent to all registered listeners.

Parameters: generator the generator (null permitted).

setItemURLGenerator

public void setItemURLGenerator(CategoryURLGenerator generator)
Sets the item URL generator for ALL series.

Parameters: generator the generator.

setLegendItemLabelGenerator

public void setLegendItemLabelGenerator(CategorySeriesLabelGenerator generator)
Sets the legend item label generator and sends a RendererChangeEvent to all registered listeners.

Parameters: generator the generator (null not permitted).

See Also: getLegendItemLabelGenerator

setLegendItemToolTipGenerator

public void setLegendItemToolTipGenerator(CategorySeriesLabelGenerator generator)
Sets the legend item tool tip generator and sends a RendererChangeEvent to all registered listeners.

Parameters: generator the generator (null permitted).

See Also: setLegendItemToolTipGenerator

setLegendItemURLGenerator

public void setLegendItemURLGenerator(CategorySeriesLabelGenerator generator)
Sets the legend item URL generator and sends a RendererChangeEvent to all registered listeners.

Parameters: generator the generator (null permitted).

See Also: getLegendItemURLGenerator

setPlot

public void setPlot(CategoryPlot plot)
Sets the plot that the renderer has been assigned to. This method is usually called by the CategoryPlot, in normal usage you shouldn't need to call this method directly.

Parameters: plot the plot (null not permitted).

See Also: getPlot

setSeriesItemLabelGenerator

public void setSeriesItemLabelGenerator(int series, CategoryItemLabelGenerator generator)
Sets the item label generator for a series and sends a RendererChangeEvent to all registered listeners.

Parameters: series the series index (zero based). generator the generator (null permitted).

See Also: AbstractCategoryItemRenderer

setSeriesItemURLGenerator

public void setSeriesItemURLGenerator(int series, CategoryURLGenerator generator)
Sets the URL generator for a series.

Parameters: series the series index (zero based). generator the generator.

See Also: AbstractCategoryItemRenderer

setSeriesToolTipGenerator

public void setSeriesToolTipGenerator(int series, CategoryToolTipGenerator generator)
Sets the tool tip generator for a series and sends a RendererChangeEvent to all registered listeners.

Parameters: series the series index (zero-based). generator the generator (null permitted).

See Also: AbstractCategoryItemRenderer

setToolTipGenerator

public void setToolTipGenerator(CategoryToolTipGenerator generator)
Sets the tool tip generator for ALL series and sends a RendererChangeEvent to all registered listeners.

Parameters: generator the generator (null permitted).

See Also: getToolTipGenerator