Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.jfree.chart.renderer.AbstractRenderer
org.jfree.chart.renderer.category.AbstractCategoryItemRenderer
public abstract class AbstractCategoryItemRenderer
extends AbstractRenderer
implements CategoryItemRenderer, Cloneable, PublicCloneable, Serializable
CategoryItemRenderer
. When you create a new
CategoryItemRenderer
you are not required to extend this class,
but it makes the job easier.
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 |
Constructor Summary | |
|
Method Summary | |
protected void |
|
protected Point2D |
|
protected Point2D |
|
Object |
|
protected CategoryItemRendererState |
|
void |
|
void |
|
void |
|
protected void |
|
void |
|
void |
|
void |
|
boolean |
|
Range |
|
CategoryItemLabelGenerator |
|
CategoryURLGenerator |
|
CategoryToolTipGenerator |
|
int |
|
protected CategoryAxis |
|
DrawingSupplier |
|
CategoryItemLabelGenerator |
|
CategoryURLGenerator |
|
LegendItem |
|
CategorySeriesLabelGenerator |
|
CategorySeriesLabelGenerator |
|
CategorySeriesLabelGenerator |
|
LegendItemCollection |
|
int |
|
CategoryPlot |
|
protected ValueAxis |
|
int |
|
CategoryItemLabelGenerator |
|
CategoryURLGenerator |
|
CategoryToolTipGenerator |
|
CategoryToolTipGenerator |
|
CategoryToolTipGenerator |
|
int |
|
CategoryItemRendererState |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
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.
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.
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.
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.
public Object clone() throws CloneNotSupportedException
Returns an independent copy of the renderer. Theplot
reference is shallow copied.
- Overrides:
- clone in interface AbstractRenderer
- Returns:
- A clone.
protected CategoryItemRendererState createState(PlotRenderingInfo info)
Creates a new state instance---this method is called from theinitialise(Graphics2D,Rectangle2D,CategoryPlot,int,PlotRenderingInfo)
method. Subclasses can override this method if they need to use a subclass ofCategoryItemRendererState
.
- Parameters:
info
- collects plot rendering info (null
permitted).
- Returns:
- The new state instance (never
null
).
- Since:
- 1.0.5
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.
- Specified by:
- drawBackground in interface CategoryItemRenderer
- Parameters:
g2
- the graphics device.plot
- the plot.dataArea
- the data area.
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:
- 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.
public void drawDomainMarker(Graphics2D g2, CategoryPlot plot, CategoryAxis axis, CategoryMarker marker, Rectangle2D dataArea)
Draws a marker for the domain axis.
- Specified by:
- drawDomainMarker in interface CategoryItemRenderer
- 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
).
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).
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.
- Specified by:
- drawOutline in interface CategoryItemRenderer
- Parameters:
g2
- the graphics device.plot
- the plot.dataArea
- the data area.
public void drawRangeGridline(Graphics2D g2, CategoryPlot plot, ValueAxis axis, 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.
public void drawRangeMarker(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Marker marker, Rectangle2D dataArea)
Draws a marker for the range axis.
- Specified by:
- drawRangeMarker in interface CategoryItemRenderer
- 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
).
public boolean equals(Object obj)
Tests this renderer for equality with another object.
- Overrides:
- equals in interface AbstractRenderer
- Parameters:
obj
- the object.
- Returns:
true
orfalse
.
public Range findRangeBounds(CategoryDataset dataset)
Returns the range of values the renderer requires to display all the items from the specified dataset.
- Specified by:
- findRangeBounds in interface CategoryItemRenderer
- Parameters:
dataset
- the dataset (null
permitted).
- Returns:
- The range (or
null
if the dataset isnull
or empty).
public CategoryItemLabelGenerator getBaseItemLabelGenerator()
Returns the base item label generator.
- Specified by:
- getBaseItemLabelGenerator in interface CategoryItemRenderer
- Returns:
- The generator (possibly
null
).
public CategoryURLGenerator getBaseItemURLGenerator()
Returns the base item URL generator.
- Specified by:
- getBaseItemURLGenerator in interface CategoryItemRenderer
- Returns:
- The item URL generator.
public CategoryToolTipGenerator getBaseToolTipGenerator()
Returns the base tool tip generator (the "layer 2" generator).
- Specified by:
- getBaseToolTipGenerator in interface CategoryItemRenderer
- Returns:
- The tool tip generator (possibly
null
).
public int getColumnCount()
Returns the number of columns in the dataset. This value is updated in theinitialise(Graphics2D,Rectangle2D,CategoryPlot,int,PlotRenderingInfo)
method.
- Returns:
- The column count.
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.
public DrawingSupplier getDrawingSupplier()
Returns the drawing supplier from the plot.
- Overrides:
- getDrawingSupplier in interface AbstractRenderer
- Returns:
- The drawing supplier (possibly
null
).
public CategoryItemLabelGenerator getItemLabelGenerator(int row, int column)
Returns the item label generator for a data item. This implementation simply passes control to thegetSeriesItemLabelGenerator(int)
method. If, for some reason, you want a different generator for individual items, you can override this method.
- Specified by:
- getItemLabelGenerator in interface CategoryItemRenderer
- Parameters:
row
- the row index (zero based).column
- the column index (zero based).
- Returns:
- The generator (possibly
null
).
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.
- Specified by:
- getItemURLGenerator in interface CategoryItemRenderer
- Parameters:
row
- the row index (zero based).column
- the column index (zero based).
- Returns:
- The URL generator.
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.
- See Also:
getLegendItems()
public CategorySeriesLabelGenerator getLegendItemLabelGenerator()
Returns the legend item label generator.
- Returns:
- The label generator (never
null
).
public CategorySeriesLabelGenerator getLegendItemToolTipGenerator()
Returns the legend item tool tip generator.
- Returns:
- The tool tip generator (possibly
null
).
public CategorySeriesLabelGenerator getLegendItemURLGenerator()
Returns the legend item URL generator.
- Returns:
- The URL generator (possibly
null
).
public LegendItemCollection getLegendItems()
Returns a (possibly empty) collection of legend items for the series that this renderer is responsible for drawing.
- Specified by:
- getLegendItems in interface LegendItemSource
- Returns:
- The legend item collection (never
null
).
- See Also:
getLegendItem(int,int)
public int getPassCount()
Returns the number of passes through the dataset required by the renderer. This method returns1
, subclasses should override if they need more passes.
- Specified by:
- getPassCount in interface CategoryItemRenderer
- Returns:
- The pass count.
public CategoryPlot getPlot()
Returns the plot that the renderer has been assigned to (wherenull
indicates that the renderer is not currently assigned to a plot).
- Specified by:
- getPlot in interface CategoryItemRenderer
- Returns:
- The plot (possibly
null
).
- See Also:
setPlot(CategoryPlot)
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.
public int getRowCount()
Returns the number of rows in the dataset. This value is updated in theinitialise(Graphics2D,Rectangle2D,CategoryPlot,int,PlotRenderingInfo)
method.
- Returns:
- The row count.
public CategoryItemLabelGenerator getSeriesItemLabelGenerator(int series)
Returns the item label generator for a series.
- Specified by:
- getSeriesItemLabelGenerator in interface CategoryItemRenderer
- Parameters:
series
- the series index (zero based).
- Returns:
- The generator (possibly
null
).
public CategoryURLGenerator getSeriesItemURLGenerator(int series)
Returns the URL generator for a series.
- Specified by:
- getSeriesItemURLGenerator in interface CategoryItemRenderer
- Parameters:
series
- the series index (zero based).
- Returns:
- The URL generator for the series.
public CategoryToolTipGenerator getSeriesToolTipGenerator(int series)
Returns the tool tip generator for the specified series (a "layer 1" generator).
- Specified by:
- getSeriesToolTipGenerator in interface CategoryItemRenderer
- Parameters:
series
- the series index (zero-based).
- Returns:
- The tool tip generator (possibly
null
).
public CategoryToolTipGenerator getToolTipGenerator()
Returns the tool tip generator that will be used for ALL items in the dataset (the "layer 0" generator).
- Specified by:
- getToolTipGenerator in interface CategoryItemRenderer
- Returns:
- A tool tip generator (possibly
null
).
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.
- Specified by:
- getToolTipGenerator in interface CategoryItemRenderer
- Parameters:
row
- the row index (zero-based).column
- the column index (zero-based).
- Returns:
- The generator (possibly
null
).
public int hashCode()
Returns a hash code for the renderer.
- Overrides:
- hashCode in interface AbstractRenderer
- Returns:
- The hash code.
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).
- Specified by:
- initialise in interface CategoryItemRenderer
- 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.
public void setBaseItemLabelGenerator(CategoryItemLabelGenerator generator)
Sets the base item label generator and sends aRendererChangeEvent
to all registered listeners.
- Specified by:
- setBaseItemLabelGenerator in interface CategoryItemRenderer
- Parameters:
generator
- the generator (null
permitted).
- See Also:
getBaseItemLabelGenerator()
public void setBaseItemURLGenerator(CategoryURLGenerator generator)
Sets the base item URL generator.
- Specified by:
- setBaseItemURLGenerator in interface CategoryItemRenderer
- Parameters:
generator
- the item URL generator.
- See Also:
getBaseItemURLGenerator()
public void setBaseToolTipGenerator(CategoryToolTipGenerator generator)
Sets the base tool tip generator and sends aRendererChangeEvent
to all registered listeners.
- Specified by:
- setBaseToolTipGenerator in interface CategoryItemRenderer
- Parameters:
generator
- the generator (null
permitted).
- See Also:
getBaseToolTipGenerator()
public void setItemLabelGenerator(CategoryItemLabelGenerator generator)
Sets the item label generator for ALL series and sends aRendererChangeEvent
to all registered listeners.
- Specified by:
- setItemLabelGenerator in interface CategoryItemRenderer
- Parameters:
generator
- the generator (null
permitted).
public void setItemURLGenerator(CategoryURLGenerator generator)
Sets the item URL generator for ALL series.
- Specified by:
- setItemURLGenerator in interface CategoryItemRenderer
- Parameters:
generator
- the generator.
public void setLegendItemLabelGenerator(CategorySeriesLabelGenerator generator)
Sets the legend item label generator and sends aRendererChangeEvent
to all registered listeners.
- Parameters:
generator
- the generator (null
not permitted).
- See Also:
getLegendItemLabelGenerator()
public void setLegendItemToolTipGenerator(CategorySeriesLabelGenerator generator)
Sets the legend item tool tip generator and sends aRendererChangeEvent
to all registered listeners.
- Parameters:
generator
- the generator (null
permitted).
public void setLegendItemURLGenerator(CategorySeriesLabelGenerator generator)
Sets the legend item URL generator and sends aRendererChangeEvent
to all registered listeners.
- Parameters:
generator
- the generator (null
permitted).
- See Also:
getLegendItemURLGenerator()
public void setPlot(CategoryPlot plot)
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:
- setPlot in interface CategoryItemRenderer
- Parameters:
plot
- the plot (null
not permitted).
- See Also:
getPlot()
public void setSeriesItemLabelGenerator(int series, CategoryItemLabelGenerator generator)
Sets the item label generator for a series and sends aRendererChangeEvent
to all registered listeners.
- Specified by:
- setSeriesItemLabelGenerator in interface CategoryItemRenderer
- Parameters:
series
- the series index (zero based).generator
- the generator (null
permitted).
- See Also:
getSeriesItemLabelGenerator(int)
public void setSeriesItemURLGenerator(int series, CategoryURLGenerator generator)
Sets the URL generator for a series.
- Specified by:
- setSeriesItemURLGenerator in interface CategoryItemRenderer
- Parameters:
series
- the series index (zero based).generator
- the generator.
- See Also:
getSeriesItemURLGenerator(int)
public void setSeriesToolTipGenerator(int series, CategoryToolTipGenerator generator)
Sets the tool tip generator for a series and sends aRendererChangeEvent
to all registered listeners.
- Specified by:
- setSeriesToolTipGenerator in interface CategoryItemRenderer
- Parameters:
series
- the series index (zero-based).generator
- the generator (null
permitted).
- See Also:
getSeriesToolTipGenerator(int)
public void setToolTipGenerator(CategoryToolTipGenerator generator)
Sets the tool tip generator for ALL series and sends aRendererChangeEvent
to all registered listeners.
- Specified by:
- setToolTipGenerator in interface CategoryItemRenderer
- Parameters:
generator
- the generator (null
permitted).
- See Also:
getToolTipGenerator()