org.jfree.chart.renderer
Class AbstractCategoryItemRenderer

java.lang.Object
  |
  +--org.jfree.chart.renderer.AbstractRenderer
        |
        +--org.jfree.chart.renderer.AbstractCategoryItemRenderer
All Implemented Interfaces:
CategoryItemRenderer, Renderer, java.io.Serializable
Direct Known Subclasses:
AreaRenderer, BarRenderer, HorizontalShapeRenderer, LineAndShapeRenderer, MinMaxCategoryRenderer

public abstract class AbstractCategoryItemRenderer
extends AbstractRenderer
implements CategoryItemRenderer, java.io.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.

Author:
David Gilbert
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
 
Fields inherited from interface org.jfree.chart.renderer.CategoryItemRenderer
STACKED, STANDARD
 
Constructor Summary
protected AbstractCategoryItemRenderer()
          Creates a new renderer with no tool tip generator and no URL generator.
protected AbstractCategoryItemRenderer(CategoryToolTipGenerator toolTipGenerator)
          Creates a new renderer with the specified tooltip generator but no URL generator.
protected AbstractCategoryItemRenderer(CategoryToolTipGenerator toolTipGenerator, CategoryURLGenerator urlGenerator)
          Creates a new renderer with the specified tooltip generator and URL generator.
protected AbstractCategoryItemRenderer(CategoryURLGenerator urlGenerator)
          Creates a new renderer with the specified URL generator but no tooltip generator.
 
Method Summary
 void drawBackground(java.awt.Graphics2D g2, CategoryPlot plot, java.awt.geom.Rectangle2D dataArea)
          Draws a background for the data area.
 void drawDomainGridline(java.awt.Graphics2D g2, CategoryPlot plot, java.awt.geom.Rectangle2D dataArea, double value)
          Draws a grid line against the domain axis.
 void drawOutline(java.awt.Graphics2D g2, CategoryPlot plot, java.awt.geom.Rectangle2D dataArea)
          Draws an outline for the data area.
 void drawRangeGridline(java.awt.Graphics2D g2, CategoryPlot plot, ValueAxis axis, java.awt.geom.Rectangle2D dataArea, double value)
          Draws a grid line against the range axis.
 void drawRangeMarker(java.awt.Graphics2D g2, CategoryPlot plot, ValueAxis axis, Marker marker, java.awt.geom.Rectangle2D dataArea)
          Draws a marker for the range axis.
 boolean equals(java.lang.Object obj)
          Tests this renderer for equality with another object.
 int getColumnCount()
          Returns the number of columns in the dataset.
 LegendItem getLegendItem(int datasetIndex, int series)
          Returns a legend item for a series.
 int getRangeType()
          Returns the range type for the renderer.
 int getRowCount()
          Returns the number of rows in the dataset.
 CategoryToolTipGenerator getToolTipGenerator()
          Returns the tool tip generator.
 CategoryURLGenerator getURLGenerator()
          Returns the URL generator for HTML image maps.
 void initialise(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, CategoryPlot plot, ChartRenderingInfo info)
          Initialises the renderer.
 void setToolTipGenerator(CategoryToolTipGenerator generator)
          Sets the tool tip generator.
 void setURLGenerator(CategoryURLGenerator urlGenerator)
          Sets the URL generator for HTML image maps.
 
Methods inherited from class org.jfree.chart.renderer.AbstractRenderer
addPropertyChangeListener, createTransformedShape, firePropertyChanged, getDefaultOutlinePaint, getDefaultOutlineStroke, getDefaultPaint, getDefaultShape, getDefaultStroke, getDrawingSupplier, getInfo, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getPlot, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesShape, getSeriesStroke, isOutlinePaintTableActive, isOutlineStrokeTableActive, isPaintTableActive, isShapeTableActive, isStrokeTableActive, removePropertyChangeListener, setDefaultOutlinePaint, setDefaultOutlineStroke, setDefaultPaint, setDefaultShape, setDefaultStroke, setDrawingSupplier, setInfo, setOutlinePaintTableActive, setOutlineStrokeTableActive, setPaintTableActive, setPlot, setSeriesOutlinePaint, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesShape, setSeriesShape, setSeriesStroke, setSeriesStroke, setShapeTableActive, setStrokeTableActive
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jfree.chart.renderer.CategoryItemRenderer
drawItem, getItemOutlinePaint, getItemPaint, getItemShape, getItemStroke, getSeriesOutlinePaint, getSeriesPaint, getSeriesShape, getSeriesStroke
 
Methods inherited from interface org.jfree.chart.renderer.Renderer
getDefaultOutlinePaint, getDefaultOutlineStroke, getDefaultPaint, getDefaultShape, getDefaultStroke, getDrawingSupplier, getPlot, isOutlinePaintTableActive, isOutlineStrokeTableActive, isPaintTableActive, isShapeTableActive, isStrokeTableActive, setDefaultOutlinePaint, setDefaultOutlineStroke, setDefaultPaint, setDefaultShape, setDefaultStroke, setDrawingSupplier, setOutlinePaintTableActive, setOutlineStrokeTableActive, setPaintTableActive, setPlot, setSeriesPaint, setSeriesPaint, setSeriesStroke, setSeriesStroke, setShapeTableActive, setStrokeTableActive
 

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.


AbstractCategoryItemRenderer

protected AbstractCategoryItemRenderer(CategoryToolTipGenerator toolTipGenerator)
Creates a new renderer with the specified tooltip generator but no URL generator.

Parameters:
toolTipGenerator - the tool tip generator.

AbstractCategoryItemRenderer

protected AbstractCategoryItemRenderer(CategoryURLGenerator urlGenerator)
Creates a new renderer with the specified URL generator but no tooltip generator.

Parameters:
urlGenerator - the URL generator.

AbstractCategoryItemRenderer

protected AbstractCategoryItemRenderer(CategoryToolTipGenerator toolTipGenerator,
                                       CategoryURLGenerator urlGenerator)
Creates a new renderer with the specified tooltip generator and URL generator.

Parameters:
toolTipGenerator - the tool tip generator.
urlGenerator - the URL generator.
Method Detail

getRowCount

public int getRowCount()
Returns the number of rows in the dataset. This value is updated in the initialise(java.awt.Graphics2D, java.awt.geom.Rectangle2D, org.jfree.chart.plot.CategoryPlot, org.jfree.chart.ChartRenderingInfo) method.

Returns:
the row count.

getColumnCount

public int getColumnCount()
Returns the number of columns in the dataset. This value is updated in the initialise(java.awt.Graphics2D, java.awt.geom.Rectangle2D, org.jfree.chart.plot.CategoryPlot, org.jfree.chart.ChartRenderingInfo) method.

Returns:
the column count.

getToolTipGenerator

public CategoryToolTipGenerator getToolTipGenerator()
Returns the tool tip generator.

Specified by:
getToolTipGenerator in interface CategoryItemRenderer
Returns:
the tool tip generator.

setToolTipGenerator

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

Specified by:
setToolTipGenerator in interface CategoryItemRenderer
Parameters:
generator - the tool tip generator.

getURLGenerator

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

Returns:
the URL generator.

setURLGenerator

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

Parameters:
urlGenerator - the URL generator.

initialise

public void initialise(java.awt.Graphics2D g2,
                       java.awt.geom.Rectangle2D dataArea,
                       CategoryPlot plot,
                       ChartRenderingInfo info)
Initialises the renderer.

Stores a reference to the ChartRenderingInfo object (which might be null), 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:
initialise in interface CategoryItemRenderer
Parameters:
g2 - the graphics device.
dataArea - the data area.
plot - the plot.
info - an object for returning information about the structure of the chart (null permitted).

getRangeType

public int getRangeType()
Returns the range type for the renderer.

The default implementation returns STANDARD, subclasses may override this behaviour.

The CategoryPlot uses this information when auto-calculating the range for the axis.

Specified by:
getRangeType in interface CategoryItemRenderer
Returns:
the range type.

drawBackground

public void drawBackground(java.awt.Graphics2D g2,
                           CategoryPlot plot,
                           java.awt.geom.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.

Specified by:
drawBackground in interface CategoryItemRenderer
Parameters:
g2 - the graphics device.
plot - the plot.
dataArea - the data area.

drawOutline

public void drawOutline(java.awt.Graphics2D g2,
                        CategoryPlot plot,
                        java.awt.geom.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.

Specified by:
drawOutline in interface CategoryItemRenderer
Parameters:
g2 - the graphics device.
plot - the plot.
dataArea - the data area.

drawDomainGridline

public void drawDomainGridline(java.awt.Graphics2D g2,
                               CategoryPlot plot,
                               java.awt.geom.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:
drawDomainGridline in interface CategoryItemRenderer
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(java.awt.Graphics2D g2,
                              CategoryPlot plot,
                              ValueAxis axis,
                              java.awt.geom.Rectangle2D dataArea,
                              double value)
Draws a grid line against the range axis.

Specified by:
drawRangeGridline in interface CategoryItemRenderer
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(java.awt.Graphics2D g2,
                            CategoryPlot plot,
                            ValueAxis axis,
                            Marker marker,
                            java.awt.geom.Rectangle2D dataArea)
Draws a marker for the range axis.

A marker is a constant value, usually represented by a line.

Specified by:
drawRangeMarker in interface CategoryItemRenderer
Parameters:
g2 - the graphics device.
plot - the plot.
axis - the range axis.
marker - the marker to be drawn.
dataArea - the area inside the axes.

getLegendItem

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

Specified by:
getLegendItem in interface CategoryItemRenderer
Parameters:
datasetIndex - the dataset index (zero-based).
series - the series index (zero-based).
Returns:
the legend item.

equals

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

Overrides:
equals in class AbstractRenderer
Parameters:
obj - the object.
Returns:
true or false.