Package org.jfree.chart.renderer
Class BarRenderer
java.lang.Object
org.jfree.chart.renderer.AbstractRenderer
org.jfree.chart.renderer.AbstractCategoryItemRenderer
org.jfree.chart.renderer.BarRenderer
- All Implemented Interfaces:
Serializable
,Cloneable
,CategoryItemRenderer
,org.jfree.util.PublicCloneable
- Direct Known Subclasses:
BarRenderer3D
,IntervalBarRenderer
,LayeredBarRenderer
,StackedBarRenderer
,StatisticalBarRenderer
,WaterfallBarRenderer
public class BarRenderer extends AbstractCategoryItemRenderer implements Cloneable, org.jfree.util.PublicCloneable, Serializable
A
CategoryItemRenderer
that draws individual data items as bars.- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static double
BAR_OUTLINE_WIDTH_THRESHOLD
Constant that controls the minimum width before a bar has an outline drawn.static double
DEFAULT_ITEM_MARGIN
The default item margin percentage.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
Constructors Constructor Description BarRenderer()
Creates a new bar renderer with default settings. -
Method Summary
Modifier and Type Method Description void
drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column)
Draws the bar for a single (series, category) data item.boolean
equals(Object object)
Tests this instance for equality with an arbitrary object.org.jfree.ui.GradientPaintTransformer
getGradientPaintTransformer()
Returns the gradient paint transformer (an object used to transform gradient paint objects to fit each bar.double
getItemMargin()
Returns the item margin as a percentage of the available space for all bars.double
getLowerClip()
Returns the lower clip value.double
getMaxBarWidth()
Returns the maximum bar width, as a percentage of the available drawing space.double
getMinimumBarLength()
Returns the minimum bar length (in Java2D units).ItemLabelPosition
getNegativeItemLabelPositionFallback()
Returns the fallback position for negative item labels that don't fit within a bar.ItemLabelPosition
getPositiveItemLabelPositionFallback()
Returns the fallback position for positive item labels that don't fit within a bar.double
getUpperClip()
Returns the upper clip value.CategoryItemRendererState
initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info)
Initialises the renderer and returns a state object that will be passed to subsequent calls to the drawItem method.boolean
isDrawBarOutline()
Returns a flag that controls whether or not bar outlines are drawn.void
setDrawBarOutline(boolean draw)
Sets the flag that controls whether or not bar outlines are drawn and sends aRendererChangeEvent
to all registered listeners.void
setGradientPaintTransformer(org.jfree.ui.GradientPaintTransformer transformer)
Sets the gradient paint transformer and sends aRendererChangeEvent
to all registered listeners.void
setItemMargin(double percent)
Sets the item margin and sends aRendererChangeEvent
to all registered listeners.void
setMaxBarWidth(double percent)
Sets the maximum bar width, which is specified as a percentage of the available space for all bars, and sends aRendererChangeEvent
to all registered listeners.void
setMinimumBarLength(double min)
Sets the minimum bar length and sends aRendererChangeEvent
to all registered listeners.void
setNegativeItemLabelPositionFallback(ItemLabelPosition position)
Sets the fallback position for negative item labels that don't fit within a bar, and sends aRendererChangeEvent
to all registered listeners.void
setPositiveItemLabelPositionFallback(ItemLabelPosition position)
Sets the fallback position for positive item labels that don't fit within a bar, and sends aRendererChangeEvent
to all registered listeners.Methods inherited from class org.jfree.chart.renderer.AbstractCategoryItemRenderer
clone, drawBackground, drawDomainGridline, drawOutline, drawRangeGridline, drawRangeMarker, getBaseItemURLGenerator, getBaseLabelGenerator, getBaseToolTipGenerator, getColumnCount, getDrawingSupplier, getItemURLGenerator, getLabelGenerator, getLegendItem, getPlot, getRangeExtent, getRowCount, getSeriesItemURLGenerator, getSeriesLabelGenerator, getSeriesToolTipGenerator, getToolTipGenerator, getToolTipGenerator, hashCode, setBaseItemURLGenerator, setBaseLabelGenerator, setBaseToolTipGenerator, setItemURLGenerator, setLabelGenerator, setPlot, setSeriesItemURLGenerator, setSeriesLabelGenerator, setSeriesToolTipGenerator, setToolTipGenerator
Methods inherited from class org.jfree.chart.renderer.AbstractRenderer
addChangeListener, getBaseItemLabelAnchor, getBaseItemLabelAngle, getBaseItemLabelFont, getBaseItemLabelPaint, getBaseItemLabelRotationAnchor, getBaseItemLabelsVisible, getBaseItemLabelTextAnchor, getBaseNegativeItemLabelPosition, getBaseOutlinePaint, getBaseOutlineStroke, getBasePaint, getBasePositiveItemLabelPosition, getBaseShape, getBaseStroke, getItemLabelAnchor, getItemLabelAnchorOffset, getItemLabelAngle, getItemLabelFont, getItemLabelFont, getItemLabelPaint, getItemLabelPaint, getItemLabelRotationAnchor, getItemLabelTextAnchor, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getNegativeItemLabelPosition, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getPositiveItemLabelPosition, getSeriesItemLabelAnchor, getSeriesItemLabelAngle, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesItemLabelRotationAnchor, getSeriesItemLabelTextAnchor, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, isItemLabelVisible, isSeriesItemLabelsVisible, notifyListeners, removeChangeListener, setBaseAngle, setBaseItemLabelAnchor, setBaseItemLabelFont, setBaseItemLabelFont, setBaseItemLabelPaint, setBaseItemLabelPaint, setBaseItemLabelRotationAnchor, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelTextAnchor, setBaseNegativeItemLabelPosition, setBaseNegativeItemLabelPosition, setBaseOutlinePaint, setBaseOutlinePaint, setBaseOutlineStroke, setBaseOutlineStroke, setBasePaint, setBasePaint, setBasePositiveItemLabelPosition, setBasePositiveItemLabelPosition, setBaseShape, setBaseShape, setBaseStroke, setBaseStroke, setItemLabelAnchor, setItemLabelAnchorOffset, setItemLabelAngle, setItemLabelFont, setItemLabelFont, setItemLabelPaint, setItemLabelPaint, setItemLabelRotationAnchor, setItemLabelsVisible, setItemLabelsVisible, setItemLabelsVisible, setItemLabelTextAnchor, setNegativeItemLabelPosition, setNegativeItemLabelPosition, setOutlinePaint, setOutlinePaint, setOutlineStroke, setOutlineStroke, setPaint, setPaint, setPositiveItemLabelPosition, setPositiveItemLabelPosition, setSeriesAngle, setSeriesItemLabelAnchor, setSeriesItemLabelFont, setSeriesItemLabelFont, setSeriesItemLabelPaint, setSeriesItemLabelPaint, setSeriesItemLabelRotationAnchor, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelTextAnchor, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesShape, setSeriesStroke, setSeriesStroke, setShape, setShape, setStroke, setStroke
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jfree.chart.renderer.CategoryItemRenderer
addChangeListener, getBaseItemLabelAnchor, getBaseItemLabelFont, getBaseItemLabelPaint, getBaseItemLabelsVisible, getBaseItemLabelTextAnchor, getBaseNegativeItemLabelPosition, getBaseOutlinePaint, getBaseOutlineStroke, getBasePaint, getBasePositiveItemLabelPosition, getBaseShape, getBaseStroke, getItemLabelAnchor, getItemLabelFont, getItemLabelFont, getItemLabelPaint, getItemLabelPaint, getItemLabelTextAnchor, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getNegativeItemLabelPosition, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getPositiveItemLabelPosition, getSeriesItemLabelAnchor, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesItemLabelTextAnchor, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, isItemLabelVisible, isSeriesItemLabelsVisible, removeChangeListener, setBaseItemLabelAnchor, setBaseItemLabelFont, setBaseItemLabelPaint, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelTextAnchor, setBaseNegativeItemLabelPosition, setBaseNegativeItemLabelPosition, setBaseOutlinePaint, setBaseOutlineStroke, setBasePaint, setBasePositiveItemLabelPosition, setBasePositiveItemLabelPosition, setBaseShape, setBaseStroke, setItemLabelAnchor, setItemLabelFont, setItemLabelPaint, setItemLabelsVisible, setItemLabelsVisible, setItemLabelsVisible, setItemLabelTextAnchor, setNegativeItemLabelPosition, setNegativeItemLabelPosition, setOutlinePaint, setOutlineStroke, setPaint, setPositiveItemLabelPosition, setPositiveItemLabelPosition, setSeriesItemLabelAnchor, setSeriesItemLabelFont, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelTextAnchor, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesStroke, setShape, setStroke
Methods inherited from interface org.jfree.util.PublicCloneable
clone
-
Field Details
-
DEFAULT_ITEM_MARGIN
public static final double DEFAULT_ITEM_MARGINThe default item margin percentage.- See Also:
- Constant Field Values
-
BAR_OUTLINE_WIDTH_THRESHOLD
public static final double BAR_OUTLINE_WIDTH_THRESHOLDConstant that controls the minimum width before a bar has an outline drawn.- See Also:
- Constant Field Values
-
-
Constructor Details
-
BarRenderer
public BarRenderer()Creates a new bar renderer with default settings.
-
-
Method Details
-
getItemMargin
public double getItemMargin()Returns the item margin as a percentage of the available space for all bars.- Returns:
- The margin percentage (where 0.10 is ten percent).
-
setItemMargin
public void setItemMargin(double percent)Sets the item margin and sends aRendererChangeEvent
to all registered listeners. The value is expressed as a percentage of the available width for plotting all the bars, with the resulting amount to be distributed between all the bars evenly.- Parameters:
percent
- the margin (where 0.10 is ten percent).
-
isDrawBarOutline
public boolean isDrawBarOutline()Returns a flag that controls whether or not bar outlines are drawn.- Returns:
- A boolean.
-
setDrawBarOutline
public void setDrawBarOutline(boolean draw)Sets the flag that controls whether or not bar outlines are drawn and sends aRendererChangeEvent
to all registered listeners.- Parameters:
draw
- the flag.
-
getMaxBarWidth
public double getMaxBarWidth()Returns the maximum bar width, as a percentage of the available drawing space.- Returns:
- the maximum bar width.
-
setMaxBarWidth
public void setMaxBarWidth(double percent)Sets the maximum bar width, which is specified as a percentage of the available space for all bars, and sends aRendererChangeEvent
to all registered listeners.- Parameters:
percent
- the percent (where 0.05 is five percent).
-
getMinimumBarLength
public double getMinimumBarLength()Returns the minimum bar length (in Java2D units).- Returns:
- the minimum bar length.
-
setMinimumBarLength
public void setMinimumBarLength(double min)Sets the minimum bar length and sends aRendererChangeEvent
to all registered listeners. The minimum bar length is specified in Java2D units, and can be used to prevent bars that represent very small data values from disappearing when drawn on the screen.- Parameters:
min
- the minimum bar length (in Java2D units).
-
getGradientPaintTransformer
public org.jfree.ui.GradientPaintTransformer getGradientPaintTransformer()Returns the gradient paint transformer (an object used to transform gradient paint objects to fit each bar.- Returns:
- A transformer (
null
possible).
-
setGradientPaintTransformer
public void setGradientPaintTransformer(org.jfree.ui.GradientPaintTransformer transformer)Sets the gradient paint transformer and sends aRendererChangeEvent
to all registered listeners.- Parameters:
transformer
- the transformer (null
permitted).
-
getPositiveItemLabelPositionFallback
Returns the fallback position for positive item labels that don't fit within a bar.- Returns:
- The fallback position (
null
possible).
-
setPositiveItemLabelPositionFallback
Sets the fallback position for positive item labels that don't fit within a bar, and sends aRendererChangeEvent
to all registered listeners.- Parameters:
position
- the position (null
permitted).
-
getNegativeItemLabelPositionFallback
Returns the fallback position for negative item labels that don't fit within a bar.- Returns:
- The fallback position (
null
possible).
-
setNegativeItemLabelPositionFallback
Sets the fallback position for negative item labels that don't fit within a bar, and sends aRendererChangeEvent
to all registered listeners.- Parameters:
position
- the position (null
permitted).
-
getLowerClip
public double getLowerClip()Returns the lower clip value.This value is recalculated in the initialise() method.
- Returns:
- The value.
-
getUpperClip
public double getUpperClip()Returns the upper clip value.This value is recalculated in the initialise() method.
- Returns:
- The value.
-
initialise
public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info)Initialises the renderer and returns a state object that will be passed to subsequent calls to the drawItem method.This method gets called once at the start of the process of drawing a chart.
- Specified by:
initialise
in interfaceCategoryItemRenderer
- Overrides:
initialise
in classAbstractCategoryItemRenderer
- Parameters:
g2
- the graphics device.dataArea
- the area in which the data is to be plotted.plot
- the plot.rendererIndex
- the renderer index.info
- collects chart rendering information for return to caller.- Returns:
- The renderer state.
-
drawItem
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column)Draws the bar for a single (series, category) data item.- Specified by:
drawItem
in interfaceCategoryItemRenderer
- Parameters:
g2
- the graphics device.state
- the renderer state.dataArea
- the data area.plot
- the plot.domainAxis
- the domain axis.rangeAxis
- the range axis.dataset
- the dataset.row
- the row index (zero-based).column
- the column index (zero-based).
-
equals
Tests this instance for equality with an arbitrary object.- Overrides:
equals
in classAbstractCategoryItemRenderer
- Parameters:
object
- the object (null
permitted).- Returns:
- A boolean.
-