public class PiePlot extends AbstractPlot implements Navigable
Class that displays data as segments of a pie plot. Empty segments are displayed for negative values.
To create a new PiePlot
simply create a new instance using
a data source. Example:
DataTable data = new DataTable(Integer.class, Double.class); data.add(-23.50); data.add(100.00); data.add( 60.25); PiePlot plot = new PiePlot(data);
Modifier and Type | Class and Description |
---|---|
static class |
PiePlot.PiePlotArea2D
Class that represents the drawing area of a
PiePlot . |
static class |
PiePlot.PiePlotLegend
A legend implementation for pie plots that displays items for each data
value of a data source.
|
static class |
PiePlot.PiePlotNavigator
Navigator implementation for pie plots.
|
static class |
PiePlot.PieSliceRenderer
A point renderer for a single slice in a pie plot.
|
protected static class |
PiePlot.Slice
Data class for storing slice information in world units.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AXIS_TANGENTIAL
Key for specifying the tangential axis of a pie plot.
|
Constructor and Description |
---|
PiePlot(DataSource data)
Initializes a new pie plot with the specified data source.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
DataSource source,
boolean visible)
Inserts the specified data series to the plot at a specified position.
|
void |
autoscaleAxis(java.lang.String axisName)
Tries to automatically set the ranges of the axes specified by the name
if it is set to auto-scale.
|
protected void |
createDefaultAxes()
Creates all axes that are defined by the current plot type.
|
protected void |
createDefaultAxisRenderers()
Creates all axis renderers that are defined by the current plot type.
|
protected void |
dataChanged(DataSource source,
DataChangeEvent... events)
Method that is invoked when data has been added, updated, or removed.
|
java.awt.geom.Point2D |
getCenter()
Returns a point which defines the center of the pie.
|
Navigator |
getNavigator()
Returns a navigator instance that can control the current object.
|
PointRenderer |
getPointRenderer(DataSource s)
Returns the
PointRenderer for the specified data source. |
double |
getRadius()
Returns the radius of the pie relative to the plot area size.
|
protected PiePlot.Slice |
getSlice(DataSource source,
int index)
Returns the sum of all absolute values from the specified data source up
to the row with the specified index.
|
double |
getStart()
Returns the starting angle of the first segment.
|
protected double |
getSum(DataSource source)
Returns the sum of all absolute values in the data column of a specified
data source.
|
boolean |
isClockwise()
Returns whether the segments are in clockwise or counterclockwise order.
|
protected void |
revalidate(DataSource source)
Rebuilds cached information for a specified data source.
|
void |
setCenter(java.awt.geom.Point2D center)
Sets the center of the pie.
|
void |
setClockwise(boolean clockwise)
Sets whether the segments will be in clockwise or counterclockwise order.
|
void |
setPointRenderer(DataSource s,
PointRenderer pointRenderer)
Sets the
PointRenderer for a certain data source to the
specified value. |
void |
setRadius(double radius)
Sets the radius of the pie relative to the plot area size.
|
void |
setStart(double start)
Sets the starting angle of the first segment.
|
add, add, autoscaleAxes, clear, contains, dataAdded, dataRemoved, dataUpdated, draw, drawAxes, drawLegend, get, getAxesNames, getAxis, getAxisComponent, getAxisMax, getAxisMin, getAxisRenderer, getBackground, getBorderColor, getBorderStroke, getData, getLegend, getLegendContainer, getLegendDistance, getLegendLocation, getMapping, getPlotArea, getTitle, getVisibleData, isLegendVisible, isVisible, layout, layoutAxes, layoutLegend, refreshLegendLayout, remove, removeAxis, setAxis, setAxisRenderer, setBackground, setBorderColor, setBorderStroke, setLegend, setLegendDistance, setLegendLocation, setLegendVisible, setMapping, setPlotArea, setVisible
add, add, drawComponents, getConstraints, getDrawableAt, getInsets, getLayout, getPreferredSize, iterator, remove, setBounds, setBounds, setInsets, setLayout, size
getBounds, getHeight, getWidth, getX, getY
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBounds, getHeight, getPreferredSize, getWidth, getX, getY, setBounds, setBounds
public static final java.lang.String AXIS_TANGENTIAL
public PiePlot(DataSource data)
data
- Data to be displayed.protected void createDefaultAxes()
AbstractPlot
createDefaultAxes
in class AbstractPlot
public void autoscaleAxis(java.lang.String axisName)
AbstractPlot
autoscaleAxis
in interface Plot
autoscaleAxis
in class AbstractPlot
axisName
- Name of the axis that should be scaled.Axis.setAutoscaled(boolean)
protected void createDefaultAxisRenderers()
AbstractPlot
createDefaultAxisRenderers
in class AbstractPlot
public void add(int index, DataSource source, boolean visible)
AbstractPlot
add
in interface Plot
add
in class AbstractPlot
index
- Position.source
- Data series.visible
- true
if the series should be displayed,
false
otherwise.public PointRenderer getPointRenderer(DataSource s)
PointRenderer
for the specified data source.s
- Data source.public void setPointRenderer(DataSource s, PointRenderer pointRenderer)
PointRenderer
for a certain data source to the
specified value.s
- Data source.pointRenderer
- PointRenderer to be set.public Navigator getNavigator()
getNavigator
in interface Navigable
protected PiePlot.Slice getSlice(DataSource source, int index)
source
- Data source.index
- Index of the row.protected double getSum(DataSource source)
source
- Data source.protected void revalidate(DataSource source)
source
- Data source.protected void dataChanged(DataSource source, DataChangeEvent... events)
AbstractPlot
dataChanged
in class AbstractPlot
source
- Data source that has been changed.events
- Optional event object describing the data values that
have been changed.public java.awt.geom.Point2D getCenter()
public void setCenter(java.awt.geom.Point2D center)
center
- Point which defines the center of the pie.public double getRadius()
public void setRadius(double radius)
radius
- Radius of the pie relative to the plot area size.public double getStart()
public void setStart(double start)
start
- Starting angle of the first segment in degrees.public boolean isClockwise()
true
if segments are in clockwise order,
otherwise false
.public void setClockwise(boolean clockwise)
clockwise
- true
if segments should be in clockwise order,
otherwise false
.