org.sourceforge.espro.elicitation
Class FunctionalMethod

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
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, ModelInterface
Direct Known Subclasses:
BetaDist

public abstract class FunctionalMethod
extends ElicitationMethod

An abstract class which extends the ElicitationMethod in order to make it work with distributions. FunctionalMethods are methods which have an fX() method, where this calculates a function of x. The abstract class takes care of painting it correctly on the screen.

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  boolean fitFunction
          Wether the function should be fitted into the functional area.
protected  java.util.ArrayList<java.lang.Integer> highlight
          The list of points to highlight.
protected  java.util.ArrayList<java.lang.Integer> markers
          Holds a List of markers.
protected  int maxMarkers
          Maximum of possible markers.
protected  double maxValue
          The maximum value of the courve will be stored here when running method calcFunction()
protected  double[][] points
          holds the points
protected  boolean showHighlights
          Child classes can set if it want to show the highlights or not.
protected  boolean showMarkers
          Child classes can set if it wants so show markers or not.
protected  double standardHeight
          A standard height of the function area.
protected  double standardWidth
          A standard with of the function area.
 
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
protected FunctionalMethod(java.lang.String name, java.lang.String category)
          The constructor for extensions.
 
Method Summary
protected  void addSelfListeners()
          DOCUMENT ME!
protected  void calcFunction()
          Calculates the points from the function.
protected  void calcReals()
          Calculates real area.
protected  void clearMarkers()
          Removes all markers.
protected  void drawAxis()
          Draws the axis.
protected  void drawFilledScaledBox(double[] p)
          Draws a filled box arround the given point.
protected  void drawFunction()
          Draws the Function into the graph.
protected  void drawScaledBox(double[] p)
          Draws a box arround the given point.
protected  void drawStandardLine(double x1, double y1, double x2, double y2)
          Draws a small line from the function.
 int getDigits()
          Returns the digits.
 int getMaxMarkers()
          Returns the maxMarkers.
 int getMaxPoint()
          Returns the index of the point that containts the max value.
 double getStandardHeight()
          DOCUMENT ME!
 double getStandardWidth()
          DOCUMENT ME!
protected  double[] graphicsPoint(double[] p)
          Converts a point into the graphics value.
protected  double graphicsXPoint(double x)
          Calculates the graphics x point from a standard x point.
protected  double graphicsYPoint(double y)
          Calculates the graphics y point from a standard y point.
protected  int highlightNearest(java.awt.Point point, boolean save)
          Highlights the point nearest the given point.
protected  void initialize()
          An initialize function, which can be used within several constructors.
 boolean isFitFunction()
          DOCUMENT ME!
protected  int nearestPoint(double[] p)
          Calculates the nearest point on the courve to the given point.
protected  void paintComponent(java.awt.Graphics g)
          DOCUMENT ME!
 void setDigits(int digits)
          Sets the digits
 void setFitFunction(boolean fitFunction)
          DOCUMENT ME!
 void setMaxMarkers(int maxMarkers)
          Sets the maxMarkers
 void setStandardHeight(double standardHeight)
          DOCUMENT ME!
protected  void setStandardSize(double width, double height)
          Extensions can change both at once: The width and height of the function area.
 void setStandardWidth(double standardWidth)
          DOCUMENT ME!
protected  double[] standardPoint(double[] p)
          Converts a point to the standard values.
protected  double standardXPoint(double x)
          Calculates the standard x point from a graphics x point.
protected  double standardYPoint(double y)
          Calculates the standard y point from a graphics y point.
protected  void viewBox(double x, double y)
          Draws a box on the given position.
 
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

highlight

protected java.util.ArrayList<java.lang.Integer> highlight
The list of points to highlight.


markers

protected java.util.ArrayList<java.lang.Integer> markers
Holds a List of markers.


points

protected double[][] points
holds the points


fitFunction

protected boolean fitFunction
Wether the function should be fitted into the functional area.


showHighlights

protected boolean showHighlights
Child classes can set if it want to show the highlights or not.


showMarkers

protected boolean showMarkers
Child classes can set if it wants so show markers or not.


maxValue

protected double maxValue
The maximum value of the courve will be stored here when running method calcFunction()


standardHeight

protected double standardHeight
A standard height of the function area.


standardWidth

protected double standardWidth
A standard with of the function area.


maxMarkers

protected int maxMarkers
Maximum of possible markers.

Constructor Detail

FunctionalMethod

protected FunctionalMethod(java.lang.String name,
                           java.lang.String category)
The constructor for extensions.

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

getDigits

public int getDigits()
Returns the digits.

Returns:
The digits.

getMaxMarkers

public int getMaxMarkers()
Returns the maxMarkers.

Returns:
The maxMarkers.

getMaxPoint

public int getMaxPoint()
Returns the index of the point that containts the max value.

Returns:
The index.

getStandardHeight

public double getStandardHeight()
DOCUMENT ME!

Returns:
The standardHeight.

getStandardWidth

public double getStandardWidth()
DOCUMENT ME!

Returns:
The standardWidth.

isFitFunction

public boolean isFitFunction()
DOCUMENT ME!

Returns:
The fitFunction.

setDigits

public void setDigits(int digits)
Sets the digits

Parameters:
digits - The digits to set.

setFitFunction

public void setFitFunction(boolean fitFunction)
DOCUMENT ME!

Parameters:
fitFunction - The fitFunction to set.

setMaxMarkers

public void setMaxMarkers(int maxMarkers)
Sets the maxMarkers

Parameters:
maxMarkers - The maxMarkers to set.

setStandardHeight

public void setStandardHeight(double standardHeight)
DOCUMENT ME!

Parameters:
standardHeight - The standardHeight to set.

setStandardWidth

public void setStandardWidth(double standardWidth)
DOCUMENT ME!

Parameters:
standardWidth - The standardWidth to set.

addSelfListeners

protected void addSelfListeners()
DOCUMENT ME!

Overrides:
addSelfListeners in class ElicitationMethod

calcFunction

protected void calcFunction()
Calculates the points from the function. This uses your fX() method from the child class.


calcReals

protected void calcReals()
Calculates real area.


clearMarkers

protected void clearMarkers()
Removes all markers.


drawAxis

protected void drawAxis()
Draws the axis.


drawFilledScaledBox

protected void drawFilledScaledBox(double[] p)
Draws a filled box arround the given point.

Parameters:
p - The point.

drawFunction

protected void drawFunction()
Draws the Function into the graph.


drawScaledBox

protected void drawScaledBox(double[] p)
Draws a box arround the given point.

Parameters:
p - The point.

drawStandardLine

protected void drawStandardLine(double x1,
                                double y1,
                                double x2,
                                double y2)
Draws a small line from the function. Given are the real points, but drawn are the calculated points to the graphics area.

Parameters:
x1 - The first x coordinate.
y1 - The first y coodrinate.
x2 - The second x coordinate.
y2 - The second y coordinate.

graphicsPoint

protected double[] graphicsPoint(double[] p)
Converts a point into the graphics value. This is equivalent calling graphicsXPoint and graphicsYPoint at a time.

Parameters:
p - The standard point.
Returns:
The graphics point.

graphicsXPoint

protected double graphicsXPoint(double x)
Calculates the graphics x point from a standard x point.

Parameters:
x - The standard x point.
Returns:
The grapics x point.

graphicsYPoint

protected double graphicsYPoint(double y)
Calculates the graphics y point from a standard y point.

Parameters:
y - The standard y point.
Returns:
The graphics y point.

highlightNearest

protected int highlightNearest(java.awt.Point point,
                               boolean save)
Highlights the point nearest the given point.

Parameters:
point - The coordinates to find the nearest point.
save - true if the point should be saved.
Returns:
The index of the highlight list.

initialize

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

Specified by:
initialize in class ElicitationMethod
See Also:
ElicitationMethod.initialize()

nearestPoint

protected int nearestPoint(double[] p)
Calculates the nearest point on the courve to the given point.

Parameters:
p - The point.
Returns:
The nearest point id of the points array or -1 if there is none.

paintComponent

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

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

setStandardSize

protected void setStandardSize(double width,
                               double height)
Extensions can change both at once: The width and height of the function area.

Parameters:
width - The width.
height - The heigth.

standardPoint

protected double[] standardPoint(double[] p)
Converts a point to the standard values. This is equivalent to calling standardXPoint and standardYPoint at once.

Parameters:
p - The graphics point.
Returns:
The standard point.

standardXPoint

protected double standardXPoint(double x)
Calculates the standard x point from a graphics x point.

Parameters:
x - The graphics x point.
Returns:
The standard x point.

standardYPoint

protected double standardYPoint(double y)
Calculates the standard y point from a graphics y point.

Parameters:
y - The graphics y point.
Returns:
The standard y point.

viewBox

protected void viewBox(double x,
                       double y)
Draws a box on the given position.

Parameters:
x - X-axis value.
y - Y-axis value.