com.jrefinery.chart
Class BarRenderer

java.lang.Object
  extended by com.jrefinery.chart.AbstractCategoryItemRenderer
      extended by com.jrefinery.chart.BarRenderer
All Implemented Interfaces:
CategoryItemRenderer
Direct Known Subclasses:
HorizontalBarRenderer, HorizontalIntervalBarRenderer, VerticalBarRenderer, VerticalIntervalBarRenderer

public abstract class BarRenderer
extends AbstractCategoryItemRenderer

A base class for category item renderers that draw bars.


Field Summary
protected static double BAR_OUTLINE_WIDTH_THRESHOLD
          Constant that controls the minimum width before a bar has an outline drawn.
protected  double categoryGapSpan
          The total width of the category gaps.
protected  double categorySpan
          The total width of the categories.
protected  double itemGapSpan
          The total width of the item gaps.
protected  double itemSpan
          The total width of the items within a category.
protected  double itemWidth
          The width of a single item.
protected  double zeroInJava2D
          The data value ZERO translated to Java2D user space.
 
Fields inherited from class com.jrefinery.chart.AbstractCategoryItemRenderer
info, toolTipGenerator
 
Constructor Summary
BarRenderer(com.jrefinery.chart.tooltips.CategoryToolTipGenerator toolTipGenerator)
           
 
Method Summary
abstract  int barWidthsPerCategory(CategoryDataset data)
          Returns the number of bar widths per category, which depends on whether or not the renderer stacks bars.
protected  void calculateCategoryAndItemSpans(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, CategoryPlot plot, CategoryDataset data, double span)
          Calculates some dimensions required for plotting the bars.
abstract  boolean hasItemGaps()
          Returns true if there are gaps between items within a category, and false otherwise.
 void initialise(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, CategoryPlot plot, CategoryDataset data, ChartRenderingInfo info)
          Initialises the renderer.
 boolean isStacked()
          Returns a flag indicating whether or not the renderer stacks values within each category.
 
Methods inherited from class com.jrefinery.chart.AbstractCategoryItemRenderer
drawPlotBackground, getAxisArea, getDataClipRegion, getToolTipGenerator, setToolTipGenerator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jrefinery.chart.CategoryItemRenderer
drawCategoryItem, drawRangeMarker
 

Field Detail

BAR_OUTLINE_WIDTH_THRESHOLD

protected static final double BAR_OUTLINE_WIDTH_THRESHOLD
Constant that controls the minimum width before a bar has an outline drawn.

See Also:
Constant Field Values

categorySpan

protected double categorySpan
The total width of the categories.


categoryGapSpan

protected double categoryGapSpan
The total width of the category gaps.


itemSpan

protected double itemSpan
The total width of the items within a category.


itemGapSpan

protected double itemGapSpan
The total width of the item gaps.


itemWidth

protected double itemWidth
The width of a single item.


zeroInJava2D

protected double zeroInJava2D
The data value ZERO translated to Java2D user space.

Constructor Detail

BarRenderer

public BarRenderer(com.jrefinery.chart.tooltips.CategoryToolTipGenerator toolTipGenerator)
Method Detail

initialise

public void initialise(java.awt.Graphics2D g2,
                       java.awt.geom.Rectangle2D dataArea,
                       CategoryPlot plot,
                       CategoryDataset data,
                       ChartRenderingInfo info)
Initialises the renderer.

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

Specified by:
initialise in interface CategoryItemRenderer
Overrides:
initialise in class AbstractCategoryItemRenderer
Parameters:
g2 - The graphics device.
dataArea - The area in which the data is to be plotted.
plot - The plot.
data - The data.
info - Collects chart rendering information for return to caller.

barWidthsPerCategory

public abstract int barWidthsPerCategory(CategoryDataset data)
Returns the number of bar widths per category, which depends on whether or not the renderer stacks bars.

Parameters:
data - The dataset.

hasItemGaps

public abstract boolean hasItemGaps()
Returns true if there are gaps between items within a category, and false otherwise. Again, this depends on whether or not the bars are stacked.


calculateCategoryAndItemSpans

protected void calculateCategoryAndItemSpans(java.awt.Graphics2D g2,
                                             java.awt.geom.Rectangle2D dataArea,
                                             CategoryPlot plot,
                                             CategoryDataset data,
                                             double span)
Calculates some dimensions required for plotting the bars.

Parameters:
g2 - The graphics device.
dataArea - The area within the axes.
plot - The plot.
data - The data.
span - ???

isStacked

public boolean isStacked()
Returns a flag indicating whether or not the renderer stacks values within each category. This has an effect on the minimum and maximum values required for the axis to show all the data values.

Subclasses should override this method as necessary.

Specified by:
isStacked in interface CategoryItemRenderer
Overrides:
isStacked in class AbstractCategoryItemRenderer
Returns:
The flag.


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.