Package org.jfree.chart.renderer.xy
Class XYBlockRenderer
java.lang.Object
org.jfree.chart.renderer.AbstractRenderer
org.jfree.chart.renderer.xy.AbstractXYItemRenderer
org.jfree.chart.renderer.xy.XYBlockRenderer
- All Implemented Interfaces:
Serializable
,Cloneable
,EventListener
,AnnotationChangeListener
,LegendItemSource
,XYItemRenderer
,PublicCloneable
public class XYBlockRenderer
extends AbstractXYItemRenderer
implements XYItemRenderer, Cloneable, PublicCloneable, Serializable
A renderer that represents data from an

XYZDataset
by drawing a
color block at each (x, y) point, where the color is a function of the
z-value from the dataset. The example shown here is generated by the
XYBlockChartDemo1.java
program included in the JFreeChart
demo collection:

- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate RectangleAnchor
The anchor point used to align each block to its (x, y) location.private double
The block height (defaults to 1.0).private double
The block width (defaults to 1.0).private PaintScale
The paint scale.private double
Temporary storage for the x-offset used to align the block anchor.private double
Temporary storage for the y-offset used to align the block anchor.Fields inherited from class org.jfree.chart.renderer.AbstractRenderer
DEFAULT_ITEM_LABEL_INSETS, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, DEFAULT_PAINT, DEFAULT_SHAPE, DEFAULT_STROKE, DEFAULT_VALUE_LABEL_FONT, DEFAULT_VALUE_LABEL_PAINT, ZERO
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newXYBlockRenderer
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 thisXYBlockRenderer
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.Returns the anchor point used to align a block at its (x, y) location.double
Returns the block height, in data/axis units.double
Returns the block width, in data/axis units.Returns the paint scale used by the renderer.void
setBlockAnchor
(RectangleAnchor anchor) Sets the anchor point used to align a block at its (x, y) location and sends aRendererChangeEvent
to all registered listeners.void
setBlockHeight
(double height) Sets the height of the blocks used to represent each data item and sends aRendererChangeEvent
to all registered listeners.void
setBlockWidth
(double width) Sets the width of the blocks used to represent 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.private void
Updates the offsets to take into account the block width, height and anchor.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, getPassCount, getPlot, getSeriesItemLabelGenerator, getSeriesToolTipGenerator, getToolTipGenerator, getURLGenerator, hashCode, 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, getItemLabelInsets, 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, hasListener, isComputeItemLabelContrastColor, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, lookupLegendShape, lookupLegendTextFont, lookupLegendTextPaint, lookupSeriesFillPaint, lookupSeriesOutlinePaint, lookupSeriesOutlineStroke, lookupSeriesPaint, lookupSeriesShape, lookupSeriesStroke, notifyListeners, removeChangeListener, setAutoPopulateSeriesFillPaint, setAutoPopulateSeriesOutlinePaint, setAutoPopulateSeriesOutlineStroke, setAutoPopulateSeriesPaint, setAutoPopulateSeriesShape, setAutoPopulateSeriesStroke, setComputeItemLabelContrastColor, 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, setItemLabelInsets, 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, getPassCount, 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
-
Field Details
-
blockWidth
private double blockWidthThe block width (defaults to 1.0). -
blockHeight
private double blockHeightThe block height (defaults to 1.0). -
blockAnchor
The anchor point used to align each block to its (x, y) location. The default value isRectangleAnchor.CENTER
. -
xOffset
private double xOffsetTemporary storage for the x-offset used to align the block anchor. -
yOffset
private double yOffsetTemporary storage for the y-offset used to align the block anchor. -
paintScale
The paint scale.
-
-
Constructor Details
-
XYBlockRenderer
public XYBlockRenderer()Creates a newXYBlockRenderer
instance with default attributes.
-
-
Method Details
-
getBlockWidth
public double getBlockWidth()Returns the block width, in data/axis units.- Returns:
- The block width.
- See Also:
-
setBlockWidth
public void setBlockWidth(double width) Sets the width of the blocks used to represent each data item and sends aRendererChangeEvent
to all registered listeners.- Parameters:
width
- the new width, in data/axis units (must be > 0.0).- See Also:
-
getBlockHeight
public double getBlockHeight()Returns the block height, in data/axis units.- Returns:
- The block height.
- See Also:
-
setBlockHeight
public void setBlockHeight(double height) Sets the height of the blocks used to represent each data item and sends aRendererChangeEvent
to all registered listeners.- Parameters:
height
- the new height, in data/axis units (must be > 0.0).- See Also:
-
getBlockAnchor
Returns the anchor point used to align a block at its (x, y) location. The default values isRectangleAnchor.CENTER
.- Returns:
- The anchor point (never
null
). - See Also:
-
setBlockAnchor
Sets the anchor point used to align a block at its (x, y) location and sends aRendererChangeEvent
to all registered listeners.- Parameters:
anchor
- the anchor.- See Also:
-
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:
-
updateOffsets
private void updateOffsets()Updates the offsets to take into account the block width, height and anchor. -
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:
-
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.
-
equals
Tests thisXYBlockRenderer
for equality with an arbitrary object. This method returnstrue
if and only if:obj
is an instance ofXYBlockRenderer
(notnull
);obj
has the same field values as thisXYBlockRenderer
;
- 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.
-