java.lang.Object
org.jfree.chart.renderer.AbstractRenderer
org.jfree.chart.renderer.category.AbstractCategoryItemRenderer
org.jfree.chart.renderer.category.BoxAndWhiskerRenderer
- All Implemented Interfaces:
Serializable
,Cloneable
,LegendItemSource
,CategoryItemRenderer
,PublicCloneable
public class BoxAndWhiskerRenderer
extends AbstractCategoryItemRenderer
implements Cloneable, PublicCloneable, Serializable
A box-and-whisker renderer. This renderer requires a
BoxAndWhiskerCategoryDataset
and is for use with the
CategoryPlot
class. The example shown here is generated
by the BoxAndWhiskerChartDemo1.java
program included in the
JFreeChart Demo Collection:
- See Also:
-
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
drawHorizontalItem
(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column) Draws the visual representation of a single data item when the plot has a horizontal orientation.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.void
drawVerticalItem
(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column) Draws the visual representation of a single data item when the plot has a vertical orientation.boolean
Tests this renderer for equality with an arbitrary object.findRangeBounds
(CategoryDataset dataset) Returns the range of values from the specified dataset that the renderer will require to display all the data.Returns the paint used to color the median and average markers.boolean
Returns the flag that controls whether or not the box is filled.double
Returns the item margin.getLegendItem
(int datasetIndex, int series) Returns a legend item for a series.double
Returns the maximum bar width as a percentage of the available drawing space.boolean
Returns the flag that, iftrue
, causes the whiskers to be drawn using the series outline paint.double
Returns the width of the whiskers as fraction of the bar width.initialise
(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info) Initialises the renderer.boolean
Returns the flag that controls whether or not the maximum outlier is draw for each item.boolean
Returns the flag that controls whether or not the mean indicator is draw for each item.boolean
Returns the flag that controls whether or not the median indicator is draw for each item.boolean
Returns the flag that controls whether or not the minimum outlier is draw for each item.void
setArtifactPaint
(Paint paint) Sets the paint used to color the median and average markers and sends aRendererChangeEvent
to all registered listeners.void
setFillBox
(boolean flag) Sets the flag that controls whether or not the box is filled and sends aRendererChangeEvent
to all registered listeners.void
setItemMargin
(double margin) Sets the item margin and sends aRendererChangeEvent
to all registered listeners.void
setMaximumBarWidth
(double percent) Sets the maximum bar width, which is specified as a percentage of the available space for all bars, and sends aRendererChangeEvent
to all registered listeners.void
setMaxOutlierVisible
(boolean visible) Sets the flag that controls whether or not the maximum outlier is drawn for each item, and sends aRendererChangeEvent
to all registered listeners.void
setMeanVisible
(boolean visible) Sets the flag that controls whether or not the mean indicator is drawn for each item, and sends aRendererChangeEvent
to all registered listeners.void
setMedianVisible
(boolean visible) Sets the flag that controls whether or not the median indicator is drawn for each item, and sends aRendererChangeEvent
to all registered listeners.void
setMinOutlierVisible
(boolean visible) Sets the flag that controls whether or not the minimum outlier is drawn for each item, and sends aRendererChangeEvent
to all registered listeners.void
setUseOutlinePaintForWhiskers
(boolean flag) Sets the flag that, iftrue
, causes the whiskers to be drawn using the series outline paint, and sends aRendererChangeEvent
to all registered listeners.void
setWhiskerWidth
(double width) Sets the width of the whiskers as a fraction of the bar width and sends aRendererChangeEvent
to all registered listeners.Methods inherited from class org.jfree.chart.renderer.category.AbstractCategoryItemRenderer
addEntity, addItemEntity, beginElementGroup, calculateDomainMarkerTextAnchorPoint, calculateRangeMarkerTextAnchorPoint, clone, createState, drawBackground, drawDomainGridline, drawDomainMarker, drawItemLabel, drawOutline, drawRangeLine, drawRangeMarker, findRangeBounds, getColumnCount, getDefaultItemLabelGenerator, getDefaultItemURLGenerator, getDefaultToolTipGenerator, getDomainAxis, getDrawingSupplier, getItemLabelGenerator, getItemMiddle, getItemURLGenerator, getLegendItemLabelGenerator, getLegendItems, getLegendItemToolTipGenerator, getLegendItemURLGenerator, getPassCount, getPlot, getRangeAxis, getRowCount, getSeriesItemLabelGenerator, getSeriesItemURLGenerator, getSeriesToolTipGenerator, getToolTipGenerator, hashCode, setDefaultItemLabelGenerator, setDefaultItemLabelGenerator, setDefaultItemURLGenerator, setDefaultItemURLGenerator, setDefaultToolTipGenerator, setDefaultToolTipGenerator, setLegendItemLabelGenerator, setLegendItemToolTipGenerator, setLegendItemURLGenerator, setPlot, setSeriesItemLabelGenerator, setSeriesItemLabelGenerator, setSeriesItemURLGenerator, setSeriesItemURLGenerator, setSeriesToolTipGenerator, setSeriesToolTipGenerator, updateCrosshairValues
Methods inherited from class org.jfree.chart.renderer.AbstractRenderer
addChangeListener, beginElementGroup, calculateLabelAnchorPoint, clearSeriesPaints, clearSeriesStrokes, endElementGroup, fireChangeEvent, getAutoPopulateSeriesFillPaint, getAutoPopulateSeriesOutlinePaint, getAutoPopulateSeriesOutlineStroke, getAutoPopulateSeriesPaint, getAutoPopulateSeriesShape, getAutoPopulateSeriesStroke, getDataBoundsIncludesVisibleSeriesOnly, getDefaultCreateEntities, getDefaultEntityRadius, getDefaultFillPaint, getDefaultItemLabelFont, getDefaultItemLabelPaint, getDefaultItemLabelsVisible, getDefaultLegendShape, getDefaultLegendTextFont, getDefaultLegendTextPaint, getDefaultNegativeItemLabelPosition, getDefaultOutlinePaint, getDefaultOutlineStroke, getDefaultPaint, getDefaultPositiveItemLabelPosition, getDefaultSeriesVisible, getDefaultSeriesVisibleInLegend, getDefaultShape, getDefaultStroke, getItemCreateEntity, getItemFillPaint, getItemLabelAnchorOffset, getItemLabelFont, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getLegendShape, getLegendTextFont, getLegendTextPaint, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getSeriesCreateEntities, getSeriesFillPaint, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesVisible, getSeriesVisibleInLegend, getTreatLegendShapeAsLine, hasListener, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, lookupLegendShape, lookupLegendTextFont, lookupLegendTextPaint, lookupSeriesFillPaint, lookupSeriesOutlinePaint, lookupSeriesOutlineStroke, lookupSeriesPaint, lookupSeriesShape, lookupSeriesStroke, notifyListeners, removeChangeListener, setAutoPopulateSeriesFillPaint, setAutoPopulateSeriesOutlinePaint, setAutoPopulateSeriesOutlineStroke, setAutoPopulateSeriesPaint, setAutoPopulateSeriesShape, setAutoPopulateSeriesStroke, setDataBoundsIncludesVisibleSeriesOnly, setDefaultCreateEntities, setDefaultCreateEntities, setDefaultEntityRadius, setDefaultFillPaint, setDefaultFillPaint, setDefaultItemLabelFont, setDefaultItemLabelFont, setDefaultItemLabelPaint, setDefaultItemLabelPaint, setDefaultItemLabelsVisible, setDefaultItemLabelsVisible, setDefaultLegendShape, setDefaultLegendTextFont, setDefaultLegendTextPaint, setDefaultNegativeItemLabelPosition, setDefaultNegativeItemLabelPosition, setDefaultOutlinePaint, setDefaultOutlinePaint, setDefaultOutlineStroke, setDefaultOutlineStroke, setDefaultPaint, setDefaultPaint, setDefaultPositiveItemLabelPosition, setDefaultPositiveItemLabelPosition, setDefaultSeriesVisible, setDefaultSeriesVisible, setDefaultSeriesVisibleInLegend, setDefaultSeriesVisibleInLegend, setDefaultShape, setDefaultShape, setDefaultStroke, setDefaultStroke, setItemLabelAnchorOffset, setLegendShape, setLegendTextFont, setLegendTextPaint, 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, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setTreatLegendShapeAsLine
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jfree.chart.renderer.category.CategoryItemRenderer
addChangeListener, getDefaultCreateEntities, getDefaultFillPaint, getDefaultItemLabelFont, getDefaultItemLabelPaint, getDefaultItemLabelsVisible, getDefaultNegativeItemLabelPosition, getDefaultOutlinePaint, getDefaultOutlineStroke, getDefaultPaint, getDefaultPositiveItemLabelPosition, getDefaultSeriesVisible, getDefaultSeriesVisibleInLegend, getDefaultShape, getDefaultStroke, getItemCreateEntity, getItemFillPaint, getItemLabelFont, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getSeriesCreateEntities, getSeriesFillPaint, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesVisible, getSeriesVisibleInLegend, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, removeChangeListener, setDefaultCreateEntities, setDefaultCreateEntities, setDefaultFillPaint, setDefaultItemLabelFont, setDefaultItemLabelFont, setDefaultItemLabelPaint, setDefaultItemLabelPaint, setDefaultItemLabelsVisible, setDefaultItemLabelsVisible, setDefaultNegativeItemLabelPosition, setDefaultNegativeItemLabelPosition, setDefaultOutlinePaint, setDefaultOutlinePaint, setDefaultOutlineStroke, setDefaultOutlineStroke, setDefaultPaint, setDefaultPaint, setDefaultPositiveItemLabelPosition, setDefaultPositiveItemLabelPosition, setDefaultSeriesVisible, setDefaultSeriesVisible, setDefaultSeriesVisibleInLegend, setDefaultSeriesVisibleInLegend, setDefaultShape, setDefaultShape, setDefaultStroke, setDefaultStroke, setSeriesCreateEntities, setSeriesCreateEntities, setSeriesFillPaint, setSeriesItemLabelFont, setSeriesItemLabelFont, setSeriesItemLabelPaint, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesShape, setSeriesStroke, setSeriesStroke, setSeriesVisible, setSeriesVisible, setSeriesVisibleInLegend, setSeriesVisibleInLegend
Methods inherited from interface org.jfree.chart.util.PublicCloneable
clone
-
Constructor Details
-
BoxAndWhiskerRenderer
public BoxAndWhiskerRenderer()Default constructor.
-
-
Method Details
-
getArtifactPaint
Returns the paint used to color the median and average markers.- Returns:
- The paint used to draw the median and average markers (never
null
). - See Also:
-
setArtifactPaint
Sets the paint used to color the median and average markers and sends aRendererChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
-
getFillBox
public boolean getFillBox()Returns the flag that controls whether or not the box is filled.- Returns:
- A boolean.
- See Also:
-
setFillBox
public void setFillBox(boolean flag) Sets the flag that controls whether or not the box is filled and sends aRendererChangeEvent
to all registered listeners.- Parameters:
flag
- the flag.- See Also:
-
getItemMargin
public double getItemMargin()Returns the item margin. This is a percentage of the available space that is allocated to the space between items in the chart.- Returns:
- The margin.
- See Also:
-
setItemMargin
public void setItemMargin(double margin) Sets the item margin and sends aRendererChangeEvent
to all registered listeners.- Parameters:
margin
- the margin (a percentage).- See Also:
-
getMaximumBarWidth
public double getMaximumBarWidth()Returns the maximum bar width as a percentage of the available drawing space. Take care with the encoding, for example 0.10 is ten percent.- Returns:
- The maximum bar width.
- See Also:
-
setMaximumBarWidth
public void setMaximumBarWidth(double percent) Sets the maximum bar width, which is specified as a percentage of the available space for all bars, and sends aRendererChangeEvent
to all registered listeners.- Parameters:
percent
- the maximum bar width (a percentage, where 0.10 is ten percent).- See Also:
-
isMeanVisible
public boolean isMeanVisible()Returns the flag that controls whether or not the mean indicator is draw for each item.- Returns:
- A boolean.
- See Also:
-
setMeanVisible
public void setMeanVisible(boolean visible) Sets the flag that controls whether or not the mean indicator is drawn for each item, and sends aRendererChangeEvent
to all registered listeners.- Parameters:
visible
- the new flag value.- See Also:
-
isMedianVisible
public boolean isMedianVisible()Returns the flag that controls whether or not the median indicator is draw for each item.- Returns:
- A boolean.
- See Also:
-
setMedianVisible
public void setMedianVisible(boolean visible) Sets the flag that controls whether or not the median indicator is drawn for each item, and sends aRendererChangeEvent
to all registered listeners.- Parameters:
visible
- the new flag value.- See Also:
-
isMinOutlierVisible
public boolean isMinOutlierVisible()Returns the flag that controls whether or not the minimum outlier is draw for each item.- Returns:
- A boolean.
- Since:
- 1.5.2
- See Also:
-
setMinOutlierVisible
public void setMinOutlierVisible(boolean visible) Sets the flag that controls whether or not the minimum outlier is drawn for each item, and sends aRendererChangeEvent
to all registered listeners.- Parameters:
visible
- the new flag value.- Since:
- 1.5.2
- See Also:
-
isMaxOutlierVisible
public boolean isMaxOutlierVisible()Returns the flag that controls whether or not the maximum outlier is draw for each item.- Returns:
- A boolean.
- Since:
- 1.5.2
- See Also:
-
setMaxOutlierVisible
public void setMaxOutlierVisible(boolean visible) Sets the flag that controls whether or not the maximum outlier is drawn for each item, and sends aRendererChangeEvent
to all registered listeners.- Parameters:
visible
- the new flag value.- Since:
- 1.5.2
- See Also:
-
getUseOutlinePaintForWhiskers
public boolean getUseOutlinePaintForWhiskers()Returns the flag that, iftrue
, causes the whiskers to be drawn using the series outline paint.- Returns:
- A boolean.
-
setUseOutlinePaintForWhiskers
public void setUseOutlinePaintForWhiskers(boolean flag) Sets the flag that, iftrue
, causes the whiskers to be drawn using the series outline paint, and sends aRendererChangeEvent
to all registered listeners.- Parameters:
flag
- the new flag value.
-
getWhiskerWidth
public double getWhiskerWidth()Returns the width of the whiskers as fraction of the bar width.- Returns:
- The width of the whiskers.
- See Also:
-
setWhiskerWidth
public void setWhiskerWidth(double width) Sets the width of the whiskers as a fraction of the bar width and sends aRendererChangeEvent
to all registered listeners.- Parameters:
width
- a value between 0 and 1 indicating how wide the whisker is supposed to be compared to the bar.- See Also:
-
getLegendItem
Returns a legend item for a series.- Specified by:
getLegendItem
in interfaceCategoryItemRenderer
- Overrides:
getLegendItem
in classAbstractCategoryItemRenderer
- Parameters:
datasetIndex
- the dataset index (zero-based).series
- the series index (zero-based).- Returns:
- The legend item (possibly
null
). - See Also:
-
findRangeBounds
Returns the range of values from the specified dataset that the renderer will require to display all the data.- Specified by:
findRangeBounds
in interfaceCategoryItemRenderer
- Overrides:
findRangeBounds
in classAbstractCategoryItemRenderer
- Parameters:
dataset
- the dataset.- Returns:
- The range.
-
initialise
public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info) Initialises the renderer. This method gets called once at the start of the process of drawing a chart.- Specified by:
initialise
in interfaceCategoryItemRenderer
- Overrides:
initialise
in classAbstractCategoryItemRenderer
- 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.
-
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 interfaceCategoryItemRenderer
- Parameters:
g2
- the graphics device.state
- the renderer state.dataArea
- the area in which the data is drawn.plot
- the plot.domainAxis
- the domain axis.rangeAxis
- the range axis.dataset
- the data (must be an instance ofBoxAndWhiskerCategoryDataset
).row
- the row index (zero-based).column
- the column index (zero-based).pass
- the pass index.
-
drawHorizontalItem
public void drawHorizontalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column) Draws the visual representation of a single data item when the plot has a horizontal orientation.- Parameters:
g2
- the graphics device.state
- the renderer state.dataArea
- the area within which the plot is being drawn.plot
- the plot (can be used to obtain standard color information etc).domainAxis
- the domain axis.rangeAxis
- the range axis.dataset
- the dataset (must be an instance ofBoxAndWhiskerCategoryDataset
).row
- the row index (zero-based).column
- the column index (zero-based).
-
drawVerticalItem
public void drawVerticalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column) Draws the visual representation of a single data item when the plot has a vertical orientation.- Parameters:
g2
- the graphics device.state
- the renderer state.dataArea
- the area within which the plot is being drawn.plot
- the plot (can be used to obtain standard color information etc).domainAxis
- the domain axis.rangeAxis
- the range axis.dataset
- the dataset (must be an instance ofBoxAndWhiskerCategoryDataset
).row
- the row index (zero-based).column
- the column index (zero-based).
-
equals
Tests this renderer for equality with an arbitrary object.- Overrides:
equals
in classAbstractCategoryItemRenderer
- Parameters:
obj
- the object (null
permitted).- Returns:
true
orfalse
.
-