echopointng
Class Slider

java.lang.Object
  extended by nextapp.echo2.app.Component
      extended by echopointng.ComponentEx
          extended by echopointng.AbleComponent
              extended by echopointng.Slider
All Implemented Interfaces:
AccessKeyable, Attributeable, Borderable, Delegateable, Heightable, Insetable, MouseCursorable, Sizeable, ToolTipable, Widthable, java.io.Serializable, RenderIdSupport

public class Slider
extends AbleComponent

Slider is a component the presents a handle that can be dragged to move within a range of values.

The BoundedRangeModel is used to contain the range of integer values that the Slider can move between.

Since this is integer based, you can use a valueRatio to generate a double value from the BoundedRangeModel value, thereby allowing decimal numbers to be used within a Slider.

See Also:
Serialized Form

Field Summary
protected  ChangeEvent changeEvent
          Only one ChangeEvent is needed per instance since the event's only interesting property is the immutable source, which is the Slider.
protected  ChangeListener changeListener
           
static Style DEFAULT_HORIZONTAL_STYLE
          DEFAULT_HORIZONTAL_STYLE contains a default Style for a horizontal Slider
static Style DEFAULT_STYLE
          DEFAULT_STYLE is equal to DEFAULT_HORIZONTAL_STYLE
static Style DEFAULT_VERTICAL_STYLE
          DEFAULT_VERTICAL_STYLE contains a default Style for a vertical Slider
static int ORIENTATION_HORIZONTAL
           
static int ORIENTATION_VERTICAL
           
static java.lang.String PROPERTY_MODEL
           
static java.lang.String PROPERTY_ORIENTATION
           
static java.lang.String PROPERTY_VALUE_DECIMAL_PLACES
           
static java.lang.String PROPERTY_VALUE_RATIO
           
static java.lang.String VALUE_CHANGED_PROPERTY
           
 
Fields inherited from class echopointng.ComponentEx
PROPERTY_HIDDEN
 
Fields inherited from class nextapp.echo2.app.Component
CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FOCUS_TRAVERSAL_INDEX_CHANGED_PROPERTY, FOCUS_TRAVERSAL_PARTICIPANT_CHANGED_PROPERTY, LAYOUT_DIRECTION_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, PROPERTY_BACKGROUND, PROPERTY_FONT, PROPERTY_FOREGROUND, PROPERTY_LAYOUT_DATA, STYLE_CHANGED_PROPERTY, STYLE_NAME_CHANGED_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Fields inherited from interface echopointng.able.AccessKeyable
PROPERTY_ACCESS_KEY
 
Fields inherited from interface echopointng.able.Borderable
PROPERTY_BORDER
 
Fields inherited from interface echopointng.able.MouseCursorable
CURSOR_AUTO, CURSOR_CROSSHAIR, CURSOR_CUSTOM_URI, CURSOR_DEFAULT, CURSOR_E_RESIZE, CURSOR_HELP, CURSOR_MOVE, CURSOR_N_RESIZE, CURSOR_NE_RESIZE, CURSOR_NW_RESIZE, CURSOR_POINTER, CURSOR_S_RESIZE, CURSOR_SE_RESIZE, CURSOR_SW_RESIZE, CURSOR_TEXT, CURSOR_W_RESIZE, CURSOR_WAIT, PROPERTY_MOUSE_CURSOR, PROPERTY_MOUSE_CURSOR_URI
 
Fields inherited from interface echopointng.able.Insetable
DEFAULT_INSETS, DEFAULT_OUTSETS, PROPERTY_INSETS, PROPERTY_OUTSETS
 
Fields inherited from interface echopointng.able.Widthable
PROPERTY_WIDTH
 
Fields inherited from interface echopointng.able.Heightable
PROPERTY_HEIGHT
 
Fields inherited from interface echopointng.able.ToolTipable
PROPERTY_TOOL_TIP_TEXT
 
Constructor Summary
Slider()
          Constructs a Slider with a DefaultBoundedRangeModel set to zero.
Slider(BoundedRangeModel model)
          Constructs a Slider with the specified BoundedRangeModel
Slider(Style style)
          Constructs a Slider with a DefaultBoundedRangeModel and uses the specified Style.
 
Method Summary
 void addChangeListener(ChangeListener l)
          Adds a ChangeListener to the Slider.
protected  ChangeListener createChangeListener()
          Subclasses that want to handle ChangeEvents differently can override this to return a subclass of ModelListener or another ChangeListener implementation.
protected  void fireStateChanged()
          Notify all listeners that have registered interest for notification on this event type.
 double getDoubleValue()
          The getDoubleValue() method allows a decimal number to be returned by the Slider when the backing model only supports integers.
 int getMaximum()
          Returns the model's maximum value.
 int getMinimum()
          Returns the model's minimum value.
 BoundedRangeModel getModel()
          Returns the data model used by the Slider.
 int getOrientation()
          Returns Slider.ORIENTATION_VERTICAL or Slider.ORIENTATION_HORIZONTAL, depending on the orientation of the Slider.
 int getValue()
          Returns the model's current value.
 int getValueDecimalPlaces()
           
 double getValueRatio()
           
 void processInput(java.lang.String inputName, java.lang.Object inputValue)
          Processes client input specific to the Component received from the UpdateManager.
 void removeChangeListener(ChangeListener l)
          Removes a ChangeListener from the Slider.
 void setMaximum(int n)
          Sets the model's maximum to n .
 void setMinimum(int n)
          Sets the model's minimum to n .
 void setModel(BoundedRangeModel newModel)
          Sets the data model used by the Slider.
 void setOrientation(int newOrientation)
          Sets the Slider's orientation to newOrientation , which must be Slider.ORIENTATION_VERTICAL or Slider.ORIENTATION_HORIZONTAL.
 void setValue(int n)
          Sets the model's value to n .
 void setValueDecimalPlaces(int newValue)
          Sets the number of decimal places that will be returned in the value of the getDoubleValue() method and when displayed on the client.
 void setValueRatio(double newValue)
          Sets the ratio that will be multiplied by the current model value when its is returned by the getDoubleValue() and when displayed on the client.
 java.lang.String toString()
           
 
Methods inherited from class echopointng.AbleComponent
getAccessKey, getBorder, getHeight, getInsets, getMouseCursor, getMouseCursorURI, getOutsets, getToolTipText, getWidth, setAccessKey, setBorder, setHeight, setInsets, setMouseCursor, setMouseCursorURI, setOutsets, setToolTipText, setWidth
 
Methods inherited from class echopointng.ComponentEx
getAttribute, getAttributeNames, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, isHidden, setAttribute, setHidden, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty
 
Methods inherited from class nextapp.echo2.app.Component
add, add, addPropertyChangeListener, dispose, firePropertyChange, getApplicationInstance, getBackground, getComponent, getComponent, getComponentCount, getComponents, getEventListenerList, getFocusTraversalIndex, getFont, getForeground, getId, getIndexedProperty, getLayoutData, getLayoutDirection, getLocale, getParent, getProperty, getRenderId, getRenderIndexedProperty, getRenderIndexedProperty, getRenderLayoutDirection, getRenderLocale, getRenderProperty, getRenderProperty, getStyle, getStyleName, getVisibleComponent, getVisibleComponentCount, getVisibleComponents, hasEventListenerList, indexOf, init, isAncestorOf, isEnabled, isFocusTraversalParticipant, isRegistered, isRenderEnabled, isRenderVisible, isValidChild, isValidParent, isVisible, remove, remove, removeAll, removePropertyChangeListener, setBackground, setEnabled, setFocusTraversalIndex, setFocusTraversalParticipant, setFont, setForeground, setId, setIndexedProperty, setLayoutData, setLayoutDirection, setLocale, setProperty, setStyle, setStyleName, setVisible, validate, verifyInput, visibleIndexOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 

Field Detail

DEFAULT_HORIZONTAL_STYLE

public static final Style DEFAULT_HORIZONTAL_STYLE
DEFAULT_HORIZONTAL_STYLE contains a default Style for a horizontal Slider


DEFAULT_VERTICAL_STYLE

public static final Style DEFAULT_VERTICAL_STYLE
DEFAULT_VERTICAL_STYLE contains a default Style for a vertical Slider


DEFAULT_STYLE

public static final Style DEFAULT_STYLE
DEFAULT_STYLE is equal to DEFAULT_HORIZONTAL_STYLE


ORIENTATION_HORIZONTAL

public static final int ORIENTATION_HORIZONTAL
See Also:
Constant Field Values

ORIENTATION_VERTICAL

public static final int ORIENTATION_VERTICAL
See Also:
Constant Field Values

PROPERTY_MODEL

public static final java.lang.String PROPERTY_MODEL
See Also:
Constant Field Values

PROPERTY_ORIENTATION

public static final java.lang.String PROPERTY_ORIENTATION
See Also:
Constant Field Values

PROPERTY_VALUE_DECIMAL_PLACES

public static final java.lang.String PROPERTY_VALUE_DECIMAL_PLACES
See Also:
Constant Field Values

PROPERTY_VALUE_RATIO

public static final java.lang.String PROPERTY_VALUE_RATIO
See Also:
Constant Field Values

VALUE_CHANGED_PROPERTY

public static final java.lang.String VALUE_CHANGED_PROPERTY
See Also:
Constant Field Values

changeEvent

protected transient ChangeEvent changeEvent
Only one ChangeEvent is needed per instance since the event's only interesting property is the immutable source, which is the Slider.


changeListener

protected ChangeListener changeListener
Constructor Detail

Slider

public Slider()
Constructs a Slider with a DefaultBoundedRangeModel set to zero.


Slider

public Slider(BoundedRangeModel model)
Constructs a Slider with the specified BoundedRangeModel

Parameters:
model - - the new BoundedRangeModel

Slider

public Slider(Style style)
Constructs a Slider with a DefaultBoundedRangeModel and uses the specified Style. Typically you might use this constructor like this
   Slider slider = new Slider(Slider.DEFAULT_VERTICAL_STYLE);

Parameters:
style - - the Style to use
Method Detail

processInput

public void processInput(java.lang.String inputName,
                         java.lang.Object inputValue)
Description copied from class: Component
Processes client input specific to the Component received from the UpdateManager. Derivative implementations should take care to invoke super.processInput().

Overrides:
processInput in class Component
Parameters:
inputName - the name of the input
inputValue - the value of the input
See Also:
Component.processInput(java.lang.String, java.lang.Object)

addChangeListener

public void addChangeListener(ChangeListener l)
Adds a ChangeListener to the Slider.

Parameters:
l - the ChangeListener to add

createChangeListener

protected ChangeListener createChangeListener()
Subclasses that want to handle ChangeEvents differently can override this to return a subclass of ModelListener or another ChangeListener implementation.


fireStateChanged

protected void fireStateChanged()
Notify all listeners that have registered interest for notification on this event type.


getMaximum

public int getMaximum()
Returns the model's maximum value. By default, this is 100.

Returns:
an int -- the model's maximum

getMinimum

public int getMinimum()
Returns the model's minimum value. By default, this is 0.


getModel

public BoundedRangeModel getModel()
Returns the data model used by the Slider.


getOrientation

public int getOrientation()
Returns Slider.ORIENTATION_VERTICAL or Slider.ORIENTATION_HORIZONTAL, depending on the orientation of the Slider. The default orientation is ORIENTATION_HORIZONTAL.


getValue

public int getValue()
Returns the model's current value. The value is always between the model's minimum and maximum values, inclusive. By default, the value equals the minimum.


getDoubleValue

public double getDoubleValue()
The getDoubleValue() method allows a decimal number to be returned by the Slider when the backing model only supports integers. The number is the current getValue() * getValueRatio(), which is then rounded to getValueDecimalPlaces()

Returns:
- getValue() * getValueRatio() rounded to getValueDecimalPlaces()

getValueDecimalPlaces

public int getValueDecimalPlaces()
Returns:
- the value decimal places in use, which is by default 0

getValueRatio

public double getValueRatio()
Returns:
- the value ratio in use, which is by default 1

setValueDecimalPlaces

public void setValueDecimalPlaces(int newValue)
Sets the number of decimal places that will be returned in the value of the getDoubleValue() method and when displayed on the client.

Parameters:
newValue - - the number of decimal places to use

setValueRatio

public void setValueRatio(double newValue)
Sets the ratio that will be multiplied by the current model value when its is returned by the getDoubleValue() and when displayed on the client.

Parameters:
newValue - - a new ratio to multiply the value by such as 0.01.

removeChangeListener

public void removeChangeListener(ChangeListener l)
Removes a ChangeListener from the Slider.

Parameters:
l - the ChangeListener to remove

setMaximum

public void setMaximum(int n)
Sets the model's maximum to n . The underlying BoundedRangeModel will handle any mathematical issues arrising from assigning faulty values.

Notifies any listeners if the data changes.


setMinimum

public void setMinimum(int n)
Sets the model's minimum to n .

The underlying BoundedRangeModel will handle any mathematical issues arrising from assigning faulty values.

Notifies any listeners if the data changes.


setModel

public void setModel(BoundedRangeModel newModel)
Sets the data model used by the Slider.

Parameters:
newModel - - the new BoundedRangeModel to use
Throws:
java.lang.IllegalArgumentException - is the model is null

setOrientation

public void setOrientation(int newOrientation)
Sets the Slider's orientation to newOrientation , which must be Slider.ORIENTATION_VERTICAL or Slider.ORIENTATION_HORIZONTAL. The default orientation is ORIENTATION_HORIZONTAL.


setValue

public void setValue(int n)
Sets the model's value to n .

The underlying BoundedRangeModel will handle any mathematical issues arrising from assigning faulty values.

Notifies any listeners if the data changes.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()