org.jfree.chart.renderer.category

Class StackedAreaRenderer

Implemented Interfaces:
Cloneable, PublicCloneable, Serializable, CategoryItemRenderer, LegendItemSource, Serializable

public class StackedAreaRenderer
extends AreaRenderer
implements Cloneable, PublicCloneable, Serializable

A renderer that draws stacked area charts for a CategoryPlot.

Field Summary

Fields inherited from class org.jfree.chart.renderer.AbstractRenderer

DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, DEFAULT_PAINT, DEFAULT_SHAPE, DEFAULT_STROKE, DEFAULT_VALUE_LABEL_FONT, DEFAULT_VALUE_LABEL_PAINT, ZERO

Constructor Summary

StackedAreaRenderer()
Creates a new renderer.
StackedAreaRenderer(boolean renderAsPercentages)
Creates a new renderer.

Method Summary

void
drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass)
Draw a single data item.
boolean
equals(Object obj)
Checks this instance for equality with an arbitrary object.
Range
findRangeBounds(CategoryDataset dataset)
Returns the range of values the renderer requires to display all the items from the specified dataset.
int
getPassCount()
Returns the number of passes (2) required by this renderer.
protected double
getPreviousHeight(CategoryDataset dataset, int series, int category)
Calculates the stacked value of the all series up to, but not including series for the specified category, category.
boolean
getRenderAsPercentages()
Returns true if the renderer displays each item value as a percentage (so that the stacked areas add to 100%), and false otherwise.
void
setRenderAsPercentages(boolean asPercentages)
Sets the flag that controls whether the renderer displays each item value as a percentage (so that the stacked areas add to 100%), and sends a RendererChangeEvent to all registered listeners.

Methods inherited from class org.jfree.chart.renderer.category.AreaRenderer

clone, drawItem, equals, getEndType, getLegendItem, setEndType

Methods inherited from class org.jfree.chart.renderer.category.AbstractCategoryItemRenderer

addItemEntity, calculateDomainMarkerTextAnchorPoint, calculateRangeMarkerTextAnchorPoint, clone, createState, drawBackground, drawDomainGridline, drawDomainMarker, drawItemLabel, drawOutline, drawRangeGridline, drawRangeMarker, equals, findRangeBounds, getBaseItemLabelGenerator, getBaseItemURLGenerator, getBaseToolTipGenerator, getColumnCount, getDomainAxis, getDrawingSupplier, getItemLabelGenerator, getItemURLGenerator, getLegendItem, getLegendItemLabelGenerator, getLegendItemToolTipGenerator, getLegendItemURLGenerator, getLegendItems, getPassCount, getPlot, getRangeAxis, getRowCount, getSeriesItemLabelGenerator, getSeriesItemURLGenerator, getSeriesToolTipGenerator, getToolTipGenerator, getToolTipGenerator, hashCode, initialise, setBaseItemLabelGenerator, setBaseItemURLGenerator, setBaseToolTipGenerator, setItemLabelGenerator, setItemURLGenerator, setLegendItemLabelGenerator, setLegendItemToolTipGenerator, setLegendItemURLGenerator, setPlot, setSeriesItemLabelGenerator, setSeriesItemURLGenerator, setSeriesToolTipGenerator, setToolTipGenerator

Methods inherited from class org.jfree.chart.renderer.AbstractRenderer

addChangeListener, calculateLabelAnchorPoint, clone, equals, fireChangeEvent, getBaseCreateEntities, getBaseFillPaint, getBaseItemLabelFont, getBaseItemLabelPaint, getBaseItemLabelsVisible, getBaseNegativeItemLabelPosition, getBaseOutlinePaint, getBaseOutlineStroke, getBasePaint, getBasePositiveItemLabelPosition, getBaseSeriesVisible, getBaseSeriesVisibleInLegend, getBaseShape, getBaseStroke, getCreateEntities, getDrawingSupplier, getItemCreateEntity, getItemFillPaint, getItemLabelAnchorOffset, getItemLabelFont, getItemLabelFont, getItemLabelPaint, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getNegativeItemLabelPosition, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getPositiveItemLabelPosition, getSeriesCreateEntities, getSeriesFillPaint, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesVisible, getSeriesVisible, getSeriesVisibleInLegend, getSeriesVisibleInLegend, hasListener, hashCode, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, notifyListeners, removeChangeListener, setBaseCreateEntities, setBaseCreateEntities, setBaseFillPaint, setBaseFillPaint, setBaseItemLabelFont, setBaseItemLabelFont, setBaseItemLabelPaint, setBaseItemLabelPaint, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseItemLabelsVisible, setBaseNegativeItemLabelPosition, setBaseNegativeItemLabelPosition, setBaseOutlinePaint, setBaseOutlinePaint, setBaseOutlineStroke, setBaseOutlineStroke, setBasePaint, setBasePaint, setBasePositiveItemLabelPosition, setBasePositiveItemLabelPosition, setBaseSeriesVisible, setBaseSeriesVisible, setBaseSeriesVisibleInLegend, setBaseSeriesVisibleInLegend, setBaseShape, setBaseShape, setBaseStroke, setBaseStroke, setCreateEntities, setCreateEntities, setFillPaint, setFillPaint, setItemLabelAnchorOffset, setItemLabelFont, setItemLabelFont, setItemLabelPaint, setItemLabelPaint, setItemLabelsVisible, setItemLabelsVisible, setItemLabelsVisible, setNegativeItemLabelPosition, setNegativeItemLabelPosition, setOutlinePaint, setOutlinePaint, setOutlineStroke, setOutlineStroke, setPaint, setPaint, setPositiveItemLabelPosition, setPositiveItemLabelPosition, setSeriesCreateEntities, setSeriesCreateEntities, setSeriesFillPaint, setSeriesFillPaint, setSeriesItemLabelFont, setSeriesItemLabelFont, setSeriesItemLabelPaint, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesShape, setSeriesStroke, setSeriesStroke, setSeriesVisible, setSeriesVisible, setSeriesVisible, setSeriesVisible, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setShape, setShape, setStroke, setStroke

Constructor Details

StackedAreaRenderer

public StackedAreaRenderer()
Creates a new renderer.

StackedAreaRenderer

public StackedAreaRenderer(boolean renderAsPercentages)
Creates a new renderer.
Parameters:
renderAsPercentages - a flag that controls whether the data values are rendered as percentages.

Method Details

drawItem

public void drawItem(Graphics2D g2,
                     CategoryItemRendererState state,
                     Rectangle2D dataArea,
                     CategoryPlot plot,
                     CategoryAxis domainAxis,
                     ValueAxis rangeAxis,
                     CategoryDataset dataset,
                     int row,
                     int column,
                     int pass)
Draw a single data item.
Specified by:
drawItem in interface CategoryItemRenderer
Overrides:
drawItem in interface AreaRenderer
Parameters:
g2 - the graphics device.
state - the renderer state.
dataArea - the data plot area.
plot - the plot.
domainAxis - the domain axis.
rangeAxis - the range axis.
dataset - the data.
row - the row index (zero-based).
column - the column index (zero-based).
pass - the pass index.

equals

public boolean equals(Object obj)
Checks this instance for equality with an arbitrary object.
Overrides:
equals in interface AreaRenderer
Parameters:
obj - the object (null not permitted).
Returns:
A boolean.

findRangeBounds

public Range findRangeBounds(CategoryDataset dataset)
Returns the range of values the renderer requires to display all the items from the specified dataset.
Specified by:
findRangeBounds in interface CategoryItemRenderer
Overrides:
findRangeBounds in interface AbstractCategoryItemRenderer
Parameters:
dataset - the dataset (null not permitted).
Returns:
The range (or null if the dataset is empty).

getPassCount

public int getPassCount()
Returns the number of passes (2) required by this renderer. The first pass is used to draw the bars, the second pass is used to draw the item labels (if visible).
Specified by:
getPassCount in interface CategoryItemRenderer
Overrides:
getPassCount in interface AbstractCategoryItemRenderer
Returns:
The number of passes required by the renderer.

getPreviousHeight

protected double getPreviousHeight(CategoryDataset dataset,
                                   int series,
                                   int category)
Calculates the stacked value of the all series up to, but not including series for the specified category, category. It returns 0.0 if series is the first series, i.e. 0.
Parameters:
dataset - the dataset (null not permitted).
series - the series.
category - the category.
Returns:
double returns a cumulative value for all series' values up to but excluding series for Object category.

getRenderAsPercentages

public boolean getRenderAsPercentages()
Returns true if the renderer displays each item value as a percentage (so that the stacked areas add to 100%), and false otherwise.
Returns:
A boolean.
Since:
1.0.3

setRenderAsPercentages

public void setRenderAsPercentages(boolean asPercentages)
Sets the flag that controls whether the renderer displays each item value as a percentage (so that the stacked areas add to 100%), and sends a RendererChangeEvent to all registered listeners.
Parameters:
asPercentages - the flag.
Since:
1.0.3