Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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, LegendItemSource, XYItemRenderer, org.jfree.util.PublicCloneable

Direct Known Subclasses:
  ClusteredXYBarRenderer, StackedXYBarRenderer

    public class XYBarRenderer

extends AbstractXYItemRenderer
implements XYItemRenderer, java.lang.Cloneable, org.jfree.util.PublicCloneable, java.io.Serializable

A renderer that draws bars on an `XYPlot` (requires an `IntervalXYDataset`).

See Also:
  Serialized Form

Nested Class Summary
`protected class` | `XYBarRenderer.XYBarRendererState` The state class used by this renderer.

Field Summary

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
`XYBarRenderer()` The default constructor.
`XYBarRenderer(double margin)` Constructs a new renderer.

Method Summary
`java.lang.Object` | `clone()` Returns a clone of the 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 visual representation of a single data item.
`protected void` | `drawItemLabel(java.awt.Graphics2D g2, XYDataset dataset, int series, int item, XYPlot plot, XYItemLabelGenerator generator, java.awt.geom.Rectangle2D bar, boolean negative)` Draws an item label.
`boolean` | `equals(java.lang.Object obj)` Tests this renderer 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.
`double` | `getBase()` Returns the base value for the bars.
`org.jfree.ui.GradientPaintTransformer` | `getGradientPaintTransformer()` Returns the gradient paint transformer (an object used to transform gradient paint objects to fit each bar.
`java.awt.Shape` | `getLegendBar()` Returns the shape used to represent bars in each legend item.
`LegendItem` | `getLegendItem(int datasetIndex, int series)` Returns a default legend item for the specified series.
`double` | `getMargin()` Returns the margin which is a percentage amount by which the bars are trimmed.
`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.
`boolean` | `getUseYInterval()` Returns a flag that determines whether the y-interval from the dataset is used to calculate the length of each bar.
`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.
`boolean` | `isDrawBarOutline()` Returns a flag that controls whether or not bar outlines are drawn.
`void` | `setBase(double base)` Sets the base value for the bars and sends a `RendererChangeEvent` to all registered listeners.
`void` | `setDrawBarOutline(boolean draw)` Sets the flag that controls whether or not bar outlines are drawn and sends a `RendererChangeEvent` to all registered listeners.
`void` | `setGradientPaintTransformer(org.jfree.ui.GradientPaintTransformer transformer)` Sets the gradient paint transformer and sends a `RendererChangeEvent` to all registered listeners.
`void` | `setLegendBar(java.awt.Shape bar)` Sets the shape used to represent bars in each legend item and sends a `RendererChangeEvent` to all registered listeners.
`void` | `setMargin(double margin)` Sets the percentage amount by which the bars are trimmed and sends a `RendererChangeEvent` 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 a `RendererChangeEvent` 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 a `RendererChangeEvent` to all registered listeners.
`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 a `RendererChangeEvent` to all registered listeners.

Methods inherited from class org.jfree.chart.renderer.xy.AbstractXYItemRenderer
`addAnnotation, addAnnotation, addEntity, calculateDomainMarkerTextAnchorPoint, drawAnnotations, drawDomainGridLine, drawDomainLine, drawDomainMarker, drawItemLabel, drawRangeLine, drawRangeMarker, fillDomainGridBand, fillRangeGridBand, findRangeBounds, getBaseItemLabelGenerator, getBaseToolTipGenerator, getDefaultEntityRadius, getDrawingSupplier, getItemLabelGenerator, getItemLabelGenerator, getLegendItemLabelGenerator, getLegendItems, getLegendItemToolTipGenerator, getLegendItemURLGenerator, getPassCount, getPlot, getSeriesItemLabelGenerator, getSeriesToolTipGenerator, getToolTipGenerator, getToolTipGenerator, getURLGenerator, removeAnnotation, removeAnnotations, setBaseItemLabelGenerator, setBaseToolTipGenerator, setDefaultEntityRadius, setItemLabelGenerator, setLegendItemLabelGenerator, setLegendItemToolTipGenerator, setLegendItemURLGenerator, setPlot, setSeriesItemLabelGenerator, setSeriesToolTipGenerator, setToolTipGenerator, setURLGenerator, updateCrosshairValues, updateCrosshairValues`

Methods inherited from class org.jfree.chart.renderer.AbstractRenderer
`addChangeListener, calculateLabelAnchorPoint, fireChangeEvent, getBaseCreateEntities, getBaseFillPaint, getBaseItemLabelFont, getBaseItemLabelPaint, getBaseItemLabelsVisible, getBaseNegativeItemLabelPosition, getBaseOutlinePaint, getBaseOutlineStroke, getBasePaint, getBasePositiveItemLabelPosition, getBaseSeriesVisible, getBaseSeriesVisibleInLegend, getBaseShape, getBaseStroke, getCreateEntities, getItemCreateEntity, getItemFillPaint, getItemLabelAnchorOffset, getItemLabelFont, getItemLabelFont, getItemLabelPaint, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getNegativeItemLabelPosition, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getPositiveItemLabelPosition, getSeriesCreateEntities, getSeriesFillPaint, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesVisible, getSeriesVisible, getSeriesVisibleInLegend, getSeriesVisibleInLegend, hashCode, hasListener, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, notifyListeners, removeChangeListener, setBaseCreateEntities, setBaseCreateEntities, setBaseFillPaint, setBaseFillPaint, setBaseItemLabelFont, setBaseItemLabelFont, setBaseItemLabelPaint, setBaseItemLabelPaint, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseNegativeItemLabelPosition, setBaseNegativeItemLabelPosition, setBaseOutlinePaint, setBaseOutlinePaint, setBaseOutlineStroke, setBaseOutlineStroke, setBasePaint, setBasePaint, setBasePositiveItemLabelPosition, setBasePositiveItemLabelPosition, setBaseSeriesVisible, setBaseSeriesVisible, setBaseSeriesVisibleInLegend, setBaseSeriesVisibleInLegend, setBaseShape, setBaseShape, setBaseStroke, setBaseStroke, setCreateEntities, setCreateEntities, setFillPaint, setFillPaint, setItemLabelAnchorOffset, setItemLabelFont, setItemLabelFont, setItemLabelPaint, setItemLabelPaint, setItemLabelsVisible, setItemLabelsVisible, setItemLabelsVisible, setNegativeItemLabelPosition, setNegativeItemLabelPosition, setOutlinePaint, setOutlinePaint, setOutlineStroke, setOutlineStroke, setPaint, setPaint, setPositiveItemLabelPosition, setPositiveItemLabelPosition, 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, setSeriesVisible, setSeriesVisible, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setShape, setShape, setStroke, setStroke`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.jfree.chart.renderer.xy.XYItemRenderer
`addAnnotation, addAnnotation, addChangeListener, drawAnnotations, drawDomainGridLine, drawDomainMarker, drawRangeLine, drawRangeMarker, fillDomainGridBand, fillRangeGridBand, findRangeBounds, getBaseItemLabelFont, getBaseItemLabelGenerator, getBaseItemLabelPaint, getBaseItemLabelsVisible, getBaseNegativeItemLabelPosition, getBaseOutlinePaint, getBaseOutlineStroke, getBasePaint, getBasePositiveItemLabelPosition, getBaseSeriesVisible, getBaseSeriesVisibleInLegend, getBaseShape, getBaseStroke, getBaseToolTipGenerator, getItemLabelFont, getItemLabelFont, getItemLabelGenerator, getItemLabelPaint, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getLegendItemLabelGenerator, getNegativeItemLabelPosition, getNegativeItemLabelPosition, getPassCount, getPlot, getPositiveItemLabelPosition, getPositiveItemLabelPosition, getSeriesItemLabelFont, getSeriesItemLabelGenerator, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesToolTipGenerator, getSeriesVisible, getSeriesVisible, getSeriesVisibleInLegend, getSeriesVisibleInLegend, getToolTipGenerator, getURLGenerator, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, removeAnnotation, removeAnnotations, removeChangeListener, setBaseItemLabelFont, setBaseItemLabelGenerator, setBaseItemLabelPaint, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseNegativeItemLabelPosition, setBaseNegativeItemLabelPosition, setBaseOutlinePaint, setBaseOutlineStroke, setBasePaint, setBasePositiveItemLabelPosition, setBasePositiveItemLabelPosition, setBaseSeriesVisible, setBaseSeriesVisible, setBaseSeriesVisibleInLegend, setBaseSeriesVisibleInLegend, setBaseShape, setBaseStroke, setBaseToolTipGenerator, setItemLabelFont, setItemLabelGenerator, setItemLabelPaint, setItemLabelsVisible, setItemLabelsVisible, setItemLabelsVisible, setLegendItemLabelGenerator, setNegativeItemLabelPosition, setNegativeItemLabelPosition, setOutlinePaint, setOutlineStroke, setPaint, setPlot, setPositiveItemLabelPosition, setPositiveItemLabelPosition, setSeriesItemLabelFont, setSeriesItemLabelGenerator, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesStroke, setSeriesToolTipGenerator, setSeriesVisible, setSeriesVisible, setSeriesVisible, setSeriesVisible, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setShape, setStroke, setToolTipGenerator, setURLGenerator`

Methods inherited from interface org.jfree.chart.LegendItemSource
`getLegendItems`

Constructor Detail

### XYBarRenderer

    public XYBarRenderer()

  The default constructor.

### XYBarRenderer

    public XYBarRenderer(double margin)

  Constructs a new renderer.

  Parameters:
    `margin` - the percentage amount to trim from the width of each bar.

Method Detail

### 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 a `RendererChangeEvent` to 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 a `RendererChangeEvent` to 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 a `RendererChangeEvent` to 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 a `RendererChangeEvent` to all registered listeners.

  Parameters:
    `draw` - the flag.
  See Also:
    `isDrawBarOutline()`

### 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).
  See Also:
    `setGradientPaintTransformer(GradientPaintTransformer)`

### setGradientPaintTransformer

    public void setGradientPaintTransformer(org.jfree.ui.GradientPaintTransformer transformer)

  Sets the gradient paint transformer and sends a `RendererChangeEvent` to all registered listeners.

  Parameters:
    `transformer` - the transformer (`null` permitted).
  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 a `RendererChangeEvent` to all registered listeners.

  Parameters:
    `bar` - the bar shape (`null` not 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 (`null` possible).
  Since:
    1.0.2
  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 a `RendererChangeEvent` to all registered listeners.

  Parameters:
    `position` - the position (`null` permitted).
  Since:
    1.0.2
  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 (`null` possible).
  Since:
    1.0.2
  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 a `RendererChangeEvent` to all registered listeners.

  Parameters:
    `position` - the position (`null` permitted).
  Since:
    1.0.2
  See Also:
    `getNegativeItemLabelPositionFallback()`

### 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:
    `initialise` in interface `XYItemRenderer`
  Overrides:
    `initialise` in class `AbstractXYItemRenderer`
  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:
    `getLegendItem` in interface `XYItemRenderer`
  Overrides:
    `getLegendItem` in class `AbstractXYItemRenderer`
  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:
    `drawItem` in interface `XYItemRenderer`
  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 (`null` permitted).
    `pass` - the pass index.

### drawItemLabel

    protected void drawItemLabel(java.awt.Graphics2D g2,
                                 XYDataset dataset,
                                 int series,
                                 int item,
                                 XYPlot plot,
                                 XYItemLabelGenerator generator,
                                 java.awt.geom.Rectangle2D bar,
                                 boolean negative)

  Draws an item label. This method is overridden so that the bar can be used to calculate the label anchor point.

  Parameters:
    `g2` - the graphics device.
    `dataset` - the dataset.
    `series` - the series index.
    `item` - the item index.
    `plot` - the plot.
    `generator` - the label generator.
    `bar` - the bar.
    `negative` - a flag indicating a negative value.

### 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:
    `findDomainBounds` in interface `XYItemRenderer`
  Overrides:
    `findDomainBounds` in class `AbstractXYItemRenderer`
  Parameters:
    `dataset` - the dataset (`null` permitted).
  Returns:
    The range (`null` if the dataset is `null` or empty).

### clone

    public java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  Returns a clone of the renderer.

  Specified by:
    `clone` in interface `org.jfree.util.PublicCloneable`
  Overrides:
    `clone` in class `AbstractXYItemRenderer`
  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:
    `equals` in class `AbstractXYItemRenderer`
  Parameters:
    `obj` - the object to test against (`null` permitted).
  Returns:
    A boolean.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD