public class

LevelRenderer

extends AbstractCategoryItemRenderer
implements Serializable Cloneable
java.lang.Object
   ↳ org.jfree.chart.renderer.AbstractRenderer
     ↳ org.jfree.chart.renderer.category.AbstractCategoryItemRenderer
       ↳ org.jfree.chart.renderer.category.LevelRenderer

Class Overview

A CategoryItemRenderer that draws individual data items as horizontal lines, spaced in the same way as bars in a bar chart. The example shown here is generated by the OverlaidBarChartDemo2.java program included in the JFreeChart Demo Collection:

LevelRendererSample.png

Summary

Constants
double DEFAULT_ITEM_MARGIN The default item margin percentage.
[Expand]
Inherited Fields
From class org.jfree.chart.renderer.AbstractRenderer
Public Constructors
LevelRenderer()
Creates a new renderer with default settings.
Public Methods
void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass)
Draws the bar for a single (series, category) data item.
boolean equals(Object obj)
Tests an object for equality with this instance.
double getItemMargin()
Returns the item margin.
double getItemMiddle(Comparable rowKey, Comparable columnKey, CategoryDataset dataset, CategoryAxis axis, Rectangle2D area, RectangleEdge edge)
Returns the Java2D coordinate for the middle of the specified data item.
double getMaxItemWidth()
This method is deprecated. Use getMaximumItemWidth() instead.
double getMaximumItemWidth()
Returns the maximum width, as a percentage of the available drawing space.
int hashCode()
Returns a hash code for this instance.
CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info)
Initialises the renderer and returns a state object that will be passed to subsequent calls to the drawItem method.
void setItemMargin(double percent)
Sets the item margin and sends a RendererChangeEvent to all registered listeners.
void setMaxItemWidth(double percent)
This method is deprecated. Use setMaximumItemWidth(double) instead.
void setMaximumItemWidth(double percent)
Sets the maximum item width, which is specified as a percentage of the available space for all items, and sends a RendererChangeEvent to all registered listeners.
Protected Methods
double calculateBarW0(CategoryPlot plot, PlotOrientation orientation, Rectangle2D dataArea, CategoryAxis domainAxis, CategoryItemRendererState state, int row, int column)
Calculates the coordinate of the first "side" of a bar.
void calculateItemWidth(CategoryPlot plot, Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state)
Calculates the bar width and stores it in the renderer state.
double calculateSeriesWidth(double space, CategoryAxis axis, int categories, int series)
Calculates the available space for each series.
[Expand]
Inherited Methods
From class org.jfree.chart.renderer.category.AbstractCategoryItemRenderer
From class org.jfree.chart.renderer.AbstractRenderer
From class java.lang.Object
From interface org.jfree.chart.LegendItemSource
From interface org.jfree.chart.renderer.category.CategoryItemRenderer

Constants

public static final double DEFAULT_ITEM_MARGIN

The default item margin percentage.

Constant Value: 0.2

Public Constructors

public LevelRenderer ()

Creates a new renderer with default settings.

Public Methods

public void drawItem (Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass)

Draws the bar for a single (series, category) data item.

Parameters
g2 the graphics device.
state the renderer state.
dataArea the data area.
plot the plot.
domainAxis the domain axis.
rangeAxis the range axis.
dataset the dataset.
row the row index (zero-based).
column the column index (zero-based).
pass the pass index.

public boolean equals (Object obj)

Tests an object for equality with this instance.

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

public double getItemMargin ()

Returns the item margin.

Returns
  • The margin.

public double getItemMiddle (Comparable rowKey, Comparable columnKey, CategoryDataset dataset, CategoryAxis axis, Rectangle2D area, RectangleEdge edge)

Returns the Java2D coordinate for the middle of the specified data item.

Parameters
rowKey the row key.
columnKey the column key.
dataset the dataset.
axis the axis.
area the drawing area.
edge the edge along which the axis lies.
Returns
  • The Java2D coordinate.

public double getMaxItemWidth ()

This method is deprecated.
Use getMaximumItemWidth() instead.

Returns the maximum width, as a percentage of the available drawing space.

Returns
  • The maximum width.

public double getMaximumItemWidth ()

Returns the maximum width, as a percentage of the available drawing space.

Returns
  • The maximum width.

public int hashCode ()

Returns a hash code for this instance.

Returns
  • A hash code.

public CategoryItemRendererState initialise (Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info)

Initialises the renderer and returns a state object that will be passed to subsequent calls to the drawItem method.

This method gets called once at the start of the process of drawing a chart.

Parameters
g2 the graphics device.
dataArea the area in which the data is to be plotted.
plot the plot.
rendererIndex the renderer index.
info collects chart rendering information for return to caller.
Returns
  • The renderer state.

public void setItemMargin (double percent)

Sets the item margin and sends a RendererChangeEvent to all registered listeners. The value is expressed as a percentage of the available width for plotting all the bars, with the resulting amount to be distributed between all the bars evenly.

Parameters
percent the new margin.
See Also

public void setMaxItemWidth (double percent)

This method is deprecated.
Use setMaximumItemWidth(double) instead.

Sets the maximum item width, which is specified as a percentage of the available space for all items, and sends a RendererChangeEvent to all registered listeners.

Parameters
percent the percent.

public void setMaximumItemWidth (double percent)

Sets the maximum item width, which is specified as a percentage of the available space for all items, and sends a RendererChangeEvent to all registered listeners.

Parameters
percent the percent.

Protected Methods

protected double calculateBarW0 (CategoryPlot plot, PlotOrientation orientation, Rectangle2D dataArea, CategoryAxis domainAxis, CategoryItemRendererState state, int row, int column)

Calculates the coordinate of the first "side" of a bar. This will be the minimum x-coordinate for a vertical bar, and the minimum y-coordinate for a horizontal bar.

Parameters
plot the plot.
orientation the plot orientation.
dataArea the data area.
domainAxis the domain axis.
state the renderer state (has the bar width precalculated).
row the row index.
column the column index.
Returns
  • The coordinate.

protected void calculateItemWidth (CategoryPlot plot, Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state)

Calculates the bar width and stores it in the renderer state.

Parameters
plot the plot.
dataArea the data area.
rendererIndex the renderer index.
state the renderer state.

protected double calculateSeriesWidth (double space, CategoryAxis axis, int categories, int series)

Calculates the available space for each series.

Parameters
space the space along the entire axis (in Java2D units).
axis the category axis.
categories the number of categories.
series the number of series.
Returns
  • The width of one series.