All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.objectplanet.chart.PieChart

java.lang.Object
   |
   +----java.awt.Component
           |
           +----com.objectplanet.chart.Chart
                   |
                   +----com.objectplanet.chart.PieChart

public class PieChart
extends Chart
This class implements a piechart component. The pie chart can be displayed either in 2D or 3D mode. In 3D mode the depth and degree of the pie can be adjusted. The pie segments as well as the legend labels can be selected by the user.

The following attributes can be set:

You can turn on or off the following feature: The following code creates a pie chart with four samples (segments).
// create the chart and its samples
PieChart chart = new PieChart(4);
long[] values = new long[] {100, 150, 70, 200};
String[] labels = new String[] {"one", "two", "three", "four"};
// set the chart attributes
chart.setTitle("Pie Chart");
chart.setSampleValues(values);
chart.setSampleLabels(labels);
// set the chart features
chart.set3DModeOn(true);
chart.setTitleOn(true);
chart.setLegendOn(true);
chart.setValueLabelsOn(true);
chart.setPercentLabelsOn(true);
 

Author:
Bjorn J. Kvande.

Constructor Index

 o PieChart()
Creates a pie chart with 5 samples.
 o PieChart(int)
Creates a pie chart with the given number of pie segments.

Method Index

 o checkSelection(Point)
Checks if a pie segment or legend label was selected.
 o getAngle()
Gets the angle of the pie chart.
 o getDepth()
Gets the depth of the pie.
 o getGraphBounds()
Calculates the bounding rectangle of the graph itself, based on which features are on and how they are configured.
 o getPercentDecimalCount()
Gets the number of decimals used with the percent values.
 o getPercentValue(int)
Gets the value of the given pie segment as a percentage value (out of 100).
 o isPercentLabelsOn()
Checks if the percent labels are turned on.
 o isSampleLabelsOn()
Checks if the sample label is turned on.
 o render(Graphics)
Renders the bar chart according to the current chart attributes and GUI state values.
 o setAngle(int)
Sets the angle of the pie chart.
 o setDepth(float)
Sets the depth of the pie.
 o setPercentDecimalCount(int)
Sets the number of decimals to use with the percent values.
 o setPercentLabelsOn(boolean)
Display percent labels when the mouse pointer is above the pie segment.
 o setSampleLabelsOn(boolean)
Display the sample label when the mouse pointer is above the pie segment.

Constructors

 o PieChart
 public PieChart()
Creates a pie chart with 5 samples.

 o PieChart
 public PieChart(int count)
Creates a pie chart with the given number of pie segments.

Parameters:
count - The number of pie segments for the chart.

Methods

 o getPercentValue
 public double getPercentValue(int index)
Gets the value of the given pie segment as a percentage value (out of 100).

Parameters:
index - The index of the pie segment (0-based).
Returns:
The number of percent the specified segment occupies.
 o setAngle
 public void setAngle(int angle)
Sets the angle of the pie chart. The default angle is 20.

Parameters:
angle - (0-80).
See Also:
setDepth
 o getAngle
 public int getAngle()
Gets the angle of the pie chart.

Returns:
The angle in degrees (0-90).
 o setDepth
 public void setDepth(float depth)
Sets the depth of the pie. The depth is a fraction of the width of the pie. If the depth is set to 1.0, the depth is the same as the width. The default depth is set to 0.4.

Parameters:
depth - The depth (0.0-1.0).
See Also:
setAngle
 o getDepth
 public float getDepth()
Gets the depth of the pie.

Returns:
a float in the range 0.0-1.0.
 o setPercentDecimalCount
 public void setPercentDecimalCount(int count)
Sets the number of decimals to use with the percent values. The default is 0 decimals.

Parameters:
count - The number of decimals to use.
 o getPercentDecimalCount
 public int getPercentDecimalCount()
Gets the number of decimals used with the percent values.

 o setPercentLabelsOn
 public void setPercentLabelsOn(boolean on)
Display percent labels when the mouse pointer is above the pie segment. The label shows the percent the pie segment occupies of the whole pie. If the value labels are turned on both of them will be displayed.

Parameters:
on - True for on, false for off.
See Also:
setValueLabelsOn
 o isPercentLabelsOn
 public boolean isPercentLabelsOn()
Checks if the percent labels are turned on.

Returns:
True if on, false if off.
 o setSampleLabelsOn
 public void setSampleLabelsOn(boolean on)
Display the sample label when the mouse pointer is above the pie segment.

Parameters:
on - True for on, false for off (default).
 o isSampleLabelsOn
 public boolean isSampleLabelsOn()
Checks if the sample label is turned on.

Returns:
True if on, false if off.
 o checkSelection
 protected ChartSample checkSelection(Point point)
Checks if a pie segment or legend label was selected.

Parameters:
point - The point clicked on.
Returns:
The pie segment selected, or null if no segment was selected.
Overrides:
checkSelection in class Chart
 o getGraphBounds
 public Rectangle getGraphBounds()
Calculates the bounding rectangle of the graph itself, based on which features are on and how they are configured.

 o render
 public void render(Graphics g)
Renders the bar chart according to the current chart attributes and GUI state values.

Overrides:
render in class Chart

All Packages  Class Hierarchy  This Package  Previous  Next  Index