Package org.jfree.chart.renderer.xy
Class ClusteredXYBarRenderer
java.lang.Object
org.jfree.chart.renderer.AbstractRenderer
org.jfree.chart.renderer.xy.AbstractXYItemRenderer
org.jfree.chart.renderer.xy.XYBarRenderer
org.jfree.chart.renderer.xy.ClusteredXYBarRenderer
- All Implemented Interfaces:
Serializable,Cloneable,EventListener,AnnotationChangeListener,LegendItemSource,XYItemRenderer,PublicCloneable
public class ClusteredXYBarRenderer
extends XYBarRenderer
implements Cloneable, PublicCloneable, Serializable
An extension of
XYBarRenderer that displays bars for different
series values at the same x next to each other. The assumption here is
that for each x (time or else) there is a y value for each series. If
this is not the case, there will be spaces between bars for a given x.
The example shown here is generated by the
ClusteredXYBarRendererDemo1.java program included in the
JFreeChart demo collection:
This renderer does not include code to calculate the crosshair point for the plot.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jfree.chart.renderer.xy.XYBarRenderer
XYBarRenderer.XYBarRendererState -
Field Summary
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
ConstructorsConstructorDescriptionDefault constructor.ClusteredXYBarRenderer(double margin, boolean centerBarAtStartValue) Constructs a new XY clustered bar renderer. -
Method Summary
Modifier and TypeMethodDescriptionclone()Returns a clone of the 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 visual representation of a single data item.booleanTests this renderer for equality with an arbitrary object, returningtrueifobjis aClusteredXYBarRendererwith the same settings as this renderer, andfalseotherwise.findDomainBounds(XYDataset dataset) Returns the x-value bounds for the specified dataset.protected RangeIterates over the items in anIntervalXYDatasetto find the range of x-values including the interval OFFSET so that it centers the interval around the start value.intReturns the number of passes through the dataset that this renderer requires.Methods inherited from class org.jfree.chart.renderer.xy.XYBarRenderer
drawItemLabel, findRangeBounds, getBarAlignmentFactor, getBarPainter, getBase, getDefaultBarPainter, getDefaultShadowsVisible, getGradientPaintTransformer, getLegendBar, getLegendItem, getMargin, getMinimumLabelSize, getNegativeItemLabelPositionFallback, getPositiveItemLabelPositionFallback, getShadowsVisible, getShadowXOffset, getShadowYOffset, getUseYInterval, initialise, isDrawBarOutline, isShowLabelInsideVisibleBar, setBarAlignmentFactor, setBarPainter, setBase, setDefaultBarPainter, setDefaultShadowsVisible, setDrawBarOutline, setGradientPaintTransformer, setLegendBar, setMargin, setMinimumLabelSize, setNegativeItemLabelPositionFallback, setPositiveItemLabelPositionFallback, setShadowVisible, setShadowXOffset, setShadowYOffset, setShowLabelInsideVisibleBar, setUseYIntervalMethods 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, getLegendItemLabelGenerator, getLegendItems, getLegendItemToolTipGenerator, getLegendItemURLGenerator, getPlot, getSeriesItemLabelGenerator, getSeriesToolTipGenerator, getToolTipGenerator, getURLGenerator, hashCode, 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, getLegendItemLabelGenerator, getNegativeItemLabelPosition, getPlot, getPositiveItemLabelPosition, getSeriesCreateEntities, getSeriesFillPaint, getSeriesItemLabelFont, getSeriesItemLabelGenerator, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesToolTipGenerator, getSeriesVisible, getSeriesVisibleInLegend, getToolTipGenerator, getURLGenerator, 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
-
ClusteredXYBarRenderer
public ClusteredXYBarRenderer()Default constructor. Bar margin is set to 0.0. -
ClusteredXYBarRenderer
Constructs a new XY clustered bar renderer.- Parameters:
margin- the percentage amount to trim from the width of each bar.centerBarAtStartValue- if true, bars will be centered on the start of the time period.
-
-
Method Details
-
getPassCount
Returns the number of passes through the dataset that this renderer requires. In this case, two passes are required, the first for drawing the shadows (if visible), and the second for drawing the bars.- Specified by:
getPassCountin interfaceXYItemRenderer- Overrides:
getPassCountin classAbstractXYItemRenderer- Returns:
2.
-
findDomainBounds
Returns the x-value bounds for the specified dataset.- Specified by:
findDomainBoundsin interfaceXYItemRenderer- Overrides:
findDomainBoundsin classXYBarRenderer- Parameters:
dataset- the dataset (nullpermitted).- Returns:
- The bounds (possibly
null). - See Also:
-
findDomainBoundsWithOffset
Iterates over the items in anIntervalXYDatasetto find the range of x-values including the interval OFFSET so that it centers the interval around the start value.- Parameters:
dataset- the dataset (nullnot permitted).- Returns:
- The range (possibly
null).
-
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 visual representation of a single data item. This method is mostly copied from the superclass, the change is that in the calculated space for a singe bar we draw bars for each series next to each other. The width of each bar is the available width divided by the number of series. Bars for each series are drawn in order left to right.- Specified by:
drawItemin interfaceXYItemRenderer- Overrides:
drawItemin classXYBarRenderer- Parameters:
g2- the graphics device.state- the renderer state.dataArea- the area within which the plot is being drawn.info- collects information about the drawing.plot- the plot (can be used to obtain standard color information etc).domainAxis- the domain axis.rangeAxis- the range axis.dataset- the dataset.series- the series index.item- the item index.crosshairState- crosshair information for the plot (nullpermitted).pass- the pass index.
-
equals
Tests this renderer for equality with an arbitrary object, returningtrueifobjis aClusteredXYBarRendererwith the same settings as this renderer, andfalseotherwise.- Overrides:
equalsin classXYBarRenderer- Parameters:
obj- the object (nullpermitted).- Returns:
- A boolean.
-
clone
Returns a clone of the renderer.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classXYBarRenderer- Returns:
- A clone.
- Throws:
CloneNotSupportedException- if the renderer cannot be cloned.
-