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:
java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,AnnotationChangeListener
,LegendItemSource
,XYItemRenderer
,PublicCloneable
public class XYBlockRenderer extends AbstractXYItemRenderer implements XYItemRenderer, java.lang.Cloneable, PublicCloneable, java.io.Serializable
A renderer that represents data from anXYZDataset
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 theXYBlockChartDemo1.java
program included in the JFreeChart demo collection:
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private RectangleAnchor
blockAnchor
The anchor point used to align each block to its (x, y) location.private double
blockHeight
The block height (defaults to 1.0).private double
blockWidth
The block width (defaults to 1.0).private PaintScale
paintScale
The paint scale.private double
xOffset
Temporary storage for the x-offset used to align the block anchor.private double
yOffset
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
Constructors Constructor Description XYBlockRenderer()
Creates a newXYBlockRenderer
instance with default attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 thisXYBlockRenderer
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.RectangleAnchor
getBlockAnchor()
Returns the anchor point used to align a block at its (x, y) location.double
getBlockHeight()
Returns the block height, in data/axis units.double
getBlockWidth()
Returns the block width, in data/axis units.PaintScale
getPaintScale()
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
updateOffsets()
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 Detail
-
blockWidth
private double blockWidth
The block width (defaults to 1.0).
-
blockHeight
private double blockHeight
The block height (defaults to 1.0).
-
blockAnchor
private RectangleAnchor blockAnchor
The anchor point used to align each block to its (x, y) location. The default value isRectangleAnchor.CENTER
.
-
xOffset
private double xOffset
Temporary storage for the x-offset used to align the block anchor.
-
yOffset
private double yOffset
Temporary storage for the y-offset used to align the block anchor.
-
paintScale
private PaintScale paintScale
The paint scale.
-
-
Method Detail
-
getBlockWidth
public double getBlockWidth()
Returns the block width, in data/axis units.- Returns:
- The block width.
- See Also:
setBlockWidth(double)
-
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:
getBlockWidth()
-
getBlockHeight
public double getBlockHeight()
Returns the block height, in data/axis units.- Returns:
- The block height.
- See Also:
setBlockHeight(double)
-
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:
getBlockHeight()
-
getBlockAnchor
public RectangleAnchor 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(RectangleAnchor)
-
setBlockAnchor
public 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.- Parameters:
anchor
- the anchor.- See Also:
getBlockAnchor()
-
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 aRendererChangeEvent
to all registered listeners.- Parameters:
scale
- the scale (null
not permitted).- See Also:
getPaintScale()
-
updateOffsets
private void updateOffsets()
Updates the offsets to take into account the block width, height and anchor.
-
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 interfaceXYItemRenderer
- Overrides:
findDomainBounds
in classAbstractXYItemRenderer
- Parameters:
dataset
- the dataset (null
permitted).- Returns:
- The range (
null
if the dataset isnull
or empty). - See Also:
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 interfaceXYItemRenderer
- Overrides:
findRangeBounds
in classAbstractXYItemRenderer
- Parameters:
dataset
- the dataset (null
permitted).- Returns:
- The range (
null
if the dataset isnull
or empty). - See Also:
findDomainBounds(XYDataset)
-
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 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
public boolean equals(java.lang.Object obj)
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
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a clone of this renderer.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classAbstractXYItemRenderer
- Returns:
- A clone of this renderer.
- Throws:
java.lang.CloneNotSupportedException
- if there is a problem creating the clone.
-
-