java.lang.Object
org.jfree.chart.renderer.AbstractRenderer
org.jfree.chart.renderer.xy.AbstractXYItemRenderer
org.jfree.chart.renderer.xy.XYShapeRenderer
- All Implemented Interfaces:
Serializable
,Cloneable
,EventListener
,AnnotationChangeListener
,LegendItemSource
,XYItemRenderer
,PublicCloneable
public class XYShapeRenderer
extends AbstractXYItemRenderer
implements XYItemRenderer, Cloneable, PublicCloneable, Serializable
A renderer that draws shapes at (x, y) coordinates and, if the dataset
is an instance of
The example shown here is generated by the
This renderer has similarities to, but also differences from, the
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:
This renderer has similarities to, but also differences from, the
XYLineAndShapeRenderer
.- See Also:
-
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
ConstructorDescriptionCreates a newXYShapeRenderer
instance with default attributes. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a clone of this renderer.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.boolean
Tests this instance for equality with an arbitrary object.findDomainBounds
(XYDataset dataset) Returns the lower and upper bounds (range) of the x-values in the specified dataset.findRangeBounds
(XYDataset dataset) Returns the range of values the renderer requires to display all the items from the specified dataset.findZBounds
(XYZDataset dataset) Return the range of z-values in the specified dataset.boolean
Returnstrue
if outlines should be drawn for shapes, andfalse
otherwise.Returns the paint used to draw the guide lines.Returns the stroke used to draw the guide lines.protected Paint
Get the paint for a given series and item from a dataset.Returns the paint scale used by the renderer.int
Returns the number of passes required by this renderer.boolean
Returnstrue
if the renderer should use the fill paint setting to fill shapes, andfalse
if it should just use the regular paint.boolean
Returns the flag that controls whether the outline paint is used for shape outlines.boolean
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 aRendererChangeEvent
to all registered listeners.void
setGuideLinePaint
(Paint paint) Sets the paint used to draw the guide lines and sends aRendererChangeEvent
to all registered listeners.void
setGuideLineStroke
(Stroke stroke) Sets the stroke used to draw the guide lines and sends aRendererChangeEvent
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 aRendererChangeEvent
to all registered listeners.void
setPaintScale
(PaintScale scale) Sets the paint scale used by the renderer and sends aRendererChangeEvent
to all registered listeners.void
setUseFillPaint
(boolean flag) Sets the flag that controls whether the fill paint is used to fill shapes, and sends aRendererChangeEvent
to all registered listeners.void
setUseOutlinePaint
(boolean use) Sets the flag that controls whether the outline paint is used for shape outlines, and sends aRendererChangeEvent
to all registered listeners.Methods inherited from class org.jfree.chart.renderer.xy.AbstractXYItemRenderer
addAnnotation, addAnnotation, addEntity, annotationChanged, beginElementGroup, calculateDomainMarkerTextAnchorPoint, drawAnnotations, drawDomainLine, drawDomainMarker, drawItemLabel, drawRangeLine, drawRangeMarker, fillDomainGridBand, fillRangeGridBand, findDomainBounds, findRangeBounds, getAnnotations, getDefaultItemLabelGenerator, getDefaultToolTipGenerator, getDrawingSupplier, getItemLabelGenerator, getLegendItem, getLegendItemLabelGenerator, getLegendItems, getLegendItemToolTipGenerator, getLegendItemURLGenerator, getPlot, getSeriesItemLabelGenerator, getSeriesToolTipGenerator, getToolTipGenerator, getURLGenerator, initialise, lineTo, moveTo, removeAnnotation, removeAnnotations, setDefaultItemLabelGenerator, setDefaultToolTipGenerator, setLegendItemLabelGenerator, setLegendItemToolTipGenerator, setLegendItemURLGenerator, setPlot, setSeriesItemLabelGenerator, setSeriesToolTipGenerator, setURLGenerator, updateCrosshairValues
Methods inherited from class org.jfree.chart.renderer.AbstractRenderer
addChangeListener, beginElementGroup, calculateLabelAnchorPoint, clearSeriesPaints, clearSeriesStrokes, endElementGroup, fireChangeEvent, getAutoPopulateSeriesFillPaint, getAutoPopulateSeriesOutlinePaint, getAutoPopulateSeriesOutlineStroke, getAutoPopulateSeriesPaint, getAutoPopulateSeriesShape, getAutoPopulateSeriesStroke, getDataBoundsIncludesVisibleSeriesOnly, getDefaultCreateEntities, getDefaultEntityRadius, getDefaultFillPaint, getDefaultItemLabelFont, getDefaultItemLabelPaint, getDefaultItemLabelsVisible, getDefaultLegendShape, getDefaultLegendTextFont, getDefaultLegendTextPaint, getDefaultNegativeItemLabelPosition, getDefaultOutlinePaint, getDefaultOutlineStroke, getDefaultPaint, getDefaultPositiveItemLabelPosition, getDefaultSeriesVisible, getDefaultSeriesVisibleInLegend, getDefaultShape, getDefaultStroke, getItemCreateEntity, getItemFillPaint, getItemLabelAnchorOffset, getItemLabelFont, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getLegendShape, getLegendTextFont, getLegendTextPaint, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getSeriesCreateEntities, getSeriesFillPaint, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesVisible, getSeriesVisibleInLegend, getTreatLegendShapeAsLine, hashCode, hasListener, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, lookupLegendShape, lookupLegendTextFont, lookupLegendTextPaint, lookupSeriesFillPaint, lookupSeriesOutlinePaint, lookupSeriesOutlineStroke, lookupSeriesPaint, lookupSeriesShape, lookupSeriesStroke, notifyListeners, removeChangeListener, setAutoPopulateSeriesFillPaint, setAutoPopulateSeriesOutlinePaint, setAutoPopulateSeriesOutlineStroke, setAutoPopulateSeriesPaint, setAutoPopulateSeriesShape, setAutoPopulateSeriesStroke, setDataBoundsIncludesVisibleSeriesOnly, setDefaultCreateEntities, setDefaultCreateEntities, setDefaultEntityRadius, setDefaultFillPaint, setDefaultFillPaint, setDefaultItemLabelFont, setDefaultItemLabelFont, setDefaultItemLabelPaint, setDefaultItemLabelPaint, setDefaultItemLabelsVisible, setDefaultItemLabelsVisible, setDefaultLegendShape, setDefaultLegendTextFont, setDefaultLegendTextPaint, setDefaultNegativeItemLabelPosition, setDefaultNegativeItemLabelPosition, setDefaultOutlinePaint, setDefaultOutlinePaint, setDefaultOutlineStroke, setDefaultOutlineStroke, setDefaultPaint, setDefaultPaint, setDefaultPositiveItemLabelPosition, setDefaultPositiveItemLabelPosition, setDefaultSeriesVisible, setDefaultSeriesVisible, setDefaultSeriesVisibleInLegend, setDefaultSeriesVisibleInLegend, setDefaultShape, setDefaultShape, setDefaultStroke, setDefaultStroke, setItemLabelAnchorOffset, setLegendShape, setLegendTextFont, setLegendTextPaint, 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, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setTreatLegendShapeAsLine
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jfree.chart.LegendItemSource
getLegendItems
Methods inherited from interface org.jfree.chart.renderer.xy.XYItemRenderer
addAnnotation, addAnnotation, addChangeListener, drawAnnotations, drawDomainLine, drawDomainMarker, drawRangeLine, drawRangeMarker, fillDomainGridBand, fillRangeGridBand, getDefaultCreateEntities, getDefaultFillPaint, getDefaultItemLabelFont, getDefaultItemLabelGenerator, getDefaultItemLabelPaint, getDefaultItemLabelsVisible, getDefaultNegativeItemLabelPosition, getDefaultOutlinePaint, getDefaultOutlineStroke, getDefaultPaint, getDefaultPositiveItemLabelPosition, getDefaultSeriesVisible, getDefaultSeriesVisibleInLegend, getDefaultShape, getDefaultStroke, getDefaultToolTipGenerator, getItemCreateEntity, getItemFillPaint, getItemLabelFont, getItemLabelGenerator, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getLegendItem, getLegendItemLabelGenerator, getNegativeItemLabelPosition, getPlot, getPositiveItemLabelPosition, getSeriesCreateEntities, getSeriesFillPaint, getSeriesItemLabelFont, getSeriesItemLabelGenerator, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesToolTipGenerator, getSeriesVisible, getSeriesVisibleInLegend, getToolTipGenerator, getURLGenerator, initialise, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, removeAnnotation, removeAnnotations, removeChangeListener, setDefaultCreateEntities, setDefaultCreateEntities, setDefaultFillPaint, setDefaultFillPaint, setDefaultItemLabelFont, setDefaultItemLabelGenerator, setDefaultItemLabelPaint, setDefaultItemLabelsVisible, setDefaultItemLabelsVisible, setDefaultNegativeItemLabelPosition, setDefaultNegativeItemLabelPosition, setDefaultOutlinePaint, setDefaultOutlinePaint, setDefaultOutlineStroke, setDefaultOutlineStroke, setDefaultPaint, setDefaultPaint, setDefaultPositiveItemLabelPosition, setDefaultPositiveItemLabelPosition, setDefaultSeriesVisible, setDefaultSeriesVisible, setDefaultSeriesVisibleInLegend, setDefaultSeriesVisibleInLegend, setDefaultShape, setDefaultShape, setDefaultStroke, setDefaultStroke, setDefaultToolTipGenerator, setLegendItemLabelGenerator, setPlot, setSeriesCreateEntities, setSeriesCreateEntities, setSeriesFillPaint, setSeriesFillPaint, setSeriesItemLabelFont, setSeriesItemLabelGenerator, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesShape, setSeriesStroke, setSeriesStroke, setSeriesToolTipGenerator, setSeriesVisible, setSeriesVisible, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setURLGenerator
-
Constructor Details
-
XYShapeRenderer
public XYShapeRenderer()Creates a newXYShapeRenderer
instance with default attributes.
-
-
Method Details
-
getPaintScale
Returns the paint scale used by the renderer.- Returns:
- The paint scale (never
null
). - See Also:
-
setPaintScale
Sets the paint scale used by the renderer and sends aRendererChangeEvent
to all registered listeners.- Parameters:
scale
- the scale (null
not permitted).- See Also:
-
getDrawOutlines
public boolean getDrawOutlines()Returnstrue
if outlines should be drawn for shapes, andfalse
otherwise.- Returns:
- A boolean.
- See Also:
-
setDrawOutlines
public void setDrawOutlines(boolean flag) Sets the flag that controls whether outlines are drawn for shapes, and sends aRendererChangeEvent
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:
-
getUseFillPaint
public boolean getUseFillPaint()Returnstrue
if the renderer should use the fill paint setting to fill shapes, andfalse
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
public void setUseFillPaint(boolean flag) Sets the flag that controls whether the fill paint is used to fill shapes, and sends aRendererChangeEvent
to all registered listeners.- Parameters:
flag
- the flag.- See Also:
-
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
public void setUseOutlinePaint(boolean use) Sets the flag that controls whether the outline paint is used for shape outlines, and sends aRendererChangeEvent
to all registered listeners.- Parameters:
use
- the flag.- See Also:
-
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
public void setGuideLinesVisible(boolean visible) Sets the flag that controls whether or not guide lines are drawn for each data item and sends aRendererChangeEvent
to all registered listeners.- Parameters:
visible
- the new flag value.- See Also:
-
getGuideLinePaint
Returns the paint used to draw the guide lines.- Returns:
- The paint (never
null
). - See Also:
-
setGuideLinePaint
Sets the paint used to draw the guide lines and sends aRendererChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
-
getGuideLineStroke
Returns the stroke used to draw the guide lines.- Returns:
- The stroke.
- See Also:
-
setGuideLineStroke
Sets the stroke used to draw the guide lines and sends aRendererChangeEvent
to all registered listeners.- Parameters:
stroke
- the stroke (null
not permitted).- See Also:
-
findDomainBounds
Returns the lower and upper bounds (range) of the x-values in the specified dataset.- Specified by:
findDomainBounds
in interfaceXYItemRenderer
- Overrides:
findDomainBounds
in classAbstractXYItemRenderer
- Parameters:
dataset
- the dataset (null
permitted).- Returns:
- The range (
null
if the dataset isnull
or empty). - See Also:
-
findRangeBounds
Returns the range of values the renderer requires to display all the items from the specified dataset.- Specified by:
findRangeBounds
in interfaceXYItemRenderer
- Overrides:
findRangeBounds
in classAbstractXYItemRenderer
- Parameters:
dataset
- the dataset (null
permitted).- Returns:
- The range (
null
if the dataset isnull
or empty). - See Also:
-
findZBounds
Return the range of z-values in the specified dataset.- Parameters:
dataset
- the dataset (null
permitted).- Returns:
- The range (
null
if the dataset isnull
or empty).
-
getPassCount
public int getPassCount()Returns the number of passes required by this renderer.- Specified by:
getPassCount
in interfaceXYItemRenderer
- Overrides:
getPassCount
in classAbstractXYItemRenderer
- Returns:
2
.
-
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.- Specified by:
drawItem
in interfaceXYItemRenderer
- 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
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
Tests this instance for equality with an arbitrary object. This method returnstrue
if and only if:obj
is an instance ofXYShapeRenderer
(notnull
);obj
has the same field values as thisXYShapeRenderer
;
- Overrides:
equals
in classAbstractXYItemRenderer
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
clone
Returns a clone of this renderer.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classAbstractXYItemRenderer
- Returns:
- A clone of this renderer.
- Throws:
CloneNotSupportedException
- if there is a problem creating the clone.
-