org.jfree.chart.renderer
Interface XYItemRenderer

All Known Implementing Classes:
AbstractXYItemRenderer, AreaXYRenderer, CandlestickRenderer, HighLowRenderer, SignalRenderer, StandardXYItemRenderer, WindItemRenderer, XYAreaRenderer, XYBarRenderer, XYBoxAndWhiskerRenderer, XYBubbleRenderer, XYDifferenceRenderer, XYDotRenderer, XYStepAreaRenderer, XYStepRenderer, YIntervalRenderer

public interface XYItemRenderer

Interface for rendering the visual representation of a single (x, y) item on an XYPlot.

To support cloning charts, it is recommended that renderers implement both the Cloneable and PublicCloneable interfaces.

Author:
David Gilbert

Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a property change listener to the renderer.
 void drawDomainGridLine(java.awt.Graphics2D g2, XYPlot plot, ValueAxis axis, java.awt.geom.Rectangle2D dataArea, double value)
          Draws a grid line against the domain axis.
 void drawDomainMarker(java.awt.Graphics2D g2, XYPlot plot, ValueAxis axis, Marker marker, java.awt.geom.Rectangle2D dataArea)
          Draws a vertical line on the chart to represent a 'range marker'.
 void drawItem(java.awt.Graphics2D g2, XYItemRendererState state, java.awt.geom.Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairInfo crosshairInfo, int pass)
          Called for each item to be plotted.
 void drawRangeGridLine(java.awt.Graphics2D g2, XYPlot plot, ValueAxis axis, java.awt.geom.Rectangle2D dataArea, double value)
          Draws a grid line against the range axis.
 void drawRangeMarker(java.awt.Graphics2D g2, XYPlot plot, ValueAxis axis, Marker marker, java.awt.geom.Rectangle2D dataArea)
          Draws a horizontal line across the chart to represent a 'range marker'.
 void fillDomainGridBand(java.awt.Graphics2D g2, XYPlot plot, ValueAxis axis, java.awt.geom.Rectangle2D dataArea, double start, double end)
          Fills a band between two values on the axis.
 void fillRangeGridBand(java.awt.Graphics2D g2, XYPlot plot, ValueAxis axis, java.awt.geom.Rectangle2D dataArea, double start, double end)
          Fills a band between two values on the range axis.
 java.awt.Stroke getBaseStroke()
          Returns the base stroke.
 java.awt.Paint getItemOutlinePaint(int series, int item)
          Returns the paint used to outline an item.
 java.awt.Paint getItemPaint(int series, int item)
          Returns the paint used to fill an item.
 java.awt.Shape getItemShape(int series, int item)
          Returns the shape for an item.
 java.awt.Stroke getItemStroke(int series, int item)
          Returns the stroke for an item.
 LegendItem getLegendItem(int datasetIndex, int series)
          Returns a legend item for a series from a dataset.
 int getPassCount()
          Returns the number of passes through the data required by the renderer.
 XYPlot getPlot()
          Returns the plot that this renderer has been assigned to.
 RangeType getRangeType()
          Returns the range type for the renderer.
 java.awt.Paint getSeriesOutlinePaint(int series)
          Returns the paint used to outline items in a series.
 java.awt.Paint getSeriesPaint(int series)
          Returns the paint used to fill items in a series.
 java.awt.Shape getSeriesShape(int series)
          Returns the shape for a series.
 java.awt.Stroke getSeriesStroke(int series)
          Returns the stroke for a series.
 XYToolTipGenerator getToolTipGenerator()
          Returns the tool tip generator for the renderer (possibly null).
 XYURLGenerator getURLGenerator()
          Returns the URL generator for HTML image maps.
 XYItemRendererState initialise(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info)
          Initialises the renderer then returns the number of 'passes' through the data that the renderer will require (usually just one).
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a property change listener from the renderer.
 void setBaseStroke(java.awt.Stroke stroke)
          Sets the base stroke.
 void setPlot(XYPlot plot)
          Sets the plot that this renderer is assigned to.
 void setSeriesPaint(int series, java.awt.Paint paint)
          Sets the paint for a series in the primary dataset.
 void setSeriesStroke(int series, java.awt.Stroke stroke)
          Sets the stroke for a series in the primary dataset.
 void setStroke(java.awt.Stroke stroke)
          Sets the stroke for ALL series (optional).
 void setToolTipGenerator(XYToolTipGenerator toolTipGenerator)
          Sets the tool tip generator for the renderer.
 void setURLGenerator(XYURLGenerator urlGenerator)
          Sets the URL generator for HTML image maps.
 

Method Detail

initialise

public XYItemRendererState initialise(java.awt.Graphics2D g2,
                                      java.awt.geom.Rectangle2D dataArea,
                                      XYPlot plot,
                                      XYDataset data,
                                      PlotRenderingInfo info)
Initialises the renderer then returns the number of 'passes' through the data that the renderer will require (usually just one). 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 number of passes the renderer requires.

getPassCount

public int getPassCount()
Returns the number of passes through the data required by the renderer.

Returns:
The pass count.

getToolTipGenerator

public XYToolTipGenerator getToolTipGenerator()
Returns the tool tip generator for the renderer (possibly null).

Returns:
the tool tip generator.

setToolTipGenerator

public void setToolTipGenerator(XYToolTipGenerator toolTipGenerator)
Sets the tool tip generator for the renderer.

Parameters:
toolTipGenerator - the tool tip generator (null permitted).

getURLGenerator

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

Returns:
the URL generator (possibly null).

setURLGenerator

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

Parameters:
urlGenerator - the URL generator (null permitted).

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a property change listener to the renderer.

Parameters:
listener - the listener.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a property change listener from the renderer.

Parameters:
listener - the listener.

getItemPaint

public java.awt.Paint getItemPaint(int series,
                                   int item)
Returns the paint used to fill an item.

Parameters:
series - the series index (zero-based).
item - the item index (zero-based).
Returns:
The paint.

getSeriesPaint

public java.awt.Paint getSeriesPaint(int series)
Returns the paint used to fill items in a series.

Parameters:
series - the series index (zero-based).
Returns:
The paint.

setSeriesPaint

public void setSeriesPaint(int series,
                           java.awt.Paint paint)
Sets the paint for a series in the primary dataset.

Parameters:
series - the series index (zero-based).
paint - the paint.

getItemOutlinePaint

public java.awt.Paint getItemOutlinePaint(int series,
                                          int item)
Returns the paint used to outline an item.

Parameters:
series - the series index (zero-based).
item - the item index (zero-based).
Returns:
The paint.

getSeriesOutlinePaint

public java.awt.Paint getSeriesOutlinePaint(int series)
Returns the paint used to outline items in a series.

Parameters:
series - the series index (zero-based).
Returns:
The paint.

getItemStroke

public java.awt.Stroke getItemStroke(int series,
                                     int item)
Returns the stroke for an item.

Parameters:
series - the series index (zero-based).
item - the item index (zero-based).
Returns:
The stroke.

getSeriesStroke

public java.awt.Stroke getSeriesStroke(int series)
Returns the stroke for a series.

Parameters:
series - the series index (zero-based).
Returns:
The stroke.

setStroke

public void setStroke(java.awt.Stroke stroke)
Sets the stroke for ALL series (optional).

Parameters:
stroke - the stroke.

setSeriesStroke

public void setSeriesStroke(int series,
                            java.awt.Stroke stroke)
Sets the stroke for a series in the primary dataset.

Parameters:
series - the series index (zero-based).
stroke - the stroke.

getBaseStroke

public java.awt.Stroke getBaseStroke()
Returns the base stroke.

Returns:
The stroke.

setBaseStroke

public void setBaseStroke(java.awt.Stroke stroke)
Sets the base stroke.

Parameters:
stroke - the stroke.

getItemShape

public java.awt.Shape getItemShape(int series,
                                   int item)
Returns the shape for an item.

Parameters:
series - the series index (zero-based).
item - the item index (zero-based).
Returns:
The shape.

getSeriesShape

public java.awt.Shape getSeriesShape(int series)
Returns the shape for a series.

Parameters:
series - the series index (zero-based).
Returns:
The shape.

drawItem

public void drawItem(java.awt.Graphics2D g2,
                     XYItemRendererState state,
                     java.awt.geom.Rectangle2D dataArea,
                     PlotRenderingInfo info,
                     XYPlot plot,
                     ValueAxis domainAxis,
                     ValueAxis rangeAxis,
                     XYDataset dataset,
                     int series,
                     int item,
                     CrosshairInfo crosshairInfo,
                     int pass)
Called for each item to be plotted.

The XYPlot can make multiple passes through the dataset, depending on the value returned by the renderer's initialise(java.awt.Graphics2D, java.awt.geom.Rectangle2D, org.jfree.chart.plot.XYPlot, org.jfree.data.XYDataset, org.jfree.chart.plot.PlotRenderingInfo) method.

Parameters:
g2 - the graphics device.
state - the renderer state.
dataArea - the area within which the data is being rendered.
info - collects drawing info.
plot - the plot (can be used to obtain standard color information etc).
domainAxis - the domain axis.
rangeAxis - the range axis.
dataset - the dataset.
series - the series index (zero-based).
item - the item index (zero-based).
crosshairInfo - collects information about crosshairs.
pass - the pass index.

getLegendItem

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

Parameters:
datasetIndex - the dataset index.
series - the series (zero-based index).
Returns:
the legend item.

fillDomainGridBand

public void fillDomainGridBand(java.awt.Graphics2D g2,
                               XYPlot plot,
                               ValueAxis axis,
                               java.awt.geom.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.

fillRangeGridBand

public void fillRangeGridBand(java.awt.Graphics2D g2,
                              XYPlot plot,
                              ValueAxis axis,
                              java.awt.geom.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.

drawDomainGridLine

public void drawDomainGridLine(java.awt.Graphics2D g2,
                               XYPlot plot,
                               ValueAxis axis,
                               java.awt.geom.Rectangle2D dataArea,
                               double value)
Draws a grid line against 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.

drawRangeGridLine

public void drawRangeGridLine(java.awt.Graphics2D g2,
                              XYPlot plot,
                              ValueAxis axis,
                              java.awt.geom.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.

drawDomainMarker

public void drawDomainMarker(java.awt.Graphics2D g2,
                             XYPlot plot,
                             ValueAxis axis,
                             Marker marker,
                             java.awt.geom.Rectangle2D dataArea)
Draws a vertical line on the chart to represent a 'range marker'.

Parameters:
g2 - the graphics device.
plot - the plot.
axis - the value axis.
marker - the marker line.
dataArea - the axis data area.

drawRangeMarker

public void drawRangeMarker(java.awt.Graphics2D g2,
                            XYPlot plot,
                            ValueAxis axis,
                            Marker marker,
                            java.awt.geom.Rectangle2D dataArea)
Draws a horizontal line across the chart to represent a 'range marker'.

Parameters:
g2 - the graphics device.
plot - the plot.
axis - the value axis.
marker - the marker line.
dataArea - the axis data area.

getPlot

public XYPlot getPlot()
Returns the plot that this renderer has been assigned to.

Returns:
the plot.

setPlot

public void setPlot(XYPlot plot)
Sets the plot that this renderer is assigned to.

This method will be called by the plot class...you do not need to call it yourself.

Parameters:
plot - the plot.

getRangeType

public RangeType getRangeType()
Returns the range type for the renderer. The plot needs to know this information in order to determine an appropriate axis range (when the axis auto-range calculation is on).

Two types are recognised:

If the data values are stacked, this affects the axis range required to display all the data items.

Returns:
a flag indicating whether or not the data values are stacked.