org.sourceforge.espro.elicitation
Class BetaDist

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.FunctionalMethod
                      extended by org.sourceforge.espro.elicitation.BetaDist
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, ModelInterface

public class BetaDist
extends FunctionalMethod

The BetaDist method shows a beta distribution to the user and lets them manipulate it by dragging the function courve arround.

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
protected  double betaP
          The p value of the beta distribution function.
protected  double betaQ
          The q value of the beta distribution function.
static int DISTANCED_TWO_POINT
           
static int DYNAMIC_POINT
           
static int THREE_POINT
           
static int THREE_POINT_FIT
           
 
Fields inherited from class org.sourceforge.espro.elicitation.FunctionalMethod
fitFunction, highlight, markers, maxMarkers, maxValue, points, showHighlights, showMarkers, standardHeight, standardWidth
 
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
  BetaDist()
          Default constructor.
protected BetaDist(java.lang.String name, java.lang.String category)
          Constructor for extensions of this class.
 
Method Summary
protected  double angleOfPoint(int pid)
          Calculates the angle of a given point.
protected  void distancedTwoPointMethod(java.awt.Point p)
          The fixedTwoPointMethod takes the next point on the actual courve to calculate two points next to it with the distance of the give distance, or the last point of the actual courve.
protected  void dynamicPointsMethod(java.awt.Point p)
          This finds dynamic points using an algorithm, so the user can intuitivly modify the courve.
protected  void fit(java.awt.Point point)
          Fits the given point into the curve, using the given fit method.
protected  void fitCurve(double[] p1, double[] p2, double[] p3)
          Fits the curve so it matches this point.
 double fX(double x)
          DOCUMENT ME!
 double getBetaP()
          DOCUMENT ME!
 double getBetaQ()
          DOCUMENT ME!
 double getDistance()
          Returns the distance.
 int getFitMethod()
          Returns the fitMethod.
protected  void initialize()
          An initialize function, which can be used within several constructors.
protected  void paintComponent(java.awt.Graphics g)
          DOCUMENT ME!
protected  int seekPoint(int pid, double alpha, int direction)
          Seeks a point which reaches the angle.
 void setBetaP(double betaP)
          DOCUMENT ME!
 void setBetaQ(double betaQ)
          DOCUMENT ME!
 void setDistance(double distance)
          Sets the distance
 void setFitMethod(int fitMethod)
          Sets the fitMethod
protected  void threePointFitMethod(java.awt.Point point)
          This is a three Point Method where the points are fitted into the courve.
protected  void threePointMethod(java.awt.Point point)
          Takes three cursur inputs and draws on this.
protected  void trackMouse(int x, int y)
          This watches the mouse where it is and if the button is pressed this recalculates the beta curve.
 
Methods inherited from class org.sourceforge.espro.elicitation.FunctionalMethod
addSelfListeners, calcFunction, calcReals, clearMarkers, drawAxis, drawFilledScaledBox, drawFunction, drawScaledBox, drawStandardLine, getDigits, getMaxMarkers, getMaxPoint, getStandardHeight, getStandardWidth, graphicsPoint, graphicsXPoint, graphicsYPoint, highlightNearest, isFitFunction, nearestPoint, setDigits, setFitFunction, setMaxMarkers, setStandardHeight, setStandardSize, setStandardWidth, standardPoint, standardXPoint, standardYPoint, viewBox
 
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
 

Field Detail

THREE_POINT

public static final int THREE_POINT
See Also:
threePointMethod(Point), Constant Field Values

THREE_POINT_FIT

public static final int THREE_POINT_FIT
See Also:
threePointFitMethod(Point), Constant Field Values

DISTANCED_TWO_POINT

public static final int DISTANCED_TWO_POINT
See Also:
distancedTwoPointMethod(Point), Constant Field Values

DYNAMIC_POINT

public static final int DYNAMIC_POINT
See Also:
dynamicPointsMethod(Point), Constant Field Values

betaP

protected double betaP
The p value of the beta distribution function.


betaQ

protected double betaQ
The q value of the beta distribution function.

Constructor Detail

BetaDist

public BetaDist()
Default constructor.


BetaDist

protected BetaDist(java.lang.String name,
                   java.lang.String category)
Constructor for extensions of this class.

Parameters:
name - The name of the method.
category - The (menu) category of the method.
Method Detail

fX

public double fX(double x)
Description copied from class: FunctionalMethod
DOCUMENT ME!

Parameters:
x - DOCUMENT ME!
Returns:
DOCUMENT ME!
See Also:
FunctionalMethod.fX(double)

getBetaP

public double getBetaP()
DOCUMENT ME!

Returns:
The betaP.

getBetaQ

public double getBetaQ()
DOCUMENT ME!

Returns:
The betaQ.

getDistance

public double getDistance()
Returns the distance.

Returns:
The distance.

getFitMethod

public int getFitMethod()
Returns the fitMethod.

Returns:
The fitMethod.

setBetaP

public void setBetaP(double betaP)
DOCUMENT ME!

Parameters:
betaP - The betaP to set.

setBetaQ

public void setBetaQ(double betaQ)
DOCUMENT ME!

Parameters:
betaQ - The betaQ to set.

setDistance

public void setDistance(double distance)
Sets the distance

Parameters:
distance - The distance to set.

setFitMethod

public void setFitMethod(int fitMethod)
Sets the fitMethod

Parameters:
fitMethod - The fitMethod to set.

angleOfPoint

protected double angleOfPoint(int pid)
Calculates the angle of a given point.

Parameters:
pid - The index of the point in the points array.
Returns:
the angle in degrees.

distancedTwoPointMethod

protected void distancedTwoPointMethod(java.awt.Point p)
The fixedTwoPointMethod takes the next point on the actual courve to calculate two points next to it with the distance of the give distance, or the last point of the actual courve.

Parameters:
p - The mouse pointer on the scale.

dynamicPointsMethod

protected void dynamicPointsMethod(java.awt.Point p)
This finds dynamic points using an algorithm, so the user can intuitivly modify the courve.

Parameters:
p - The mouse pointer position.

fit

protected void fit(java.awt.Point point)
Fits the given point into the curve, using the given fit method.

Parameters:
point - The mouse pointer position.

fitCurve

protected void fitCurve(double[] p1,
                        double[] p2,
                        double[] p3)
Fits the curve so it matches this point. We need three points to calculate the P and Q values for the new Beta Distribution. Note: We need standard points, so if you get it from the mouse, convert it first.

Parameters:
p1 - Point 1.
p2 - Point 2.
p3 - Point 3.

initialize

protected void initialize()
Description copied from class: ElicitationMethod
An initialize function, which can be used within several constructors.

Overrides:
initialize in class FunctionalMethod
See Also:
ElicitationMethod.initialize()

paintComponent

protected void paintComponent(java.awt.Graphics g)
Description copied from class: ElicitationMethod
DOCUMENT ME!

Overrides:
paintComponent in class FunctionalMethod
Parameters:
g - DOCUMENT ME!
See Also:
FunctionalMethod.paintComponent(java.awt.Graphics)

seekPoint

protected int seekPoint(int pid,
                        double alpha,
                        int direction)
Seeks a point which reaches the angle. If the point in pid has a higher angle it searches the next point with the lower angle, and it search the higher angle if the pid has a higher angle.

Parameters:
pid - The point to start from.
alpha - The angle searched.
direction - The direction (1 = forward, -1 = backwards)
Returns:
The index of the point from the points array or -1 if there couldn't be found a point (in the given direction).
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

threePointFitMethod

protected void threePointFitMethod(java.awt.Point point)
This is a three Point Method where the points are fitted into the courve.

Parameters:
point - The mouse pointer position.
See Also:
threePointMethod(java.awt.Point)

threePointMethod

protected void threePointMethod(java.awt.Point point)
Takes three cursur inputs and draws on this. The 4th and more points will redraw the neares point of the 3 given before.

Parameters:
point - A Point from the mouse.

trackMouse

protected void trackMouse(int x,
                          int y)
This watches the mouse where it is and if the button is pressed this recalculates the beta curve.

Parameters:
x - The x position of the mouse.
y - The y position of the mouse.