Package org.jfree.chart.renderer.xy
Class XYBarRenderer
- java.lang.Object
-
- org.jfree.chart.renderer.AbstractRenderer
-
- org.jfree.chart.renderer.xy.AbstractXYItemRenderer
-
- org.jfree.chart.renderer.xy.XYBarRenderer
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.EventListener,AnnotationChangeListener,LegendItemSource,XYItemRenderer,PublicCloneable
- Direct Known Subclasses:
ClusteredXYBarRenderer,StackedXYBarRenderer
public class XYBarRenderer extends AbstractXYItemRenderer implements XYItemRenderer, java.lang.Cloneable, PublicCloneable, java.io.Serializable
A renderer that draws bars on anXYPlot(requires anIntervalXYDataset). The example shown here is generated by theXYBarChartDemo1.javaprogram included in the JFreeChart demo collection:

- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classXYBarRenderer.XYBarRendererStateThe state class used by this renderer.
-
Field Summary
Fields Modifier and Type Field Description private doublebarAlignmentFactorA factor used to align the bars about the x-value.private XYBarPainterbarPainterThe bar painter (nevernull).private doublebaseThe default base value for the bars.private static XYBarPainterdefaultBarPainterThe default bar painter assigned to each new instance of this renderer.private static booleandefaultShadowsVisibleThe default value for the initialisation of the shadowsVisible flag.private booleandrawBarOutlineA flag that controls whether or not bar outlines are drawn.private GradientPaintTransformergradientPaintTransformerAn optional class used to transform gradient paint objects to fit each bar.private java.awt.ShapelegendBarThe shape used to represent a bar in each legend item (this should never benull).private doublemarginPercentage margin (to reduce the width of bars).private java.awt.DimensionminimumLabelSizeThe minimum size for the bar to draw a labelprivate ItemLabelPositionnegativeItemLabelPositionFallbackThe fallback position if a negative item label doesn't fit inside the bar.private ItemLabelPositionpositiveItemLabelPositionFallbackThe fallback position if a positive item label doesn't fit inside the bar.private static longserialVersionUIDFor serialization.private booleanshadowsVisibleThe flag that controls whether or not shadows are drawn for the bars.private doubleshadowXOffsetThe x-offset for the shadow effect.private doubleshadowYOffsetThe y-offset for the shadow effect.private booleanshowLabelInsideVisibleBartrueif the label should be aligned to the visible part of the bar.private booleanuseYIntervalA flag that controls whether the bars use the y-interval supplied by the dataset.-
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 XYBarRenderer()The default constructor.XYBarRenderer(double margin)Constructs a new renderer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.awt.geom.Point2DcalculateLabelAnchorPoint(ItemLabelAnchor anchor, java.awt.geom.Rectangle2D bar, PlotOrientation orientation)Calculates the item label anchor point.private java.lang.StringcalculateLabeltoDraw(java.lang.String label, java.awt.geom.Point2D anchorPoint, ItemLabelPosition position, java.awt.geom.Rectangle2D bar, java.awt.Graphics2D g2)java.lang.Objectclone()Returns a clone of the renderer.voiddrawItem(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 visual representation of a single data item.protected voiddrawItemLabel(java.awt.Graphics2D g, XYDataset dataset, int series, int item, XYPlot plot, XYItemLabelGenerator generator, java.awt.geom.Rectangle2D bar, boolean negative)Draws an item label.booleanequals(java.lang.Object obj)Tests this renderer for equality with an arbitrary object.RangefindDomainBounds(XYDataset dataset)Returns the lower and upper bounds (range) of the x-values in the specified dataset.RangefindRangeBounds(XYDataset dataset)Returns the lower and upper bounds (range) of the y-values in the specified dataset.doublegetBarAlignmentFactor()Returns the bar alignment factor.XYBarPaintergetBarPainter()Returns the bar painter.doublegetBase()Returns the base value for the bars.static XYBarPaintergetDefaultBarPainter()Returns the default bar painter.static booleangetDefaultShadowsVisible()Returns the default value for theshadowsVisibleflag.GradientPaintTransformergetGradientPaintTransformer()Returns the gradient paint transformer (an object used to transform gradient paint objects to fit each bar).java.awt.ShapegetLegendBar()Returns the shape used to represent bars in each legend item.LegendItemgetLegendItem(int datasetIndex, int series)Returns a default legend item for the specified series.doublegetMargin()Returns the margin which is a percentage amount by which the bars are trimmed.java.awt.DimensiongetMinimumLabelSize()Returns the minimum size for the bar to draw a label.ItemLabelPositiongetNegativeItemLabelPositionFallback()Returns the fallback position for negative item labels that don't fit within a bar.ItemLabelPositiongetPositiveItemLabelPositionFallback()Returns the fallback position for positive item labels that don't fit within a bar.booleangetShadowsVisible()Returns the flag that controls whether or not shadows are drawn for the bars.doublegetShadowXOffset()Returns the shadow x-offset.doublegetShadowYOffset()Returns the shadow y-offset.booleangetUseYInterval()Returns a flag that determines whether the y-interval from the dataset is used to calculate the length of each bar.XYItemRendererStateinitialise(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info)Initialises the renderer and returns a state object that should be passed to all subsequent calls to the drawItem() method.booleanisDrawBarOutline()Returns a flag that controls whether or not bar outlines are drawn.booleanisShowLabelInsideVisibleBar()Returnstrueif the label should be aligned to the visible part of the bar.private voidreadObject(java.io.ObjectInputStream stream)Provides serialization support.voidsetBarAlignmentFactor(double factor)Sets the bar alignment factor and sends aRendererChangeEventto all registered listeners.voidsetBarPainter(XYBarPainter painter)Sets the bar painter and sends aRendererChangeEventto all registered listeners.voidsetBase(double base)Sets the base value for the bars and sends aRendererChangeEventto all registered listeners.static voidsetDefaultBarPainter(XYBarPainter painter)Sets the default bar painter.static voidsetDefaultShadowsVisible(boolean visible)Sets the default value for the shadows visible flag.voidsetDrawBarOutline(boolean draw)Sets the flag that controls whether or not bar outlines are drawn and sends aRendererChangeEventto all registered listeners.voidsetGradientPaintTransformer(GradientPaintTransformer transformer)Sets the gradient paint transformer and sends aRendererChangeEventto all registered listeners.voidsetLegendBar(java.awt.Shape bar)Sets the shape used to represent bars in each legend item and sends aRendererChangeEventto all registered listeners.voidsetMargin(double margin)Sets the percentage amount by which the bars are trimmed and sends aRendererChangeEventto all registered listeners.voidsetMinimumLabelSize(java.awt.Dimension minimumLabelSize)Sets the minimum size for the bar to draw a label.voidsetNegativeItemLabelPositionFallback(ItemLabelPosition position)Sets the fallback position for negative item labels that don't fit within a bar, and sends aRendererChangeEventto all registered listeners.voidsetPositiveItemLabelPositionFallback(ItemLabelPosition position)Sets the fallback position for positive item labels that don't fit within a bar, and sends aRendererChangeEventto all registered listeners.voidsetShadowVisible(boolean visible)Sets the flag that controls whether or not the renderer draws shadows for the bars, and sends aRendererChangeEventto all registered listeners.voidsetShadowXOffset(double offset)Sets the x-offset for the bar shadow and sends aRendererChangeEventto all registered listeners.voidsetShadowYOffset(double offset)Sets the y-offset for the bar shadow and sends aRendererChangeEventto all registered listeners.voidsetShowLabelInsideVisibleBar(boolean showLabelInsideVisibleBar)Sets whether the label should be aligned to the visible part of the bar.
This setting has no effect whenItemLabelAnchor.isInternal()returnsfalse.voidsetUseYInterval(boolean use)Sets the flag that determines whether the y-interval from the dataset is used to calculate the length of each bar, and sends aRendererChangeEventto all registered listeners.private voidwriteObject(java.io.ObjectOutputStream stream)Provides serialization support.-
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, getLegendItemLabelGenerator, getLegendItems, getLegendItemToolTipGenerator, getLegendItemURLGenerator, getPassCount, getPlot, getSeriesItemLabelGenerator, getSeriesToolTipGenerator, getToolTipGenerator, getURLGenerator, hashCode, 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, getLegendItemLabelGenerator, getNegativeItemLabelPosition, getPassCount, 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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
defaultBarPainter
private static XYBarPainter defaultBarPainter
The default bar painter assigned to each new instance of this renderer.
-
defaultShadowsVisible
private static boolean defaultShadowsVisible
The default value for the initialisation of the shadowsVisible flag.
-
base
private double base
The default base value for the bars.
-
useYInterval
private boolean useYInterval
A flag that controls whether the bars use the y-interval supplied by the dataset.
-
margin
private double margin
Percentage margin (to reduce the width of bars).
-
drawBarOutline
private boolean drawBarOutline
A flag that controls whether or not bar outlines are drawn.
-
gradientPaintTransformer
private GradientPaintTransformer gradientPaintTransformer
An optional class used to transform gradient paint objects to fit each bar.
-
legendBar
private transient java.awt.Shape legendBar
The shape used to represent a bar in each legend item (this should never benull).
-
positiveItemLabelPositionFallback
private ItemLabelPosition positiveItemLabelPositionFallback
The fallback position if a positive item label doesn't fit inside the bar.
-
negativeItemLabelPositionFallback
private ItemLabelPosition negativeItemLabelPositionFallback
The fallback position if a negative item label doesn't fit inside the bar.
-
barPainter
private XYBarPainter barPainter
The bar painter (nevernull).
-
shadowsVisible
private boolean shadowsVisible
The flag that controls whether or not shadows are drawn for the bars.
-
shadowXOffset
private double shadowXOffset
The x-offset for the shadow effect.
-
shadowYOffset
private double shadowYOffset
The y-offset for the shadow effect.
-
barAlignmentFactor
private double barAlignmentFactor
A factor used to align the bars about the x-value.
-
minimumLabelSize
private java.awt.Dimension minimumLabelSize
The minimum size for the bar to draw a label
-
showLabelInsideVisibleBar
private boolean showLabelInsideVisibleBar
trueif the label should be aligned to the visible part of the bar.
-
-
Method Detail
-
getDefaultBarPainter
public static XYBarPainter getDefaultBarPainter()
Returns the default bar painter.- Returns:
- The default bar painter.
-
setDefaultBarPainter
public static void setDefaultBarPainter(XYBarPainter painter)
Sets the default bar painter.- Parameters:
painter- the painter (nullnot permitted).
-
getDefaultShadowsVisible
public static boolean getDefaultShadowsVisible()
Returns the default value for theshadowsVisibleflag.- Returns:
- A boolean.
- See Also:
setDefaultShadowsVisible(boolean)
-
setDefaultShadowsVisible
public static void setDefaultShadowsVisible(boolean visible)
Sets the default value for the shadows visible flag.- Parameters:
visible- the new value for the default.- See Also:
getDefaultShadowsVisible()
-
getBase
public double getBase()
Returns the base value for the bars.- Returns:
- The base value for the bars.
- See Also:
setBase(double)
-
setBase
public void setBase(double base)
Sets the base value for the bars and sends aRendererChangeEventto all registered listeners. The base value is not used if the dataset's y-interval is being used to determine the bar length.- Parameters:
base- the new base value.- See Also:
getBase(),getUseYInterval()
-
getUseYInterval
public boolean getUseYInterval()
Returns a flag that determines whether the y-interval from the dataset is used to calculate the length of each bar.- Returns:
- A boolean.
- See Also:
setUseYInterval(boolean)
-
setUseYInterval
public void setUseYInterval(boolean use)
Sets the flag that determines whether the y-interval from the dataset is used to calculate the length of each bar, and sends aRendererChangeEventto all registered listeners.- Parameters:
use- the flag.- See Also:
getUseYInterval()
-
getMargin
public double getMargin()
Returns the margin which is a percentage amount by which the bars are trimmed.- Returns:
- The margin.
- See Also:
setMargin(double)
-
setMargin
public void setMargin(double margin)
Sets the percentage amount by which the bars are trimmed and sends aRendererChangeEventto all registered listeners.- Parameters:
margin- the new margin.- See Also:
getMargin()
-
isDrawBarOutline
public boolean isDrawBarOutline()
Returns a flag that controls whether or not bar outlines are drawn.- Returns:
- A boolean.
- See Also:
setDrawBarOutline(boolean)
-
setDrawBarOutline
public void setDrawBarOutline(boolean draw)
Sets the flag that controls whether or not bar outlines are drawn and sends aRendererChangeEventto all registered listeners.- Parameters:
draw- the flag.- See Also:
isDrawBarOutline()
-
getGradientPaintTransformer
public GradientPaintTransformer getGradientPaintTransformer()
Returns the gradient paint transformer (an object used to transform gradient paint objects to fit each bar).- Returns:
- A transformer (
nullpossible). - See Also:
setGradientPaintTransformer(GradientPaintTransformer)
-
setGradientPaintTransformer
public void setGradientPaintTransformer(GradientPaintTransformer transformer)
Sets the gradient paint transformer and sends aRendererChangeEventto all registered listeners.- Parameters:
transformer- the transformer (nullpermitted).- See Also:
getGradientPaintTransformer()
-
getLegendBar
public java.awt.Shape getLegendBar()
Returns the shape used to represent bars in each legend item.- Returns:
- The shape used to represent bars in each legend item (never
null). - See Also:
setLegendBar(Shape)
-
setLegendBar
public void setLegendBar(java.awt.Shape bar)
Sets the shape used to represent bars in each legend item and sends aRendererChangeEventto all registered listeners.- Parameters:
bar- the bar shape (nullnot permitted).- See Also:
getLegendBar()
-
getPositiveItemLabelPositionFallback
public ItemLabelPosition getPositiveItemLabelPositionFallback()
Returns the fallback position for positive item labels that don't fit within a bar.- Returns:
- The fallback position (
nullpossible). - See Also:
setPositiveItemLabelPositionFallback(ItemLabelPosition)
-
setPositiveItemLabelPositionFallback
public void setPositiveItemLabelPositionFallback(ItemLabelPosition position)
Sets the fallback position for positive item labels that don't fit within a bar, and sends aRendererChangeEventto all registered listeners.- Parameters:
position- the position (nullpermitted).- See Also:
getPositiveItemLabelPositionFallback()
-
getNegativeItemLabelPositionFallback
public ItemLabelPosition getNegativeItemLabelPositionFallback()
Returns the fallback position for negative item labels that don't fit within a bar.- Returns:
- The fallback position (
nullpossible). - See Also:
setNegativeItemLabelPositionFallback(ItemLabelPosition)
-
setNegativeItemLabelPositionFallback
public void setNegativeItemLabelPositionFallback(ItemLabelPosition position)
Sets the fallback position for negative item labels that don't fit within a bar, and sends aRendererChangeEventto all registered listeners.- Parameters:
position- the position (nullpermitted).- See Also:
getNegativeItemLabelPositionFallback()
-
getBarPainter
public XYBarPainter getBarPainter()
Returns the bar painter.- Returns:
- The bar painter (never
null).
-
setBarPainter
public void setBarPainter(XYBarPainter painter)
Sets the bar painter and sends aRendererChangeEventto all registered listeners.- Parameters:
painter- the painter (nullnot permitted).
-
getShadowsVisible
public boolean getShadowsVisible()
Returns the flag that controls whether or not shadows are drawn for the bars.- Returns:
- A boolean.
-
setShadowVisible
public void setShadowVisible(boolean visible)
Sets the flag that controls whether or not the renderer draws shadows for the bars, and sends aRendererChangeEventto all registered listeners.- Parameters:
visible- the new flag value.
-
getShadowXOffset
public double getShadowXOffset()
Returns the shadow x-offset.- Returns:
- The shadow x-offset.
-
setShadowXOffset
public void setShadowXOffset(double offset)
Sets the x-offset for the bar shadow and sends aRendererChangeEventto all registered listeners.- Parameters:
offset- the offset.
-
getShadowYOffset
public double getShadowYOffset()
Returns the shadow y-offset.- Returns:
- The shadow y-offset.
-
setShadowYOffset
public void setShadowYOffset(double offset)
Sets the y-offset for the bar shadow and sends aRendererChangeEventto all registered listeners.- Parameters:
offset- the offset.
-
getBarAlignmentFactor
public double getBarAlignmentFactor()
Returns the bar alignment factor.- Returns:
- The bar alignment factor.
-
setBarAlignmentFactor
public void setBarAlignmentFactor(double factor)
Sets the bar alignment factor and sends aRendererChangeEventto all registered listeners. If the alignment factor is outside the range 0.0 to 1.0, no alignment will be performed by the renderer.- Parameters:
factor- the factor.
-
getMinimumLabelSize
public java.awt.Dimension getMinimumLabelSize()
Returns the minimum size for the bar to draw a label.- Returns:
- The minimum size to draw a label.
-
setMinimumLabelSize
public void setMinimumLabelSize(java.awt.Dimension minimumLabelSize)
Sets the minimum size for the bar to draw a label.- Parameters:
minimumLabelSize- The size
-
isShowLabelInsideVisibleBar
public boolean isShowLabelInsideVisibleBar()
Returnstrueif the label should be aligned to the visible part of the bar.- Returns:
trueif the label should be aligned to the visible part of the bar.- See Also:
setShowLabelInsideVisibleBar(boolean)
-
setShowLabelInsideVisibleBar
public void setShowLabelInsideVisibleBar(boolean showLabelInsideVisibleBar)
Sets whether the label should be aligned to the visible part of the bar.
This setting has no effect whenItemLabelAnchor.isInternal()returnsfalse.- Parameters:
showLabelInsideVisibleBar-trueto align to the visible part.
-
initialise
public XYItemRendererState initialise(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info)
Initialises the renderer and returns a state object that should be passed to all subsequent calls to the drawItem() method. Here we calculate the Java2D y-coordinate for zero, since all the bars have their bases fixed at zero.- Specified by:
initialisein interfaceXYItemRenderer- Overrides:
initialisein classAbstractXYItemRenderer- Parameters:
g2- the graphics device.dataArea- the area inside the axes.plot- the plot.dataset- the data.info- an optional info collection object to return data back to the caller.- Returns:
- A state object.
-
getLegendItem
public LegendItem getLegendItem(int datasetIndex, int series)
Returns a default legend item for the specified series. Subclasses should override this method to generate customised items.- Specified by:
getLegendItemin interfaceXYItemRenderer- Overrides:
getLegendItemin classAbstractXYItemRenderer- Parameters:
datasetIndex- the dataset index (zero-based).series- the series index (zero-based).- Returns:
- A legend item for the series.
-
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 visual representation of a single data item.- Specified by:
drawItemin interfaceXYItemRenderer- 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 (zero-based).item- the item index (zero-based).crosshairState- crosshair information for the plot (nullpermitted).pass- the pass index.
-
drawItemLabel
protected void drawItemLabel(java.awt.Graphics2D g, XYDataset dataset, int series, int item, XYPlot plot, XYItemLabelGenerator generator, java.awt.geom.Rectangle2D bar, boolean negative)Draws an item label. This method is provided as an alternative toAbstractXYItemRenderer.drawItemLabel(Graphics2D, PlotOrientation, XYDataset, int, int, double, double, boolean)so that the bar can be used to calculate the label anchor point.- Parameters:
g- the graphics device.dataset- the dataset.series- the series index.item- the item index.plot- the plot.generator- the label generator (nullpermitted, in which case the method does nothing, just returns).bar- the bar.negative- a flag indicating a negative value.
-
calculateLabeltoDraw
private java.lang.String calculateLabeltoDraw(java.lang.String label, java.awt.geom.Point2D anchorPoint, ItemLabelPosition position, java.awt.geom.Rectangle2D bar, java.awt.Graphics2D g2)- Returns:
- The label to draw or
nullif label should not be drawn.
-
calculateLabelAnchorPoint
private java.awt.geom.Point2D calculateLabelAnchorPoint(ItemLabelAnchor anchor, java.awt.geom.Rectangle2D bar, PlotOrientation orientation)
Calculates the item label anchor point.Inside: +-----------------+ | 10/11 12 1/2 | | 9 C 3 | | 7/8 6 4/5 | +-----------------+ Outside: 10/11 12 1/2 +----------------+ | | 9 | | 3 | | +----------------+ 7/8 6 4/5- Parameters:
anchor- the anchor.bar- the bar.orientation- the plot orientation.- Returns:
- The anchor point.
-
findDomainBounds
public Range findDomainBounds(XYDataset dataset)
Returns the lower and upper bounds (range) of the x-values in the specified dataset. Since this renderer uses the x-interval in the dataset, this is taken into account for the range.- Specified by:
findDomainBoundsin interfaceXYItemRenderer- Overrides:
findDomainBoundsin classAbstractXYItemRenderer- Parameters:
dataset- the dataset (nullpermitted).- Returns:
- The range (
nullif the dataset isnullor empty). - See Also:
AbstractXYItemRenderer.findRangeBounds(XYDataset)
-
findRangeBounds
public Range findRangeBounds(XYDataset dataset)
Returns the lower and upper bounds (range) of the y-values in the specified dataset. If the renderer is plotting the y-interval from the dataset, this is taken into account for the range.- Specified by:
findRangeBoundsin interfaceXYItemRenderer- Overrides:
findRangeBoundsin classAbstractXYItemRenderer- Parameters:
dataset- the dataset (nullpermitted).- Returns:
- The range (
nullif the dataset isnullor empty). - See Also:
AbstractXYItemRenderer.findDomainBounds(XYDataset)
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns a clone of the renderer.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classAbstractXYItemRenderer- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException- if the renderer cannot be cloned.
-
equals
public boolean equals(java.lang.Object obj)
Tests this renderer for equality with an arbitrary object.- Overrides:
equalsin classAbstractXYItemRenderer- Parameters:
obj- the object to test against (nullpermitted).- Returns:
- A boolean.
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundExceptionProvides serialization support.- Parameters:
stream- the input stream.- Throws:
java.io.IOException- if there is an I/O error.java.lang.ClassNotFoundException- if there is a classpath problem.
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOExceptionProvides serialization support.- Parameters:
stream- the output stream.- Throws:
java.io.IOException- if there is an I/O error.
-
-