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 RectangleAnchorThe anchor point used to align each block to its (x, y) location.private doubleThe block height (defaults to 1.0).private doubleThe block width (defaults to 1.0).private PaintScaleThe paint scale.private doubleTemporary storage for the x-offset used to align the block anchor.private doubleTemporary 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 newXYBlockRendererinstance with default attributes. -
Method Summary
Modifier and TypeMethodDescriptionclone()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.booleanTests thisXYBlockRendererfor 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.doubleReturns the block height, in data/axis units.doubleReturns the block width, in data/axis units.Returns the paint scale used by the renderer.voidsetBlockAnchor(RectangleAnchor anchor) Sets the anchor point used to align a block at its (x, y) location and sends aRendererChangeEventto all registered listeners.voidsetBlockHeight(double height) Sets the height of the blocks used to represent each data item and sends aRendererChangeEventto all registered listeners.voidsetBlockWidth(double width) Sets the width of the blocks used to represent each data item and sends aRendererChangeEventto all registered listeners.voidsetPaintScale(PaintScale scale) Sets the paint scale used by the renderer and sends aRendererChangeEventto all registered listeners.private voidUpdates 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, updateCrosshairValuesMethods 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, setTreatLegendShapeAsLineMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jfree.chart.LegendItemSource
getLegendItemsMethods 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 newXYBlockRendererinstance 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 aRendererChangeEventto 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 aRendererChangeEventto 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 aRendererChangeEventto 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 aRendererChangeEventto all registered listeners.- Parameters:
scale- the scale (nullnot 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:
findDomainBoundsin interfaceXYItemRenderer- Overrides:
findDomainBoundsin classAbstractXYItemRenderer- Parameters:
dataset- the dataset (nullpermitted).- Returns:
- The range (
nullif the dataset isnullor empty). - See Also:
-
findRangeBounds
Returns the range of values the renderer requires to display all the items from the specified dataset.- Specified by:
findRangeBoundsin interfaceXYItemRenderer- Overrides:
findRangeBoundsin classAbstractXYItemRenderer- Parameters:
dataset- the dataset (nullpermitted).- Returns:
- The range (
nullif the dataset isnullor 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:
drawItemin 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 thisXYBlockRendererfor equality with an arbitrary object. This method returnstrueif and only if:objis an instance ofXYBlockRenderer(notnull);objhas the same field values as thisXYBlockRenderer;
- Overrides:
equalsin classAbstractXYItemRenderer- Parameters:
obj- the object (nullpermitted).- Returns:
- A boolean.
-
clone
Returns a clone of this renderer.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classAbstractXYItemRenderer- Returns:
- A clone of this renderer.
- Throws:
CloneNotSupportedException- if there is a problem creating the clone.
-