com.jrefinery.chart
Class AbstractCategoryItemRenderer

java.lang.Object
  |
  +--com.jrefinery.chart.AbstractRenderer
        |
        +--com.jrefinery.chart.AbstractCategoryItemRenderer
All Implemented Interfaces:
CategoryItemRenderer
Direct Known Subclasses:
AreaCategoryItemRenderer, BarRenderer, HorizontalShapeRenderer, LineAndShapeRenderer, MinMaxCategoryRenderer

public abstract class AbstractCategoryItemRenderer
extends AbstractRenderer
implements CategoryItemRenderer

Abstract base class for category item renderers.

Author:
DG

Constructor Summary
protected AbstractCategoryItemRenderer()
          Creates a renderer with no tool tip generator and no URL generator.
protected AbstractCategoryItemRenderer(CategoryToolTipGenerator toolTipGenerator)
          Constructs a new renderer with the specified tooltip generator.
protected AbstractCategoryItemRenderer(CategoryToolTipGenerator toolTipGenerator, CategoryURLGenerator urlGenerator)
          Constructs a new renderer with the specified tooltip generator.
protected AbstractCategoryItemRenderer(CategoryURLGenerator urlGenerator)
          Constructs a new renderer with the specified URL generator.
 
Method Summary
 void drawPlotBackground(java.awt.Graphics2D g2, CategoryPlot plot, java.awt.geom.Rectangle2D axisDataArea, java.awt.Shape dataClipArea)
          Draws the background for the plot.
 java.awt.geom.Rectangle2D getAxisArea(java.awt.geom.Rectangle2D plotArea)
          Returns the area that the axes (and data) must fit into.
 java.awt.Paint[] getCategoriesPaint()
          Returns the paint to use for the categories when there is just one series.
 java.awt.Paint getCategoryPaint(int index)
          Returns the paint for a specific category (possibly null).
 java.awt.Shape getDataClipRegion(java.awt.geom.Rectangle2D dataArea)
          Returns the clip region...
 LegendItem getLegendItem(int series)
          Returns a legend item for a series.
 CategoryPlot getPlot()
          Returns the plot.
 CategoryToolTipGenerator getToolTipGenerator()
          Returns the tool tip generator.
 CategoryURLGenerator getURLGenerator()
          Returns the URL generator for HTML image maps.
 boolean getUseCategoriesPaint()
          Returns the flag that controls whether or not the renderer uses the category paint settings.
 void initialise(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, CategoryPlot plot, ValueAxis axis, CategoryDataset data, ChartRenderingInfo info)
          Initialises the renderer.
 boolean isStacked()
          Returns a flag indicating whether the items within one category are stacked up when represented by the renderer.
 void setCategoriesPaint(java.awt.Paint[] paint)
          Sets the paint to be used for categories under special circumstances.
 void setPlot(CategoryPlot plot)
          Sets the plot.
 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 com.jrefinery.chart.AbstractRenderer
addPropertyChangeListener, firePropertyChanged, getInfo, removePropertyChangeListener, setInfo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jrefinery.chart.CategoryItemRenderer
drawCategoryItem, drawRangeMarker
 

Constructor Detail

AbstractCategoryItemRenderer

protected AbstractCategoryItemRenderer()
Creates a 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)
Constructs a new renderer with the specified tooltip generator.
Parameters:
toolTipGenerator - the tool tip generator.

AbstractCategoryItemRenderer

protected AbstractCategoryItemRenderer(CategoryURLGenerator urlGenerator)
Constructs a new renderer with the specified URL generator.
Parameters:
urlGenerator - the URL generator.

AbstractCategoryItemRenderer

protected AbstractCategoryItemRenderer(CategoryToolTipGenerator toolTipGenerator,
                                       CategoryURLGenerator urlGenerator)
Constructs a new renderer with the specified tooltip generator.
Parameters:
toolTipGenerator - the tool tip generator.
urlGenerator - the URL generator.
Method Detail

getPlot

public CategoryPlot getPlot()
Returns the plot.
Specified by:
getPlot in interface CategoryItemRenderer
Returns:
the plot.

setPlot

public void setPlot(CategoryPlot plot)
Sets the plot.
Specified by:
setPlot in interface CategoryItemRenderer
Parameters:
plot - the plot.

getUseCategoriesPaint

public boolean getUseCategoriesPaint()
Returns the flag that controls whether or not the renderer uses the category paint settings.
Returns:
the flag.

getCategoriesPaint

public java.awt.Paint[] getCategoriesPaint()
Returns the paint to use for the categories when there is just one series.

If this is null, the categories will all have the same color (that of the series).

Returns:
The paint for the categories.

setCategoriesPaint

public void setCategoriesPaint(java.awt.Paint[] paint)
Sets the paint to be used for categories under special circumstances.

This attribute is provided for the situation where there is just one series, and you want each category item to be plotted using a different color (ordinarily, the series color is used for all the items in the series).

May not be observed by all subclasses yet.

Parameters:
paint - The colors.

getCategoryPaint

public java.awt.Paint getCategoryPaint(int index)
Returns the paint for a specific category (possibly null).
Parameters:
index - The category index.
Returns:
The paint for the category.

getToolTipGenerator

public CategoryToolTipGenerator getToolTipGenerator()
Returns the tool tip generator.
Returns:
The tool tip generator.

setToolTipGenerator

public void setToolTipGenerator(CategoryToolTipGenerator generator)
Sets the tool tip generator.
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,
                       ValueAxis axis,
                       CategoryDataset data,
                       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.
axis - The axis.
data - The data.
info - An object for returning information about the structure of the chart.

isStacked

public boolean isStacked()
Returns a flag indicating whether the items within one category are stacked up when represented by the renderer.
Specified by:
isStacked in interface CategoryItemRenderer
Returns:
The flag.

getAxisArea

public java.awt.geom.Rectangle2D getAxisArea(java.awt.geom.Rectangle2D plotArea)
Returns the area that the axes (and data) must fit into.

Often this is the same as the plotArea, but sometimes a smaller region should be used (for example, the 3D charts require the axes to use less space in order to leave room for the 'depth' part of the chart).

Specified by:
getAxisArea in interface CategoryItemRenderer
Parameters:
plotArea - The plot area.
Returns:
the area that the axes (and date) must fit into.

getDataClipRegion

public java.awt.Shape getDataClipRegion(java.awt.geom.Rectangle2D dataArea)
Returns the clip region... usually returns the dataArea, but some charts (e.g. 3D) have non rectangular clip regions.
Specified by:
getDataClipRegion in interface CategoryItemRenderer
Parameters:
dataArea - The data area.
Returns:
the clip region.

drawPlotBackground

public void drawPlotBackground(java.awt.Graphics2D g2,
                               CategoryPlot plot,
                               java.awt.geom.Rectangle2D axisDataArea,
                               java.awt.Shape dataClipArea)
Draws the background for the plot.

For most charts, the axisDataArea and the dataClipArea are the same.

Specified by:
drawPlotBackground in interface CategoryItemRenderer
Parameters:
g2 - The graphics device.
plot - The plot.
axisDataArea - The area inside the axes.
dataClipArea - The data clip area.

getLegendItem

public LegendItem getLegendItem(int series)
Returns a legend item for a series.
Specified by:
getLegendItem in interface CategoryItemRenderer
Parameters:
series - the series (zero-based index).
Returns:
the legend item.