org.sourceforge.espro.elicitation
Class AbstractScale

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.PointMethod
                      extended by org.sourceforge.espro.elicitation.AbstractScale
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, ModelInterface
Direct Known Subclasses:
OutOfScale, Scale

public abstract class AbstractScale
extends PointMethod

The AbstractScale is basic for the other scales.

Author:
martin
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  int heightRect
          Height of the scale rectangle.
protected  boolean invert
          This sets if the scale should be inverted.
protected  int numberOfBetweenLinesRight
          The number of small lines between the lines of the right side.
protected  int numberOfLinesRight
          This is the number of lines on the right side of the scale.
protected  int padding
          The space between the outline of the component and the scale.
protected  java.util.ArrayList<ScaleHint> verbalHintsList
          This holds the list of verbal hints.
protected  int widthRect
          Width of the scale rectangle.
protected  int xRect
          Top left position of the scale rectangle.
protected  int yPointer
          This holds the position of the slider.
protected  int yRect
          Top left position of the scale rectangle.
 
Fields inherited from class org.sourceforge.espro.elicitation.PointMethod
value
 
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 AbstractScale(java.lang.String name, java.lang.String category)
          Creates a new AbstractScale object.
 
Method Summary
 void addScaleHint(ScaleHint scaleHint)
          DOCUMENT ME!
protected  void addSelfListeners()
          Adds the internal listeners to itself.
protected abstract  ScalePointSet calcPoints()
          DOCUMENT ME!
protected  void drawLineLeft(double yPos, double length)
          Creates a line at the left handside of the scale at the specified y-coordinate and adds the created line in a vector.
protected  void drawLineRight(double yPos, double lenght)
          Creates a line at the right handside of the scale at the specified y-coordinate and adds the created line in a vector.
protected  void drawLines()
          Draws the lines of the scale.
protected abstract  void drawNumberRight(double numForPos, double yPos)
          DOCUMENT ME!
protected  void drawSlider()
          Method for drawing a slider and an invisible slider.
protected  void drawStringLeft(java.lang.String text, double yPos)
          Draws a string to the left side of the scale.
protected  void drawVerbalHints()
          Draws all verbal hints from the list.
 int getNumberOfBetweenLinesRight()
          Returns the number of lines between the main lines.
 int getNumberOfLinesRight()
          Returns the number of main lines.
 java.util.ArrayList<ScaleHint> getVerbalHintsList()
          Returns the verbalHintsList.
 boolean isInvert()
          Tells if we want to invert the scale.
 boolean isUseRight()
          Tells us if the scale uses the right side for drawing lines and numbers.
 boolean isVerbalHints()
          Returns the verbalHints.
 void moveSlider(int y)
          Moves the slider to the given y position.
 void moveSlider(int x, int y)
          Moves slider to the actual mouse-position by dragging the mouse on the slideArea. that is the baseline of the scale and the area near the scale.
protected  void paintComponent(java.awt.Graphics g)
          Paints the component.
 void setInvert(boolean invert)
          Sets if we want to invert the Scale.
 void setNumberOfBetweenLinesRight(int numberOfBetweenLines)
          Sets the number of lines between the main lines.
 void setNumberOfLinesRight(int numberOfLines)
          Sets the number of main lines.
 void setUseRight(boolean useRight)
          Sets if we use the right side of the scale for lines and numbers.
 void setVerbalHints(boolean verbalHints)
          Sets the verbalHints
 void setVerbalHintsList(java.util.ArrayList<ScaleHint> verbalHintsList)
          Sets the verbalHintsList
protected  double valueFromYPointer()
          Calculates the value from the current yPointer.
protected abstract  double valueFromYPointer(double pointer)
          Calculates the value from a given pointer.
protected  double yPointerFromValue()
          This calculates the yPointer from the current value.
protected abstract  int yPointerFromValue(double value)
          Calculates the yPointer from the value of the elicitation method.
 
Methods inherited from class org.sourceforge.espro.elicitation.PointMethod
getValue, setValue
 
Methods inherited from class org.sourceforge.espro.elicitation.ElicitationMethod
addPropertyChangeListener, addPropertyChangeListener, getCategory, getName, initialize, 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

verbalHintsList

protected java.util.ArrayList<ScaleHint> verbalHintsList
This holds the list of verbal hints. The list is used to make verbal ques to the skale.


invert

protected boolean invert
This sets if the scale should be inverted. This makes 0 at the bottom and 1 at the top of the scale. (default: true)


heightRect

protected int heightRect
Height of the scale rectangle.


numberOfBetweenLinesRight

protected int numberOfBetweenLinesRight
The number of small lines between the lines of the right side.


numberOfLinesRight

protected int numberOfLinesRight
This is the number of lines on the right side of the scale.


padding

protected int padding
The space between the outline of the component and the scale. At the moment this is used only for top and bottom.


widthRect

protected int widthRect
Width of the scale rectangle.


xRect

protected int xRect
Top left position of the scale rectangle. (x-position)


yPointer

protected int yPointer
This holds the position of the slider.


yRect

protected int yRect
Top left position of the scale rectangle. (y-position)

Constructor Detail

AbstractScale

protected AbstractScale(java.lang.String name,
                        java.lang.String category)
Creates a new AbstractScale object.

Parameters:
name - DOCUMENT ME!
category - DOCUMENT ME!
Method Detail

addScaleHint

public void addScaleHint(ScaleHint scaleHint)
DOCUMENT ME!

Parameters:
scaleHint - DOCUMENT ME!

getNumberOfBetweenLinesRight

public int getNumberOfBetweenLinesRight()
Returns the number of lines between the main lines.

Returns:
The number of lines between the main lines.

getNumberOfLinesRight

public int getNumberOfLinesRight()
Returns the number of main lines.

Returns:
The number.

getVerbalHintsList

public java.util.ArrayList<ScaleHint> getVerbalHintsList()
Returns the verbalHintsList.

Returns:
The verbalHintsList.

isInvert

public boolean isInvert()
Tells if we want to invert the scale. Because java starts to draw the y coordinate from top to bottom, we can invert the scale, because ofen we want to start with the lower value on the bottom of the scale. Thats why we invert the scale for default.

Returns:
True if we want to draw the numbers from bottom to top, false otherwise.

isUseRight

public boolean isUseRight()
Tells us if the scale uses the right side for drawing lines and numbers.

Returns:
true if we use the right side, false otherwise.

isVerbalHints

public boolean isVerbalHints()
Returns the verbalHints.

Returns:
The verbalHints.

moveSlider

public void moveSlider(int y)
Moves the slider to the given y position. On the basis of Daniela Wurhofer (2006).

Parameters:
y - The y position.

moveSlider

public void moveSlider(int x,
                       int y)
Moves slider to the actual mouse-position by dragging the mouse on the slideArea. that is the baseline of the scale and the area near the scale.

Parameters:
x - x-coordinate of mouse
y - y-coordinate of mouse

setInvert

public void setInvert(boolean invert)
Sets if we want to invert the Scale. If the scale is inverted, it will draw the low numbers from bottom to top, if not it draws from top to bottom.

Parameters:
invert - true if the scale should be inverted.

setNumberOfBetweenLinesRight

public void setNumberOfBetweenLinesRight(int numberOfBetweenLines)
Sets the number of lines between the main lines.

Parameters:
numberOfBetweenLines - The number.

setNumberOfLinesRight

public void setNumberOfLinesRight(int numberOfLines)
Sets the number of main lines.

Parameters:
numberOfLines - The number.

setUseRight

public void setUseRight(boolean useRight)
Sets if we use the right side of the scale for lines and numbers.

Parameters:
useRight - True if we want to use the right side.

setVerbalHints

public void setVerbalHints(boolean verbalHints)
Sets the verbalHints

Parameters:
verbalHints - The verbalHints to set.

setVerbalHintsList

public void setVerbalHintsList(java.util.ArrayList<ScaleHint> verbalHintsList)
Sets the verbalHintsList

Parameters:
verbalHintsList - The verbalHintsList to set.

addSelfListeners

protected void addSelfListeners()
Adds the internal listeners to itself.

Overrides:
addSelfListeners in class ElicitationMethod

calcPoints

protected abstract ScalePointSet calcPoints()
DOCUMENT ME!

Returns:
DOCUMENT ME!

drawLineLeft

protected void drawLineLeft(double yPos,
                            double length)
Creates a line at the left handside of the scale at the specified y-coordinate and adds the created line in a vector. On the basis of Daniela Wurhofers espro.

Parameters:
yPos - y-coordinate of line
length - The length of the line.

drawLineRight

protected void drawLineRight(double yPos,
                             double lenght)
Creates a line at the right handside of the scale at the specified y-coordinate and adds the created line in a vector. This is created on the basis of Daniela Wurhofers espro.

Parameters:
yPos - y-coordinate of line.
lenght - The length of the line.

drawLines

protected void drawLines()
Draws the lines of the scale.


drawNumberRight

protected abstract void drawNumberRight(double numForPos,
                                        double yPos)
DOCUMENT ME!

Parameters:
numForPos - DOCUMENT ME!
yPos - DOCUMENT ME!

drawSlider

protected void drawSlider()
Method for drawing a slider and an invisible slider. The sliders are both represented as polygons with a peak. The invisible slider overlaps the slider and represents the slide-area which can be dragged with the mouse. Original by Daniela Wurhofer (2005), adjusted


drawStringLeft

protected void drawStringLeft(java.lang.String text,
                              double yPos)
Draws a string to the left side of the scale.

Parameters:
text - The string.
yPos - The vertical position of the string.

drawVerbalHints

protected void drawVerbalHints()
Draws all verbal hints from the list.


paintComponent

protected void paintComponent(java.awt.Graphics g)
Paints the component.

Overrides:
paintComponent in class ElicitationMethod
Parameters:
g - The graphics instance to paint the component on.
See Also:
ElicitationMethod.paintComponent(java.awt.Graphics)

valueFromYPointer

protected abstract double valueFromYPointer(double pointer)
Calculates the value from a given pointer. You don't have to use the return value, because this will be automatically set to the elicitation methods value.

Parameters:
pointer - The position to calculate the pointer from.
Returns:
The calculated value.
See Also:
valueFromYPointer()

valueFromYPointer

protected double valueFromYPointer()
Calculates the value from the current yPointer. You don't have to use the return value, because this will be automatically set to the elicitation methods value.

Returns:
The calculated value.

yPointerFromValue

protected double yPointerFromValue()
This calculates the yPointer from the current value.

Returns:
The pPointer position.
See Also:
yPointerFromValue(double value)

yPointerFromValue

protected abstract int yPointerFromValue(double value)
Calculates the yPointer from the value of the elicitation method. Note that you don't have to use the return value, because this will be set automatically when you recalculate the yPointer.

Parameters:
value - The value.
Returns:
The yPointer.
See Also:
valueFromYPointer()