edu.neu.ccs.gui
Class SliderView

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JSlider
                          |
                          +--edu.neu.ccs.gui.SliderView
All Implemented Interfaces:
Accessible, Displayable, ImageObserver, JPTConstants, MenuContainer, Serializable, SwingConstants, TypedView

public class SliderView
extends JSlider
implements TypedView, JPTConstants

A TypedView for input of int values in a bounded range using direct manipulation.

Since:
1.0
See Also:
Serialized Form

Field Summary
protected  int defaultValue
          The default value for this slider.
protected  InputProperties properties
          The property list for this view object.
protected  Action releaseAction
          The action triggered by sliding movement of this slider.
protected  ActionSequence releaseActions
          The action sequence performed each time the slider knob is released.
protected  Action slideAction
          The action triggered by sliding movement of this slider.
protected  ActionSequence slidingActions
          The action sequence performed each time the slider knob is moved.
 
Fields inherited from class javax.swing.JSlider
changeEvent, changeListener, majorTickSpacing, minorTickSpacing, orientation, sliderModel, snapToTicks
 
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 edu.neu.ccs.gui.TypedView
DATA_TYPE
 
Fields inherited from interface edu.neu.ccs.gui.Displayable
DEFAULT_VIEW_STATE, VIEW_STATE
 
Fields inherited from interface edu.neu.ccs.util.JPTConstants
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SliderView()
          Constructs a horizontal slider with the range [0, 100] and a default value of 50.
SliderView(int orientation)
          Constructs a slider with the given orientation, the range [0, 100] and a default value of 50.
SliderView(int orientation, int min, int max, int value)
          Constructs a slider with the given orientation, a range from the provided minimum to the provided maximum, and the given default value.
 
Method Summary
 void addReleaseAction(ActionListener a)
          Adds the given action listener to the sequence of actions that is performed when the value for this slider is changed through method calls, or when the value for this slider has finished changing through direct manipulation of the slider knob.
 void addSlidingAction(ActionListener a)
          Adds the given action listener to the sequence of actions that is performed when the value for this slider is changed through direct manipulation of the slider knob.
 Stringable demandObject()
          Returns an XInt object whose state is set to the value of this slider.
 Class getDataType()
          Returns the XInt class object.
 String getDefaultViewState()
          Returns a String representation of the default value for this slider.
 InputProperties getInputProperties()
          Returns the input properties for this view.
 ActionSequence getReleaseActions()
          Returns the sequence of action listeners that is performed when the value for this slider is changed through method calls, or when the value for this slider has finished changing through direct manipulation of the slider knob.
 ActionSequence getSlidingActions()
          Returns the sequence of action listeners that is performed when the value for this slider is changed through direct manipulation of the slider knob, or when the user has first selected the slider knob to perform direct manipulation of the value for this slider.
 String getViewState()
          Returns a String representation of the current value for this slider.
 void installStandardLabels()
          Installs labels at the major tick marks for this slider, and labels at the maximum and minimum value for this slider, each of which displays the value at that location.
 void installStandardTicks()
          Installs ten major tick marks for this slider, which includes tick marks at the maximum and minimum values.
protected static int parseInt(String data, String caller)
          Returns the int value represented by the given String data.
 void removeReleaseAction(ActionListener a)
          Removes the given action listener from the sequence of actions that is performed when the value for this slider is changed through method calls, or when the value for this slider has finished changing through direct manipulation of the slider knob.
 void removeSlidingAction(ActionListener a)
          Removes the given action listener from the sequence of actions that is performed when the value for this slider is changed through direct manipulation of the slider knob.
 Stringable requestObject()
          Returns an XInt object whose state is set to the value of this slider.
 void reset()
          Resets the view state of this object to the default view state for this object.
 void setDefaultViewState(String data)
          Sets the default value for this slider to the int value represented by the given String data.
 void setInputProperties(InputProperties p)
          Sets the input properties for this view to the provided input properties.
 void setReleaseActions(ActionSequence sequence)
          Sets the sequence of action listeners that is performed when the value for this slider is changed through method calls, or when the value for this slider has finished changing through direct manipulation of the slider knob.
 void setSlidingActions(ActionSequence sequence)
          Sets the sequence of action listeners that is performed when the value for this slider is changed through direct manipulation of the slider knob.
 void setViewState(String data)
          Sets the value for this slider to the int value represented by the given String data.
 
Methods inherited from class javax.swing.JSlider
addChangeListener, createChangeListener, createStandardLabels, createStandardLabels, fireStateChanged, getAccessibleContext, getChangeListeners, getExtent, getInverted, getLabelTable, getMajorTickSpacing, getMaximum, getMinimum, getMinorTickSpacing, getModel, getOrientation, getPaintLabels, getPaintTicks, getPaintTrack, getSnapToTicks, getUI, getUIClassID, getValue, getValueIsAdjusting, paramString, removeChangeListener, setExtent, setInverted, setLabelTable, setMajorTickSpacing, setMaximum, setMinimum, setMinorTickSpacing, setModel, setOrientation, setPaintLabels, setPaintTicks, setPaintTrack, setSnapToTicks, setUI, setValue, setValueIsAdjusting, updateLabelUIs, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
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, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, 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
 
Methods inherited from interface edu.neu.ccs.gui.Displayable
setEnabled
 

Field Detail

defaultValue

protected int defaultValue
The default value for this slider.


properties

protected InputProperties properties
The property list for this view object.


slideAction

protected Action slideAction
The action triggered by sliding movement of this slider.


slidingActions

protected ActionSequence slidingActions
The action sequence performed each time the slider knob is moved.


releaseAction

protected Action releaseAction
The action triggered by sliding movement of this slider.


releaseActions

protected ActionSequence releaseActions
The action sequence performed each time the slider knob is released.

Constructor Detail

SliderView

public SliderView()
Constructs a horizontal slider with the range [0, 100] and a default value of 50.


SliderView

public SliderView(int orientation)
Constructs a slider with the given orientation, the range [0, 100] and a default value of 50.

Parameters:
orientation - the orientation for this slider

SliderView

public SliderView(int orientation,
                  int min,
                  int max,
                  int value)
Constructs a slider with the given orientation, a range from the provided minimum to the provided maximum, and the given default value.

Parameters:
orientation - the orientation for this slider
min - the minimum value for this slider
max - the maximum value for this slider
value - the default value for this slider
Method Detail

demandObject

public Stringable demandObject()
Returns an XInt object whose state is set to the value of this slider.

Specified by:
demandObject in interface TypedView
Returns:
a Stringable model object
See Also:
requestObject(), TypedView

requestObject

public Stringable requestObject()
Returns an XInt object whose state is set to the value of this slider.

Specified by:
requestObject in interface TypedView
Returns:
a Stringable model object
See Also:
demandObject(), TypedView

setInputProperties

public void setInputProperties(InputProperties p)
Description copied from interface: TypedView

Sets the input properties for this view to the provided input properties.

If the given input properties list is null, the property list for this view is set to the base property list containing default property values.

Specified by:
setInputProperties in interface TypedView
Parameters:
p - the new input properties for the view
See Also:
TypedView.getInputProperties()

getInputProperties

public InputProperties getInputProperties()
Description copied from interface: TypedView
Returns the input properties for this view.

Specified by:
getInputProperties in interface TypedView
Returns:
the input properties
See Also:
TypedView.setInputProperties(InputProperties)

getDataType

public Class getDataType()
Returns the XInt class object.

Specified by:
getDataType in interface TypedView
Returns:
the current class of a model object
See Also:
TypedView

setViewState

public void setViewState(String data)
Sets the value for this slider to the int value represented by the given String data. If the value to be set is out of the bounded range for this slider, the current value is not changed.

Specified by:
setViewState in interface Displayable
Parameters:
data - the new view state
See Also:
getViewState(), Displayable

getViewState

public String getViewState()
Returns a String representation of the current value for this slider.

Specified by:
getViewState in interface Displayable
Returns:
the view state as a String
See Also:
setViewState(String), Displayable

setDefaultViewState

public void setDefaultViewState(String data)
Sets the default value for this slider to the int value represented by the given String data. If the new default value is out of the bounded range for this slider, the current default value is not changed.

Specified by:
setDefaultViewState in interface Displayable
Parameters:
data - the new default view state
See Also:
reset(), Displayable

getDefaultViewState

public String getDefaultViewState()
Returns a String representation of the default value for this slider.

Specified by:
getDefaultViewState in interface Displayable
Returns:
the default view state as a String
See Also:
setDefaultViewState(String), reset()

reset

public void reset()
Description copied from interface: Displayable

Resets the view state of this object to the default view state for this object.

Equivalent to: setViewState(getDefaultViewState()).

Specified by:
reset in interface Displayable
See Also:
Displayable.setViewState(String), Displayable.getDefaultViewState()

addSlidingAction

public void addSlidingAction(ActionListener a)
Adds the given action listener to the sequence of actions that is performed when the value for this slider is changed through direct manipulation of the slider knob.

Parameters:
a - the action listener to be added

addReleaseAction

public void addReleaseAction(ActionListener a)
Adds the given action listener to the sequence of actions that is performed when the value for this slider is changed through method calls, or when the value for this slider has finished changing through direct manipulation of the slider knob.

Parameters:
a - the action listener to be added

removeSlidingAction

public void removeSlidingAction(ActionListener a)
Removes the given action listener from the sequence of actions that is performed when the value for this slider is changed through direct manipulation of the slider knob.

Parameters:
a - the action listener to be removed

removeReleaseAction

public void removeReleaseAction(ActionListener a)
Removes the given action listener from the sequence of actions that is performed when the value for this slider is changed through method calls, or when the value for this slider has finished changing through direct manipulation of the slider knob.

Parameters:
a - the action listener to be removed

setSlidingActions

public void setSlidingActions(ActionSequence sequence)
Sets the sequence of action listeners that is performed when the value for this slider is changed through direct manipulation of the slider knob.

Parameters:
sequence - the new action sequence to be performed
See Also:
addSlidingAction(ActionListener), removeSlidingAction(ActionListener), getSlidingActions()

setReleaseActions

public void setReleaseActions(ActionSequence sequence)
Sets the sequence of action listeners that is performed when the value for this slider is changed through method calls, or when the value for this slider has finished changing through direct manipulation of the slider knob.

Parameters:
sequence - the new action sequence to be performed
See Also:
addReleaseAction(ActionListener), removeReleaseAction(ActionListener), getReleaseActions()

getSlidingActions

public ActionSequence getSlidingActions()
Returns the sequence of action listeners that is performed when the value for this slider is changed through direct manipulation of the slider knob, or when the user has first selected the slider knob to perform direct manipulation of the value for this slider.

See Also:
setSlidingActions(ActionSequence), addSlidingAction(ActionListener), removeSlidingAction(ActionListener)

getReleaseActions

public ActionSequence getReleaseActions()
Returns the sequence of action listeners that is performed when the value for this slider is changed through method calls, or when the value for this slider has finished changing through direct manipulation of the slider knob.

See Also:
setReleaseActions(ActionSequence), addReleaseAction(ActionListener), removeReleaseAction(ActionListener)

installStandardTicks

public void installStandardTicks()
Installs ten major tick marks for this slider, which includes tick marks at the maximum and minimum values.


installStandardLabels

public void installStandardLabels()
Installs labels at the major tick marks for this slider, and labels at the maximum and minimum value for this slider, each of which displays the value at that location.


parseInt

protected static int parseInt(String data,
                              String caller)
Returns the int value represented by the given String data.

Parameters:
data - the data String to be parsed
caller - the name of the method that requires parsing
Throws:
JPTError - if there is an error parsing the data