Package org.jfree.chart.plot
Class SpiderWebPlot
java.lang.Object
org.jfree.chart.plot.Plot
org.jfree.chart.plot.SpiderWebPlot
- All Implemented Interfaces:
Serializable,Cloneable,EventListener,AnnotationChangeListener,AxisChangeListener,MarkerChangeListener,LegendItemSource,PublicCloneable,DatasetChangeListener
A plot that displays data from a
CategoryDataset in the form of a
"spider web". Multiple series can be plotted on the same axis to allow
easy comparison. This plot doesn't support negative values at present.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe default axis label gap (currently 10%).static final doubleThe default head radius percent (currently 1%).static final doubleThe default interior gap.static final PaintThe default series label background paint.static final FontThe default series label font.static final PaintThe default series label outline paint.static final StrokeThe default series label outline stroke.static final PaintThe default series label paint.static final PaintThe default series label shadow paint.static final doubleThe default maximum value plotted - forces the plot to evaluate the maximum from the data passed instatic final doubleThe default starting angle for the radar chart axes.protected doubleThe head radius as a percentage of the available drawing area.static final doubleThe maximum interior gap (currently 40%).Fields inherited from class org.jfree.chart.plot.Plot
DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_FOREGROUND_ALPHA, DEFAULT_INSETS, DEFAULT_LEGEND_ITEM_BOX, DEFAULT_LEGEND_ITEM_CIRCLE, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, MINIMUM_HEIGHT_TO_DRAW, MINIMUM_WIDTH_TO_DRAW, ZERO -
Constructor Summary
ConstructorsConstructorDescriptionCreates a default plot with no dataset.SpiderWebPlot(CategoryDataset dataset) Creates a new spider web plot with the given dataset, with each row representing a series.SpiderWebPlot(CategoryDataset dataset, TableOrder extract) Creates a new spider web plot with the given dataset. -
Method Summary
Modifier and TypeMethodDescriptionprotected Point2DcalculateLabelLocation(Rectangle2D labelBounds, double ascent, Rectangle2D plotArea, double startAngle) Returns the location for a labelclone()Returns a clone of this plot.voiddraw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) Draws the plot on a Java 2D graphics device (such as the screen or a printer).protected voiddrawLabel(Graphics2D g2, Rectangle2D plotArea, double value, int cat, double startAngle, double extent) Draws the label for one axis.protected voiddrawRadarPoly(Graphics2D g2, Rectangle2D plotArea, Point2D centre, PlotRenderingInfo info, int series, int catCount, double headH, double headW) Draws a radar plot polygon.booleanTests this plot for equality with an arbitrary object.doubleReturns the axis label gap.Returns the paint used to draw the axis lines.Returns the stroke used to draw the axis lines.Returns the base series paint.Returns the base series stroke.Returns the base series paint.Returns the data extract order (by row or by column).Returns the dataset.Returns the direction in which the radar axes are drawn (clockwise or anti-clockwise).doubleReturns the head percent (the default value is 0.01).doubleReturns the interior gap, measured as a percentage of the available drawing space.Returns the series label font.Returns the label generator.Returns the series label paint.Returns a collection of legend items for the spider web chart.Returns the shape used for legend items.doubleReturns the maximum value any category axis can take.Returns a short string describing the type of plot.protected NumbergetPlotValue(int series, int cat) Returns the value to be plotted at the intersection of the series and the category.Returns the outline paint for ALL series in the plot.getSeriesOutlinePaint(int series) Returns the paint for the specified series.Returns the outline stroke for ALL series in the plot.getSeriesOutlineStroke(int series) Returns the stroke for the specified series.Returns the paint for ALL series in the plot.getSeriesPaint(int series) Returns the paint for the specified series.doubleReturns the start angle for the first radar axis.Returns the tool tip generator for the plot.Returns the URL generator for the plot.floatReturns the alpha value for filling a graph (in the range 0.0 to 1.0).protected Point2DgetWebPoint(Rectangle2D bounds, double angle, double length) Returns a cartesian point from a polar angle, length and bounding boxbooleanMethod to determine if the web chart is to be filled.voidsetAxisLabelGap(double gap) Sets the axis label gap and sends aPlotChangeEventto all registered listeners.voidsetAxisLinePaint(Paint paint) Sets the paint used to draw the axis lines and sends aPlotChangeEventto all registered listeners.voidsetAxisLineStroke(Stroke stroke) Sets the stroke used to draw the axis lines and sends aPlotChangeEventto all registered listeners.voidsetBaseSeriesOutlinePaint(Paint paint) Sets the base series paint.voidsetBaseSeriesOutlineStroke(Stroke stroke) Sets the base series stroke.voidsetBaseSeriesPaint(Paint paint) Sets the base series paint.voidsetDataExtractOrder(TableOrder order) Sets the data extract order (by row or by column) and sends aPlotChangeEventto all registered listeners.voidsetDataset(CategoryDataset dataset) Sets the dataset used by the plot and sends aPlotChangeEventto all registered listeners.voidsetDirection(Rotation direction) Sets the direction in which the radar axes are drawn and sends aPlotChangeEventto all registered listeners.voidsetHeadPercent(double percent) Sets the head percent and sends aPlotChangeEventto all registered listeners.voidsetInteriorGap(double percent) Sets the interior gap and sends aPlotChangeEventto all registered listeners.voidsetLabelFont(Font font) Sets the series label font and sends aPlotChangeEventto all registered listeners.voidsetLabelGenerator(CategoryItemLabelGenerator generator) Sets the label generator and sends aPlotChangeEventto all registered listeners.voidsetLabelPaint(Paint paint) Sets the series label paint and sends aPlotChangeEventto all registered listeners.voidsetLegendItemShape(Shape shape) Sets the shape used for legend items and sends aPlotChangeEventto all registered listeners.voidsetMaxValue(double value) Sets the maximum value any category axis can take and sends aPlotChangeEventto all registered listeners.voidsetSeriesOutlinePaint(int series, Paint paint) Sets the paint used to fill a series of the radar and sends aPlotChangeEventto all registered listeners.voidsetSeriesOutlinePaint(Paint paint) Sets the outline paint for ALL series in the plot.voidsetSeriesOutlineStroke(int series, Stroke stroke) Sets the stroke used to fill a series of the radar and sends aPlotChangeEventto all registered listeners.voidsetSeriesOutlineStroke(Stroke stroke) Sets the outline stroke for ALL series in the plot.voidsetSeriesPaint(int series, Paint paint) Sets the paint used to fill a series of the radar and sends aPlotChangeEventto all registered listeners.voidsetSeriesPaint(Paint paint) Sets the paint for ALL series in the plot.voidsetStartAngle(double angle) Sets the starting angle and sends aPlotChangeEventto all registered listeners.voidsetToolTipGenerator(CategoryToolTipGenerator generator) Sets the tool tip generator for the plot and sends aPlotChangeEventto all registered listeners.voidsetURLGenerator(CategoryURLGenerator generator) Sets the URL generator for the plot and sends aPlotChangeEventto all registered listeners.voidsetWebFillAlpha(float alpha) Sets the alpha value for the fill of a plot polygon and sends aPlotChangeEventto all registered listeners.voidsetWebFilled(boolean flag) Sets the webFilled flag and sends aPlotChangeEventto all registered listeners.Methods inherited from class org.jfree.chart.plot.Plot
addChangeListener, annotationChanged, axisChanged, canEqual, createAndAddEntity, datasetChanged, drawBackground, drawBackgroundImage, drawNoDataMessage, drawOutline, fetchElementHintingFlag, fillBackground, fillBackground, fireChangeEvent, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundImageAlpha, getBackgroundPaint, getChart, getDatasetGroup, getDrawingSupplier, getForegroundAlpha, getInsets, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getOutlinePaint, getOutlineStroke, getParent, getRectX, getRectY, getRootPlot, handleClick, hashCode, isNotify, isOutlineVisible, isSubplot, markerChanged, notifyListeners, removeChangeListener, resolveDomainAxisLocation, resolveRangeAxisLocation, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundImageAlpha, setBackgroundPaint, setChart, setDatasetGroup, setDrawingSupplier, setDrawingSupplier, setForegroundAlpha, setInsets, setInsets, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setNotify, setOutlinePaint, setOutlineStroke, setOutlineVisible, setParent, zoom
-
Field Details
-
DEFAULT_HEAD
The default head radius percent (currently 1%).- See Also:
-
DEFAULT_AXIS_LABEL_GAP
The default axis label gap (currently 10%).- See Also:
-
DEFAULT_INTERIOR_GAP
The default interior gap.- See Also:
-
MAX_INTERIOR_GAP
The maximum interior gap (currently 40%).- See Also:
-
DEFAULT_START_ANGLE
The default starting angle for the radar chart axes.- See Also:
-
DEFAULT_LABEL_FONT
The default series label font. -
DEFAULT_LABEL_PAINT
The default series label paint. -
DEFAULT_LABEL_BACKGROUND_PAINT
The default series label background paint. -
DEFAULT_LABEL_OUTLINE_PAINT
The default series label outline paint. -
DEFAULT_LABEL_OUTLINE_STROKE
The default series label outline stroke. -
DEFAULT_LABEL_SHADOW_PAINT
The default series label shadow paint. -
DEFAULT_MAX_VALUE
The default maximum value plotted - forces the plot to evaluate the maximum from the data passed in- See Also:
-
headPercent
The head radius as a percentage of the available drawing area.
-
-
Constructor Details
-
SpiderWebPlot
public SpiderWebPlot()Creates a default plot with no dataset. -
SpiderWebPlot
Creates a new spider web plot with the given dataset, with each row representing a series.- Parameters:
dataset- the dataset (nullpermitted).
-
SpiderWebPlot
Creates a new spider web plot with the given dataset.- Parameters:
dataset- the dataset.extract- controls how data is extracted (TableOrder.BY_ROWorTableOrder.BY_COLUMN).
-
-
Method Details
-
getPlotType
Returns a short string describing the type of plot.- Specified by:
getPlotTypein classPlot- Returns:
- The plot type.
-
getDataset
Returns the dataset.- Returns:
- The dataset (possibly
null). - See Also:
-
setDataset
Sets the dataset used by the plot and sends aPlotChangeEventto all registered listeners.- Parameters:
dataset- the dataset (nullpermitted).- See Also:
-
isWebFilled
Method to determine if the web chart is to be filled.- Returns:
- A boolean.
- See Also:
-
setWebFilled
Sets the webFilled flag and sends aPlotChangeEventto all registered listeners.- Parameters:
flag- the flag.- See Also:
-
getWebFillAlpha
Returns the alpha value for filling a graph (in the range 0.0 to 1.0).- Returns:
- The alpha value for filling a spider plot polygon.
- See Also:
-
setWebFillAlpha
Sets the alpha value for the fill of a plot polygon and sends aPlotChangeEventto all registered listeners.- Parameters:
alpha- the new alpha value. If it is outside [0,1] it will be corrected to fit the range.- See Also:
-
getDataExtractOrder
Returns the data extract order (by row or by column).- Returns:
- The data extract order (never
null). - See Also:
-
setDataExtractOrder
Sets the data extract order (by row or by column) and sends aPlotChangeEventto all registered listeners.- Parameters:
order- the order (nullnot permitted).- Throws:
IllegalArgumentException- iforderisnull.- See Also:
-
getHeadPercent
Returns the head percent (the default value is 0.01).- Returns:
- The head percent (always > 0).
- See Also:
-
setHeadPercent
Sets the head percent and sends aPlotChangeEventto all registered listeners. Note that 0.10 is 10 percent.- Parameters:
percent- the percent (must be greater than zero).- See Also:
-
getStartAngle
Returns the start angle for the first radar axis.
This is measured in degrees starting from 3 o'clock (Java Arc2D default) and measuring anti-clockwise.- Returns:
- The start angle.
- See Also:
-
setStartAngle
Sets the starting angle and sends aPlotChangeEventto all registered listeners.The initial default value is 90 degrees, which corresponds to 12 o'clock. A value of zero corresponds to 3 o'clock... this is the encoding used by Java's Arc2D class.
- Parameters:
angle- the angle (in degrees).- See Also:
-
getMaxValue
Returns the maximum value any category axis can take.- Returns:
- The maximum value.
- See Also:
-
setMaxValue
Sets the maximum value any category axis can take and sends aPlotChangeEventto all registered listeners.- Parameters:
value- the maximum value.- See Also:
-
getDirection
Returns the direction in which the radar axes are drawn (clockwise or anti-clockwise).- Returns:
- The direction (never
null). - See Also:
-
setDirection
Sets the direction in which the radar axes are drawn and sends aPlotChangeEventto all registered listeners.- Parameters:
direction- the direction (nullnot permitted).- See Also:
-
getInteriorGap
Returns the interior gap, measured as a percentage of the available drawing space.- Returns:
- The gap (as a percentage of the available drawing space).
- See Also:
-
setInteriorGap
Sets the interior gap and sends aPlotChangeEventto all registered listeners. This controls the space between the edges of the plot and the plot area itself (the region where the axis labels appear).- Parameters:
percent- the gap (as a percentage of the available drawing space).- See Also:
-
getAxisLabelGap
Returns the axis label gap.- Returns:
- The axis label gap.
- See Also:
-
setAxisLabelGap
Sets the axis label gap and sends aPlotChangeEventto all registered listeners.- Parameters:
gap- the gap.- See Also:
-
getAxisLinePaint
Returns the paint used to draw the axis lines.- Returns:
- The paint used to draw the axis lines (never
null). - See Also:
-
setAxisLinePaint
Sets the paint used to draw the axis lines and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
getAxisLineStroke
Returns the stroke used to draw the axis lines.- Returns:
- The stroke used to draw the axis lines (never
null). - See Also:
-
setAxisLineStroke
Sets the stroke used to draw the axis lines and sends aPlotChangeEventto all registered listeners.- Parameters:
stroke- the stroke (nullnot permitted).- See Also:
-
getSeriesPaint
Returns the paint for ALL series in the plot.- Returns:
- The paint (possibly
null). - See Also:
-
setSeriesPaint
Sets the paint for ALL series in the plot. If this is set tonull, then a list of paints is used instead (to allow different colors to be used for each series of the radar group).- Parameters:
paint- the paint (nullpermitted).- See Also:
-
getSeriesPaint
Returns the paint for the specified series.- Parameters:
series- the series index (zero-based).- Returns:
- The paint (never
null). - See Also:
-
setSeriesPaint
Sets the paint used to fill a series of the radar and sends aPlotChangeEventto all registered listeners.- Parameters:
series- the series index (zero-based).paint- the paint (nullpermitted).- See Also:
-
getBaseSeriesPaint
Returns the base series paint. This is used when no other paint is available.- Returns:
- The paint (never
null). - See Also:
-
setBaseSeriesPaint
Sets the base series paint.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
getSeriesOutlinePaint
Returns the outline paint for ALL series in the plot.- Returns:
- The paint (possibly
null).
-
setSeriesOutlinePaint
Sets the outline paint for ALL series in the plot. If this is set tonull, then a list of paints is used instead (to allow different colors to be used for each series).- Parameters:
paint- the paint (nullpermitted).
-
getSeriesOutlinePaint
Returns the paint for the specified series.- Parameters:
series- the series index (zero-based).- Returns:
- The paint (never
null).
-
setSeriesOutlinePaint
Sets the paint used to fill a series of the radar and sends aPlotChangeEventto all registered listeners.- Parameters:
series- the series index (zero-based).paint- the paint (nullpermitted).
-
getBaseSeriesOutlinePaint
Returns the base series paint. This is used when no other paint is available.- Returns:
- The paint (never
null).
-
setBaseSeriesOutlinePaint
Sets the base series paint.- Parameters:
paint- the paint (nullnot permitted).
-
getSeriesOutlineStroke
Returns the outline stroke for ALL series in the plot.- Returns:
- The stroke (possibly
null).
-
setSeriesOutlineStroke
Sets the outline stroke for ALL series in the plot. If this is set tonull, then a list of paints is used instead (to allow different colors to be used for each series).- Parameters:
stroke- the stroke (nullpermitted).
-
getSeriesOutlineStroke
Returns the stroke for the specified series.- Parameters:
series- the series index (zero-based).- Returns:
- The stroke (never
null).
-
setSeriesOutlineStroke
Sets the stroke used to fill a series of the radar and sends aPlotChangeEventto all registered listeners.- Parameters:
series- the series index (zero-based).stroke- the stroke (nullpermitted).
-
getBaseSeriesOutlineStroke
Returns the base series stroke. This is used when no other stroke is available.- Returns:
- The stroke (never
null).
-
setBaseSeriesOutlineStroke
Sets the base series stroke.- Parameters:
stroke- the stroke (nullnot permitted).
-
getLegendItemShape
Returns the shape used for legend items.- Returns:
- The shape (never
null). - See Also:
-
setLegendItemShape
Sets the shape used for legend items and sends aPlotChangeEventto all registered listeners.- Parameters:
shape- the shape (nullnot permitted).- See Also:
-
getLabelFont
Returns the series label font.- Returns:
- The font (never
null). - See Also:
-
setLabelFont
Sets the series label font and sends aPlotChangeEventto all registered listeners.- Parameters:
font- the font (nullnot permitted).- See Also:
-
getLabelPaint
Returns the series label paint.- Returns:
- The paint (never
null). - See Also:
-
setLabelPaint
Sets the series label paint and sends aPlotChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
-
getLabelGenerator
Returns the label generator.- Returns:
- The label generator (never
null). - See Also:
-
setLabelGenerator
Sets the label generator and sends aPlotChangeEventto all registered listeners.- Parameters:
generator- the generator (nullnot permitted).- See Also:
-
getToolTipGenerator
Returns the tool tip generator for the plot.- Returns:
- The tool tip generator (possibly
null). - See Also:
-
setToolTipGenerator
Sets the tool tip generator for the plot and sends aPlotChangeEventto all registered listeners.- Parameters:
generator- the generator (nullpermitted).- See Also:
-
getURLGenerator
Returns the URL generator for the plot.- Returns:
- The URL generator (possibly
null). - See Also:
-
setURLGenerator
Sets the URL generator for the plot and sends aPlotChangeEventto all registered listeners.- Parameters:
generator- the generator (nullpermitted).- See Also:
-
getLegendItems
Returns a collection of legend items for the spider web chart.- Specified by:
getLegendItemsin interfaceLegendItemSource- Overrides:
getLegendItemsin classPlot- Returns:
- The legend items (never
null).
-
getWebPoint
Returns a cartesian point from a polar angle, length and bounding box- Parameters:
bounds- the area inside which the point needs to be.angle- the polar angle, in degrees.length- the relative length. Given in percent of maximum extend.- Returns:
- The cartesian point.
-
draw
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) Draws the plot on a Java 2D graphics device (such as the screen or a printer). -
drawRadarPoly
protected void drawRadarPoly(Graphics2D g2, Rectangle2D plotArea, Point2D centre, PlotRenderingInfo info, int series, int catCount, double headH, double headW) Draws a radar plot polygon.- Parameters:
g2- the graphics device.plotArea- the area we are plotting in (already adjusted).centre- the centre point of the radar axesinfo- chart rendering info.series- the series within the dataset we are plottingcatCount- the number of categories per radar plotheadH- the data point heightheadW- the data point width
-
getPlotValue
Returns the value to be plotted at the intersection of the series and the category. This allows us to plotBY_ROWorBY_COLUMNwhich basically is just reversing the definition of the categories and data series being plotted.- Parameters:
series- the series to be plotted.cat- the category within the series to be plotted.- Returns:
- The value to be plotted (possibly
null). - See Also:
-
drawLabel
protected void drawLabel(Graphics2D g2, Rectangle2D plotArea, double value, int cat, double startAngle, double extent) Draws the label for one axis.- Parameters:
g2- the graphics device.plotArea- the plot areavalue- the value of the label (ignored).cat- the category (zero-based index).startAngle- the starting angle.extent- the extent of the arc.
-
calculateLabelLocation
protected Point2D calculateLabelLocation(Rectangle2D labelBounds, double ascent, Rectangle2D plotArea, double startAngle) Returns the location for a label- Parameters:
labelBounds- the label bounds.ascent- the ascent (height of font).plotArea- the plot areastartAngle- the start angle for the pie series.- Returns:
- The location for a label.
-
equals
Tests this plot for equality with an arbitrary object. -
clone
Returns a clone of this plot.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classPlot- Returns:
- A clone of this plot.
- Throws:
CloneNotSupportedException- if the plot cannot be cloned for any reason.
-