Class ClusteredXYBarRenderer

All Implemented Interfaces:
Serializable, Cloneable, XYItemRenderer, org.jfree.util.PublicCloneable

public class ClusteredXYBarRenderer
extends XYBarRenderer
implements Cloneable, org.jfree.util.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.

This renderer does not include code to calculate the crosshair point for the plot.

Author:
Paolo Cova
See Also:
Serialized Form
  • Constructor Details

    • ClusteredXYBarRenderer

      public ClusteredXYBarRenderer()
      Default constructor. Bar margin is set to 0.0.
    • ClusteredXYBarRenderer

      public ClusteredXYBarRenderer​(double margin, boolean centerBarAtStartValue)
      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

    • initialise

      public XYItemRendererState initialise​(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info)
      Initialises the renderer. Here we calculate the Java2D y-coordinate for zero, since all the bars have their bases fixed at zero. Copied from superclass to initialize local variables.
      Specified by:
      initialise in interface XYItemRenderer
      Overrides:
      initialise in class XYBarRenderer
      Parameters:
      g2 - the graphics device.
      dataArea - the area inside the axes.
      plot - the plot.
      data - the data.
      info - an optional info collection object to return data back to the caller.
      Returns:
      The number of passes required by the renderer.
    • setMargin

      public void setMargin​(double margin)
      Sets the margin.
      Overrides:
      setMargin in class XYBarRenderer
      Parameters:
      margin - the margin.
    • 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:
      drawItem in interface XYItemRenderer
      Overrides:
      drawItem in class XYBarRenderer
      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 (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
      Overrides:
      clone in class XYBarRenderer
      Returns:
      A clone.
      Throws:
      CloneNotSupportedException - if the renderer cannot be cloned.