edu.neu.ccs.gui
Class SliderView

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byedu.neu.ccs.gui.DisplayPanel
                      extended byedu.neu.ccs.gui.BasePane
                          extended byedu.neu.ccs.gui.SliderView
All Implemented Interfaces:
Accessible, AlertListener, Displayable, EventListener, ImageObserver, JPTConstants, MalformedDataListener, MenuContainer, Serializable, SwingConstants, TypedView

public class SliderView
extends BasePane
implements TypedView

Class SliderView permits the construction of a slider with pixel-level control of the size of the slider track. The caller can therefore control the relationship between the minimum and maximum values represented by the slider and the physical implementation in pixels. This can permit users to make slider selections with more accuracy.

The SliderView code was completely rewritten for version 2.6.0. A few older methods that are now obsolete have been retained for backward compatibility as is noted in the comments. This class no longer depends on the Java class JSlider.

In addition to pixel-level control of the size of the slider, SliderView offers several advantages over the Java class JSlider.

The constructors for class SliderView allow the following options:

Remarks on the minimum and maximum settings and the track pixels setting:

After construction, the caller may add one or more actions that will be performed in any of the following 3 situations:

These actions should normally behave as listeners, that is, they may query information about the slider from methods such as getValue and getTrackLocation but they should normally not call methods that change the slider state. These actions are intended to be used to control other objects in the program, especially, in the GUI.

The actions are explicity forbidden to call four methods: setValue, setTrackLocation, setViewState, and reset. The reason for this explict ban is that the four methods invoke the actions internally and therefore calling them from the actions will set up a recursive infinite loop.

In unusual situations, the actions may change slider state via calls to two helper methods setValueHelper and setTrackLocationHelper which do not invoke the actions. This facility should be used with great caution as what happens may be confusing to the interactive user.

Final comment: When the mouse is released after a click or a slide, both the sliding action and the release action will be performed. This policy guarantees that the sliding action is performed at least once between the mouse press on the thumb or track and the subsequent mouse release.

Since:
1.0
Version:
2.6.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  MouseActionAdapter adapter
          The mouse adapter of the main component.
protected  Color commonColor
          The common color for lines, borders, and text labels.
protected  int cornerX
          The x-coordinate of the top-left corner of the main bounds (as an integer).
protected  int cornerY
          The y-coordinate of the top-left corner of the main bounds (as an integer).
protected  int defaultValue
          The default value for this slider.
protected  int delta
          The difference (maximum - minimum).
protected  boolean dragging
          The dragging parameter will be set to true if and only if the user is currently dragging the thumb.
protected  double f_loc_to_val
          The scale factor for locationToValue.
protected  double f_val_to_loc
          The scale factor for valueToLocation.
protected  PaintableSequence labelSequence
          The paintable sequence for slider labels.
protected  int limit
          The track limit, that is, the last valid location on the track along its major direction.
protected  int location
          The thumb location along the track.
protected  XRect mainBounds
          Once initialized by freezeBounds(), this rectangle contains the bounds of the sequence mainSequence.
protected  PaintableComponent mainComponent
          The paintable component to hold the main sequence.
protected  PaintableSequence mainSequence
          The paintable sequence for all of the paintables in the slider GUI including the thumb, the track, the major and minor tick marks, and the labels.
static int MAJOR_TICK_SIZE
          The default major tick size: 8.
protected  int majorTicks
          The major ticks setting.
protected  int maximum
          The track maximum value.
protected  int minimum
          The track minimum value.
static int MINIMUM_PIXELS
          The minimum permitted pixels value: 20.
static int MINOR_TICK_SIZE
          The default minor tick size: 4.
protected  int minorTicks
          The minor ticks setting.
protected  MouseAction mousePressAction
          The mouse press action.
protected  MouseAction mouseReleaseAction
          The mouse release action.
protected  MouseAction mouseSlidingAction
          The mouse sliding action.
protected  int mouseX
          The x-coordinate of the current mouse position as adjusted by cornerX to be in the coordinate system of the main sequence.
protected  int mouseY
          The y-coordinate of the current mouse position as adjusted by cornerY to be in the coordinate system of the main sequence.
protected  PaintableSequence objectSequence
          The paintable sequence for more general Paintable objects.
protected  Paint ordinaryThumbPaint
          The ordinary fill paint for the thumb.
protected  int orientation
          The slider orientation which should be either HORIZONTAL or VERTICAL.
protected  int pixels
          The track pixels, that is, the size of the track along its major direction.
static int PRESS_ACTION
          The ID for a press action event.
protected  ActionSequence pressActions
          The caller-defined actions performed when the slider thumb is pressed.
 ActionEvent pressEvent
          The standard event that will be passed to the sequence pressActions when the mouse is pressed in the active area of the slider (thumb or track).
protected  InputProperties properties
          The property list for this view object.
static int RELEASE_ACTION
          The ID for a release action event.
protected  ActionSequence releaseActions
          The caller-defined actions performed when the slider thumb is released.
 ActionEvent releaseEvent
          The standard event that will be passed to the sequence releaseActions when the mouse is released after being pressed in the active area of the slider (thumb or track).
protected  Paint selectedThumbPaint
          The selected fill paint for the thumb.
protected  SimpleAction setValueFromValueTFV
          The action to set the slider value from the value text field view.
static int SLIDING_ACTION
          The ID for a sliding action event.
protected  ActionSequence slidingActions
          The caller-defined actions performed when the slider thumb is sliding.
 ActionEvent slidingEvent
          The standard event that will be passed to the sequence slidingActions when the mouse is sliding after being pressed in the active area of the slider (thumb or track).
static Stroke STROKE2
          Stroke of size 2: BasicStroke(2).
protected  double t_loc_to_val
          The translation for locationToValue.
protected  double t_val_to_loc
          The translation for valueToLocation.
protected  ShapePaintable thumb
          The slider thumb.
static int THUMB_PLUS
          The thumb size plus 1.
static int THUMB_SIZE
          The thumb size: 9.
protected  Shape thumbShape
          The slider thumb shape.
protected  PaintableSequence tickSequence
          The paintable sequence for slider tick marks.
protected  ShapePaintable track
          The slider track.
static int TRACK_BORDER_THICK
          The track border thickness: 2.
static int TRACK_THICK
          The track thickness: 6.
protected  ShapePaintable trackBorder
          The slider track border.
protected  XRect trackBorderRect
          The slider track border rect.
protected  Paint trackPaint
          The fill paint for the track.
protected  XRect trackRect
          The slider track rect.
protected  int value
          The value of the slider, that is, what will be returned by the call getValue().
protected  TextFieldView valueTFV
          The text field view that will echo the current conceptual value of the slider.
 
Fields inherited from class edu.neu.ccs.gui.BasePane
baseFontSize, buttonFont, DEFAULT_BASE_FONT_SIZE, fieldFont, fontSize, gap, labelFont, largeFieldWidth, mediumFieldWidth, MINIMUM_FONT_SIZE, monospacedFontName, sansserifFontName, serifFontName, smallFieldWidth
 
Fields inherited from class edu.neu.ccs.gui.DisplayPanel
background, codec, CODEC
 
Fields inherited from class javax.swing.JPanel
 
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.Container
 
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, VALUE
 
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 default SliderView.
SliderView(int orientation)
          Constructs a SliderView with the given orientation which must be HORIZONTAL or VERTICAL.
SliderView(int orientation, int minimum, int maximum, int value)
          Constructs a SliderView with the given parameters.
SliderView(int orientation, int minimum, int maximum, int value, int pixels)
          Constructs a SliderView with the given parameters.
SliderView(int orientation, int minimum, int maximum, int value, int pixels, int majorTicks, int minorTicks)
          Constructs a SliderView with the given parameters.
SliderView(int orientation, int minimum, int maximum, int value, int pixels, int majorTicks, int minorTicks, Paint ordinaryThumbPaint, Paint selectedThumbPaint, Paint trackPaint, Color commonColor, boolean showValueTFV)
          Constructs a SliderView with the given parameters.
 
Method Summary
 void addPressAction(ActionListener a)
          Adds the given action listener to the sequence of actions that is performed when slider is pressed in its active area (thumb or track).
 void addReleaseAction(ActionListener a)
          Adds the given action listener to the sequence of actions that is performed when slider is released after being pressed in its active area (thumb or track).
 void addSlidingAction(ActionListener a)
          Adds the given action listener to the sequence of actions that is performed when slider is sliding after being pressed in its active area (thumb or track).
 Stringable demandObject()
          Returns an XInt object whose state is set to the value of this slider.
protected  void freezeBounds()
          This method computes the bounds of the sequence mainSequence, stores those bounds in mainBounds, and sets the corner data cornerX and cornerY for use in computation of mouse coordinates.
 Class getDataType()
          Returns the XInt class object.
 String getDefaultViewState()
          Returns a String representation of the default integer value of this slider.
 InputProperties getInputProperties()
          Returns the input properties for this view.
 ActionSequence getPressActions()
          Returns the sequence of press actions.
 ActionSequence getReleaseActions()
          Returns the sequence of release actions.
 ActionSequence getSlidingActions()
          Returns the sequence of sliding actions.
 int[] getTickValues(int spacing)
          Returns the array of slider values that will be used to generate the tick value positions based on the given tick spacing and the internal minimum and maximum.
 int getTrackLocation()
          Returns the current track location of the slider.
 int getValidLocation(int loc)
          If the given location is between 0 and limit, then return that location; otherwise return the closest valid location to the given location.
 int getValidValue(int val)
          If the given value is between minimum and maximum, then return that value; otherwise return the closest valid value to the given value.
 int getValue()
          Returns the current conceptual value of the slider.
 String getViewState()
          Returns a String representation of the current integer value of this slider.
protected  void initializeMainSequence()
          Appends all items to the main paintable sequence.
protected  void initializeMouse()
          Initializes the mouse behavior.
protected  void initializeNumerics(int orientation, int minimum, int maximum, int value, int pixels, int majorTicks, int minorTicks)
          Initializes important numerical parameters.
protected  void initializePaints(Paint ordinaryThumbPaint, Paint selectedThumbPaint, Paint trackPaint, Color commonColor)
          Performs the paint and color initializations.
protected  void initializeThumb()
          Performs the initializations for the thumb.
protected  void initializeTrack()
          Performs the initializations for the track and track border.
protected  void initializeValueTFV()
          Performs the initializations for the value text field.
 void installDefaultLabels()
          Installs the default labels provided that the majorTicks value is positive.
 void installDefaultMajorTicks()
          Installs the default major ticks provided that the majorTicks value is positive.
 void installDefaultMinorTicks()
          Installs the default minor ticks provided that the minorTicks value is positive.
 void installLabels(int[] values, String[] labels, int size)
          Makes an array of TextPaintable labels using the given value positions and String labels and installs the created labels in the internal paintable sequence that is associated with labels.
protected  void installMainPanel(boolean showValueTFV)
          Installs the main panel with the slider and optionally the value text field.
 void installObjects(Paintable[] objects)
          Installs the given Paintable objects as decorations in the internal paintable sequence that is associated with objects.
 void installStandardLabels()
          Installs standard labels following the very simple algorithm available in this class prior to version 2.6.0.
 void installStandardTicks()
          Installs standard major tick marks following the very simple algorithm available in this class prior to version 2.6.0.
 void installTicks(int[] values, int size)
          Installs ticks of the given size at the given value positions.
 int locationToValue(int loc)
          The affine transform that converts the given location on the track to its best approximation as a value.
 TextPaintable makeLabel(int val, String label, int size)
          Creates the paintable for one label.
 TextPaintable[] makeLabels(int[] values, String[] labels, int size)
          Returns the array of TextPaintable labels positioned at the given value positions and using the given String labels.
 String[] makeLabelStrings(int[] values)
          Returns the array of numeric Strings corresponding to the array of integer values.
 ShapePaintable makeTick(int val, int size)
          Creates the paintable for one tick.
protected  void mousePress(MouseEvent evt)
          The mouse press behavior.
protected  void mouseRelease(MouseEvent evt)
          The mouse release behavior.
protected  void mouseSliding(MouseEvent evt)
          The mouse sliding behavior.
 void removePressAction(ActionListener a)
          Removes the given action listener from the press actions.
 void removeReleaseAction(ActionListener a)
          Removes the given action listener from the release actions.
 void removeSlidingAction(ActionListener a)
          Removes the given action listener from the sliding actions.
 Stringable requestObject()
          Returns an XInt object whose state is set to the value of this slider.
 void reset()
          Resets the slider to its default value.
 void resetThumb()
          The method to reset the location of the slider thumb on the track.
 void setCommonColor(Color color)
          Set the common color of ticks, borders, and text labels.
 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.
protected  void setMouseCoordinates(MouseEvent evt)
          Sets mouseX and mouseY by adjusting the mouse position in the given mouse event by the corner coordinates.
 void setOrdinaryThumbPaint(Paint paint)
          Set the ordinary paint for the thumb.
 void setPressActions(ActionSequence sequence)
          Sets the sequence of press actions.
 void setReleaseActions(ActionSequence sequence)
          Sets the sequence of release actions.
 void setSelectedThumbPaint(Paint paint)
          Set the selected paint for the thumb.
 void setSlidingActions(ActionSequence sequence)
          Sets the sequence of sliding actions.
 void setTrackLocation(int loc)
          Sets the current track location of the slider in a manner that simulates what happens when the slider is set interactively via the mouse.
 void setTrackLocationHelper(int loc)
          Sets the current track location of the slider but does not invoke the press, sliding, or release actions.
 void setTrackPaint(Paint paint)
          Set the paint for the track.
 void setValue(int val)
          Sets the current conceptual value of the slider in a manner that simulates what happens when the slider is set interactively via the mouse.
protected  void setValueFromValueTFV()
          The method to update the value using the contents of the value text field view.
 void setValueHelper(int val)
          Sets the current conceptual value of the slider but does not invoke the press, sliding, or release actions.
 void setViewState(String data)
          Sets the value for this slider to the int value represented by the given String data.
 String toString()
          Returns a String representation of the current integer value of this slider.
protected  void updateValueTFV()
          The method to update the value text field view using the current value settings.
 int valueToLocation(int val)
          The affine transform that converts the given value to its best approximation as a location on the track.
 
Methods inherited from class edu.neu.ccs.gui.BasePane
getButtonFont, getFieldFont, getFontSize, getGap, getLabelFont, getLargeFieldWidth, getMediumFieldWidth, getSmallFieldWidth, initializeBasePane
 
Methods inherited from class edu.neu.ccs.gui.DisplayPanel
add, add, add, add, add, addBorder, addObject, addObject, addObject, addObject, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, compoundBorder, compoundBorder, dataMalformed, emptyBorder, emptyBorder, emptyBorder, endAlert, etchBorderLowered, etchBorderLowered, etchBorderLowered, etchBorderRaised, etchBorderRaised, etchBorderRaised, frame, frame, frame, frame, frame, frame, generalDialog, generalDialog, generalDialog, generalDialog, getCodec, getDefaultViewStates, getDisplayables, getViewStates, lineBorder, lineBorder, lineBorder, lineBorder, makeComponent, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, OKCancelDialog, OKCancelDialog, OKDialog, OKDialog, refreshComponent, remove, remove, removeAll, removeBorder, sandwichBorder, setCodec, setDeepBackground, setDeepBackground, setDefaultViewStates, setEnabled, setViewStates, startAlert, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, uniformizeHeight, uniformizeSize, uniformizeWidth, YesNoCancelDialog, YesNoCancelDialog
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
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, 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, 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

MINIMUM_PIXELS

public static final int MINIMUM_PIXELS
The minimum permitted pixels value: 20.

See Also:
Constant Field Values

THUMB_SIZE

public static final int THUMB_SIZE
The thumb size: 9.

See Also:
Constant Field Values

THUMB_PLUS

public static final int THUMB_PLUS
The thumb size plus 1.

See Also:
Constant Field Values

TRACK_THICK

public static final int TRACK_THICK
The track thickness: 6.

See Also:
Constant Field Values

TRACK_BORDER_THICK

public static final int TRACK_BORDER_THICK
The track border thickness: 2.

See Also:
Constant Field Values

MAJOR_TICK_SIZE

public static final int MAJOR_TICK_SIZE
The default major tick size: 8.

See Also:
Constant Field Values

MINOR_TICK_SIZE

public static final int MINOR_TICK_SIZE
The default minor tick size: 4.

See Also:
Constant Field Values

STROKE2

public static final Stroke STROKE2
Stroke of size 2: BasicStroke(2).


PRESS_ACTION

public static final int PRESS_ACTION
The ID for a press action event.

See Also:
Constant Field Values

SLIDING_ACTION

public static final int SLIDING_ACTION
The ID for a sliding action event.

See Also:
Constant Field Values

RELEASE_ACTION

public static final int RELEASE_ACTION
The ID for a release action event.

See Also:
Constant Field Values

thumbShape

protected Shape thumbShape

The slider thumb shape.


thumb

protected ShapePaintable thumb

The slider thumb.


ordinaryThumbPaint

protected Paint ordinaryThumbPaint

The ordinary fill paint for the thumb.

Default: Color.white.


selectedThumbPaint

protected Paint selectedThumbPaint

The selected fill paint for the thumb.

Default: Color.red.


trackRect

protected XRect trackRect

The slider track rect.


track

protected ShapePaintable track

The slider track.


trackPaint

protected Paint trackPaint

The fill paint for the track.

Default: Color.yellow.


trackBorderRect

protected XRect trackBorderRect

The slider track border rect.


trackBorder

protected ShapePaintable trackBorder

The slider track border.


commonColor

protected Color commonColor

The common color for lines, borders, and text labels.

Default: Color.black.


tickSequence

protected final PaintableSequence tickSequence

The paintable sequence for slider tick marks.

An empty sequence is constructed in this class.

If majorTicks and/or minorTicks is positive then the corresponding default methods below will populate this paintable sequence with ticks.

If both majorTicks and minorTicks are zero, then the caller has complete control of what ticks, if any, will be installed.


labelSequence

protected final PaintableSequence labelSequence

The paintable sequence for slider labels.

An empty sequence is constructed in this class.

If majorTicks is positive, then the default labels will be installed at the corresponding ticks.

If majorTicks is zero, then the caller has complete control of what labels, if any, will be installed.


objectSequence

protected final PaintableSequence objectSequence

The paintable sequence for more general Paintable objects.

The caller has complete control of what objects, if any, will be installed.


mainSequence

protected final PaintableSequence mainSequence

The paintable sequence for all of the paintables in the slider GUI including the thumb, the track, the major and minor tick marks, and the labels.

Populated by initializeSequence(). This sequence contains other sequences as items. These other sequences are populated by their own methods.


mainBounds

protected XRect mainBounds

Once initialized by freezeBounds(), this rectangle contains the bounds of the sequence mainSequence.


cornerX

protected int cornerX
The x-coordinate of the top-left corner of the main bounds (as an integer).


cornerY

protected int cornerY
The y-coordinate of the top-left corner of the main bounds (as an integer).


mainComponent

protected PaintableComponent mainComponent
The paintable component to hold the main sequence.


adapter

protected MouseActionAdapter adapter
The mouse adapter of the main component.


mouseX

protected int mouseX
The x-coordinate of the current mouse position as adjusted by cornerX to be in the coordinate system of the main sequence.


mouseY

protected int mouseY
The y-coordinate of the current mouse position as adjusted by cornerY to be in the coordinate system of the main sequence.


mousePressAction

protected MouseAction mousePressAction
The mouse press action.


mouseSlidingAction

protected MouseAction mouseSlidingAction
The mouse sliding action.


mouseReleaseAction

protected MouseAction mouseReleaseAction
The mouse release action.


pressActions

protected ActionSequence pressActions
The caller-defined actions performed when the slider thumb is pressed.


slidingActions

protected ActionSequence slidingActions
The caller-defined actions performed when the slider thumb is sliding.


releaseActions

protected ActionSequence releaseActions
The caller-defined actions performed when the slider thumb is released.


pressEvent

public final ActionEvent pressEvent

The standard event that will be passed to the sequence pressActions when the mouse is pressed in the active area of the slider (thumb or track).

The source is this.

The ID is PRESS_ACTION.

The command string is empty.


slidingEvent

public final ActionEvent slidingEvent

The standard event that will be passed to the sequence slidingActions when the mouse is sliding after being pressed in the active area of the slider (thumb or track).

The source is this.

The ID is SLIDING_ACTION.

The command string is empty.


releaseEvent

public final ActionEvent releaseEvent

The standard event that will be passed to the sequence releaseActions when the mouse is released after being pressed in the active area of the slider (thumb or track).

The source is this.

The ID is RELEASE_ACTION.

The command string is empty.


valueTFV

protected TextFieldView valueTFV
The text field view that will echo the current conceptual value of the slider. This view may also be used for input of the slider value.


setValueFromValueTFV

protected SimpleAction setValueFromValueTFV
The action to set the slider value from the value text field view.


orientation

protected int orientation
The slider orientation which should be either HORIZONTAL or VERTICAL.


minimum

protected int minimum

The track minimum value.

If the caller enters a minimum larger than the maximum then that will reverse the order on the slider.

It is required that minimum and maximum be unequal.


maximum

protected int maximum

The track maximum value.

If the caller enters a minimum larger than the maximum then that will reverse the order on the slider.

It is required that minimum and maximum be unequal.


delta

protected int delta
The difference (maximum - minimum).


value

protected int value

The value of the slider, that is, what will be returned by the call getValue().

The value should be between minimum and maximum.


defaultValue

protected int defaultValue
The default value for this slider.


pixels

protected int pixels

The track pixels, that is, the size of the track along its major direction.

It is required that pixels be at least MINIMUM_PIXELS.


limit

protected int limit

The track limit, that is, the last valid location on the track along its major direction.

Equivalent to (pixels - 1).


location

protected int location

The thumb location along the track.

The location should be between 0 and limit.


f_loc_to_val

protected double f_loc_to_val
The scale factor for locationToValue.


t_loc_to_val

protected double t_loc_to_val
The translation for locationToValue.


f_val_to_loc

protected double f_val_to_loc
The scale factor for valueToLocation.


t_val_to_loc

protected double t_val_to_loc
The translation for valueToLocation.


majorTicks

protected int majorTicks

The major ticks setting.

If zero, then major ticks and labels will not be shown automatically but may be added by the caller.


minorTicks

protected int minorTicks

The minor ticks setting.

If zero, then minor ticks will not be shown automatically but may be added by the caller.


dragging

protected boolean dragging

The dragging parameter will be set to true if and only if the user is currently dragging the thumb. This is only used internally.


properties

protected InputProperties properties
The property list for this view object.

Constructor Detail

SliderView

public SliderView()

Constructs a default SliderView.

The orientation will be horizontal.

The minimum will be 0.

The maximum will be 100.

The initial value will be 50.

The size of the track will be 101 pixels. To control the track size you must use one of the constructors that include the pixels parameter.

If this constructor is used, there will be no automatic major ticks, minor ticks, or labels. These may be added by the caller if desired by using the methods of this class.

This constructor will show the text field in which the value of the slider is automatically displayed.

This constructor is included for backward compatibility and to permit experiments since no parameters are required.


SliderView

public SliderView(int orientation)

Constructs a SliderView with the given orientation which must be HORIZONTAL or VERTICAL.

The minimum will be 0.

The maximum will be 100.

The initial value will be 50.

The size of the track will be 101 pixels. To control the track size you must use one of the constructors that include the pixels parameter.

If this constructor is used, there will be no automatic major ticks, minor ticks, or labels. These may be added by the caller if desired by using the methods of this class.

This constructor will show the text field in which the value of the slider is automatically displayed.

This constructor is included for backward compatibility.


SliderView

public SliderView(int orientation,
                  int minimum,
                  int maximum,
                  int value)

Constructs a SliderView with the given parameters.

The orientation controls the orientation of the slider in the GUI and should be either HORIZONTAL or VERTICAL.

The minimum and maximum parameters determine the minimum and maximum values that the slider can return via the getValue() method. It is permissible for these values to be in the opposite order and in that case the slider will work in the opposite order.

The value paramter is the initial slider value, except that, if it is out of range, then it will be forced into range.

The size of the track will be 101 pixels. To control the track size you must use one of the constructors that include the pixels parameter.

If this constructor is used, there will be no automatic major ticks, minor ticks, or labels. These may be added by the caller if desired by using the methods of this class.

This constructor will show the text field in which the value of the slider is automatically displayed.

Throws IllegalArgumentException if minimum equals maximum or if pixels is less than MINIMUM_PIXELS.

This constructor is included for backward compatibility.


SliderView

public SliderView(int orientation,
                  int minimum,
                  int maximum,
                  int value,
                  int pixels)

Constructs a SliderView with the given parameters.

The orientation controls the orientation of the slider in the GUI and should be either HORIZONTAL or VERTICAL.

The minimum and maximum parameters determine the minimum and maximum values that the slider can return via the getValue() method. It is permissible for these values to be in the opposite order and in that case the slider will work in the opposite order.

The value paramter is the initial slider value, except that, if it is out of range, then it will be forced into range.

The pixelsparameter is the physical size of the slider track in the direction of slider motion.

If this constructor is used, there will be no automatic major ticks, minor ticks, or labels. These may be added by the caller if desired by using the methods of this class.

This constructor will show the text field in which the value of the slider is automatically displayed.

Throws IllegalArgumentException if minimum equals maximum or if pixels is less than MINIMUM_PIXELS.


SliderView

public SliderView(int orientation,
                  int minimum,
                  int maximum,
                  int value,
                  int pixels,
                  int majorTicks,
                  int minorTicks)

Constructs a SliderView with the given parameters.

The orientation controls the orientation of the slider in the GUI and should be either HORIZONTAL or VERTICAL.

The minimum and maximum parameters determine the minimum and maximum values that the slider can return via the getValue() method. It is permissible for these values to be in the opposite order and in that case the slider will work in the opposite order.

The value paramter is the initial slider value, except that, if it is out of range, then it will be forced into range.

The pixelsparameter is the physical size of the slider track in the direction of slider motion.

The majorTicksparameter controls the position of the major ticks along the slider and the associated automatic labels. If this parameter is 0, then major ticks and labels will not be automatically drawn. These decorations may be supplied manually by the caller using methods in the class.

The minorTicksparameter controls the position of the minor ticks along the slider. If this parameter is 0, then minor ticks will not be automatically drawn.

This constructor will show the text field in which the value of the slider is automatically displayed.

Throws IllegalArgumentException if minimum equals maximum or if pixels is less than MINIMUM_PIXELS.


SliderView

public SliderView(int orientation,
                  int minimum,
                  int maximum,
                  int value,
                  int pixels,
                  int majorTicks,
                  int minorTicks,
                  Paint ordinaryThumbPaint,
                  Paint selectedThumbPaint,
                  Paint trackPaint,
                  Color commonColor,
                  boolean showValueTFV)

Constructs a SliderView with the given parameters.

The orientation controls the orientation of the slider in the GUI and should be either HORIZONTAL or VERTICAL.

The minimum and maximum parameters determine the minimum and maximum values that the slider can return via the getValue() method. It is permissible for these values to be in the opposite order and in that case the slider will work in the opposite order.

The value paramter is the initial slider value, except that, if it is out of range, then it will be forced into range.

The pixelsparameter is the physical size of the slider track in the direction of slider motion.

The majorTicksparameter controls the position of the major ticks along the slider and the associated automatic labels. If this parameter is 0, then major ticks and labels will not be automatically drawn. These decorations may be supplied manually by the caller using methods in the class.

The minorTicksparameter controls the position of the minor ticks along the slider. If this parameter is 0, then minor ticks will not be automatically drawn.

This constructor allows the caller to set the various paints and colors used in the GUI. If a parameter is null then the default will be used.

The paint and color defaults are:

The common color is used for tick marks, borders, and text.

This constructor will show the text field in which the value of the slider is automatically displayed if the showValueTFV parameter is set to true.

Throws IllegalArgumentException if minimum equals maximum or if pixels is less than MINIMUM_PIXELS.

Method Detail

initializeNumerics

protected final void initializeNumerics(int orientation,
                                        int minimum,
                                        int maximum,
                                        int value,
                                        int pixels,
                                        int majorTicks,
                                        int minorTicks)

Initializes important numerical parameters.

Initializes the orientation so that it must be either HORIZONTAL or VERTICAL.

Initializes the numeric relationships between the conceptual slider data (minimum, maximum, value) and the pixel data (pixels, limit, location).

Initializes the tick settings. Furthermore, if both tick settings are positive, then minorTicks is forced to be a divisor of majorTicks.

Throws IllegalArgumentException if minimum equals maximum or if pixels is less than MINIMUM_PIXELS.


initializePaints

protected final void initializePaints(Paint ordinaryThumbPaint,
                                      Paint selectedThumbPaint,
                                      Paint trackPaint,
                                      Color commonColor)

Performs the paint and color initializations.

This method which is called by the most elaborate constructor allows the caller to set the various paints and colors used in the GUI. If a parameter is null then the default will be used.

The paint and color defaults are:

The common color is used by tick marks, borders, and text.

There are individual public methods to reset each particular paint or color after a constructor has been called.


initializeValueTFV

protected final void initializeValueTFV()
Performs the initializations for the value text field.


initializeThumb

protected final void initializeThumb()
Performs the initializations for the thumb.


initializeTrack

protected final void initializeTrack()

Performs the initializations for the track and track border.

Sets the original default bounds to allow for the thumb.


initializeMainSequence

protected final void initializeMainSequence()

Appends all items to the main paintable sequence.

These are in order:

This order is the top-to-bottom order of painting. In particular, any general decorations will be below all other objects in the GUI.


initializeMouse

protected final void initializeMouse()
Initializes the mouse behavior.


installMainPanel

protected final void installMainPanel(boolean showValueTFV)

Installs the main panel with the slider and optionally the value text field.

If showValueTFV is true then the text field in which the value of the slider is automatically displayed will be installed in the GUI.


makeTick

public final ShapePaintable makeTick(int val,
                                     int size)

Creates the paintable for one tick.

Parameters:
val - the tick position in value coordinates
size - the tick size

getTickValues

public int[] getTickValues(int spacing)

Returns the array of slider values that will be used to generate the tick value positions based on the given tick spacing and the internal minimum and maximum.

For example, if minimum = 1, maximum = 99, and spacing = 10, the following array of values will be returned:

    1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 99

Thus, the tick value positions strictly between minimum and maximum are multiples of the spacing.

This algorithm in NOT the one used in the Java JSlider class.

This method may be overridden in a derived class if a different algorithm is desired. Alternatively, several methods below accept an explicit array of values and a caller may supply whatever values are desired.

Returns an empty array if spacing <= 0;

Parameters:
spacing - the tick spacing in value coordinates

installTicks

public final void installTicks(int[] values,
                               int size)

Installs ticks of the given size at the given value positions.

Parameters:
values - the tick positions in value coordinates
size - the tick size

installDefaultMajorTicks

public final void installDefaultMajorTicks()

Installs the default major ticks provided that the majorTicks value is positive. Does nothing if majorTicks is zero.

Calls getTickValues to get the tick positions.

Uses MAJOR_TICK_SIZE for the tick size.


installDefaultMinorTicks

public final void installDefaultMinorTicks()

Installs the default minor ticks provided that the minorTicks value is positive. Does nothing if minorTicks is zero.

Calls getTickValues to get the tick positions.

Uses MINOR_TICK_SIZE for the tick size.


installStandardTicks

public final void installStandardTicks()

Installs standard major tick marks following the very simple algorithm available in this class prior to version 2.6.0.

Since the installation of tick marks is now made automatic in several constructors, this method will do nothing if either majorTicks or minorTicks is positive. If both of these settings are zero, then this method will make major ticks using a spacing of (1/10) of the difference between maximum and minimum. It will not make minor ticks.

This method is retained for backward compatibility but is not recommended for new code.


makeLabel

public final TextPaintable makeLabel(int val,
                                     String label,
                                     int size)

Creates the paintable for one label.

This method allows space for a tick whose size is given by the size parameter. If this parameter is zero, then no allowance is made for a tick.

Parameters:
val - the label position in value coordinates
label - the label as a String
size - the tick size

makeLabelStrings

public final String[] makeLabelStrings(int[] values)

Returns the array of numeric Strings corresponding to the array of integer values.

Returns an empty array if the parameter array is null.

Parameters:
values - the integer values to convert to String

makeLabels

public final TextPaintable[] makeLabels(int[] values,
                                        String[] labels,
                                        int size)

Returns the array of TextPaintable labels positioned at the given value positions and using the given String labels.

Returns an empty array if either parameter array is null.

If the parameter arrays have unequal length, then the minimum of the lengths is used in the construction.

This method allows space for a tick whose size is given by the size parameter. If this parameter is zero, then no allowance is made for a tick.

Parameters:
values - the value positions for the labels
labels - the label data as String
size - the tick size

installLabels

public final void installLabels(int[] values,
                                String[] labels,
                                int size)

Makes an array of TextPaintable labels using the given value positions and String labels and installs the created labels in the internal paintable sequence that is associated with labels.

This method allows space for a tick whose size is given by the size parameter. If this parameter is zero, then no allowance is made for a tick.

Parameters:
values - the value positions for the labels
labels - the label data as String
size - the tick size

installDefaultLabels

public final void installDefaultLabels()

Installs the default labels provided that the majorTicks value is positive. Does nothing if majorTicks is zero.

Calls getTickValues to get the tick positions.

Then calls makeLabelStrings to get the String labels.

Assumes MAJOR_TICK_SIZE as the tick size.

Then calls installLabels.


installStandardLabels

public void installStandardLabels()

Installs standard labels following the very simple algorithm available in this class prior to version 2.6.0.

Since the installation of labels is now made automatic in several constructors, this method will do nothing if either majorTicks or minorTicks is positive. If both of these settings are zero, then this method will make labels using a spacing of (1/10) of the difference between maximum and minimum.

This method is retained for backward compatibility but is not recommended for new code.


installObjects

public final void installObjects(Paintable[] objects)

Installs the given Paintable objects as decorations in the internal paintable sequence that is associated with objects.

This method gives the caller complete control of what Paintable objects are placed as decorations in the slider GUI and where.

These decorations will be below all other objects in the GUI. It is recommended that the caller experiment carefully with the placement of decorations to avoid visual conflicts.

This method supports rather esoteric needs and will likely not be used by most callers of this class.

Parameters:
objects - the paintable objects to place in the GUI

getValidValue

public final int getValidValue(int val)

If the given value is between minimum and maximum, then return that value; otherwise return the closest valid value to the given value.

This method is a helper method that does not change the slider state.

Parameters:
val - the value to test

getValidLocation

public final int getValidLocation(int loc)

If the given location is between 0 and limit, then return that location; otherwise return the closest valid location to the given location.

This method is a helper method that does not change the slider state.

Parameters:
loc - the location to test

valueToLocation

public final int valueToLocation(int val)

The affine transform that converts the given value to its best approximation as a location on the track.

This method is a helper method that does not change the slider state.

Parameters:
val - the value to convert

locationToValue

public final int locationToValue(int loc)

The affine transform that converts the given location on the track to its best approximation as a value.

This method is a helper method that does not change the slider state.

Parameters:
loc - the location to convert

getValue

public final int getValue()
Returns the current conceptual value of the slider.


setValue

public final void setValue(int val)

Sets the current conceptual value of the slider in a manner that simulates what happens when the slider is set interactively via the mouse.

Uses the following steps:

Parameters:
val - the value to set

setValueHelper

public final void setValueHelper(int val)

Sets the current conceptual value of the slider but does not invoke the press, sliding, or release actions.

Ensures that the value used is valid.

Updates the corresponding track location to the best approximation for this value.

Calls resetThumb() and updateValueTFV() to update the GUI.

This method is normally not called directly since it does not invoke the user defined actions. However, to support unusual circumstances, it is available as a public method.

Parameters:
val - the value to set

getTrackLocation

public final int getTrackLocation()
Returns the current track location of the slider.


setTrackLocation

public final void setTrackLocation(int loc)

Sets the current track location of the slider in a manner that simulates what happens when the slider is set interactively via the mouse.

Uses the following steps:

Parameters:
loc - the location to set

setTrackLocationHelper

public final void setTrackLocationHelper(int loc)

Sets the current track location of the slider but does not invoke the press, sliding, or release actions.

Ensures that the location used is valid.

Updates the corresponding conceptual value to the best approximation for this location.

Calls resetThumb() and updateValueTFV() to update the GUI.

This method is normally not called directly since it does not invoke the user defined actions. However, to support unusual circumstances, it is available as a public method.

Parameters:
loc - the location to set

resetThumb

public final void resetThumb()

The method to reset the location of the slider thumb on the track.


setOrdinaryThumbPaint

public final void setOrdinaryThumbPaint(Paint paint)
Set the ordinary paint for the thumb.

Parameters:
paint - the paint to set

setSelectedThumbPaint

public final void setSelectedThumbPaint(Paint paint)
Set the selected paint for the thumb.

Parameters:
paint - the paint to set

setTrackPaint

public final void setTrackPaint(Paint paint)
Set the paint for the track.

Parameters:
paint - the paint to set

setCommonColor

public final void setCommonColor(Color color)
Set the common color of ticks, borders, and text labels.


addPressAction

public void addPressAction(ActionListener a)

Adds the given action listener to the sequence of actions that is performed when slider is pressed in its active area (thumb or track).

This action will be invoked with the standard event pressEvent.

This action may query this slider using the methods getValue() or getTrackLocation() to decide what to do.

Parameters:
a - the press action listener to add

addSlidingAction

public void addSlidingAction(ActionListener a)

Adds the given action listener to the sequence of actions that is performed when slider is sliding after being pressed in its active area (thumb or track).

This action will be invoked with the standard event slidingEvent.

This action may query this slider using the methods getValue() or getTrackLocation() to decide what to do.

Parameters:
a - the sliding action listener to add

addReleaseAction

public void addReleaseAction(ActionListener a)

Adds the given action listener to the sequence of actions that is performed when slider is released after being pressed in its active area (thumb or track).

This action will be invoked with the standard event releaseEvent.

This action may query this slider using the methods getValue() or getTrackLocation() to decide what to do.

Parameters:
a - the release action listener to add

removePressAction

public void removePressAction(ActionListener a)
Removes the given action listener from the press actions.

Parameters:
a - the press action listener to remove

removeSlidingAction

public void removeSlidingAction(ActionListener a)
Removes the given action listener from the sliding actions.

Parameters:
a - the sliding action listener to remove

removeReleaseAction

public void removeReleaseAction(ActionListener a)
Removes the given action listener from the release actions.

Parameters:
a - the release action listener to remove

setPressActions

public void setPressActions(ActionSequence sequence)

Sets the sequence of press actions.

Clears the press actions if the parameter is null.

Parameters:
sequence - the new press actions

setSlidingActions

public void setSlidingActions(ActionSequence sequence)

Sets the sequence of sliding actions.

Clears the sliding actions if the parameter is null.

Parameters:
sequence - the new sliding actions

setReleaseActions

public void setReleaseActions(ActionSequence sequence)

Sets the sequence of release actions.

Clears the release actions if the parameter is null.

Parameters:
sequence - the new release actions

getPressActions

public ActionSequence getPressActions()
Returns the sequence of press actions.


getSlidingActions

public ActionSequence getSlidingActions()
Returns the sequence of sliding actions.


getReleaseActions

public ActionSequence getReleaseActions()
Returns the sequence of release actions.


freezeBounds

protected final void freezeBounds()

This method computes the bounds of the sequence mainSequence, stores those bounds in mainBounds, and sets the corner data cornerX and cornerY for use in computation of mouse coordinates.

This method also sets the default bounds of mainSequence to the newly computed mainBounds so that any further change to the main sequence cannot affect its bounds.

The purpose of this method is make computations with the mouse efficient.

This method will be called when the first mouse interaction with the main component occurs. If it is called again, it will do nothing.


setMouseCoordinates

protected final void setMouseCoordinates(MouseEvent evt)

Sets mouseX and mouseY by adjusting the mouse position in the given mouse event by the corner coordinates.

Parameters:
evt - the mouse event

updateValueTFV

protected final void updateValueTFV()

The method to update the value text field view using the current value settings.


setValueFromValueTFV

protected final void setValueFromValueTFV()

The method to update the value using the contents of the value text field view.

If the contents of the value text field view causes a parse exception, the user will be given a chance to correct the error or cancel. If the contents is parsable as an integer, then it will be used in a call to setValue. If that call determines that the value is invalid then the value set will be forced into range.

This method implements the action of the same name and the corresponding action is set as a listener for the value text field view.

If successful, this method will reset the thumb and perform a press, sliding, release sequence for the user-defined actions.


mousePress

protected final void mousePress(MouseEvent evt)

The mouse press behavior.

If the mouse was pressed in the active area of the slider (thumb or track), performs the standard startup behavior for the mouse press:

Before processing, calls freezeBounds to ensure that the relation between the event coordinates for the main component and the mouse coordinates relative to the main sequence is fixed once and for all.


mouseSliding

protected final void mouseSliding(MouseEvent evt)

The mouse sliding behavior.

If the mouse was pressed in the active area of the slider (thumb or track), performs the standard sliding behavior for the subsequent mouse movement:


mouseRelease

protected final void mouseRelease(MouseEvent evt)

The mouse release behavior.

If the mouse was pressed in the active area of the slider (thumb or track), performs the standard release behavior for the subsequent mouse release:


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:
TypedView.requestObject()

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:
TypedView.demandObject()

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

setViewState

public void setViewState(String data)

Sets the value for this slider to the int value represented by the given String data.

If the String is not parsable to an int, then this method does nothing.

If the String is parsable to an int but that int is not in range then the value will be forced into range.

Specified by:
setViewState in interface Displayable
Overrides:
setViewState in class DisplayPanel
Parameters:
data - the new view state

getViewState

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

Specified by:
getViewState in interface Displayable
Overrides:
getViewState in class DisplayPanel

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 String is not parsable to an int, then this method does nothing.

If the String is parsable to an int but that int is not in range then the value will be forced into range.

Specified by:
setDefaultViewState in interface Displayable
Overrides:
setDefaultViewState in class DisplayPanel
Parameters:
data - the new default view state

getDefaultViewState

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

Specified by:
getDefaultViewState in interface Displayable
Overrides:
getDefaultViewState in class DisplayPanel

reset

public void reset()
Resets the slider to its default value.

Specified by:
reset in interface Displayable
Overrides:
reset in class DisplayPanel

toString

public String toString()
Returns a String representation of the current integer value of this slider.