Header
And More


org.jfree.chart.renderer.xy
Class XYShapeRenderer

java.lang.Object
  extended by org.jfree.chart.renderer.AbstractRenderer
      extended by org.jfree.chart.renderer.xy.AbstractXYItemRenderer
          extended by org.jfree.chart.renderer.xy.XYShapeRenderer
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, LegendItemSource, XYItemRenderer

public class XYShapeRenderer
extends AbstractXYItemRenderer
implements XYItemRenderer, java.lang.Cloneable, java.io.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
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jfree.chart.renderer.AbstractRenderer
DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, DEFAULT_PAINT, DEFAULT_SHAPE, DEFAULT_STROKE, DEFAULT_VALUE_LABEL_FONT, DEFAULT_VALUE_LABEL_PAINT, ZERO
 
Constructor Summary
XYShapeRenderer()
          Creates a new XYShapeRenderer instance with default attributes.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this renderer.
 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, CrosshairState crosshairState, int pass)
          Draws the block representing the specified item.
 boolean equals(java.lang.Object obj)
          Tests this instance for equality with an arbitrary object.
 Range findDomainBounds(XYDataset dataset)
          Returns the lower and upper bounds (range) of the x-values in the specified dataset.
 Range findRangeBounds(XYDataset dataset)
          Returns the range of values the renderer requires to display all the items from the specified dataset.
 boolean getDrawOutlines()
          Returns true if outlines should be drawn for shapes, and false otherwise.
 java.awt.Paint getGuideLinePaint()
          Returns the paint used to draw the guide lines.
 java.awt.Stroke getGuideLineStroke()
          Returns the stroke used to draw the guide lines.
protected  java.awt.Paint getPaint(XYDataset dataset, int series, int item)
          Get the paint for a given series and item from a dataset.
 PaintScale getPaintScale()
          Returns the paint scale used by the renderer.
 int getPassCount()
          Returns the number of passes required by this renderer.
 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.
 boolean getUseOutlinePaint()
          Returns the flag that controls whether the outline paint is used for shape outlines.
 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).
 void setDrawOutlines(boolean flag)
          Sets the flag that controls whether outlines are drawn for shapes, and sends a RendererChangeEvent to all registered listeners.
 void setGuideLinePaint(java.awt.Paint paint)
          Sets the paint used to draw the guide lines and sends a RendererChangeEvent to all registered listeners.
 void setGuideLineStroke(java.awt.Stroke stroke)
          Sets the stroke used to draw the guide lines and sends a RendererChangeEvent to all registered listeners.
 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.
 void setPaintScale(PaintScale scale)
          Sets the paint scale used by the renderer and sends a RendererChangeEvent to all registered listeners.
 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.
 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.
 
Methods inherited from class org.jfree.chart.renderer.xy.AbstractXYItemRenderer
addAnnotation, addAnnotation, addEntity, calculateDomainMarkerTextAnchorPoint, drawAnnotations, drawDomainGridLine, drawDomainLine, drawDomainMarker, drawItemLabel, drawRangeLine, drawRangeMarker, fillDomainGridBand, fillRangeGridBand, findDomainBounds, findRangeBounds, getAnnotations, getBaseItemLabelGenerator, getBaseToolTipGenerator, getDrawingSupplier, getItemLabelGenerator, getItemLabelGenerator, getLegendItem, getLegendItemLabelGenerator, getLegendItems, getLegendItemToolTipGenerator, getLegendItemURLGenerator, getPlot, getSeriesItemLabelGenerator, getSeriesToolTipGenerator, getToolTipGenerator, getToolTipGenerator, getURLGenerator, initialise, isPointInRect, removeAnnotation, removeAnnotations, setBaseItemLabelGenerator, setBaseToolTipGenerator, setItemLabelGenerator, setLegendItemLabelGenerator, setLegendItemToolTipGenerator, setLegendItemURLGenerator, setPlot, setSeriesItemLabelGenerator, setSeriesToolTipGenerator, setToolTipGenerator, setURLGenerator, updateCrosshairValues, updateCrosshairValues
 
Methods inherited from class org.jfree.chart.renderer.AbstractRenderer
addChangeListener, calculateLabelAnchorPoint, clearSeriesPaints, clearSeriesStrokes, fireChangeEvent, getAutoPopulateSeriesFillPaint, getAutoPopulateSeriesOutlinePaint, getAutoPopulateSeriesOutlineStroke, getAutoPopulateSeriesPaint, getAutoPopulateSeriesShape, getAutoPopulateSeriesStroke, getBaseCreateEntities, getBaseFillPaint, getBaseItemLabelFont, getBaseItemLabelPaint, getBaseItemLabelsVisible, getBaseLegendShape, getBaseLegendTextFont, getBaseLegendTextPaint, getBaseNegativeItemLabelPosition, getBaseOutlinePaint, getBaseOutlineStroke, getBasePaint, getBasePositiveItemLabelPosition, getBaseSeriesVisible, getBaseSeriesVisibleInLegend, getBaseShape, getBaseStroke, getCreateEntities, getDataBoundsIncludesVisibleSeriesOnly, getDefaultEntityRadius, getItemCreateEntity, getItemFillPaint, getItemLabelAnchorOffset, getItemLabelFont, getItemLabelFont, getItemLabelPaint, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getLegendShape, getLegendTextFont, getLegendTextPaint, getNegativeItemLabelPosition, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getPositiveItemLabelPosition, getSeriesCreateEntities, getSeriesFillPaint, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesVisible, getSeriesVisible, getSeriesVisibleInLegend, getSeriesVisibleInLegend, hashCode, hasListener, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, lookupLegendShape, lookupLegendTextFont, lookupLegendTextPaint, lookupSeriesFillPaint, lookupSeriesOutlinePaint, lookupSeriesOutlineStroke, lookupSeriesPaint, lookupSeriesShape, lookupSeriesStroke, notifyListeners, removeChangeListener, setAutoPopulateSeriesFillPaint, setAutoPopulateSeriesOutlinePaint, setAutoPopulateSeriesOutlineStroke, setAutoPopulateSeriesPaint, setAutoPopulateSeriesShape, setAutoPopulateSeriesStroke, setBaseCreateEntities, setBaseCreateEntities, setBaseFillPaint, setBaseFillPaint, setBaseItemLabelFont, setBaseItemLabelFont, setBaseItemLabelPaint, setBaseItemLabelPaint, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseLegendShape, setBaseLegendTextFont, setBaseLegendTextPaint, setBaseNegativeItemLabelPosition, setBaseNegativeItemLabelPosition, setBaseOutlinePaint, setBaseOutlinePaint, setBaseOutlineStroke, setBaseOutlineStroke, setBasePaint, setBasePaint, setBasePositiveItemLabelPosition, setBasePositiveItemLabelPosition, setBaseSeriesVisible, setBaseSeriesVisible, setBaseSeriesVisibleInLegend, setBaseSeriesVisibleInLegend, setBaseShape, setBaseShape, setBaseStroke, setBaseStroke, setCreateEntities, setCreateEntities, setDataBoundsIncludesVisibleSeriesOnly, setDefaultEntityRadius, setFillPaint, setFillPaint, setItemLabelAnchorOffset, setItemLabelFont, setItemLabelFont, setItemLabelPaint, setItemLabelPaint, setItemLabelsVisible, setItemLabelsVisible, setItemLabelsVisible, setLegendShape, setLegendTextFont, setLegendTextPaint, setNegativeItemLabelPosition, setNegativeItemLabelPosition, setOutlinePaint, setOutlinePaint, setOutlineStroke, setOutlineStroke, setPaint, setPaint, setPositiveItemLabelPosition, setPositiveItemLabelPosition, setSeriesCreateEntities, setSeriesCreateEntities, setSeriesFillPaint, setSeriesFillPaint, setSeriesItemLabelFont, setSeriesItemLabelFont, setSeriesItemLabelPaint, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesShape, setSeriesStroke, setSeriesStroke, setSeriesVisible, setSeriesVisible, setSeriesVisible, setSeriesVisible, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setShape, setShape, setStroke, setStroke
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jfree.chart.renderer.xy.XYItemRenderer
addAnnotation, addAnnotation, addChangeListener, drawAnnotations, drawDomainGridLine, drawDomainMarker, drawRangeLine, drawRangeMarker, fillDomainGridBand, fillRangeGridBand, getBaseItemLabelFont, getBaseItemLabelGenerator, getBaseItemLabelPaint, getBaseItemLabelsVisible, getBaseNegativeItemLabelPosition, getBaseOutlinePaint, getBaseOutlineStroke, getBasePaint, getBasePositiveItemLabelPosition, getBaseSeriesVisible, getBaseSeriesVisibleInLegend, getBaseShape, getBaseStroke, getBaseToolTipGenerator, getItemLabelFont, getItemLabelFont, getItemLabelGenerator, getItemLabelPaint, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getLegendItem, getLegendItemLabelGenerator, getNegativeItemLabelPosition, getNegativeItemLabelPosition, getPlot, getPositiveItemLabelPosition, getPositiveItemLabelPosition, getSeriesItemLabelFont, getSeriesItemLabelGenerator, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesToolTipGenerator, getSeriesVisible, getSeriesVisible, getSeriesVisibleInLegend, getSeriesVisibleInLegend, getToolTipGenerator, getURLGenerator, initialise, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, removeAnnotation, removeAnnotations, removeChangeListener, setBaseItemLabelFont, setBaseItemLabelGenerator, setBaseItemLabelPaint, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseNegativeItemLabelPosition, setBaseNegativeItemLabelPosition, setBaseOutlinePaint, setBaseOutlineStroke, setBasePaint, setBasePositiveItemLabelPosition, setBasePositiveItemLabelPosition, setBaseSeriesVisible, setBaseSeriesVisible, setBaseSeriesVisibleInLegend, setBaseSeriesVisibleInLegend, setBaseShape, setBaseStroke, setBaseToolTipGenerator, setItemLabelFont, setItemLabelGenerator, setItemLabelPaint, setItemLabelsVisible, setItemLabelsVisible, setItemLabelsVisible, setLegendItemLabelGenerator, setNegativeItemLabelPosition, setNegativeItemLabelPosition, setOutlinePaint, setOutlineStroke, setPaint, setPlot, setPositiveItemLabelPosition, setPositiveItemLabelPosition, setSeriesItemLabelFont, setSeriesItemLabelGenerator, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesStroke, setSeriesToolTipGenerator, setSeriesVisible, setSeriesVisible, setSeriesVisible, setSeriesVisible, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setShape, setStroke, setToolTipGenerator, setURLGenerator
 
Methods inherited from interface org.jfree.chart.LegendItemSource
getLegendItems
 

Constructor Detail

XYShapeRenderer

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

Method Detail

getPaintScale

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

Returns:
The paint scale (never null).
See Also:
setPaintScale(PaintScale)

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

getDrawOutlines

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

Returns:
A boolean.
See Also:
setDrawOutlines(boolean)

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

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:
setUseFillPaint(boolean), getUseOutlinePaint()

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

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:
setUseOutlinePaint(boolean)

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

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:
setGuideLinesVisible(boolean)

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

getGuideLinePaint

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

Returns:
The paint (never null).
See Also:
setGuideLinePaint(Paint)

setGuideLinePaint

public void setGuideLinePaint(java.awt.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()

getGuideLineStroke

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

Returns:
The stroke.
See Also:
setGuideLineStroke(Stroke)

setGuideLineStroke

public void setGuideLineStroke(java.awt.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()

findDomainBounds

public Range findDomainBounds(XYDataset dataset)
Returns the lower and upper bounds (range) of the x-values in the specified dataset.

Specified by:
findDomainBounds in interface XYItemRenderer
Overrides:
findDomainBounds in class AbstractXYItemRenderer
Parameters:
dataset - the dataset (null permitted).
Returns:
The range (null if the dataset is null or empty).
See Also:
AbstractXYItemRenderer.findRangeBounds(XYDataset)

findRangeBounds

public Range findRangeBounds(XYDataset dataset)
Returns the range of values the renderer requires to display all the items from the specified dataset.

Specified by:
findRangeBounds in interface XYItemRenderer
Overrides:
findRangeBounds in class AbstractXYItemRenderer
Parameters:
dataset - the dataset (null permitted).
Returns:
The range (null if the dataset is null or empty).
See Also:
AbstractXYItemRenderer.findDomainBounds(XYDataset)

getPassCount

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

Specified by:
getPassCount in interface XYItemRenderer
Overrides:
getPassCount in class AbstractXYItemRenderer
Returns:
2.

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,
                     CrosshairState crosshairState,
                     int pass)
Draws the block representing the specified item.

Specified by:
drawItem in interface XYItemRenderer
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.

getPaint

protected java.awt.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.

equals

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

Overrides:
equals in class AbstractXYItemRenderer
Parameters:
obj - the object (null permitted).
Returns:
A boolean.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns a clone of this renderer.

Overrides:
clone in class AbstractXYItemRenderer
Returns:
A clone of this renderer.
Throws:
java.lang.CloneNotSupportedException - if there is a problem creating the clone.

Footer
And More


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