|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--com.objectplanet.chart.Chart | +--com.objectplanet.chart.PieChart
This pie chart component enables you to add a pie chart to your java
applications with just a few lines of code.
A simple pie chart can be created with the following code:
See here for a list of parameters to
set for the pie chart.
PieChart chart = new PieChart(5);
long[] values = new long[] {100, 200, 300, 400, 500};
chart.setSampleValues(values);
A chart with the legend turned on and displayed in 3D can be
created with the following code:
PieChart chart = new PieChart(5);
long[] values = new long[] {100, 200, 300, 400, 500};
chart.setSampleValues(values);
chart.setLegendOn(true);
chart.set3DModeOn(true);
Nested Class Summary |
Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
static int |
SELECTION_STYLE_CIRCLE
Used to mark a selected pie segment with a indented circle |
static int |
SELECTION_STYLE_DETACHED
Used to mark a selected pie segment as detached from the pie |
static int |
SELECTION_STYLE_TRIANGLE
Used to mark a selected pie segment with a triangle |
Fields inherited from class com.objectplanet.chart.Chart |
BELOW, BELOW_AND_FLOATING, BOTTOM, chartData, FLOATING, HORIZONTAL, INSIDE, LEFT, OUTSIDE, overlayCharts, RIGHT, STATIC, TARGET_LINE_ID_AND_VALUE_LABEL, TARGET_LINE_ID_LABEL, TARGET_LINE_NO_LABEL, TARGET_LINE_VALUE_LABEL, TOP, VERTICAL, visibleSamples |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
PieChart()
Creates a pie chart with 1 sample. |
|
PieChart(int sampleCount)
Creates a pie chart with the given number of pie segments. |
|
PieChart(int seriesCount,
int sampleCount)
Creates a pie chart with the given number of series and samples. |
Method Summary | |
protected void |
calculateChartData(java.awt.Rectangle grid,
java.awt.Rectangle dataBounds)
Calculates the chart data. |
protected void |
checkDataIntegrity()
Makes sure the linechart specific data has the same number of series and samples as the chart data has. |
com.objectplanet.chart.ChartSample |
checkSelection(java.awt.Point point)
Checks if a pie segment or legend label was selected. |
int |
getAngle()
Gets the angle of the pie chart. |
float |
getDepth()
Gets the depth of the pie. |
double |
getDetachedDistance()
Gets the default detach distance. |
double |
getDetachedSlice(int serie,
int index)
Gets the distance a pie slice is detached from the given pie. |
java.awt.Rectangle |
getGraphBounds()
Calculates the bounding rectangle of the graph itself, based on which features are on and how they are configured. |
java.awt.Color |
getInsideLabelColor(int index)
Gets the color of the inside labels of the specified pie. |
int |
getPercentDecimalCount()
Gets the number of decimals used with the percent values. |
int |
getPercentLabelStyle()
Gets the style of the percent labels. |
double |
getPercentValue(int serie,
int index)
Gets the value of the given pie segment as a percentage value (out of 100). |
int |
getSampleLabelStyle()
Gets the style of the sample labels. |
int |
getSelectionStyle()
Gets the current selection style. |
int |
getSeriesLabelStyle()
Gets the style of the series labels. |
java.awt.Color |
getSliceSeperatorColor()
Gets the current pie slice seperator line color. |
int |
getValueLabelStyle()
Gets the style of the value labels. |
boolean |
isPercentLabelsOn()
Checks if the percent labels are turned on. |
boolean |
isPieLabelsOn()
Checks if the pie lablels are turned on. |
boolean |
isSampleLabelsOn()
Checks if the sample label is turned on. |
boolean |
isSeriesLabelsOn()
Checks if the series label is turned on. |
boolean |
isSliceSeperatorOn()
Checks if the pie slice seperators are on. |
void |
render(java.awt.Graphics g)
Renders the pie chart according to the current chart attributes and GUI state values. |
protected void |
renderData(java.awt.Graphics g,
java.awt.Rectangle grid,
java.awt.Rectangle dataBounds)
Renders the pies for the chart. |
void |
reset()
Resets the chart data and features. |
void |
setAngle(int angle)
Sets the angle of the pie chart. |
void |
setDepth(double depth)
Sets the depth of the pie. |
void |
setDetachedDistance(double distance)
Sets the default detach distance when detached selection style is set. |
void |
setDetachedSlice(int serie,
int index,
double distance)
Detaches a pie slice. |
void |
setFont(java.lang.String label,
java.awt.Font font)
Sets the font for the title, legend, pie labels, sample labels, percent labels, or value labels. |
void |
setInsideLabelColor(int index,
java.awt.Color color)
Sets the color of the inside label for the specified pie. |
void |
setPercentDecimalCount(int count)
Sets the number of decimals to use with the percent values. |
void |
setPercentLabelsOn(boolean on)
Display percent labels when the mouse pointer is above the pie segment. |
void |
setPercentLabelStyle(int style)
Sets the style of the percent labels. |
void |
setPieLabelsOn(boolean on)
Use this to display the sample labels below each pie when multiple data series (multiple pies) are used. |
void |
setSampleLabelsOn(boolean on)
Display the sample label when the mouse pointer is above the pie segment. |
void |
setSampleLabelStyle(int style)
Sets the style of the sample labels. |
void |
setSelectionStyle(int style)
Sets the selection style. |
void |
setSeriesLabelsOn(boolean on)
Display the series label when the mouse pointer is above the pie segment. |
void |
setSeriesLabelStyle(int style)
Sets the style of the series labels. |
void |
setSliceSeperatorColor(java.awt.Color color)
Sets the pie slice seperator line color. |
void |
setSliceSeperatorOn(boolean state)
Turns on or off the pie slice seperator lines. |
void |
setValueLabelStyle(int style)
Sets the style of the value labels. |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle, validate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int SELECTION_STYLE_CIRCLE
public static final int SELECTION_STYLE_DETACHED
public static final int SELECTION_STYLE_TRIANGLE
Constructor Detail |
public PieChart()
public PieChart(int sampleCount)
sampleCount
- The number of pie segments for the chart.public PieChart(int seriesCount, int sampleCount)
seriesCount
- The number of pies.sampleCount
- The number of segments in each pie.Method Detail |
protected void calculateChartData(java.awt.Rectangle grid, java.awt.Rectangle dataBounds)
calculateChartData
in class Chart
grid
- The chart grid bounds to paint data within.dataBounds
- The scrolled bounds to calculate the data within.protected void checkDataIntegrity()
checkDataIntegrity
in class Chart
public com.objectplanet.chart.ChartSample checkSelection(java.awt.Point point)
checkSelection
in class Chart
point
- The point clicked on.
public int getAngle()
public float getDepth()
public double getDetachedDistance()
setDetachedDistance(double)
public double getDetachedSlice(int serie, int index)
serie
- The series index of the slice.index
- The sample index of the slice.
public java.awt.Rectangle getGraphBounds()
getGraphBounds
in class Chart
public java.awt.Color getInsideLabelColor(int index)
index
- The index of the pie (0-based).
java.lang.IllegalArgumentException
- if the pie index is invalid.public int getPercentDecimalCount()
public int getPercentLabelStyle()
setPercentLabelStyle(int)
public double getPercentValue(int serie, int index)
serie
- The index of the serie (0-based).index
- The index of the pie segment (0-based).
java.lang.IllegalArgumentException
- If the index or series is invalid.public int getSampleLabelStyle()
getSampleLabelStyle
in class Chart
setSampleLabelStyle(int)
public int getSelectionStyle()
setSelectionStyle(int)
public int getSeriesLabelStyle()
getSeriesLabelStyle
in class Chart
setSeriesLabelStyle(int)
public java.awt.Color getSliceSeperatorColor()
public int getValueLabelStyle()
setValueLabelStyle(int)
public boolean isPercentLabelsOn()
public boolean isPieLabelsOn()
setPieLabelsOn(boolean)
public boolean isSampleLabelsOn()
isSampleLabelsOn
in class Chart
public boolean isSeriesLabelsOn()
isSeriesLabelsOn
in class Chart
public boolean isSliceSeperatorOn()
setSliceSeperatorOn(boolean)
public void render(java.awt.Graphics g)
render
in class Chart
g
- The graphics context used to paint with.Chart.paint(java.awt.Graphics)
protected void renderData(java.awt.Graphics g, java.awt.Rectangle grid, java.awt.Rectangle dataBounds)
renderData
in class Chart
g
- The graphics context used to paint with.grid
- The chart grid bounds to paint data within.dataBounds
- The scrolled bounds to calculate the data within.public void reset()
reset
in class Chart
public void setAngle(int angle)
angle
- (0-80).setDepth(double)
public void setDepth(double depth)
depth
- The depth (0.0-1.0).setAngle(int)
public void setDetachedDistance(double distance)
distance
- The distance to use.setDetachedSlice(int, int, double)
public void setDetachedSlice(int serie, int index, double distance)
serie
- The series index of the slice.index
- The sample index of the slice.distance
- The distance as a factor of the pie size.public void setFont(java.lang.String label, java.awt.Font font)
setFont
in class Chart
label
- "titleFont", "legendFont", "pieLabelFont",
"floatingLabelFont".font
- The font to set for the specified label.public void setInsideLabelColor(int index, java.awt.Color color)
index
- The index of the pie (0-based).color
- The color to use, null for the default color.
java.lang.IllegalArgumentException
- if the pie index is invalid.public void setPercentDecimalCount(int count)
count
- The number of decimals to use.public void setPercentLabelsOn(boolean on)
on
- True for on, false for off.Chart.setValueLabelsOn(boolean)
public void setPercentLabelStyle(int style)
style
- FLOATING or INSIDE.public void setPieLabelsOn(boolean on)
on
- True for on, false for off (default).public void setSampleLabelsOn(boolean on)
setSampleLabelsOn
in class Chart
on
- True for on, false for off (default).public void setSampleLabelStyle(int style)
setSampleLabelStyle
in class Chart
style
- FLOATING or INSIDE.public void setSelectionStyle(int style)
style
- SELECTION_STYLE_CIRCLE, SELECTION_STYLE_TRIANGLE, SELECTION_STYLE_DETACHED.public void setSeriesLabelsOn(boolean on)
setSeriesLabelsOn
in class Chart
on
- True for on, false for off (default).public void setSeriesLabelStyle(int style)
setSeriesLabelStyle
in class Chart
style
- FLOATING or INSIDE.public void setSliceSeperatorColor(java.awt.Color color)
color
- The color to use.public void setSliceSeperatorOn(boolean state)
state
- True for on, false for off.public void setValueLabelStyle(int style)
style
- FLOATING or INSIDE.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |