Package org.jfree.chart.renderer.xy
Class XYBoxAndWhiskerRenderer
- java.lang.Object
-
- org.jfree.chart.renderer.AbstractRenderer
-
- org.jfree.chart.renderer.xy.AbstractXYItemRenderer
-
- org.jfree.chart.renderer.xy.XYBoxAndWhiskerRenderer
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,AnnotationChangeListener
,LegendItemSource
,XYItemRenderer
,PublicCloneable
public class XYBoxAndWhiskerRenderer extends AbstractXYItemRenderer implements XYItemRenderer, java.lang.Cloneable, PublicCloneable, java.io.Serializable
A renderer that draws box-and-whisker items on anXYPlot
. This renderer requires aBoxAndWhiskerXYDataset
). The example shown here is generated by theBoxAndWhiskerChartDemo2.java
program included in the JFreeChart demo collection:
This renderer does not include any code to calculate the crosshair point.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.Paint
artifactPaint
The paint used to draw various artifacts such as outliers, farout symbol, average ellipse and median line.private java.awt.Paint
boxPaint
The paint used to fill the box.private double
boxWidth
The box width.private boolean
fillBox
A flag that controls whether or not the box is filled.private static long
serialVersionUID
For serialization.-
Fields inherited from class org.jfree.chart.renderer.AbstractRenderer
DEFAULT_ITEM_LABEL_INSETS, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, DEFAULT_PAINT, DEFAULT_SHAPE, DEFAULT_STROKE, DEFAULT_VALUE_LABEL_FONT, DEFAULT_VALUE_LABEL_PAINT, ZERO
-
-
Constructor Summary
Constructors Constructor Description XYBoxAndWhiskerRenderer()
Creates a new renderer for box and whisker charts.XYBoxAndWhiskerRenderer(double boxWidth)
Creates a new renderer for box and whisker charts.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Returns a clone of the renderer.protected void
drawEllipse(java.awt.geom.Point2D point, double oRadius, java.awt.Graphics2D g2)
Draws an ellipse to represent an outlier.protected void
drawHighFarOut(double aRadius, java.awt.Graphics2D g2, double xx, double m)
Draws a triangle to indicate the presence of far out values.void
drawHorizontalItem(java.awt.Graphics2D g2, java.awt.geom.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.void
drawItem(java.awt.Graphics2D g2, XYItemRendererState state, java.awt.geom.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.protected void
drawLowFarOut(double aRadius, java.awt.Graphics2D g2, double xx, double m)
Draws a triangle to indicate the presence of far out values.protected void
drawMultipleEllipse(java.awt.geom.Point2D point, double boxWidth, double oRadius, java.awt.Graphics2D g2)
Draws two ellipses to represent overlapping outliers.void
drawVerticalItem(java.awt.Graphics2D g2, java.awt.geom.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(java.lang.Object obj)
Tests this renderer for equality with another object.Range
findRangeBounds(XYDataset dataset)
Returns the range of values the renderer requires to display all the items from the specified dataset.java.awt.Paint
getArtifactPaint()
Returns the paint used to paint the various artifacts such as outliers, farout symbol, median line and the averages ellipse.java.awt.Paint
getBoxPaint()
Returns the paint used to fill boxes.double
getBoxWidth()
Returns the width of each box.boolean
getFillBox()
Returns the flag that controls whether or not the box is filled.protected java.awt.Paint
lookupBoxPaint(int series, int item)
Returns the box paint or, if this isnull
, the item paint.private void
readObject(java.io.ObjectInputStream stream)
Provides serialization support.void
setArtifactPaint(java.awt.Paint paint)
Sets the paint used to paint the various artifacts such as outliers, farout symbol, median line and the averages ellipse, and sends aRendererChangeEvent
to all registered listeners.void
setBoxPaint(java.awt.Paint paint)
Sets the paint used to fill boxes and sends aRendererChangeEvent
to all registered listeners.void
setBoxWidth(double width)
Sets the box width 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.private void
writeObject(java.io.ObjectOutputStream stream)
Provides serialization support.-
Methods inherited from class org.jfree.chart.renderer.xy.AbstractXYItemRenderer
addAnnotation, addAnnotation, addEntity, annotationChanged, beginElementGroup, calculateDomainMarkerTextAnchorPoint, drawAnnotations, drawDomainLine, drawDomainMarker, drawItemLabel, drawRangeLine, drawRangeMarker, fillDomainGridBand, fillRangeGridBand, findDomainBounds, findDomainBounds, findRangeBounds, getAnnotations, getDefaultItemLabelGenerator, getDefaultToolTipGenerator, getDrawingSupplier, getItemLabelGenerator, getLegendItem, getLegendItemLabelGenerator, getLegendItems, getLegendItemToolTipGenerator, getLegendItemURLGenerator, getPassCount, getPlot, getSeriesItemLabelGenerator, getSeriesToolTipGenerator, getToolTipGenerator, getURLGenerator, hashCode, initialise, lineTo, moveTo, removeAnnotation, removeAnnotations, setDefaultItemLabelGenerator, setDefaultToolTipGenerator, setLegendItemLabelGenerator, setLegendItemToolTipGenerator, setLegendItemURLGenerator, setPlot, setSeriesItemLabelGenerator, setSeriesToolTipGenerator, setURLGenerator, 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, getItemLabelInsets, 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, isComputeItemLabelContrastColor, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, lookupLegendShape, lookupLegendTextFont, lookupLegendTextPaint, lookupSeriesFillPaint, lookupSeriesOutlinePaint, lookupSeriesOutlineStroke, lookupSeriesPaint, lookupSeriesShape, lookupSeriesStroke, notifyListeners, removeChangeListener, setAutoPopulateSeriesFillPaint, setAutoPopulateSeriesOutlinePaint, setAutoPopulateSeriesOutlineStroke, setAutoPopulateSeriesPaint, setAutoPopulateSeriesShape, setAutoPopulateSeriesStroke, setComputeItemLabelContrastColor, 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, setItemLabelInsets, 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.LegendItemSource
getLegendItems
-
Methods inherited from interface org.jfree.chart.renderer.xy.XYItemRenderer
addAnnotation, addAnnotation, addChangeListener, drawAnnotations, drawDomainLine, drawDomainMarker, drawRangeLine, drawRangeMarker, fillDomainGridBand, fillRangeGridBand, findDomainBounds, getDefaultCreateEntities, getDefaultFillPaint, getDefaultItemLabelFont, getDefaultItemLabelGenerator, getDefaultItemLabelPaint, getDefaultItemLabelsVisible, getDefaultNegativeItemLabelPosition, getDefaultOutlinePaint, getDefaultOutlineStroke, getDefaultPaint, getDefaultPositiveItemLabelPosition, getDefaultSeriesVisible, getDefaultSeriesVisibleInLegend, getDefaultShape, getDefaultStroke, getDefaultToolTipGenerator, getItemCreateEntity, getItemFillPaint, getItemLabelFont, getItemLabelGenerator, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getLegendItem, getLegendItemLabelGenerator, getNegativeItemLabelPosition, getPassCount, getPlot, getPositiveItemLabelPosition, getSeriesCreateEntities, getSeriesFillPaint, getSeriesItemLabelFont, getSeriesItemLabelGenerator, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesToolTipGenerator, getSeriesVisible, getSeriesVisibleInLegend, getToolTipGenerator, getURLGenerator, initialise, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, removeAnnotation, removeAnnotations, removeChangeListener, setDefaultCreateEntities, setDefaultCreateEntities, setDefaultFillPaint, setDefaultFillPaint, setDefaultItemLabelFont, setDefaultItemLabelGenerator, setDefaultItemLabelPaint, setDefaultItemLabelsVisible, setDefaultItemLabelsVisible, setDefaultNegativeItemLabelPosition, setDefaultNegativeItemLabelPosition, setDefaultOutlinePaint, setDefaultOutlinePaint, setDefaultOutlineStroke, setDefaultOutlineStroke, setDefaultPaint, setDefaultPaint, setDefaultPositiveItemLabelPosition, setDefaultPositiveItemLabelPosition, setDefaultSeriesVisible, setDefaultSeriesVisible, setDefaultSeriesVisibleInLegend, setDefaultSeriesVisibleInLegend, setDefaultShape, setDefaultShape, setDefaultStroke, setDefaultStroke, setDefaultToolTipGenerator, setLegendItemLabelGenerator, setPlot, setSeriesCreateEntities, setSeriesCreateEntities, setSeriesFillPaint, setSeriesFillPaint, setSeriesItemLabelFont, setSeriesItemLabelGenerator, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesShape, setSeriesStroke, setSeriesStroke, setSeriesToolTipGenerator, setSeriesVisible, setSeriesVisible, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setURLGenerator
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
boxWidth
private double boxWidth
The box width.
-
boxPaint
private transient java.awt.Paint boxPaint
The paint used to fill the box.
-
fillBox
private boolean fillBox
A flag that controls whether or not the box is filled.
-
artifactPaint
private transient java.awt.Paint artifactPaint
The paint used to draw various artifacts such as outliers, farout symbol, average ellipse and median line.
-
-
Constructor Detail
-
XYBoxAndWhiskerRenderer
public XYBoxAndWhiskerRenderer()
Creates a new renderer for box and whisker charts.
-
XYBoxAndWhiskerRenderer
public XYBoxAndWhiskerRenderer(double boxWidth)
Creates a new renderer for box and whisker charts.Use -1 for the box width if you prefer the width to be calculated automatically.
- Parameters:
boxWidth
- the box width.
-
-
Method Detail
-
getBoxWidth
public double getBoxWidth()
Returns the width of each box.- Returns:
- The box width.
- See Also:
setBoxWidth(double)
-
setBoxWidth
public void setBoxWidth(double width)
Sets the box width and sends aRendererChangeEvent
to all registered listeners.If you set the width to a negative value, the renderer will calculate the box width automatically based on the space available on the chart.
- Parameters:
width
- the width.- See Also:
getBoxWidth()
-
getBoxPaint
public java.awt.Paint getBoxPaint()
Returns the paint used to fill boxes.- Returns:
- The paint (possibly
null
). - See Also:
setBoxPaint(Paint)
-
setBoxPaint
public void setBoxPaint(java.awt.Paint paint)
Sets the paint used to fill boxes and sends aRendererChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
permitted).- See Also:
getBoxPaint()
-
getFillBox
public boolean getFillBox()
Returns the flag that controls whether or not the box is filled.- Returns:
- A boolean.
- See Also:
setFillBox(boolean)
-
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:
setFillBox(boolean)
-
getArtifactPaint
public java.awt.Paint getArtifactPaint()
Returns the paint used to paint the various artifacts such as outliers, farout symbol, median line and the averages ellipse.- Returns:
- The paint (never
null
). - See Also:
setArtifactPaint(Paint)
-
setArtifactPaint
public void setArtifactPaint(java.awt.Paint paint)
Sets the paint used to paint the various artifacts such as outliers, farout symbol, median line and the averages ellipse, and sends aRendererChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
getArtifactPaint()
-
findRangeBounds
public Range findRangeBounds(XYDataset dataset)
Returns the range of values the renderer requires to display all the items from the specified dataset.- Specified by:
findRangeBounds
in interfaceXYItemRenderer
- Overrides:
findRangeBounds
in classAbstractXYItemRenderer
- Parameters:
dataset
- the dataset (null
permitted).- Returns:
- The range (
null
if the dataset isnull
or empty). - See Also:
AbstractXYItemRenderer.findDomainBounds(XYDataset)
-
lookupBoxPaint
protected java.awt.Paint lookupBoxPaint(int series, int item)
Returns the box paint or, if this isnull
, the item paint.- Parameters:
series
- the series index.item
- the item index.- Returns:
- The paint used to fill the box for the specified item (never
null
).
-
drawItem
public void drawItem(java.awt.Graphics2D g2, XYItemRendererState state, java.awt.geom.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.- Specified by:
drawItem
in interfaceXYItemRenderer
- Parameters:
g2
- the graphics device.state
- the renderer state.dataArea
- the area within which the plot is being drawn.info
- collects info 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 (must be an instance ofBoxAndWhiskerXYDataset
).series
- the series index (zero-based).item
- the item index (zero-based).crosshairState
- crosshair information for the plot (null
permitted).pass
- the pass index.
-
drawHorizontalItem
public void drawHorizontalItem(java.awt.Graphics2D g2, java.awt.geom.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.- Parameters:
g2
- the graphics device.dataArea
- the area within which the plot is being drawn.info
- collects info 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 (must be an instance ofBoxAndWhiskerXYDataset
).series
- the series index (zero-based).item
- the item index (zero-based).crosshairState
- crosshair information for the plot (null
permitted).pass
- the pass index.
-
drawVerticalItem
public void drawVerticalItem(java.awt.Graphics2D g2, java.awt.geom.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.- Parameters:
g2
- the graphics device.dataArea
- the area within which the plot is being drawn.info
- collects info 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 (must be an instance ofBoxAndWhiskerXYDataset
).series
- the series index (zero-based).item
- the item index (zero-based).crosshairState
- crosshair information for the plot (null
permitted).pass
- the pass index.
-
drawEllipse
protected void drawEllipse(java.awt.geom.Point2D point, double oRadius, java.awt.Graphics2D g2)
Draws an ellipse to represent an outlier.- Parameters:
point
- the location.oRadius
- the radius.g2
- the graphics device.
-
drawMultipleEllipse
protected void drawMultipleEllipse(java.awt.geom.Point2D point, double boxWidth, double oRadius, java.awt.Graphics2D g2)
Draws two ellipses to represent overlapping outliers.- Parameters:
point
- the location.boxWidth
- the box width.oRadius
- the radius.g2
- the graphics device.
-
drawHighFarOut
protected void drawHighFarOut(double aRadius, java.awt.Graphics2D g2, double xx, double m)
Draws a triangle to indicate the presence of far out values.- Parameters:
aRadius
- the radius.g2
- the graphics device.xx
- the x value.m
- the max y value.
-
drawLowFarOut
protected void drawLowFarOut(double aRadius, java.awt.Graphics2D g2, double xx, double m)
Draws a triangle to indicate the presence of far out values.- Parameters:
aRadius
- the radius.g2
- the graphics device.xx
- the x value.m
- the min y value.
-
equals
public boolean equals(java.lang.Object obj)
Tests this renderer for equality with another object.- Overrides:
equals
in classAbstractXYItemRenderer
- Parameters:
obj
- the object (null
permitted).- Returns:
true
orfalse
.
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOException
Provides serialization support.- Parameters:
stream
- the output stream.- Throws:
java.io.IOException
- if there is an I/O error.
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Provides serialization support.- Parameters:
stream
- the input stream.- Throws:
java.io.IOException
- if there is an I/O error.java.lang.ClassNotFoundException
- if there is a classpath problem.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a clone of the renderer.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classAbstractXYItemRenderer
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- if the renderer cannot be cloned.
-
-