org.jfree.chart.plot

Class SpiderWebPlot

public class SpiderWebPlot extends Plot implements Cloneable, Serializable

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.
Field Summary
static doubleDEFAULT_AXIS_LABEL_GAP
The default axis label gap (currently 10%).
static doubleDEFAULT_HEAD
The default head radius percent (currently 1%).
static doubleDEFAULT_INTERIOR_GAP
The default interior gap.
static PaintDEFAULT_LABEL_BACKGROUND_PAINT
The default series label background paint.
static FontDEFAULT_LABEL_FONT
The default series label font.
static PaintDEFAULT_LABEL_OUTLINE_PAINT
The default series label outline paint.
static StrokeDEFAULT_LABEL_OUTLINE_STROKE
The default series label outline stroke.
static PaintDEFAULT_LABEL_PAINT
The default series label paint.
static PaintDEFAULT_LABEL_SHADOW_PAINT
The default series label shadow paint.
static doubleDEFAULT_MAX_VALUE
The default maximum value plotted - forces the plot to evaluate the maximum from the data passed in
static doubleDEFAULT_START_ANGLE
The default starting angle for the radar chart axes.
protected doubleheadPercent
The head radius as a percentage of the available drawing area.
static doubleMAX_INTERIOR_GAP
The maximum interior gap (currently 40%).
Constructor Summary
SpiderWebPlot()
Creates 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
protected Point2DcalculateLabelLocation(Rectangle2D labelBounds, double ascent, Rectangle2D plotArea, double startAngle)
Returns the location for a label
Objectclone()
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.
booleanequals(Object obj)
Tests this plot for equality with an arbitrary object.
doublegetAxisLabelGap()
Returns the axis label gap.
PaintgetAxisLinePaint()
Returns the paint used to draw the axis lines.
StrokegetAxisLineStroke()
Returns the stroke used to draw the axis lines.
PaintgetBaseSeriesOutlinePaint()
Returns the base series paint.
StrokegetBaseSeriesOutlineStroke()
Returns the base series stroke.
PaintgetBaseSeriesPaint()
Returns the base series paint.
TableOrdergetDataExtractOrder()
Returns the data extract order (by row or by column).
CategoryDatasetgetDataset()
Returns the dataset.
RotationgetDirection()
Returns the direction in which the radar axes are drawn (clockwise or anti-clockwise).
doublegetHeadPercent()
Returns the head percent.
doublegetInteriorGap()
Returns the interior gap, measured as a percentage of the available drawing space.
FontgetLabelFont()
Returns the series label font.
CategoryItemLabelGeneratorgetLabelGenerator()
Returns the label generator.
PaintgetLabelPaint()
Returns the series label paint.
LegendItemCollectiongetLegendItems()
Returns a collection of legend items for the radar chart.
ShapegetLegendItemShape()
Returns the shape used for legend items.
doublegetMaxValue()
Returns the maximum value any category axis can take.
StringgetPlotType()
Returns a short string describing the type of plot.
protected NumbergetPlotValue(int series, int cat)
Returns the value to be plotted at the interseries of the series and the category.
PaintgetSeriesOutlinePaint()
Returns the outline paint for ALL series in the plot.
PaintgetSeriesOutlinePaint(int series)
Returns the paint for the specified series.
StrokegetSeriesOutlineStroke()
Returns the outline stroke for ALL series in the plot.
StrokegetSeriesOutlineStroke(int series)
Returns the stroke for the specified series.
PaintgetSeriesPaint()
Returns the paint for ALL series in the plot.
PaintgetSeriesPaint(int series)
Returns the paint for the specified series.
doublegetStartAngle()
Returns the start angle for the first radar axis.
CategoryToolTipGeneratorgetToolTipGenerator()
Returns the tool tip generator for the plot.
CategoryURLGeneratorgetURLGenerator()
Returns the URL generator for the plot.
protected Point2DgetWebPoint(Rectangle2D bounds, double angle, double length)
Returns a cartesian point from a polar angle, length and bounding box
booleanisWebFilled()
Method to determine if the web chart is to be filled.
voidsetAxisLabelGap(double gap)
Sets the axis label gap and sends a PlotChangeEvent to all registered listeners.
voidsetAxisLinePaint(Paint paint)
Sets the paint used to draw the axis lines and sends a PlotChangeEvent to all registered listeners.
voidsetAxisLineStroke(Stroke stroke)
Sets the stroke used to draw the axis lines and sends a PlotChangeEvent to 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 a PlotChangeEventto all registered listeners.
voidsetDataset(CategoryDataset dataset)
Sets the dataset used by the plot and sends a PlotChangeEvent to all registered listeners.
voidsetDirection(Rotation direction)
Sets the direction in which the radar axes are drawn and sends a PlotChangeEvent to all registered listeners.
voidsetHeadPercent(double percent)
Sets the head percent and sends a PlotChangeEvent to all registered listeners.
voidsetInteriorGap(double percent)
Sets the interior gap and sends a PlotChangeEvent to all registered listeners.
voidsetLabelFont(Font font)
Sets the series label font and sends a PlotChangeEvent to all registered listeners.
voidsetLabelGenerator(CategoryItemLabelGenerator generator)
Sets the label generator and sends a PlotChangeEvent to all registered listeners.
voidsetLabelPaint(Paint paint)
Sets the series label paint and sends a PlotChangeEvent to all registered listeners.
voidsetLegendItemShape(Shape shape)
Sets the shape used for legend items and sends a PlotChangeEvent to all registered listeners.
voidsetMaxValue(double value)
Sets the maximum value any category axis can take and sends a PlotChangeEvent to all registered listeners.
voidsetSeriesOutlinePaint(Paint paint)
Sets the outline paint for ALL series in the plot.
voidsetSeriesOutlinePaint(int series, Paint paint)
Sets the paint used to fill a series of the radar and sends a PlotChangeEvent to all registered listeners.
voidsetSeriesOutlineStroke(Stroke stroke)
Sets the outline stroke for ALL series in the plot.
voidsetSeriesOutlineStroke(int series, Stroke stroke)
Sets the stroke used to fill a series of the radar and sends a PlotChangeEvent to all registered listeners.
voidsetSeriesPaint(Paint paint)
Sets the paint for ALL series in the plot.
voidsetSeriesPaint(int series, Paint paint)
Sets the paint used to fill a series of the radar and sends a PlotChangeEvent to all registered listeners.
voidsetStartAngle(double angle)
Sets the starting angle and sends a PlotChangeEvent to all registered listeners.
voidsetToolTipGenerator(CategoryToolTipGenerator generator)
Sets the tool tip generator for the plot and sends a PlotChangeEvent to all registered listeners.
voidsetURLGenerator(CategoryURLGenerator generator)
Sets the URL generator for the plot and sends a PlotChangeEvent to all registered listeners.
voidsetWebFilled(boolean flag)
Sets the webFilled flag and sends a PlotChangeEvent to all registered listeners.

Field Detail

DEFAULT_AXIS_LABEL_GAP

public static final double DEFAULT_AXIS_LABEL_GAP
The default axis label gap (currently 10%).

DEFAULT_HEAD

public static final double DEFAULT_HEAD
The default head radius percent (currently 1%).

DEFAULT_INTERIOR_GAP

public static final double DEFAULT_INTERIOR_GAP
The default interior gap.

DEFAULT_LABEL_BACKGROUND_PAINT

public static final Paint DEFAULT_LABEL_BACKGROUND_PAINT
The default series label background paint.

DEFAULT_LABEL_FONT

public static final Font DEFAULT_LABEL_FONT
The default series label font.

DEFAULT_LABEL_OUTLINE_PAINT

public static final Paint DEFAULT_LABEL_OUTLINE_PAINT
The default series label outline paint.

DEFAULT_LABEL_OUTLINE_STROKE

public static final Stroke DEFAULT_LABEL_OUTLINE_STROKE
The default series label outline stroke.

DEFAULT_LABEL_PAINT

public static final Paint DEFAULT_LABEL_PAINT
The default series label paint.

DEFAULT_LABEL_SHADOW_PAINT

public static final Paint DEFAULT_LABEL_SHADOW_PAINT
The default series label shadow paint.

DEFAULT_MAX_VALUE

public static final double DEFAULT_MAX_VALUE
The default maximum value plotted - forces the plot to evaluate the maximum from the data passed in

DEFAULT_START_ANGLE

public static final double DEFAULT_START_ANGLE
The default starting angle for the radar chart axes.

headPercent

protected double headPercent
The head radius as a percentage of the available drawing area.

MAX_INTERIOR_GAP

public static final double MAX_INTERIOR_GAP
The maximum interior gap (currently 40%).

Constructor Detail

SpiderWebPlot

public SpiderWebPlot()
Creates a default plot with no dataset.

SpiderWebPlot

public SpiderWebPlot(CategoryDataset dataset)
Creates a new spider web plot with the given dataset, with each row representing a series.

Parameters: dataset the dataset (null permitted).

SpiderWebPlot

public SpiderWebPlot(CategoryDataset dataset, TableOrder extract)
Creates a new spider web plot with the given dataset.

Parameters: dataset the dataset. extract controls how data is extracted (TableOrder#BY_ROW or TableOrder#BY_COLUMN).

Method Detail

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 area startAngle the start angle for the pie series.

Returns: The location for a label.

clone

public Object clone()
Returns a clone of this plot.

Returns: A clone of this plot.

Throws: CloneNotSupportedException if the plot cannot be cloned for any reason.

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).

Parameters: g2 the graphics device. area the area within which the plot should be drawn. anchor the anchor point (null permitted). parentState the state from the parent plot, if there is one. info collects info about the drawing.

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 area value the value of the label (ignored). cat the category (zero-based index). startAngle the starting angle. extent the extent of the arc.

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 axes info chart rendering info. series the series within the dataset we are plotting catCount the number of categories per radar plot headH the data point height headW the data point width

equals

public boolean equals(Object obj)
Tests this plot for equality with an arbitrary object.

Parameters: obj the object (null permitted).

Returns: A boolean.

getAxisLabelGap

public double getAxisLabelGap()
Returns the axis label gap.

Returns: The axis label gap.

See Also: SpiderWebPlot

getAxisLinePaint

public Paint getAxisLinePaint()
Returns the paint used to draw the axis lines.

Returns: The paint used to draw the axis lines (never null).

Since: 1.0.4

See Also: setAxisLinePaint getAxisLineStroke

getAxisLineStroke

public Stroke getAxisLineStroke()
Returns the stroke used to draw the axis lines.

Returns: The stroke used to draw the axis lines (never null).

Since: 1.0.4

See Also: setAxisLineStroke getAxisLinePaint

getBaseSeriesOutlinePaint

public Paint getBaseSeriesOutlinePaint()
Returns the base series paint. This is used when no other paint is available.

Returns: The paint (never null).

getBaseSeriesOutlineStroke

public Stroke getBaseSeriesOutlineStroke()
Returns the base series stroke. This is used when no other stroke is available.

Returns: The stroke (never null).

getBaseSeriesPaint

public Paint getBaseSeriesPaint()
Returns the base series paint. This is used when no other paint is available.

Returns: The paint (never null).

See Also: setBaseSeriesPaint

getDataExtractOrder

public TableOrder getDataExtractOrder()
Returns the data extract order (by row or by column).

Returns: The data extract order (never null).

See Also: setDataExtractOrder

getDataset

public CategoryDataset getDataset()
Returns the dataset.

Returns: The dataset (possibly null).

See Also: setDataset

getDirection

public Rotation getDirection()
Returns the direction in which the radar axes are drawn (clockwise or anti-clockwise).

Returns: The direction (never null).

See Also: setDirection

getHeadPercent

public double getHeadPercent()
Returns the head percent.

Returns: The head percent.

See Also: SpiderWebPlot

getInteriorGap

public double 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: SpiderWebPlot

getLabelFont

public Font getLabelFont()
Returns the series label font.

Returns: The font (never null).

See Also: setLabelFont

getLabelGenerator

public CategoryItemLabelGenerator getLabelGenerator()
Returns the label generator.

Returns: The label generator (never null).

See Also: setLabelGenerator

getLabelPaint

public Paint getLabelPaint()
Returns the series label paint.

Returns: The paint (never null).

See Also: setLabelPaint

getLegendItems

public LegendItemCollection getLegendItems()
Returns a collection of legend items for the radar chart.

Returns: The legend items.

getLegendItemShape

public Shape getLegendItemShape()
Returns the shape used for legend items.

Returns: The shape (never null).

See Also: setLegendItemShape

getMaxValue

public double getMaxValue()
Returns the maximum value any category axis can take.

Returns: The maximum value.

See Also: SpiderWebPlot

getPlotType

public String getPlotType()
Returns a short string describing the type of plot.

Returns: The plot type.

getPlotValue

protected Number getPlotValue(int series, int cat)
Returns the value to be plotted at the interseries of the series and the category. This allows us to plot BY_ROW or BY_COLUMN which 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: getDataExtractOrder

getSeriesOutlinePaint

public Paint getSeriesOutlinePaint()
Returns the outline paint for ALL series in the plot.

Returns: The paint (possibly null).

getSeriesOutlinePaint

public Paint getSeriesOutlinePaint(int series)
Returns the paint for the specified series.

Parameters: series the series index (zero-based).

Returns: The paint (never null).

getSeriesOutlineStroke

public Stroke getSeriesOutlineStroke()
Returns the outline stroke for ALL series in the plot.

Returns: The stroke (possibly null).

getSeriesOutlineStroke

public Stroke getSeriesOutlineStroke(int series)
Returns the stroke for the specified series.

Parameters: series the series index (zero-based).

Returns: The stroke (never null).

getSeriesPaint

public Paint getSeriesPaint()
Returns the paint for ALL series in the plot.

Returns: The paint (possibly null).

See Also: setSeriesPaint

getSeriesPaint

public Paint getSeriesPaint(int series)
Returns the paint for the specified series.

Parameters: series the series index (zero-based).

Returns: The paint (never null).

See Also: SpiderWebPlot

getStartAngle

public double 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: SpiderWebPlot

getToolTipGenerator

public CategoryToolTipGenerator getToolTipGenerator()
Returns the tool tip generator for the plot.

Returns: The tool tip generator (possibly null).

Since: 1.0.2

See Also:

getURLGenerator

public CategoryURLGenerator getURLGenerator()
Returns the URL generator for the plot.

Returns: The URL generator (possibly null).

Since: 1.0.2

See Also:

getWebPoint

protected Point2D getWebPoint(Rectangle2D bounds, double angle, double length)
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.

isWebFilled

public boolean isWebFilled()
Method to determine if the web chart is to be filled.

Returns: A boolean.

See Also: SpiderWebPlot

setAxisLabelGap

public void setAxisLabelGap(double gap)
Sets the axis label gap and sends a PlotChangeEvent to all registered listeners.

Parameters: gap the gap.

See Also: getAxisLabelGap

setAxisLinePaint

public void setAxisLinePaint(Paint paint)
Sets the paint used to draw the axis lines and sends a PlotChangeEvent to all registered listeners.

Parameters: paint the paint (null not permitted).

Since: 1.0.4

See Also: getAxisLinePaint

setAxisLineStroke

public void setAxisLineStroke(Stroke stroke)
Sets the stroke used to draw the axis lines and sends a PlotChangeEvent to all registered listeners.

Parameters: stroke the stroke (null not permitted).

Since: 1.0.4

See Also: getAxisLineStroke

setBaseSeriesOutlinePaint

public void setBaseSeriesOutlinePaint(Paint paint)
Sets the base series paint.

Parameters: paint the paint (null not permitted).

setBaseSeriesOutlineStroke

public void setBaseSeriesOutlineStroke(Stroke stroke)
Sets the base series stroke.

Parameters: stroke the stroke (null not permitted).

setBaseSeriesPaint

public void setBaseSeriesPaint(Paint paint)
Sets the base series paint.

Parameters: paint the paint (null not permitted).

See Also: getBaseSeriesPaint

setDataExtractOrder

public void setDataExtractOrder(TableOrder order)
Sets the data extract order (by row or by column) and sends a PlotChangeEventto all registered listeners.

Parameters: order the order (null not permitted).

Throws: IllegalArgumentException if order is null.

See Also: getDataExtractOrder

setDataset

public void setDataset(CategoryDataset dataset)
Sets the dataset used by the plot and sends a PlotChangeEvent to all registered listeners.

Parameters: dataset the dataset (null permitted).

See Also: getDataset

setDirection

public void setDirection(Rotation direction)
Sets the direction in which the radar axes are drawn and sends a PlotChangeEvent to all registered listeners.

Parameters: direction the direction (null not permitted).

See Also: getDirection

setHeadPercent

public void setHeadPercent(double percent)
Sets the head percent and sends a PlotChangeEvent to all registered listeners.

Parameters: percent the percent.

See Also: getHeadPercent

setInteriorGap

public void setInteriorGap(double percent)
Sets the interior gap and sends a PlotChangeEvent to 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: getInteriorGap

setLabelFont

public void setLabelFont(Font font)
Sets the series label font and sends a PlotChangeEvent to all registered listeners.

Parameters: font the font (null not permitted).

See Also: getLabelFont

setLabelGenerator

public void setLabelGenerator(CategoryItemLabelGenerator generator)
Sets the label generator and sends a PlotChangeEvent to all registered listeners.

Parameters: generator the generator (null not permitted).

See Also: getLabelGenerator

setLabelPaint

public void setLabelPaint(Paint paint)
Sets the series label paint and sends a PlotChangeEvent to all registered listeners.

Parameters: paint the paint (null not permitted).

See Also: getLabelPaint

setLegendItemShape

public void setLegendItemShape(Shape shape)
Sets the shape used for legend items and sends a PlotChangeEvent to all registered listeners.

Parameters: shape the shape (null not permitted).

See Also: getLegendItemShape

setMaxValue

public void setMaxValue(double value)
Sets the maximum value any category axis can take and sends a PlotChangeEvent to all registered listeners.

Parameters: value the maximum value.

See Also: getMaxValue

setSeriesOutlinePaint

public void setSeriesOutlinePaint(Paint paint)
Sets the outline paint for ALL series in the plot. If this is set to null, then a list of paints is used instead (to allow different colors to be used for each series).

Parameters: paint the paint (null permitted).

setSeriesOutlinePaint

public void setSeriesOutlinePaint(int series, Paint paint)
Sets the paint used to fill a series of the radar and sends a PlotChangeEvent to all registered listeners.

Parameters: series the series index (zero-based). paint the paint (null permitted).

setSeriesOutlineStroke

public void setSeriesOutlineStroke(Stroke stroke)
Sets the outline stroke for ALL series in the plot. If this is set to null, then a list of paints is used instead (to allow different colors to be used for each series).

Parameters: stroke the stroke (null permitted).

setSeriesOutlineStroke

public void setSeriesOutlineStroke(int series, Stroke stroke)
Sets the stroke used to fill a series of the radar and sends a PlotChangeEvent to all registered listeners.

Parameters: series the series index (zero-based). stroke the stroke (null permitted).

setSeriesPaint

public void setSeriesPaint(Paint paint)
Sets the paint for ALL series in the plot. If this is set to null , 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 (null permitted).

See Also: getSeriesPaint

setSeriesPaint

public void setSeriesPaint(int series, Paint paint)
Sets the paint used to fill a series of the radar and sends a PlotChangeEvent to all registered listeners.

Parameters: series the series index (zero-based). paint the paint (null permitted).

See Also: SpiderWebPlot

setStartAngle

public void setStartAngle(double angle)
Sets the starting angle and sends a PlotChangeEvent to 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: getStartAngle

setToolTipGenerator

public void setToolTipGenerator(CategoryToolTipGenerator generator)
Sets the tool tip generator for the plot and sends a PlotChangeEvent to all registered listeners.

Parameters: generator the generator (null permitted).

Since: 1.0.2

See Also:

setURLGenerator

public void setURLGenerator(CategoryURLGenerator generator)
Sets the URL generator for the plot and sends a PlotChangeEvent to all registered listeners.

Parameters: generator the generator (null permitted).

Since: 1.0.2

See Also:

setWebFilled

public void setWebFilled(boolean flag)
Sets the webFilled flag and sends a PlotChangeEvent to all registered listeners.

Parameters: flag the flag.

See Also: isWebFilled