|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent com.objectplanet.chart.GenericChart com.objectplanet.chart.Chart com.objectplanet.chart.PieChart
public class 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/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces 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, POINTING, RIGHT, 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 com.objectplanet.chart.GenericChart |
---|
chartType, DEFAULT_SAMPLE_COLORS, depth3dPoint, display3dOn, displayVersionOn, dragged_label, grid, gridRenderer, legend, legendRenderer, legendSelection, needChartCalculation, needGraphBounds, needRender, new_cursor, old_cursor, overlayCharts, renderer |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
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 |
checkDataIntegrity()
Makes sure the linechart specific data has the same number of series and samples as the chart data has. |
ChartSample |
checkSelection(java.awt.Point point)
This method is called when the user releases the mouse and checks if the given point is inside a bar or a legend label. |
protected java.lang.String |
constructLabel(int series,
int sample,
int style,
boolean paintSeriesOn,
java.lang.String percentLabel)
Constructs the combination of labels. |
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.Color |
getInsideLabelColor(int index)
Gets the color of the inside labels of the specified pie. |
java.awt.Color |
getOutsideLabelColor(int index)
Gets the color of the outside 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). |
java.awt.Color |
getPointingLabelColor(int index)
Gets the color of the pointing labels of the specified pie. |
int |
getSelectionStyle()
Gets the current selection style. |
java.awt.Polygon |
getSlicePolygon(int serie,
int sample)
Gets the polygon describing the pie slice. |
java.awt.Color |
getSliceSeperatorColor()
Gets the current pie slice seperator line color. |
int |
getStartAngle(int index)
Gets the angle of the initial starting point of the slices. |
protected java.awt.Rectangle |
getTotalGraphBounds()
Gets total bounds of all pies on the chart. |
boolean |
isGradientSamplesOn()
|
boolean |
isPercentLabelsOn()
Checks if the percent labels are turned on. |
boolean |
isPieLabelsOn()
Checks if the pie lablels are turned on. |
boolean |
isPieRotationOn()
Checks if the pie rotation is on or off. |
boolean |
isSliceSeperatorOn()
Checks if the pie slice seperators are on. |
protected void |
processEvent(java.awt.AWTEvent e)
Handles the chart events. |
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 |
setGradientSamplesOn(boolean on)
|
void |
setInsideLabelColor(int index,
java.awt.Color color)
Sets the color of the inside labels for the specified pie. |
void |
setOutsideLabelColor(int index,
java.awt.Color color)
Sets the color of the outside labels 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 |
setPieRotationOn(boolean on)
Set pie rotation on or off. |
void |
setPointingLabelColor(int index,
java.awt.Color color)
Sets the color of the pointing labels for the specified pie. |
void |
setSelectionStyle(int style)
Sets the selection style. |
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 |
setStartAngle(int angle)
Sets the angle of the initial starting point of the slices. |
void |
setStartAngle(int index,
int angle)
Sets the angle of the initial starting point of the slices for the specified pie. |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateUI |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle |
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 checkDataIntegrity()
checkDataIntegrity
in class Chart
public ChartSample checkSelection(java.awt.Point point)
checkSelection
in class Chart
point
- The point clicked on.
protected java.lang.String constructLabel(int series, int sample, int style, boolean paintSeriesOn, java.lang.String percentLabel)
constructLabel
in class Chart
series
- The series index.sample
- The sample index.style
- The style of the label: INSIDE, OUTSIDE, FLOATING or POINTING.paintSeriesOn
- True if the series label should be on.percentLabel
- A percent label for pie chart.
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.Color getInsideLabelColor(int index)
index
- The index of the pie (0-based).
java.lang.IllegalArgumentException
- if the pie index is invalid.public java.awt.Color getOutsideLabelColor(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 java.awt.Color getPointingLabelColor(int index)
index
- The index of the pie (0-based).
java.lang.IllegalArgumentException
- if the pie index is invalid.public int getSelectionStyle()
setSelectionStyle(int)
public java.awt.Polygon getSlicePolygon(int serie, int sample)
serie
- The series indexsample
- The sample index.
public java.awt.Color getSliceSeperatorColor()
public int getStartAngle(int index)
protected java.awt.Rectangle getTotalGraphBounds()
getTotalGraphBounds
in class GenericChart
public boolean isGradientSamplesOn()
public boolean isPercentLabelsOn()
public boolean isPieLabelsOn()
setPieLabelsOn(boolean)
public boolean isPieRotationOn()
public boolean isSliceSeperatorOn()
setSliceSeperatorOn(boolean)
protected void processEvent(java.awt.AWTEvent e)
processEvent
in class Chart
e
- The event to process.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 GenericChart
label
- "titleFont", "legendFont", "pieLabelFont",
"floatingLabelFont".font
- The font to set for the specified label.public void setGradientSamplesOn(boolean on)
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 setOutsideLabelColor(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, INSIDE, OUTSIDE or POINTING.public void setPieLabelsOn(boolean on)
on
- True for on, false for off (default).public void setPieRotationOn(boolean on)
on
- True for on, false for off.public void setPointingLabelColor(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 setSelectionStyle(int style)
style
- SELECTION_STYLE_CIRCLE, SELECTION_STYLE_TRIANGLE, SELECTION_STYLE_DETACHED.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 setStartAngle(int angle)
angle
- ( from -360 to +360).setPieRotationOn(boolean)
public void setStartAngle(int index, int angle)
angle
- ( from -360 to +360).setPieRotationOn(boolean)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |