com.jrefinery.chart
Class StandardXYItemRenderer

java.lang.Object
  extended by com.jrefinery.chart.AbstractXYItemRenderer
      extended by 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.


Field Summary
static int IMAGES
          Useful constant for specifying the type of rendering (images only).
protected  java.awt.geom.Line2D line
          A working line (to save creating thousands of instances).
static int LINES
          Useful constant for specifying the type of rendering (lines only).
protected  boolean plotImages
          A flag indicating whether or not images are drawn between XY points.
protected  boolean plotLines
          A flag indicating whether or not lines are drawn between XY points.
protected  boolean plotShapes
          A flag indicating whether or not shapes are drawn at each XY point.
static int SHAPES
          Useful constant for specifying the type of rendering (shapes only).
static int SHAPES_AND_LINES
          Useful constant for specifying the type of rendering (shapes and lines).
protected  double shapeScale
          Deprecated. Use getShapeScale() instead
 
Fields inherited from class com.jrefinery.chart.AbstractXYItemRenderer
info, listeners, toolTipGenerator
 
Constructor Summary
StandardXYItemRenderer()
          Constructs a new renderer.
StandardXYItemRenderer(int type, com.jrefinery.chart.tooltips.XYToolTipGenerator toolTipGenerator)
          Constructs a new renderer.
 
Method Summary
 void drawItem(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, ChartRenderingInfo info, XYPlot plot, ValueAxis horizontalAxis, ValueAxis verticalAxis, XYDataset data, int series, int item, CrosshairInfo crosshairInfo)
          Draws the visual representation of a single data item.
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
 
Methods inherited from class com.jrefinery.chart.AbstractXYItemRenderer
addPropertyChangeListener, firePropertyChanged, getToolTipGenerator, initialise, removePropertyChangeListener, setToolTipGenerator
 
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, getToolTipGenerator, initialise, removePropertyChangeListener, setToolTipGenerator
 

Field Detail

SHAPES

public static final int SHAPES
Useful constant for specifying the type of rendering (shapes only).

See Also:
Constant Field Values

LINES

public static final int LINES
Useful constant for specifying the type of rendering (lines only).

See Also:
Constant Field Values

SHAPES_AND_LINES

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

See Also:
Constant Field Values

IMAGES

public static final int IMAGES
Useful constant for specifying the type of rendering (images only).

See Also:
Constant Field Values

plotShapes

protected boolean plotShapes
A flag indicating whether or not shapes are drawn at each XY point.


plotLines

protected boolean plotLines
A flag indicating whether or not lines are drawn between XY points.


plotImages

protected boolean plotImages
A flag indicating whether or not images are drawn between XY points.


shapeScale

protected double shapeScale
Deprecated. Use getShapeScale() instead
Scale factor for standard shapes.


line

protected java.awt.geom.Line2D line
A working line (to save creating thousands of instances).

Constructor Detail

StandardXYItemRenderer

public StandardXYItemRenderer()
Constructs a new renderer.


StandardXYItemRenderer

public StandardXYItemRenderer(int type,
                              com.jrefinery.chart.tooltips.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.
Method Detail

getPlotShapes

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


getPlotLines

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


getPlotImages

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


getShapeScale

protected double getShapeScale(Plot plot,
                               int series,
                               int item,
                               double x,
                               double y)
Returns the shape scale of 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

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

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

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

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, false otherwise.

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

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 used to draw the item. If this method returns null the Paint used will remain unchanged

drawItem

public void drawItem(java.awt.Graphics2D g2,
                     java.awt.geom.Rectangle2D dataArea,
                     ChartRenderingInfo info,
                     XYPlot plot,
                     ValueAxis horizontalAxis,
                     ValueAxis verticalAxis,
                     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).
horizontalAxis - The horizontal axis.
verticalAxis - The vertical axis.
data - The dataset.
series - The series index.
item - The item index.


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.