com.jrefinery.chart
Class StandardXYItemRenderer

java.lang.Object
  |
  +--com.jrefinery.chart.AbstractRenderer
        |
        +--com.jrefinery.chart.AbstractXYItemRenderer
              |
              +--com.jrefinery.chart.StandardXYItemRenderer
All Implemented Interfaces:
XYItemRenderer

public class StandardXYItemRenderer
extends AbstractXYItemRenderer
implements XYItemRenderer

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:
DG

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
          Cconstant for the type of rendering (shapes only).
static int SHAPES_AND_LINES
          Constant for the type of rendering (shapes and lines).
 
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 data, int series, int item, CrosshairInfo crosshairInfo)
          Draws the visual representation of a single data item.
 boolean getDefaultShapeFilled()
          Returns the default value returned by the isShapeFilled(...) method.
 double getDefaultShapeScale()
          Returns the default shape scale.
 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 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  java.awt.Shape getShape(Plot plot, int series, int item, double x, double y, double scale)
          Returns the shape used to draw a single data item.
protected  double getShapeScale(Plot plot, int series, int item, double x, double y)
          Returns the shape scale of a single data item.
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 setDefaultShapeScale(double scale)
          Sets the default shape scale.
 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 com.jrefinery.chart.AbstractXYItemRenderer
drawDomainMarker, drawRangeMarker, getLegendItem, getPlot, getToolTipGenerator, getURLGenerator, initialise, setPlot, setToolTipGenerator, setURLGenerator
 
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.XYItemRenderer
addPropertyChangeListener, drawDomainMarker, drawRangeMarker, getLegendItem, getPlot, getToolTipGenerator, getURLGenerator, initialise, removePropertyChangeListener, setPlot, setToolTipGenerator, setURLGenerator
 

Field Detail

SHAPES

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

LINES

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

SHAPES_AND_LINES

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

IMAGES

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

DISCONTINUOUS

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

DISCONTINUOUS_LINES

public static final int DISCONTINUOUS_LINES
Constant for the type of rendering (discontinuous lines).
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.

getDefaultShapeScale

public double getDefaultShapeScale()
Returns the default shape scale.

The renderer will call getShapeScale(...) to determine the scaling factor to use for shapes. Unless overridden, the getShapeScale(...) method just returns the default shape scale.

Returns:
the default shape scale.

setDefaultShapeScale

public void setDefaultShapeScale(double scale)
Sets the default shape scale.
Parameters:
scale - the shape scale.

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.

drawItem

public void drawItem(java.awt.Graphics2D g2,
                     java.awt.geom.Rectangle2D dataArea,
                     ChartRenderingInfo info,
                     XYPlot plot,
                     ValueAxis domainAxis,
                     ValueAxis rangeAxis,
                     XYDataset data,
                     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.
data - the dataset.
series - the series index.
item - the item index.
crosshairInfo - information about crosshairs on a plot.

getShape

protected java.awt.Shape getShape(Plot plot,
                                  int series,
                                  int item,
                                  double x,
                                  double y,
                                  double scale)
Returns the shape 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
scale - the scale used to draw the shape
Returns:
The shape used to draw the data item

getShapeScale

protected double getShapeScale(Plot plot,
                               int series,
                               int item,
                               double x,
                               double y)
Returns the shape scale of a single data item.

Unless overridden, this method just returns the default shape scale.

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 scale used to draw the shape used for the data item

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.