org.jfree.chart.renderer.xy

Class XYShapeRenderer

public class XYShapeRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, Serializable

A renderer that draws shapes at (x, y) coordinates and, if the dataset is an instance of XYZDataset, fills the shapes with a paint that is based on the z-value (the paint is obtained from a lookup table). The renderer also allows for optional guidelines, horizontal and vertical lines connecting the shape to the edges of the plot.

The example shown here is generated by the XYShapeRendererDemo1.java program included in the JFreeChart demo collection:

XYShapeRendererSample.png

This renderer has similarities to, but also differences from, the XYLineAndShapeRenderer.

Since: 1.0.11

Constructor Summary
XYShapeRenderer()
Creates a new XYShapeRenderer instance with default attributes.
Method Summary
Objectclone()
Returns a clone of this renderer.
voiddrawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass)
Draws the block representing the specified item.
booleanequals(Object obj)
Tests this instance for equality with an arbitrary object.
RangefindDomainBounds(XYDataset dataset)
Returns the lower and upper bounds (range) of the x-values in the specified dataset.
RangefindRangeBounds(XYDataset dataset)
Returns the range of values the renderer requires to display all the items from the specified dataset.
booleangetDrawOutlines()
Returns true if outlines should be drawn for shapes, and false otherwise.
PaintgetGuideLinePaint()
Returns the paint used to draw the guide lines.
StrokegetGuideLineStroke()
Returns the stroke used to draw the guide lines.
protected PaintgetPaint(XYDataset dataset, int series, int item)
Get the paint for a given series and item from a dataset.
PaintScalegetPaintScale()
Returns the paint scale used by the renderer.
intgetPassCount()
Returns the number of passes required by this renderer.
booleangetUseFillPaint()
Returns true if the renderer should use the fill paint setting to fill shapes, and false if it should just use the regular paint.
booleangetUseOutlinePaint()
Returns the flag that controls whether the outline paint is used for shape outlines.
booleanisGuideLinesVisible()
Returns a flag that controls whether or not guide lines are drawn for each data item (the lines are horizontal and vertical "crosshairs" linking the data point to the axes).
voidsetDrawOutlines(boolean flag)
Sets the flag that controls whether outlines are drawn for shapes, and sends a RendererChangeEvent to all registered listeners.
voidsetGuideLinePaint(Paint paint)
Sets the paint used to draw the guide lines and sends a RendererChangeEvent to all registered listeners.
voidsetGuideLinesVisible(boolean visible)
Sets the flag that controls whether or not guide lines are drawn for each data item and sends a RendererChangeEvent to all registered listeners.
voidsetGuideLineStroke(Stroke stroke)
Sets the stroke used to draw the guide lines and sends a RendererChangeEvent to all registered listeners.
voidsetPaintScale(PaintScale scale)
Sets the paint scale used by the renderer and sends a RendererChangeEvent to all registered listeners.
voidsetUseFillPaint(boolean flag)
Sets the flag that controls whether the fill paint is used to fill shapes, and sends a RendererChangeEvent to all registered listeners.
voidsetUseOutlinePaint(boolean use)
Sets the flag that controls whether the outline paint is used for shape outlines, and sends a RendererChangeEvent to all registered listeners.

Constructor Detail

XYShapeRenderer

public XYShapeRenderer()
Creates a new XYShapeRenderer instance with default attributes.

Method Detail

clone

public Object clone()
Returns a clone of this renderer.

Returns: A clone of this renderer.

Throws: CloneNotSupportedException if there is a problem creating the clone.

drawItem

public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass)
Draws the block representing the specified item.

Parameters: g2 the graphics device. state the state. dataArea the data area. info the plot rendering info. plot the plot. domainAxis the x-axis. rangeAxis the y-axis. dataset the dataset. series the series index. item the item index. crosshairState the crosshair state. pass the pass index.

equals

public boolean equals(Object obj)
Tests this instance for equality with an arbitrary object. This method returns true if and only if:

Parameters: obj the object (null permitted).

Returns: A boolean.

findDomainBounds

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).

findRangeBounds

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).

getDrawOutlines

public boolean getDrawOutlines()
Returns true if outlines should be drawn for shapes, and false otherwise.

Returns: A boolean.

See Also: XYShapeRenderer

getGuideLinePaint

public Paint getGuideLinePaint()
Returns the paint used to draw the guide lines.

Returns: The paint (never null).

See Also: setGuideLinePaint

getGuideLineStroke

public Stroke getGuideLineStroke()
Returns the stroke used to draw the guide lines.

Returns: The stroke.

See Also: setGuideLineStroke

getPaint

protected Paint getPaint(XYDataset dataset, int series, int item)
Get the paint for a given series and item from a dataset.

Parameters: dataset the dataset.. series the series index. item the item index.

Returns: The paint.

getPaintScale

public PaintScale getPaintScale()
Returns the paint scale used by the renderer.

Returns: The paint scale (never null).

See Also: setPaintScale

getPassCount

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

Returns: 2.

getUseFillPaint

public boolean getUseFillPaint()
Returns true if the renderer should use the fill paint setting to fill shapes, and false if it should just use the regular paint.

Refer to XYLineAndShapeRendererDemo2.java to see the effect of this flag.

Returns: A boolean.

See Also: XYShapeRenderer getUseOutlinePaint

getUseOutlinePaint

public boolean getUseOutlinePaint()
Returns the flag that controls whether the outline paint is used for shape outlines. If not, the regular series paint is used.

Returns: A boolean.

See Also: XYShapeRenderer

isGuideLinesVisible

public boolean isGuideLinesVisible()
Returns a flag that controls whether or not guide lines are drawn for each data item (the lines are horizontal and vertical "crosshairs" linking the data point to the axes).

Returns: A boolean.

See Also: XYShapeRenderer

setDrawOutlines

public void setDrawOutlines(boolean flag)
Sets the flag that controls whether outlines are drawn for shapes, and sends a RendererChangeEvent to all registered listeners.

In some cases, shapes look better if they do NOT have an outline, but this flag allows you to set your own preference.

Parameters: flag the flag.

See Also: getDrawOutlines

setGuideLinePaint

public void setGuideLinePaint(Paint paint)
Sets the paint used to draw the guide lines and sends a RendererChangeEvent to all registered listeners.

Parameters: paint the paint (null not permitted).

See Also: getGuideLinePaint

setGuideLinesVisible

public void setGuideLinesVisible(boolean visible)
Sets the flag that controls whether or not guide lines are drawn for each data item and sends a RendererChangeEvent to all registered listeners.

Parameters: visible the new flag value.

See Also: isGuideLinesVisible

setGuideLineStroke

public void setGuideLineStroke(Stroke stroke)
Sets the stroke used to draw the guide lines and sends a RendererChangeEvent to all registered listeners.

Parameters: stroke the stroke (null not permitted).

See Also: getGuideLineStroke

setPaintScale

public void setPaintScale(PaintScale scale)
Sets the paint scale used by the renderer and sends a RendererChangeEvent to all registered listeners.

Parameters: scale the scale (null not permitted).

See Also: getPaintScale

setUseFillPaint

public void setUseFillPaint(boolean flag)
Sets the flag that controls whether the fill paint is used to fill shapes, and sends a RendererChangeEvent to all registered listeners.

Parameters: flag the flag.

See Also: getUseFillPaint

setUseOutlinePaint

public void setUseOutlinePaint(boolean use)
Sets the flag that controls whether the outline paint is used for shape outlines, and sends a RendererChangeEvent to all registered listeners.

Parameters: use the flag.

See Also: getUseOutlinePaint

Copyright © 2000-2009 by Object Refinery Limited. All Rights Reserved.