de.erichseifert.gral.plots
Class PiePlot
- java.lang.Object
-
- de.erichseifert.gral.graphics.AbstractDrawable
-
- de.erichseifert.gral.graphics.DrawableContainer
-
- de.erichseifert.gral.plots.AbstractPlot
-
- de.erichseifert.gral.plots.PiePlot
-
- All Implemented Interfaces:
- DataListener, Container, Drawable, Navigable, Plot, java.io.Serializable, java.lang.Iterable<Drawable>
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
PiePlotsimply 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);
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classPiePlot.PiePlotArea2DClass that represents the drawing area of aPiePlot.static classPiePlot.PiePlotLegendA legend implementation for pie plots that displays items for each data value of a data source.static classPiePlot.PiePlotNavigatorNavigator implementation for pie plots.static classPiePlot.PieSliceRendererA point renderer for a single slice in a pie plot.
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.StringAXIS_TANGENTIALKey for specifying the tangential axis of a pie plot.
-
Constructor Summary
Constructors Constructor and Description PiePlot(DataSource data)Initializes a new pie plot with the specified data source.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(int index, DataSource source, boolean visible)Inserts the specified data series to the plot at a specified position.voidautoscaleAxis(java.lang.String axisName)Tries to automatically set the ranges of the axes specified by the name if it is set to auto-scale.static DataSourcecreatePieData(DataSource data)java.awt.geom.Point2DgetCenter()Returns a point which defines the center of the pie.NavigatorgetNavigator()Returns a navigator instance that can control the current object.PointRenderergetPointRenderer(DataSource s)Returns thePointRendererfor the specified data source.doublegetRadius()Returns the radius of the pie relative to the plot area size.doublegetStart()Returns the starting angle of the first segment.booleanisClockwise()Returns whether the segments are in clockwise or counterclockwise order.voidsetCenter(java.awt.geom.Point2D center)Sets the center of the pie.voidsetClockwise(boolean clockwise)Sets whether the segments will be in clockwise or counterclockwise order.voidsetPointRenderer(DataSource s, PointRenderer pointRenderer)Sets thePointRendererfor a certain data source to the specified value.voidsetRadius(double radius)Sets the radius of the pie relative to the plot area size.voidsetStart(double start)Sets the starting angle of the first segment.-
Methods inherited from class de.erichseifert.gral.plots.AbstractPlot
add, add, clear, contains, dataAdded, dataRemoved, dataUpdated, draw, get, getAxesNames, getAxis, getAxisRenderer, getBackground, getBorderColor, getBorderStroke, getData, getFont, getLegend, getLegendDistance, getLegendLocation, getMapping, getPlotArea, getTitle, getVisibleData, isLegendVisible, isVisible, layout, remove, removeAxis, setAxis, setAxisRenderer, setBackground, setBorderColor, setBorderStroke, setFont, setLegendDistance, setLegendLocation, setLegendVisible, setMapping, setVisible
-
Methods inherited from class de.erichseifert.gral.graphics.DrawableContainer
add, add, contains, getConstraints, getDrawables, getDrawablesAt, getInsets, getLayout, getPreferredSize, iterator, remove, setBounds, setBounds, setInsets, setLayout, size
-
Methods inherited from class de.erichseifert.gral.graphics.AbstractDrawable
getBounds, getHeight, getWidth, getX, getY, setPosition
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.erichseifert.gral.graphics.Drawable
getBounds, getHeight, getPreferredSize, getWidth, getX, getY, setBounds, setBounds, setPosition
-
Methods inherited from interface de.erichseifert.gral.graphics.Container
add, add, contains, getBounds, getConstraints, getDrawables, getDrawablesAt, getInsets, getLayout, remove, setBounds, setInsets, setLayout, size
-
-
-
-
Field Detail
-
AXIS_TANGENTIAL
public static final java.lang.String AXIS_TANGENTIAL
Key for specifying the tangential axis of a pie plot.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PiePlot
public PiePlot(DataSource data)
Initializes a new pie plot with the specified data source.- Parameters:
data- Data to be displayed.
-
-
Method Detail
-
autoscaleAxis
public void autoscaleAxis(java.lang.String axisName)
Description copied from class:AbstractPlotTries to automatically set the ranges of the axes specified by the name if it is set to auto-scale.- Specified by:
autoscaleAxisin interfacePlot- Overrides:
autoscaleAxisin classAbstractPlot- Parameters:
axisName- Name of the axis that should be scaled.- See Also:
Axis.setAutoscaled(boolean)
-
add
public void add(int index, DataSource source, boolean visible)Description copied from class:AbstractPlotInserts the specified data series to the plot at a specified position.- Specified by:
addin interfacePlot- Overrides:
addin classAbstractPlot- Parameters:
index- Position.source- Data series.visible-trueif the series should be displayed,falseotherwise.
-
getPointRenderer
public PointRenderer getPointRenderer(DataSource s)
Returns thePointRendererfor the specified data source.- Parameters:
s- Data source.- Returns:
- PointRenderer.
-
setPointRenderer
public void setPointRenderer(DataSource s, PointRenderer pointRenderer)
Sets thePointRendererfor a certain data source to the specified value.- Parameters:
s- Data source.pointRenderer- PointRenderer to be set.
-
getNavigator
public Navigator getNavigator()
Returns a navigator instance that can control the current object.- Specified by:
getNavigatorin interfaceNavigable- Returns:
- A navigator instance.
-
createPieData
public static DataSource createPieData(DataSource data)
-
getCenter
public java.awt.geom.Point2D getCenter()
Returns a point which defines the center of the pie. The coordinates are relative to the plot area dimensions, i.e. 0.0 means left/top, 0.5 means the center, and 1.0 means right/bottom.- Returns:
- Point which defines the center of the pie.
-
setCenter
public void setCenter(java.awt.geom.Point2D center)
Sets the center of the pie. The coordinates must be relative to the plot area dimensions, i.e. 0.0 means left/top, 0.5 means the center, and 1.0 means right/bottom.- Parameters:
center- Point which defines the center of the pie.
-
getRadius
public double getRadius()
Returns the radius of the pie relative to the plot area size.- Returns:
- Radius of the pie relative to the plot area size.
-
setRadius
public void setRadius(double radius)
Sets the radius of the pie relative to the plot area size.- Parameters:
radius- Radius of the pie relative to the plot area size.
-
getStart
public double getStart()
Returns the starting angle of the first segment. The angle is counterclockwise.- Returns:
- Starting angle of the first segment in degrees.
-
setStart
public void setStart(double start)
Sets the starting angle of the first segment. The angle is always applied counterclockwise.- Parameters:
start- Starting angle of the first segment in degrees.
-
isClockwise
public boolean isClockwise()
Returns whether the segments are in clockwise or counterclockwise order.- Returns:
trueif segments are in clockwise order, otherwisefalse.
-
setClockwise
public void setClockwise(boolean clockwise)
Sets whether the segments will be in clockwise or counterclockwise order.- Parameters:
clockwise-trueif segments should be in clockwise order, otherwisefalse.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG