public abstract class

AbstractXYItemRenderer

extends AbstractRenderer
implements Serializable Cloneable XYItemRenderer
java.lang.Object
   ↳ org.jfree.chart.renderer.AbstractRenderer
     ↳ org.jfree.chart.renderer.xy.AbstractXYItemRenderer
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

A base class that can be used to create new XYItemRenderer implementations.

Summary

[Expand]
Inherited Fields
From class org.jfree.chart.renderer.AbstractRenderer
Protected Constructors
AbstractXYItemRenderer()
Creates a renderer where the tooltip generator and the URL generator are both null.
Public Methods
void addAnnotation(XYAnnotation annotation, Layer layer)
Adds an annotation to the specified layer and sends a RendererChangeEvent to all registered listeners.
void addAnnotation(XYAnnotation annotation)
Adds an annotation and sends a RendererChangeEvent to all registered listeners.
void drawAnnotations(Graphics2D g2, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, Layer layer, PlotRenderingInfo info)
Draws all the annotations for the specified layer.
void drawDomainGridLine(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double value)
Draws a grid line against the range axis.
void drawDomainLine(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double value, Paint paint, Stroke stroke)
Draws a line perpendicular to the domain axis.
void drawDomainMarker(Graphics2D g2, XYPlot plot, ValueAxis domainAxis, Marker marker, Rectangle2D dataArea)
Draws a vertical line on the chart to represent a 'range marker'.
void drawRangeLine(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double value, Paint paint, Stroke stroke)
Draws a line perpendicular to the range axis.
void drawRangeMarker(Graphics2D g2, XYPlot plot, ValueAxis rangeAxis, Marker marker, Rectangle2D dataArea)
Draws a horizontal line across the chart to represent a 'range marker'.
boolean equals(Object obj)
Tests this renderer for equality with another object.
void fillDomainGridBand(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double start, double end)
Fills a band between two values on the axis.
void fillRangeGridBand(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double start, double end)
Fills a band between two values on the range axis.
Range findDomainBounds(XYDataset dataset)
Returns the lower and upper bounds (range) of the x-values in the specified dataset.
Range findRangeBounds(XYDataset dataset)
Returns the range of values the renderer requires to display all the items from the specified dataset.
Collection getAnnotations()
Returns a collection of the annotations that are assigned to the renderer.
XYItemLabelGenerator getBaseItemLabelGenerator()
Returns the base item label generator.
XYToolTipGenerator getBaseToolTipGenerator()
Returns the base tool tip generator.
DrawingSupplier getDrawingSupplier()
Returns the drawing supplier from the plot.
XYItemLabelGenerator getItemLabelGenerator(int series, int item)
Returns the label generator for a data item.
XYItemLabelGenerator getItemLabelGenerator()
This method is deprecated. As of version 1.0.6, this override setting should not be used. You can use the base setting instead (getBaseItemLabelGenerator()).
LegendItem getLegendItem(int datasetIndex, int series)
Returns a default legend item for the specified series.
XYSeriesLabelGenerator getLegendItemLabelGenerator()
Returns the legend item label generator.
XYSeriesLabelGenerator getLegendItemToolTipGenerator()
Returns the legend item tool tip generator.
XYSeriesLabelGenerator getLegendItemURLGenerator()
Returns the legend item URL generator.
LegendItemCollection getLegendItems()
Returns a (possibly empty) collection of legend items for the series that this renderer is responsible for drawing.
int getPassCount()
Returns the number of passes through the data that the renderer requires in order to draw the chart.
XYPlot getPlot()
Returns the plot that the renderer is assigned to.
XYItemLabelGenerator getSeriesItemLabelGenerator(int series)
Returns the item label generator for a series.
XYToolTipGenerator getSeriesToolTipGenerator(int series)
Returns the tool tip generator for a series.
XYToolTipGenerator getToolTipGenerator()
This method is deprecated. As of version 1.0.6, this override setting should not be used. You can use the base setting instead (getBaseToolTipGenerator()).
XYToolTipGenerator getToolTipGenerator(int series, int item)
Returns the tool tip generator for a data item.
XYURLGenerator getURLGenerator()
Returns the URL generator for HTML image maps.
XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info)
Initialises the renderer and returns a state object that should be passed to all subsequent calls to the drawItem() method.
static boolean isPointInRect(Rectangle2D rect, double x, double y)
Returns true if the specified point (x, y) falls within or on the boundary of the specified rectangle.
boolean removeAnnotation(XYAnnotation annotation)
Removes the specified annotation and sends a RendererChangeEvent to all registered listeners.
void removeAnnotations()
Removes all annotations and sends a RendererChangeEvent to all registered listeners.
void setBaseItemLabelGenerator(XYItemLabelGenerator generator)
Sets the base item label generator and sends a RendererChangeEvent to all registered listeners.
void setBaseToolTipGenerator(XYToolTipGenerator generator)
Sets the base tool tip generator and sends a RendererChangeEvent to all registered listeners.
void setItemLabelGenerator(XYItemLabelGenerator generator)
This method is deprecated. As of version 1.0.6, this override setting should not be used. You can use the base setting instead (setBaseItemLabelGenerator(XYItemLabelGenerator)).
void setLegendItemLabelGenerator(XYSeriesLabelGenerator generator)
Sets the legend item label generator and sends a RendererChangeEvent to all registered listeners.
void setLegendItemToolTipGenerator(XYSeriesLabelGenerator generator)
Sets the legend item tool tip generator and sends a RendererChangeEvent to all registered listeners.
void setLegendItemURLGenerator(XYSeriesLabelGenerator generator)
Sets the legend item URL generator and sends a RendererChangeEvent to all registered listeners.
void setPlot(XYPlot plot)
Sets the plot that the renderer is assigned to.
void setSeriesItemLabelGenerator(int series, XYItemLabelGenerator generator)
Sets the item label generator for a series and sends a RendererChangeEvent to all registered listeners.
void setSeriesToolTipGenerator(int series, XYToolTipGenerator generator)
Sets the tool tip generator for a series and sends a RendererChangeEvent to all registered listeners.
void setToolTipGenerator(XYToolTipGenerator generator)
This method is deprecated. As of version 1.0.6, this override setting should not be used. You can use the base setting instead (setBaseToolTipGenerator(XYToolTipGenerator)).
void setURLGenerator(XYURLGenerator urlGenerator)
Sets the URL generator for HTML image maps and sends a RendererChangeEvent to all registered listeners.
Protected Methods
void addEntity(EntityCollection entities, Shape area, XYDataset dataset, int series, int item, double entityX, double entityY)
Adds an entity to the collection.
Point2D calculateDomainMarkerTextAnchorPoint(Graphics2D g2, PlotOrientation orientation, Rectangle2D dataArea, Rectangle2D markerArea, RectangleInsets markerOffset, LengthAdjustmentType labelOffsetType, RectangleAnchor anchor)
Calculates the (x, y) coordinates for drawing a marker label.
Object clone()
Returns a clone of the renderer.
void drawItemLabel(Graphics2D g2, PlotOrientation orientation, XYDataset dataset, int series, int item, double x, double y, boolean negative)
Draws an item label.
Range findDomainBounds(XYDataset dataset, boolean includeInterval)
Returns the lower and upper bounds (range) of the x-values in the specified dataset.
Range findRangeBounds(XYDataset dataset, boolean includeInterval)
Returns the range of values the renderer requires to display all the items from the specified dataset.
void updateCrosshairValues(CrosshairState crosshairState, double x, double y, int domainAxisIndex, int rangeAxisIndex, double transX, double transY, PlotOrientation orientation)
Considers the current (x, y) coordinate and updates the crosshair point if it meets the criteria (usually means the (x, y) coordinate is the closest to the anchor point so far).
void updateCrosshairValues(CrosshairState crosshairState, double x, double y, double transX, double transY, PlotOrientation orientation)
[Expand]
Inherited Methods
From class org.jfree.chart.renderer.AbstractRenderer
From class java.lang.Object
From interface org.jfree.chart.LegendItemSource
From interface org.jfree.chart.renderer.xy.XYItemRenderer

Protected Constructors

protected AbstractXYItemRenderer ()

Creates a renderer where the tooltip generator and the URL generator are both null.

Public Methods

public void addAnnotation (XYAnnotation annotation, Layer layer)

Adds an annotation to the specified layer and sends a RendererChangeEvent to all registered listeners.

Parameters
annotation the annotation (null not permitted).
layer the layer (null not permitted).

public void addAnnotation (XYAnnotation annotation)

Adds an annotation and sends a RendererChangeEvent to all registered listeners. The annotation is added to the foreground layer.

Parameters
annotation the annotation (null not permitted).

public void drawAnnotations (Graphics2D g2, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, Layer layer, PlotRenderingInfo info)

Draws all the annotations for the specified layer.

Parameters
g2 the graphics device.
dataArea the data area.
domainAxis the domain axis.
rangeAxis the range axis.
layer the layer.
info the plot rendering info.

public void drawDomainGridLine (Graphics2D g2, XYPlot 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.

public void drawDomainLine (Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double value, Paint paint, Stroke stroke)

Draws a line perpendicular to the domain 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.
paint the paint (null not permitted).
stroke the stroke (null not permitted).

public void drawDomainMarker (Graphics2D g2, XYPlot plot, ValueAxis domainAxis, Marker marker, Rectangle2D dataArea)

Draws a vertical line on the chart to represent a 'range marker'.

Parameters
g2 the graphics device.
plot the plot.
domainAxis the domain axis.
marker the marker line.
dataArea the axis data area.

public void drawRangeLine (Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double value, Paint paint, Stroke stroke)

Draws a line perpendicular to 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.
paint the paint.
stroke the stroke.

public void drawRangeMarker (Graphics2D g2, XYPlot plot, ValueAxis rangeAxis, Marker marker, Rectangle2D dataArea)

Draws a horizontal line across the chart to represent a 'range marker'.

Parameters
g2 the graphics device.
plot the plot.
rangeAxis the range axis.
marker the marker line.
dataArea the axis data area.

public boolean equals (Object obj)

Tests this renderer for equality with another object.

Parameters
obj the object (null permitted).
Returns
  • true or false.

public void fillDomainGridBand (Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double start, double end)

Fills a band between two values on the axis. This can be used to color bands between the grid lines.

Parameters
g2 the graphics device.
plot the plot.
axis the domain axis.
dataArea the data area.
start the start value.
end the end value.

public void fillRangeGridBand (Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double start, double end)

Fills a band between two values on the range axis. This can be used to color bands between the grid lines.

Parameters
g2 the graphics device.
plot the plot.
axis the range axis.
dataArea the data area.
start the start value.
end the end value.

public Range findDomainBounds (XYDataset dataset)

Returns the lower and upper bounds (range) of the x-values in the specified dataset.

Parameters
dataset the dataset (null permitted).
Returns
  • The range (null if the dataset is null or empty).

public Range findRangeBounds (XYDataset 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 (null if the dataset is null or empty).

public Collection getAnnotations ()

Returns a collection of the annotations that are assigned to the renderer.

Returns
  • A collection of annotations (possibly empty but never null).

public XYItemLabelGenerator getBaseItemLabelGenerator ()

Returns the base item label generator.

Returns
  • The generator (possibly null).

public XYToolTipGenerator getBaseToolTipGenerator ()

Returns the base tool tip generator.

Returns
  • The generator (possibly null).

public DrawingSupplier getDrawingSupplier ()

Returns the drawing supplier from the plot.

Returns
  • The drawing supplier (possibly null).

public XYItemLabelGenerator getItemLabelGenerator (int series, int item)

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

Parameters
series the series index (zero based).
item the item index (zero based).
Returns
  • The generator (possibly null).

public XYItemLabelGenerator getItemLabelGenerator ()

This method is deprecated.
As of version 1.0.6, this override setting should not be used. You can use the base setting instead (getBaseItemLabelGenerator()).

Returns the item label generator override.

Returns
  • The generator (possibly null).

public LegendItem getLegendItem (int datasetIndex, int series)

Returns a default legend item for the specified series. Subclasses should override this method to generate customised items.

Parameters
datasetIndex the dataset index (zero-based).
series the series index (zero-based).
Returns
  • A legend item for the series.

public XYSeriesLabelGenerator getLegendItemLabelGenerator ()

Returns the legend item label generator.

Returns
  • The label generator (never null).

public XYSeriesLabelGenerator getLegendItemToolTipGenerator ()

Returns the legend item tool tip generator.

Returns
  • The tool tip generator (possibly null).

public XYSeriesLabelGenerator 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.

Returns
  • The legend item collection (never null).

public int getPassCount ()

Returns the number of passes through the data that the renderer requires in order to draw the chart. Most charts will require a single pass, but some require two passes.

Returns
  • The pass count.

public XYPlot getPlot ()

Returns the plot that the renderer is assigned to.

Returns
  • The plot (possibly null).

public XYItemLabelGenerator getSeriesItemLabelGenerator (int series)

Returns the item label generator for a series.

Parameters
series the series index (zero based).
Returns
  • The generator (possibly null).

public XYToolTipGenerator getSeriesToolTipGenerator (int series)

Returns the tool tip generator for a series.

Parameters
series the series index (zero based).
Returns
  • The generator (possibly null).

public XYToolTipGenerator getToolTipGenerator ()

This method is deprecated.
As of version 1.0.6, this override setting should not be used. You can use the base setting instead (getBaseToolTipGenerator()).

Returns the override tool tip generator.

Returns
  • The tool tip generator (possible null).

public XYToolTipGenerator getToolTipGenerator (int series, int item)

Returns the tool tip generator for a data item. If, for some reason, you want a different generator for individual items, you can override this method.

Parameters
series the series index (zero based).
item the item index (zero based).
Returns
  • The generator (possibly null).

public XYURLGenerator getURLGenerator ()

Returns the URL generator for HTML image maps.

Returns
  • The URL generator (possibly null).

public XYItemRendererState initialise (Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info)

Initialises the renderer and returns a state object that should be passed to all subsequent calls to the drawItem() method.

This method will be called before the first item is rendered, giving the renderer an opportunity to initialise any state information it wants to maintain. The renderer can do nothing if it chooses.

Parameters
g2 the graphics device.
dataArea the area inside the axes.
plot the plot.
data the data.
info an optional info collection object to return data back to the caller.
Returns
  • The renderer state (never null).

public static boolean isPointInRect (Rectangle2D rect, double x, double y)

Returns true if the specified point (x, y) falls within or on the boundary of the specified rectangle.

Parameters
rect the rectangle (null not permitted).
x the x-coordinate.
y the y-coordinate.
Returns
  • A boolean.

public boolean removeAnnotation (XYAnnotation annotation)

Removes the specified annotation and sends a RendererChangeEvent to all registered listeners.

Parameters
annotation the annotation to remove (null not permitted).
Returns
  • A boolean to indicate whether or not the annotation was successfully removed.

public void removeAnnotations ()

Removes all annotations and sends a RendererChangeEvent to all registered listeners.

public void setBaseItemLabelGenerator (XYItemLabelGenerator generator)

Sets the base item label generator and sends a RendererChangeEvent to all registered listeners.

Parameters
generator the generator (null permitted).

public void setBaseToolTipGenerator (XYToolTipGenerator generator)

Sets the base tool tip generator and sends a RendererChangeEvent to all registered listeners.

Parameters
generator the generator (null permitted).

public void setItemLabelGenerator (XYItemLabelGenerator generator)

This method is deprecated.
As of version 1.0.6, this override setting should not be used. You can use the base setting instead (setBaseItemLabelGenerator(XYItemLabelGenerator)).

Sets the item label generator for ALL series and sends a RendererChangeEvent to all registered listeners.

Parameters
generator the generator (null permitted).

public void setLegendItemLabelGenerator (XYSeriesLabelGenerator generator)

Sets the legend item label generator and sends a RendererChangeEvent to all registered listeners.

Parameters
generator the generator (null not permitted).

public void setLegendItemToolTipGenerator (XYSeriesLabelGenerator generator)

Sets the legend item tool tip generator and sends a RendererChangeEvent to all registered listeners.

Parameters
generator the generator (null permitted).

public void setLegendItemURLGenerator (XYSeriesLabelGenerator generator)

Sets the legend item URL generator and sends a RendererChangeEvent to all registered listeners.

Parameters
generator the generator (null permitted).

public void setPlot (XYPlot plot)

Sets the plot that the renderer is assigned to.

Parameters
plot the plot (null permitted).

public void setSeriesItemLabelGenerator (int series, XYItemLabelGenerator 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).

public void setSeriesToolTipGenerator (int series, XYToolTipGenerator 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).

public void setToolTipGenerator (XYToolTipGenerator generator)

This method is deprecated.
As of version 1.0.6, this override setting should not be used. You can use the base setting instead (setBaseToolTipGenerator(XYToolTipGenerator)).

Sets the tool tip generator for ALL series and sends a RendererChangeEvent to all registered listeners.

Parameters
generator the generator (null permitted).

public void setURLGenerator (XYURLGenerator urlGenerator)

Sets the URL generator for HTML image maps and sends a RendererChangeEvent to all registered listeners.

Parameters
urlGenerator the URL generator (null permitted).

Protected Methods

protected void addEntity (EntityCollection entities, Shape area, XYDataset dataset, int series, int item, double entityX, double entityY)

Adds an entity to the collection.

Parameters
entities the entity collection being populated.
area the entity area (if null a default will be used).
dataset the dataset.
series the series.
item the item.
entityX the entity's center x-coordinate in user space (only used if area is null).
entityY the entity's center y-coordinate in user space (only used if area is null).

protected Point2D calculateDomainMarkerTextAnchorPoint (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 area.
markerOffset the marker label offset.
labelOffsetType the label offset type.
anchor the label anchor.
Returns
  • The coordinates for drawing the marker label.

protected Object clone ()

Returns a clone of the renderer.

Returns
  • A clone.
Throws
CloneNotSupportedException if the renderer does not support cloning.

protected void drawItemLabel (Graphics2D g2, PlotOrientation orientation, XYDataset dataset, int series, int item, double x, double y, boolean negative)

Draws an item label.

Parameters
g2 the graphics device.
orientation the orientation.
dataset the dataset.
series the series index (zero-based).
item the item index (zero-based).
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).

protected Range findDomainBounds (XYDataset dataset, boolean includeInterval)

Returns the lower and upper bounds (range) of the x-values in the specified dataset.

Parameters
dataset the dataset (null permitted).
Returns
  • The range (null if the dataset is null or empty).

protected Range findRangeBounds (XYDataset dataset, boolean includeInterval)

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 (null if the dataset is null or empty).

protected void updateCrosshairValues (CrosshairState crosshairState, double x, double y, int domainAxisIndex, int rangeAxisIndex, double transX, double transY, PlotOrientation orientation)

Considers the current (x, y) coordinate and updates the crosshair point if it meets the criteria (usually means the (x, y) coordinate is the closest to the anchor point so far).

Parameters
crosshairState the crosshair state (null permitted, but the method does nothing in that case).
x the x-value (in data space).
y the y-value (in data space).
domainAxisIndex the index of the domain axis for the point.
rangeAxisIndex the index of the range axis for the point.
transX the x-value translated to Java2D space.
transY the y-value translated to Java2D space.
orientation the plot orientation (null not permitted).

protected void updateCrosshairValues (CrosshairState crosshairState, double x, double y, double transX, double transY, PlotOrientation orientation)

This method is deprecated.
Use updateCrosshairValues(CrosshairState, double, double, int, int, double, double, PlotOrientation) -- see bug report 1086307.

Considers the current (x, y) coordinate and updates the crosshair point if it meets the criteria (usually means the (x, y) coordinate is the closest to the anchor point so far).

Parameters
crosshairState the crosshair state (null permitted, but the method does nothing in that case).
x the x-value (in data space).
y the y-value (in data space).
transX the x-value translated to Java2D space.
transY the y-value translated to Java2D space.
orientation the plot orientation (null not permitted).