net.sourceforge.chart2d
Class PieChart2D

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--net.sourceforge.chart2d.Chart2D
                          |
                          +--net.sourceforge.chart2d.PieChart2D
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class PieChart2D
extends Chart2D

One of Chart2D's three general chart types. An PieChart2D is a pie chart PieChart2D extends Chart2D with extends JComponent. It can be added to a content pane or it can be used to return a BufferedImage of a chart. Use setMaximumSize to specify the maximum preferred size of the chart. Use setMinimumSize to specify the minimum preferred size of the chart. Use setPreferredSize to specify a preferred size of the chart; otherwise a preferred size will be calculated for the chart. The preferred size is the size at which all the chart's components are at their "model size" (i.e. no magnification at this size). So, if you have multiple charts in your GUI, and you want them to all have similar magnification ratios, then you should set all the charts to a common custom preferred size.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent, javax.swing.JComponent.ActionStandin, javax.swing.JComponent.IntVector, javax.swing.JComponent.KeyboardState
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
static java.awt.Dimension MAX_SIZE_DEFAULT
          The default is Dimension (1024, 768).
static java.awt.Dimension MIN_SIZE_DEFAULT
          The default is Dimension (250, 150).
 
Fields inherited from class javax.swing.JComponent
_bounds, accessibleContext, listenerList, paintingChild, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
component, containerListener, layoutMgr, listeningBoundsChildren, listeningChildren, ncomponents
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowListenerK, x, y
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PieChart2D()
          Creates a default PieChart2D object with a default PieChart2DProperties object.
PieChart2D(PieChart2DProperties pieChart2DProps)
          Creates a default PieChart2D object with the given PieChart2DProperties object.
 
Method Summary
(package private)  ChartArea getChartArea()
          Returns the ChartArea of this PieChart2D.
 java.awt.image.BufferedImage getImage()
          Returns a buffered image of the chart.
 PieChart2DProperties getPieChart2DProperties()
          Returns the PieChart2DProperties of this chart.
(package private)  PieChartArea getPieChartArea()
          Returns the PieChartArea of this PieChart2D.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of the chart.
 void pack()
          Causes the chart to set itself to its preferred size.
 void paintComponent(java.awt.Graphics g)
          Paints the chart.
 void setPieChart2DProperties(PieChart2DProperties pieChart2DProps)
          Specifies the new PieChart2DProperties for the chart.
 void setPreferredSize(java.awt.Dimension size)
          Specifies a custom preferred size for the chart.
 
Methods inherited from class javax.swing.JComponent
_paintImmediately, , addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, alwaysOnTop, checkIfChildObscuredBySibling, componentInputMapChanged, computeVisibleRect, computeVisibleRect, compWriteObjectNotify, contains, createToolTip, disable, enable, enableSerialization, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getCreatedDoubleBuffer, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseMotionEvent, putClientProperty, rectangleIsObscured, rectangleIsObscuredBySibling, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setCreatedDoubleBuffer, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPaintingChild, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, shouldDebugGraphics, superProcessMouseMotionEvent, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, adjustListeningChildren, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getLayout, getMouseEventTarget, getWindow, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, nextFocus, numListening, paintComponents, paintHeavyweightComponents, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, setFocusOwner, setLayout, transferFocus, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, constructComponentName, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getToolkit, getToolkitImpl, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isEnabledImpl, isLightweight, isRecursivelyVisible, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resetGC, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_SIZE_DEFAULT

public static java.awt.Dimension MAX_SIZE_DEFAULT
The default is Dimension (1024, 768).

MIN_SIZE_DEFAULT

public static java.awt.Dimension MIN_SIZE_DEFAULT
The default is Dimension (250, 150).
Constructor Detail

PieChart2D

public PieChart2D()
Creates a default PieChart2D object with a default PieChart2DProperties object.

PieChart2D

public PieChart2D(PieChart2DProperties pieChart2DProps)
Creates a default PieChart2D object with the given PieChart2DProperties object.
Parameters:
pieChart2DProps - The PieChart2DProperties for this chart.
Method Detail

setPreferredSize

public void setPreferredSize(java.awt.Dimension size)
Specifies a custom preferred size for the chart. This custom size will override the preferred size calculations that normally occurr. If null is passed, the preferred size calculations will be reinstated.
Overrides:
setPreferredSize in class Chart2D
Parameters:
size - The custom preferred size for this chart.

setPieChart2DProperties

public void setPieChart2DProperties(PieChart2DProperties pieChart2DProps)
Specifies the new PieChart2DProperties for the chart.
Parameters:
pieChart2DProps - The new PieChart2DProperties.

getPieChart2DProperties

public PieChart2DProperties getPieChart2DProperties()
Returns the PieChart2DProperties of this chart.
Returns:
The chart's PieChart2DProperties.

getImage

public java.awt.image.BufferedImage getImage()
Returns a buffered image of the chart. There should be no performance hit in calling this method..
Overrides:
getImage in class Chart2D
Returns:
An image of this chart

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of the chart. This method is maily written for the layout manager. The layout manager should call this method automatically to determine how much space to allocate the chart. The maximum size of the chart will be less than the maximum size set by the setMaximumSize(Dimension) method.
Overrides:
getPreferredSize in class Chart2D
Returns:
The preferred minimum size of the chart.

pack

public void pack()
Causes the chart to set itself to its preferred size. Recalculates the preferred size if the preferred size wasn't ever set.
Overrides:
pack in class Chart2D

paintComponent

public void paintComponent(java.awt.Graphics g)
Paints the chart. This is provided for the layout manager to call. The first time the chart is painted, massive computation must be made, and a delay will be noticed. After the first painting, no delay should be noticed. The chart is buffered, and should be painted immediately.
Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - The graphics context for calculations and painting.

getChartArea

ChartArea getChartArea()
Returns the ChartArea of this PieChart2D.
Overrides:
getChartArea in class Chart2D

getPieChartArea

PieChartArea getPieChartArea()
Returns the PieChartArea of this PieChart2D.