org.jfree.chart.renderer
Class StandardXYItemRenderer

java.lang.Object
  |
  +--org.jfree.chart.renderer.AbstractRenderer
        |
        +--org.jfree.chart.renderer.AbstractXYItemRenderer
              |
              +--org.jfree.chart.renderer.StandardXYItemRenderer
All Implemented Interfaces:
Renderer, java.io.Serializable, XYItemRenderer
Direct Known Subclasses:
ReverseXYItemRenderer

public class StandardXYItemRenderer
extends AbstractXYItemRenderer
implements XYItemRenderer, java.io.Serializable

Standard item renderer for an XYPlot. This class can draw (a) shapes at each point, or (b) lines between points, or (c) both shapes and lines.

Author:
David Gilbert
See Also:
Serialized Form

Field Summary
static int DISCONTINUOUS
          Constant for the type of rendering (discontinuous lines).
static int DISCONTINUOUS_LINES
          Constant for the type of rendering (discontinuous lines).
static int IMAGES
          Constant for the type of rendering (images only).
static int LINES
          Constant for the type of rendering (lines only).
static int SHAPES
          Constant for the type of rendering (shapes only).
static int SHAPES_AND_LINES
          Constant for the type of rendering (shapes and lines).
 
Fields inherited from class org.jfree.chart.renderer.AbstractRenderer
DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, DEFAULT_PAINT, DEFAULT_SHAPE, DEFAULT_STROKE
 
Constructor Summary
StandardXYItemRenderer()
          Constructs a new renderer.
StandardXYItemRenderer(int type)
          Constructs a new renderer.
StandardXYItemRenderer(int type, XYToolTipGenerator toolTipGenerator)
          Constructs a new renderer.
StandardXYItemRenderer(int type, XYToolTipGenerator toolTipGenerator, XYURLGenerator urlGenerator)
          Constructs a new renderer.
 
Method Summary
 void drawItem(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, ChartRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int datasetIndex, int series, int item, CrosshairInfo crosshairInfo)
          Draws the visual representation of a single data item.
 boolean equals(java.lang.Object obj)
          Tests this renderer for equality with another object.
 boolean getDefaultShapeFilled()
          Returns the default value returned by the isShapeFilled(...) method.
 double getGapThreshold()
          Returns the gap threshold for discontinuous lines.
protected  java.awt.Image getImage(Plot plot, int series, int item, double x, double y)
          Returns the image used to draw a single data item.
protected  java.awt.Point getImageHotspot(Plot plot, int series, int item, double x, double y, java.awt.Image image)
          Returns the hotspot of the image used to draw a single data item.
protected  java.awt.Paint getPaint(Plot plot, int series, int item, double x, double y)
          Returns the paint used to draw a single data item.
 boolean getPlotDiscontinuous()
          Returns true if lines should be discontinuous.
 boolean getPlotImages()
          Returns true if images are being plotted by the renderer.
 boolean getPlotLines()
          Returns true if lines are being plotted by the renderer.
 boolean getPlotShapes()
          Returns true if shapes are being plotted by the renderer.
protected  boolean isShapeFilled(Plot plot, int series, int item, double x, double y)
          Is used to determine if a shape is filled when drawn or not
 void setDefaultShapeFilled(boolean flag)
          Sets the default shape filled flag.
 void setGapThreshold(double t)
          Sets the gap threshold for discontinuous lines.
 void setPlotImages(boolean flag)
          Sets the flag that controls whether or not an image is drawn at each data point.
 void setPlotLines(boolean flag)
          Sets the flag that controls whether or not a line is plotted between each data point.
 void setPlotShapes(boolean flag)
          Sets the flag that controls whether or not a shape is plotted at each data point.
 
Methods inherited from class org.jfree.chart.renderer.AbstractXYItemRenderer
drawDomainGridLine, drawDomainMarker, drawRangeGridLine, drawRangeMarker, getLegendItem, getToolTipGenerator, getURLGenerator, initialise, setToolTipGenerator, setURLGenerator
 
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.XYItemRenderer
addPropertyChangeListener, drawDomainGridLine, drawDomainMarker, drawRangeGridLine, drawRangeMarker, getItemOutlinePaint, getItemPaint, getItemShape, getItemStroke, getLegendItem, getPlot, getSeriesOutlinePaint, getSeriesPaint, getSeriesShape, getSeriesStroke, getToolTipGenerator, getURLGenerator, initialise, removePropertyChangeListener, setDrawingSupplier, setPlot, setSeriesPaint, setSeriesPaint, setToolTipGenerator, setURLGenerator
 
Methods inherited from interface org.jfree.chart.renderer.Renderer
getDefaultOutlinePaint, getDefaultOutlineStroke, getDefaultPaint, getDefaultShape, getDefaultStroke, getDrawingSupplier, isOutlinePaintTableActive, isOutlineStrokeTableActive, isPaintTableActive, isShapeTableActive, isStrokeTableActive, setDefaultOutlinePaint, setDefaultOutlineStroke, setDefaultPaint, setDefaultShape, setDefaultStroke, setOutlinePaintTableActive, setOutlineStrokeTableActive, setPaintTableActive, setSeriesStroke, setSeriesStroke, setShapeTableActive, setStrokeTableActive
 

Field Detail

SHAPES

public static final int SHAPES
Constant for the type of rendering (shapes only).

See Also:
Constant Field Values

LINES

public static final int LINES
Constant for the type of rendering (lines only).

See Also:
Constant Field Values

SHAPES_AND_LINES

public static final int SHAPES_AND_LINES
Constant for the type of rendering (shapes and lines).

See Also:
Constant Field Values

IMAGES

public static final int IMAGES
Constant for the type of rendering (images only).

See Also:
Constant Field Values

DISCONTINUOUS

public static final int DISCONTINUOUS
Constant for the type of rendering (discontinuous lines).

See Also:
Constant Field Values

DISCONTINUOUS_LINES

public static final int DISCONTINUOUS_LINES
Constant for the type of rendering (discontinuous lines).

See Also:
Constant Field Values
Constructor Detail

StandardXYItemRenderer

public StandardXYItemRenderer()
Constructs a new renderer.


StandardXYItemRenderer

public StandardXYItemRenderer(int type)
Constructs a new renderer.

To specify the type of renderer, use one of the constants: SHAPES, LINES or SHAPES_AND_LINES.

Parameters:
type - the type.

StandardXYItemRenderer

public StandardXYItemRenderer(int type,
                              XYToolTipGenerator toolTipGenerator)
Constructs a new renderer.

To specify the type of renderer, use one of the constants: SHAPES, LINES or SHAPES_AND_LINES.

Parameters:
type - the type of renderer.
toolTipGenerator - the tooltip generator.

StandardXYItemRenderer

public StandardXYItemRenderer(int type,
                              XYToolTipGenerator toolTipGenerator,
                              XYURLGenerator urlGenerator)
Constructs a new renderer.

To specify the type of renderer, use one of the constants: SHAPES, LINES or SHAPES_AND_LINES.

Parameters:
type - the type of renderer.
toolTipGenerator - the tooltip generator.
urlGenerator - the URL generator.
Method Detail

getPlotShapes

public boolean getPlotShapes()
Returns true if shapes are being plotted by the renderer.

Returns:
true if shapes are being plotted by the renderer.

setPlotShapes

public void setPlotShapes(boolean flag)
Sets the flag that controls whether or not a shape is plotted at each data point.

Parameters:
flag - the flag.

getDefaultShapeFilled

public boolean getDefaultShapeFilled()
Returns the default value returned by the isShapeFilled(...) method.

The renderer will call isShapeFilled(...) to determine whether or not to fill a shape. Unless overridden, the isShapeFilled(...) method just returns the default shape filled flag.

Returns:
the flag.

setDefaultShapeFilled

public void setDefaultShapeFilled(boolean flag)
Sets the default shape filled flag.

Parameters:
flag - the flag.

getPlotLines

public boolean getPlotLines()
Returns true if lines are being plotted by the renderer.

Returns:
true if lines are being plotted by the renderer.

setPlotLines

public void setPlotLines(boolean flag)
Sets the flag that controls whether or not a line is plotted between each data point.

Parameters:
flag - the flag.

getGapThreshold

public double getGapThreshold()
Returns the gap threshold for discontinuous lines.

Returns:
the gap threshold.

setGapThreshold

public void setGapThreshold(double t)
Sets the gap threshold for discontinuous lines.

Parameters:
t - the threshold.

getPlotImages

public boolean getPlotImages()
Returns true if images are being plotted by the renderer.

Returns:
true if images are being plotted by the renderer.

setPlotImages

public void setPlotImages(boolean flag)
Sets the flag that controls whether or not an image is drawn at each data point.

Parameters:
flag - the flag.

getPlotDiscontinuous

public boolean getPlotDiscontinuous()
Returns true if lines should be discontinuous.

Returns:
true if images are being plotted by the renderer.

drawItem

public void drawItem(java.awt.Graphics2D g2,
                     java.awt.geom.Rectangle2D dataArea,
                     ChartRenderingInfo info,
                     XYPlot plot,
                     ValueAxis domainAxis,
                     ValueAxis rangeAxis,
                     XYDataset dataset,
                     int datasetIndex,
                     int series,
                     int item,
                     CrosshairInfo crosshairInfo)
Draws the visual representation of a single data item.

Specified by:
drawItem in interface XYItemRenderer
Parameters:
g2 - the graphics device.
dataArea - the area within which the data is being drawn.
info - collects information about the drawing.
plot - the plot (can be used to obtain standard color information etc).
domainAxis - the domain (horizontal) axis.
rangeAxis - the range (vertical) axis.
dataset - the dataset.
datasetIndex - the dataset index (zero-based).
series - the series index (zero-based).
item - the item index (zero-based).
crosshairInfo - information about crosshairs on a plot.

isShapeFilled

protected boolean isShapeFilled(Plot plot,
                                int series,
                                int item,
                                double x,
                                double y)
Is used to determine if a shape is filled when drawn or not

Parameters:
plot - the plot (can be used to obtain standard color information etc).
series - the series index.
item - the item index.
x - the x value of the item.
y - the y value of the item.
Returns:
true if the shape used to draw the data item should be filled.

getPaint

protected java.awt.Paint getPaint(Plot plot,
                                  int series,
                                  int item,
                                  double x,
                                  double y)
Returns the paint used to draw a single data item.

If null is returned, the renderer defaults to the paint for the current series.

Parameters:
plot - the plot (can be used to obtain standard color information etc).
series - the series index.
item - the item index.
x - the x value of the item.
y - the y value of the item.
Returns:
The paint.

getImage

protected java.awt.Image getImage(Plot plot,
                                  int series,
                                  int item,
                                  double x,
                                  double y)
Returns the image used to draw a single data item.

Parameters:
plot - the plot (can be used to obtain standard color information etc).
series - the series index.
item - the item index.
x - the x value of the item.
y - the y value of the item.
Returns:
the image.

getImageHotspot

protected java.awt.Point getImageHotspot(Plot plot,
                                         int series,
                                         int item,
                                         double x,
                                         double y,
                                         java.awt.Image image)
Returns the hotspot of the image used to draw a single data item. The hotspot is the point relative to the top left of the image that should indicate the data item. The default is the center of the image.

Parameters:
plot - the plot (can be used to obtain standard color information etc).
image - the image (can be used to get size information about the image)
series - the series index
item - the item index
x - the x value of the item
y - the y value of the item
Returns:
the hotspot used to draw the data item.

equals

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

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