org.sourceforge.espro.elicitation
Class PieChart

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.sourceforge.espro.elicitation.ElicitationMethod
                  extended by org.sourceforge.espro.elicitation.PieChart
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, ModelInterface

public class PieChart
extends ElicitationMethod

PieChart is a method where the expert can create a pie chart of her expected probabilities. The probability of 1 is splitted into n pieces which can adjusted to her fits.

Version:
2.0
Author:
(c) 2007 Martin Kaffanke
See Also:
Serialized Form

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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class org.sourceforge.espro.elicitation.ElicitationMethod
frozen, g2, pcs
 
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 new instance of PieChart
 
Method Summary
protected  void addSelfListeners()
          Adds the listeners the PieChart uses itself.
protected  double calcValue(int xPos, int yPos)
          Calculates the Value for the given x/y coordinate.
 java.awt.Color[] getColors()
          Returns the colors.
 int getNPieces()
          Returns the number of pieces the pie chart has.
 double getRotationBase()
          Returns the rotation base.
 java.lang.String[] getTexts()
          Returns the actual texts in the legend.
 double getValue(int index)
          Returns a probability value
 double[] getValues()
          Returns all values.
protected  void initialize()
          Initializes the PieChart.
 boolean isRandom()
          DOCUMENT ME!
 boolean isShowLegend()
          Returns if we want to show the legend.
 boolean isShowProbs()
          DOCUMENT ME!
protected  void paintComponent(java.awt.Graphics g)
          Calls the UI delegate's paint method, if the UI delegate is non-null.
 void setColors(java.awt.Color[] colors)
          Sets the actual color set.
 void setNPieces(int nPieces)
          Sets the number of pieces the pie chart should have.
 void setRandom(boolean random)
          DOCUMENT ME!
 void setRotationBase(double rotationBase)
          Sets the rotation base.
 void setShowLegend(boolean showLegend)
          Sets if we want to show the legend.
 void setShowProbs(boolean showProbs)
          DOCUMENT ME!
 void setTexts(java.lang.String[] texts)
          Sets the actual set of texts for the legend.
 void setValue(int index, double value)
          Sets a value.
 void setValues(double[] values)
          Set the values.
 
Methods inherited from class org.sourceforge.espro.elicitation.ElicitationMethod
addPropertyChangeListener, addPropertyChangeListener, getCategory, getName, isEdit, isFrozen, removePropertyChangeListener, removePropertyChangeListener, setEdit, setFrozen, smothed
 
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, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, 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, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processEvent, 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, 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, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, 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, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PieChart

public PieChart()
Creates a new instance of PieChart

Method Detail

getColors

public java.awt.Color[] getColors()
Returns the colors.

Returns:
The actual color set.

getNPieces

public int getNPieces()
Returns the number of pieces the pie chart has.

Returns:
The number of pieces.

getRotationBase

public double getRotationBase()
Returns the rotation base.

Returns:
The rotation base.
See Also:
calcValue(int, int)

getTexts

public java.lang.String[] getTexts()
Returns the actual texts in the legend.

Returns:
The texts.

getValue

public double getValue(int index)
Returns a probability value

Parameters:
index - The index of the value to get.
Returns:
The value.

getValues

public double[] getValues()
Returns all values.

Returns:
All values.

isRandom

public boolean isRandom()
DOCUMENT ME!

Returns:
DOCUMENT ME!

isShowLegend

public boolean isShowLegend()
Returns if we want to show the legend.

Returns:
true if we want a legend.

isShowProbs

public boolean isShowProbs()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setColors

public void setColors(java.awt.Color[] colors)
Sets the actual color set.

Parameters:
colors - The actual color set.

setNPieces

public void setNPieces(int nPieces)
Sets the number of pieces the pie chart should have.

Parameters:
nPieces - The number of pieces.

setRandom

public void setRandom(boolean random)
DOCUMENT ME!

Parameters:
random - DOCUMENT ME!

setRotationBase

public void setRotationBase(double rotationBase)
Sets the rotation base.

Parameters:
rotationBase - The rotation base.
See Also:
calcValue(int, int)

setShowLegend

public void setShowLegend(boolean showLegend)
Sets if we want to show the legend.

Parameters:
showLegend - true if we want to show the legend.

setShowProbs

public void setShowProbs(boolean showProbs)
DOCUMENT ME!

Parameters:
showProbs - DOCUMENT ME!

setTexts

public void setTexts(java.lang.String[] texts)
Sets the actual set of texts for the legend.

Parameters:
texts - The texts.

setValue

public void setValue(int index,
                     double value)
Sets a value.

Parameters:
index - The index of the value to set.
value - The value.

setValues

public void setValues(double[] values)
Set the values.

Parameters:
values - Sets the values.

addSelfListeners

protected void addSelfListeners()
Adds the listeners the PieChart uses itself.

Overrides:
addSelfListeners in class ElicitationMethod

calcValue

protected double calcValue(int xPos,
                           int yPos)
Calculates the Value for the given x/y coordinate. This asumes that the rotationBase is 0. You should adjust the value if the rotationBase is not 0.

Parameters:
xPos - Mouse x coordinate.
yPos - Mouse y coordinate.
Returns:
The value. This are the degrees / 360, so 360° is a value of 1.

initialize

protected void initialize()
Initializes the PieChart.

Specified by:
initialize in class ElicitationMethod

paintComponent

protected void paintComponent(java.awt.Graphics g)
Calls the UI delegate's paint method, if the UI delegate is non-null. We pass the delegate a copy of the Graphics object to protect the rest of the paint code from irrevocable changes (for example, Graphics.translate).

If you override this in a subclass you should not make permanent changes to the passed in Graphics. For example, you should not alter the clip Rectangle or modify the transform. If you need to do these operations you may find it easier to create a new Graphics from the passed in Graphics and manipulate it. Further, if you do not invoker super's implementation you must honor the opaque property, that is if this component is opaque, you must completely fill in the background in a non-opaque color. If you do not honor the opaque property you will likely see visual artifacts.

The passed in Graphics object might have a transform other than the identify transform installed on it. In this case, you might get unexpected results if you cumulatively apply another transform.

Overrides:
paintComponent in class ElicitationMethod
Parameters:
g - the Graphics object to protect
See Also:
JComponent.paint(java.awt.Graphics), ComponentUI