Class XYBarRenderer

All Implemented Interfaces:
Serializable, Cloneable, XYItemRenderer, org.jfree.util.PublicCloneable
Direct Known Subclasses:
ClusteredXYBarRenderer, StackedXYBarRenderer

public class XYBarRenderer
extends AbstractXYItemRenderer
implements XYItemRenderer, Cloneable, org.jfree.util.PublicCloneable, Serializable
A renderer that draws bars on an XYPlot (requires an IntervalXYDataset).

This renderer does not include any code for calculating the crosshair point.

See Also:
Serialized Form
  • Constructor Details

    • 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 Details

    • getMargin

      public double getMargin()
      Returns the margin which is a percentage amount by which the bars are trimmed.
      Returns:
      The margin.
    • 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.
    • 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 a RendererChangeEvent to all registered listeners.
      Parameters:
      transformer - the transformer (null permitted).
    • initialise

      public XYItemRendererState initialise​(Graphics2D g2, 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.
    • 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.
      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.
    • clone

      public Object clone() throws CloneNotSupportedException
      Returns a clone of the renderer.
      Specified by:
      clone in interface org.jfree.util.PublicCloneable
      Returns:
      A clone.
      Throws:
      CloneNotSupportedException - if the renderer cannot be cloned.