public class

ClusteredXYBarRenderer

extends XYBarRenderer
implements Serializable Cloneable
java.lang.Object
   ↳ org.jfree.chart.renderer.AbstractRenderer
     ↳ org.jfree.chart.renderer.xy.AbstractXYItemRenderer
       ↳ org.jfree.chart.renderer.xy.XYBarRenderer
         ↳ org.jfree.chart.renderer.xy.ClusteredXYBarRenderer

Class Overview

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. The example shown here is generated by the ClusteredXYBarRendererDemo1.java program included in the JFreeChart demo collection:

ClusteredXYBarRendererSample.png

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

Summary

[Expand]
Inherited Fields
From class org.jfree.chart.renderer.AbstractRenderer
Public Constructors
ClusteredXYBarRenderer()
Default constructor.
ClusteredXYBarRenderer(double margin, boolean centerBarAtStartValue)
Constructs a new XY clustered bar renderer.
Public Methods
Object clone()
Returns a clone of the renderer.
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.
boolean equals(Object obj)
Tests this renderer for equality with an arbitrary object, returning true if obj is a ClusteredXYBarRenderer with the same settings as this renderer, and false otherwise.
Range findDomainBounds(XYDataset dataset)
Returns the x-value bounds for the specified dataset.
int getPassCount()
Returns the number of passes through the dataset that this renderer requires.
Protected Methods
Range findDomainBoundsWithOffset(IntervalXYDataset dataset)
Iterates over the items in an IntervalXYDataset to find the range of x-values including the interval OFFSET so that it centers the interval around the start value.
[Expand]
Inherited Methods
From class org.jfree.chart.renderer.xy.XYBarRenderer
From class org.jfree.chart.renderer.xy.AbstractXYItemRenderer
From class org.jfree.chart.renderer.AbstractRenderer
From class java.lang.Object
From interface org.jfree.chart.LegendItemSource
From interface org.jfree.chart.renderer.xy.XYItemRenderer

Public Constructors

public ClusteredXYBarRenderer ()

Default constructor. Bar margin is set to 0.0.

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.

Public Methods

public Object clone ()

Returns a clone of the renderer.

Returns
  • A clone.
Throws
CloneNotSupportedException if the renderer cannot be cloned.

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.

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.

public boolean equals (Object obj)

Tests this renderer for equality with an arbitrary object, returning true if obj is a ClusteredXYBarRenderer with the same settings as this renderer, and false otherwise.

Parameters
obj the object (null permitted).
Returns
  • A boolean.

public Range findDomainBounds (XYDataset dataset)

Returns the x-value bounds for the specified dataset.

Parameters
dataset the dataset (null permitted).
Returns
  • The bounds (possibly null).

public int getPassCount ()

Returns the number of passes through the dataset that this renderer requires. In this case, two passes are required, the first for drawing the shadows (if visible), and the second for drawing the bars.

Returns
  • 2.

Protected Methods

protected Range findDomainBoundsWithOffset (IntervalXYDataset dataset)

Iterates over the items in an IntervalXYDataset to find the range of x-values including the interval OFFSET so that it centers the interval around the start value.

Parameters
dataset the dataset (null not permitted).
Returns
  • The range (possibly null).