Package org.jfree.chart.renderer
Class AbstractCategoryItemRenderer
java.lang.Object
org.jfree.chart.renderer.AbstractRenderer
org.jfree.chart.renderer.AbstractCategoryItemRenderer
- All Implemented Interfaces:
Serializable,Cloneable,CategoryItemRenderer
- Direct Known Subclasses:
AreaRenderer,BarRenderer,BoxAndWhiskerRenderer,CategoryStepRenderer,LevelRenderer,LineAndShapeRenderer,MinMaxCategoryRenderer
public abstract class AbstractCategoryItemRenderer extends AbstractRenderer implements CategoryItemRenderer, Cloneable, 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.
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class org.jfree.chart.renderer.AbstractRenderer
DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, DEFAULT_PAINT, DEFAULT_SHAPE, DEFAULT_STROKE, DEFAULT_VALUE_LABEL_FONT, DEFAULT_VALUE_LABEL_PAINT, ZERO -
Method Summary
Modifier and Type Method Description Objectclone()Returns an independent copy of the renderer.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.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.CategoryURLGeneratorgetBaseItemURLGenerator()Returns the base item URL generator.CategoryLabelGeneratorgetBaseLabelGenerator()Returns the base label generator.CategoryToolTipGeneratorgetBaseToolTipGenerator()Returns the base tool tip generator (the "layer 2" generator).intgetColumnCount()Returns the number of columns in the dataset.DrawingSuppliergetDrawingSupplier()Returns the drawing supplier from the plot.CategoryURLGeneratorgetItemURLGenerator(int row, int column)Returns the URL generator for a data item.CategoryLabelGeneratorgetLabelGenerator(int row, int column)Returns the label generator for a data item.LegendItemgetLegendItem(int datasetIndex, int series)Returns a legend item for a series.CategoryPlotgetPlot()Returns the plot that the renderer has been assigned to (wherenullindicates that the renderer is not currently assigned to a plot).RangegetRangeExtent(CategoryDataset dataset)Returns the range of values the renderer requires to display all the items from the specified dataset.intgetRowCount()Returns the number of rows in the dataset.CategoryURLGeneratorgetSeriesItemURLGenerator(int series)Returns the URL generator for a series.CategoryLabelGeneratorgetSeriesLabelGenerator(int series)Returns the label generator for a series.CategoryToolTipGeneratorgetSeriesToolTipGenerator(int series)Returns the tool tip generator for the specified series (a "layer 1" generator).CategoryToolTipGeneratorgetToolTipGenerator()Returns the tool tip generator that will be used for ALL items in the dataset (the "layer 0" generator).CategoryToolTipGeneratorgetToolTipGenerator(int row, int column)Returns the tool tip generator that should be used for the specified item.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.voidsetBaseItemURLGenerator(CategoryURLGenerator generator)Sets the base item URL generator.voidsetBaseLabelGenerator(CategoryLabelGenerator generator)Sets the base label generator and sends aRendererChangeEventto all registered listeners.voidsetBaseToolTipGenerator(CategoryToolTipGenerator generator)Sets the base tool tip generator and sends aRendererChangeEventto all registered listeners.voidsetItemURLGenerator(CategoryURLGenerator generator)Sets the item URL generator for ALL series.voidsetLabelGenerator(CategoryLabelGenerator generator)Sets the label generator for ALL series and sends aRendererChangeEventto all registered listeners.voidsetPlot(CategoryPlot plot)Sets the plot that the renderer has been assigned to.voidsetSeriesItemURLGenerator(int series, CategoryURLGenerator generator)Sets the URL generator for a series.voidsetSeriesLabelGenerator(int series, CategoryLabelGenerator generator)Sets the label generator for a series and sends aRendererChangeEventto all registered listeners.voidsetSeriesToolTipGenerator(int series, CategoryToolTipGenerator generator)Sets the tool tip generator for a series and sends aRendererChangeEventto all registered listeners.voidsetToolTipGenerator(CategoryToolTipGenerator generator)Sets the tool tip generator for ALL series and sends aRendererChangeEventto all registered listeners.Methods inherited from class org.jfree.chart.renderer.AbstractRenderer
addChangeListener, getBaseItemLabelAnchor, getBaseItemLabelAngle, getBaseItemLabelFont, getBaseItemLabelPaint, getBaseItemLabelRotationAnchor, getBaseItemLabelsVisible, getBaseItemLabelTextAnchor, getBaseNegativeItemLabelPosition, getBaseOutlinePaint, getBaseOutlineStroke, getBasePaint, getBasePositiveItemLabelPosition, getBaseShape, getBaseStroke, getItemLabelAnchor, getItemLabelAnchorOffset, getItemLabelAngle, getItemLabelFont, getItemLabelFont, getItemLabelPaint, getItemLabelPaint, getItemLabelRotationAnchor, getItemLabelTextAnchor, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getNegativeItemLabelPosition, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getPositiveItemLabelPosition, getSeriesItemLabelAnchor, getSeriesItemLabelAngle, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesItemLabelRotationAnchor, getSeriesItemLabelTextAnchor, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, isItemLabelVisible, isSeriesItemLabelsVisible, notifyListeners, removeChangeListener, setBaseAngle, setBaseItemLabelAnchor, setBaseItemLabelFont, setBaseItemLabelFont, setBaseItemLabelPaint, setBaseItemLabelPaint, setBaseItemLabelRotationAnchor, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelTextAnchor, setBaseNegativeItemLabelPosition, setBaseNegativeItemLabelPosition, setBaseOutlinePaint, setBaseOutlinePaint, setBaseOutlineStroke, setBaseOutlineStroke, setBasePaint, setBasePaint, setBasePositiveItemLabelPosition, setBasePositiveItemLabelPosition, setBaseShape, setBaseShape, setBaseStroke, setBaseStroke, setItemLabelAnchor, setItemLabelAnchorOffset, setItemLabelAngle, setItemLabelFont, setItemLabelFont, setItemLabelPaint, setItemLabelPaint, setItemLabelRotationAnchor, setItemLabelsVisible, setItemLabelsVisible, setItemLabelsVisible, setItemLabelTextAnchor, setNegativeItemLabelPosition, setNegativeItemLabelPosition, setOutlinePaint, setOutlinePaint, setOutlineStroke, setOutlineStroke, setPaint, setPaint, setPositiveItemLabelPosition, setPositiveItemLabelPosition, setSeriesAngle, setSeriesItemLabelAnchor, setSeriesItemLabelFont, setSeriesItemLabelFont, setSeriesItemLabelPaint, setSeriesItemLabelPaint, setSeriesItemLabelRotationAnchor, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelTextAnchor, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesShape, setSeriesStroke, setSeriesStroke, setShape, setShape, setStroke, setStrokeMethods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jfree.chart.renderer.CategoryItemRenderer
addChangeListener, drawItem, getBaseItemLabelAnchor, getBaseItemLabelFont, getBaseItemLabelPaint, getBaseItemLabelsVisible, getBaseItemLabelTextAnchor, getBaseNegativeItemLabelPosition, getBaseOutlinePaint, getBaseOutlineStroke, getBasePaint, getBasePositiveItemLabelPosition, getBaseShape, getBaseStroke, getItemLabelAnchor, getItemLabelFont, getItemLabelFont, getItemLabelPaint, getItemLabelPaint, getItemLabelTextAnchor, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getNegativeItemLabelPosition, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getPositiveItemLabelPosition, getSeriesItemLabelAnchor, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesItemLabelTextAnchor, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, isItemLabelVisible, isSeriesItemLabelsVisible, removeChangeListener, setBaseItemLabelAnchor, setBaseItemLabelFont, setBaseItemLabelPaint, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelTextAnchor, setBaseNegativeItemLabelPosition, setBaseNegativeItemLabelPosition, setBaseOutlinePaint, setBaseOutlineStroke, setBasePaint, setBasePositiveItemLabelPosition, setBasePositiveItemLabelPosition, setBaseShape, setBaseStroke, setItemLabelAnchor, setItemLabelFont, setItemLabelPaint, setItemLabelsVisible, setItemLabelsVisible, setItemLabelsVisible, setItemLabelTextAnchor, setNegativeItemLabelPosition, setNegativeItemLabelPosition, setOutlinePaint, setOutlineStroke, setPaint, setPositiveItemLabelPosition, setPositiveItemLabelPosition, setSeriesItemLabelAnchor, setSeriesItemLabelFont, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelTextAnchor, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesStroke, setShape, setStroke
-
Method Details
-
getPlot
Returns the plot that the renderer has been assigned to (wherenullindicates that the renderer is not currently assigned to a plot).- Specified by:
getPlotin interfaceCategoryItemRenderer- Returns:
- The plot (possibly
null).
-
setPlot
Sets the plot that the renderer has been assigned to. This method is usually called by theCategoryPlot, in normal usage you shouldn't need to call this method directly.- Specified by:
setPlotin interfaceCategoryItemRenderer- Parameters:
plot- the plot (nullnot permitted).
-
getLabelGenerator
Returns the label generator for a data item. This implementation simply passes control to thegetSeriesLabelGenerator(int)method. If, for some reason, you want a different generator for individual items, you can override this method.- Specified by:
getLabelGeneratorin interfaceCategoryItemRenderer- Parameters:
row- the row index (zero based).column- the column index (zero based).- Returns:
- the generator (possibly
null).
-
getSeriesLabelGenerator
Returns the label generator for a series.- Specified by:
getSeriesLabelGeneratorin interfaceCategoryItemRenderer- Parameters:
series- the series index (zero based).- Returns:
- the generator (possibly
null).
-
setLabelGenerator
Sets the label generator for ALL series and sends aRendererChangeEventto all registered listeners.- Specified by:
setLabelGeneratorin interfaceCategoryItemRenderer- Parameters:
generator- the generator (nullpermitted).
-
setSeriesLabelGenerator
Sets the label generator for a series and sends aRendererChangeEventto all registered listeners.- Specified by:
setSeriesLabelGeneratorin interfaceCategoryItemRenderer- Parameters:
series- the series index (zero based).generator- the generator (nullpermitted).
-
getBaseLabelGenerator
Returns the base label generator.- Specified by:
getBaseLabelGeneratorin interfaceCategoryItemRenderer- Returns:
- The generator (possibly
null).
-
setBaseLabelGenerator
Sets the base label generator and sends aRendererChangeEventto all registered listeners.- Specified by:
setBaseLabelGeneratorin interfaceCategoryItemRenderer- Parameters:
generator- the generator (nullpermitted).
-
getToolTipGenerator
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.- Specified by:
getToolTipGeneratorin interfaceCategoryItemRenderer- Parameters:
row- the row index (zero-based).column- the column index (zero-based).- Returns:
- The generator (possibly
null).
-
getToolTipGenerator
Returns the tool tip generator that will be used for ALL items in the dataset (the "layer 0" generator).- Specified by:
getToolTipGeneratorin interfaceCategoryItemRenderer- Returns:
- A tool tip generator (possibly
null).
-
setToolTipGenerator
Sets the tool tip generator for ALL series and sends aRendererChangeEventto all registered listeners.- Specified by:
setToolTipGeneratorin interfaceCategoryItemRenderer- Parameters:
generator- the generator (nullpermitted).
-
getSeriesToolTipGenerator
Returns the tool tip generator for the specified series (a "layer 1" generator).- Specified by:
getSeriesToolTipGeneratorin interfaceCategoryItemRenderer- Parameters:
series- the series index (zero-based).- Returns:
- The tool tip generator (possibly
null).
-
setSeriesToolTipGenerator
Sets the tool tip generator for a series and sends aRendererChangeEventto all registered listeners.- Specified by:
setSeriesToolTipGeneratorin interfaceCategoryItemRenderer- Parameters:
series- the series index (zero-based).generator- the generator (nullpermitted).
-
getBaseToolTipGenerator
Returns the base tool tip generator (the "layer 2" generator).- Specified by:
getBaseToolTipGeneratorin interfaceCategoryItemRenderer- Returns:
- The tool tip generator (possibly
null).
-
setBaseToolTipGenerator
Sets the base tool tip generator and sends aRendererChangeEventto all registered listeners.- Specified by:
setBaseToolTipGeneratorin interfaceCategoryItemRenderer- Parameters:
generator- the generator (nullpermitted).
-
getItemURLGenerator
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.- Specified by:
getItemURLGeneratorin interfaceCategoryItemRenderer- Parameters:
row- the row index (zero based).column- the column index (zero based).- Returns:
- The URL generator.
-
getSeriesItemURLGenerator
Returns the URL generator for a series.- Specified by:
getSeriesItemURLGeneratorin interfaceCategoryItemRenderer- Parameters:
series- the series index (zero based).- Returns:
- The URL generator for the series.
-
setItemURLGenerator
Sets the item URL generator for ALL series.- Specified by:
setItemURLGeneratorin interfaceCategoryItemRenderer- Parameters:
generator- the generator.
-
setSeriesItemURLGenerator
Sets the URL generator for a series.- Specified by:
setSeriesItemURLGeneratorin interfaceCategoryItemRenderer- Parameters:
series- the series index (zero based).generator- the generator.
-
getBaseItemURLGenerator
Returns the base item URL generator.- Specified by:
getBaseItemURLGeneratorin interfaceCategoryItemRenderer- Returns:
- The item URL generator.
-
setBaseItemURLGenerator
Sets the base item URL generator.- Specified by:
setBaseItemURLGeneratorin interfaceCategoryItemRenderer- Parameters:
generator- the item URL generator.
-
getRowCount
public int getRowCount()Returns the number of rows in the dataset. This value is updated in theinitialise(java.awt.Graphics2D, java.awt.geom.Rectangle2D, org.jfree.chart.plot.CategoryPlot, int, org.jfree.chart.plot.PlotRenderingInfo)method.- Returns:
- the row count.
-
getColumnCount
public int getColumnCount()Returns the number of columns in the dataset. This value is updated in theinitialise(java.awt.Graphics2D, java.awt.geom.Rectangle2D, org.jfree.chart.plot.CategoryPlot, int, org.jfree.chart.plot.PlotRenderingInfo)method.- Returns:
- the column count.
-
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).Stores a reference to the
PlotRenderingInfoobject (which might benull), and then sets the useCategoriesPaint flag according to the special case conditions a) there is only one series and b) the categoriesPaint array is not null.- Specified by:
initialisein interfaceCategoryItemRenderer- 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 (nullpermitted).- Returns:
- the renderer state.
-
getRangeExtent
Returns the range of values the renderer requires to display all the items from the specified dataset.- Specified by:
getRangeExtentin interfaceCategoryItemRenderer- Parameters:
dataset- the dataset (nullpermitted).- Returns:
- The range (or
nullif the dataset isnullor empty).
-
drawBackground
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.- Specified by:
drawBackgroundin interfaceCategoryItemRenderer- Parameters:
g2- the graphics device.plot- the plot.dataArea- the data area.
-
drawOutline
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.- Specified by:
drawOutlinein interfaceCategoryItemRenderer- 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.
- Specified by:
drawDomainGridlinein interfaceCategoryItemRenderer- 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.
-
drawRangeGridline
public void drawRangeGridline(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Rectangle2D dataArea, double value)Draws a grid line against the range axis.- Specified by:
drawRangeGridlinein interfaceCategoryItemRenderer- 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.
-
drawRangeMarker
public void drawRangeMarker(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Marker marker, Rectangle2D dataArea)Draws a marker for the range axis.- Specified by:
drawRangeMarkerin interfaceCategoryItemRenderer- Parameters:
g2- the graphics device (notnull).plot- the plot (notnull).axis- the range axis (notnull).marker- the marker to be drawn (notnull).dataArea- the area inside the axes (notnull).
-
getLegendItem
Returns a legend item for a series.- Specified by:
getLegendItemin interfaceCategoryItemRenderer- Parameters:
datasetIndex- the dataset index (zero-based).series- the series index (zero-based).- Returns:
- the legend item.
-
equals
Tests this renderer for equality with another object.- Overrides:
equalsin classAbstractRenderer- Parameters:
obj- the object.- Returns:
trueorfalse.
-
hashCode
public int hashCode()Returns a hash code for the renderer.- Overrides:
hashCodein classAbstractRenderer- Returns:
- The hash code.
-
getDrawingSupplier
Returns the drawing supplier from the plot.- Specified by:
getDrawingSupplierin classAbstractRenderer- Returns:
- The drawing supplier (possibly
null).
-
clone
Returns an independent copy of the renderer.The
plotreference 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).
-