org.spiffyui.client.widgets.slider
Class Slider

java.lang.Object
  extended by Widget
      extended by org.spiffyui.client.widgets.slider.Slider
Direct Known Subclasses:
RangeSlider

public class Slider
extends Widget

This widget wraps the JQuery UI Slider and allows for single slider or double slider with range. All options can be get or set using generic get/setIntOption, get/setStringOption, get/setBooleanOption methods, but some convenience methods are provided for most popular such as setValues and setMinimum and setMaximum. See SliderOptions for full list of options.

See Also:
SliderOption

Constructor Summary
Slider(java.lang.String id)
          Create the default slider with the specified ID.
Slider(java.lang.String id, int min, int max, int defaultValue)
          Create a slider with the specified ID.
Slider(java.lang.String id, int min, int max, int[] defaultValues)
          Create a slider with the specified ID.
Slider(java.lang.String id, JSONObject options)
          Create a slider with the specified ID.
 
Method Summary
 void addListener(SliderListener l)
          Add a SliderListener
 boolean getBooleanOption(SliderOption option)
          Get an option boolean value
 int getIntOption(SliderOption option)
          Get an option numeric value
 int getMaximum()
          Gets the maximum possible value for the slider
 int getMinimum()
          Gets the minimum possible value for the slider
static JSONObject getOptions(int min, int max, int[] defaultValues)
          A convenient way to create an options JSONObject.
 int getValue()
          Convenience method for only 1 anchor
 int getValueAtIndex(int index)
          Gets the value of a anchor at the specified index
protected  void onLoad()
           
protected  void onUnload()
           
 void removeListener(SliderListener l)
          Removes the SliderListener
 void setBooleanOption(SliderOption option, boolean value)
          Set an option boolean value
 void setIntOption(SliderOption option, int value)
          Set an option numeric value
 void setMaximum(int maximum)
          Sets the maximum possible value for the slider
 void setMinimum(int minimum)
          Sets the minimum possible value for the slider
 java.lang.String setStringOption(SliderOption option)
          Set an option string value
 void setStringOption(SliderOption option, java.lang.String value)
          Set an option string value
 void setValue(int value)
          Convenience method for only 1 anchor
 void setValues(int[] values)
          Sets the value of each anchor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Slider

public Slider(java.lang.String id,
              int min,
              int max,
              int defaultValue)
Create a slider with the specified ID. The ID is required because the slider needs a specific ID to connect to.

Parameters:
id - - id of the element
min - - default minimum of the slider
max - - default maximum of the slider
defaultValue - - default point of a single anchor

Slider

public Slider(java.lang.String id,
              int min,
              int max,
              int[] defaultValues)
Create a slider with the specified ID. The ID is required because the slider needs a specific ID to connect to.

Parameters:
id - - id of the element
min - - default minimum of the slider
max - - default maximum of the slider
defaultValues - - default points of each anchor

Slider

public Slider(java.lang.String id)
Create the default slider with the specified ID. The ID is required because the slider needs a specific ID to connect to.

Parameters:
id - - id of the element to create

Slider

public Slider(java.lang.String id,
              JSONObject options)
Create a slider with the specified ID. The ID is required because the slider needs a specific ID to connect to.

Parameters:
id - - id of the element to create
options - - JSONObject of any possible option, can be null for defaults
Method Detail

getOptions

public static JSONObject getOptions(int min,
                                    int max,
                                    int[] defaultValues)
A convenient way to create an options JSONObject. Use SliderOption for keys.

Parameters:
min - - default minimum of the slider
max - - default maximum of the slider
defaultValues - - default points of each anchor
Returns:
a JSONObject of Slider options

onLoad

protected void onLoad()

onUnload

protected void onUnload()

getMinimum

public int getMinimum()
Gets the minimum possible value for the slider

Returns:
Returns the minimum.

setMinimum

public void setMinimum(int minimum)
Sets the minimum possible value for the slider

Parameters:
minimum - The minimum to set.

getMaximum

public int getMaximum()
Gets the maximum possible value for the slider

Returns:
Returns the maximum.

setMaximum

public void setMaximum(int maximum)
Sets the maximum possible value for the slider

Parameters:
maximum - The maximum to set.

getValue

public int getValue()
Convenience method for only 1 anchor

Returns:
Returns the value.

setValue

public void setValue(int value)
Convenience method for only 1 anchor

Parameters:
value - to set.

setValues

public void setValues(int[] values)
Sets the value of each anchor

Parameters:
values - - int array of values

getValueAtIndex

public int getValueAtIndex(int index)
Gets the value of a anchor at the specified index

Parameters:
index - the index to retreive the value for
Returns:
the value

setIntOption

public void setIntOption(SliderOption option,
                         int value)
Set an option numeric value

Parameters:
option - the SliderOption
value - the numeric

getIntOption

public int getIntOption(SliderOption option)
Get an option numeric value

Parameters:
option - the SliderOption
Returns:
value the numeric

setBooleanOption

public void setBooleanOption(SliderOption option,
                             boolean value)
Set an option boolean value

Parameters:
option - the SliderOption
value - the boolean

getBooleanOption

public boolean getBooleanOption(SliderOption option)
Get an option boolean value

Parameters:
option - the SliderOption
Returns:
value the boolean

setStringOption

public void setStringOption(SliderOption option,
                            java.lang.String value)
Set an option string value

Parameters:
option - the SliderOption
value - the String

setStringOption

public java.lang.String setStringOption(SliderOption option)
Set an option string value

Parameters:
option - the SliderOption
Returns:
value the String

addListener

public void addListener(SliderListener l)
Add a SliderListener

Parameters:
l - - SliderListener

removeListener

public void removeListener(SliderListener l)
Removes the SliderListener

Parameters:
l - - SliderListener