com.vaadin.ui
Class Slider

java.lang.Object
  extended by com.vaadin.ui.AbstractComponent
      extended by com.vaadin.ui.AbstractField
          extended by com.vaadin.ui.Slider
All Implemented Interfaces:
Buffered, BufferedValidatable, Property, Property.Editor, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, Action.ShortcutNotifier, MethodEventSource, Paintable, Sizeable, VariableOwner, Component, Component.Focusable, Field, Serializable, EventListener

public class Slider
extends AbstractField

A component for selecting a numerical value within a range. Example code: class MyPlayer extends CustomComponent implements ValueChangeListener { Label volumeIndicator = new Label(); Slider slider; public MyPlayer() { VerticalLayout vl = new VerticalLayout(); setCompositionRoot(vl); slider = new Slider("Volume", 0, 100); slider.setImmediate(true); slider.setValue(new Double(50)); vl.addComponent(slider); vl.addComponent(volumeIndicator); volumeIndicator.setValue("Current volume:" + 50.0); slider.addListener(this); } public void setVolume(double d) { volumeIndicator.setValue("Current volume: " + d); } public void valueChange(ValueChangeEvent event) { Double d = (Double) event.getProperty().getValue(); setVolume(d.doubleValue()); } }

Author:
IT Mill Ltd.
See Also:
Serialized Form

Nested Class Summary
 class Slider.ValueOutOfBoundsException
          ValueOutOfBoundsException
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractField
AbstractField.FocusShortcut, AbstractField.ReadOnlyStatusChangeEvent
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Field
Field.ValueChangeEvent
 
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered
Buffered.SourceException
 
Nested classes/interfaces inherited from interface com.vaadin.data.Property
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
 
Field Summary
static int ORIENTATION_HORIZONTAL
           
static int ORIENTATION_VERTICAL
           
static String STYLE_SCROLLBAR
          Deprecated. 
 
Constructor Summary
Slider()
          Default Slider constructor.
Slider(double min, double max, int resolution)
          Create a new slider with given range and resolution
Slider(int min, int max)
          Create a new slider with given range
Slider(String caption)
          Create a new slider with the caption given as parameter.
Slider(String caption, int min, int max)
          Create a new slider with given caption and range
 
Method Summary
 void changeVariables(Object source, Map variables)
          Invoked when the value of a variable has changed.
 int getHandleSize()
          Deprecated. The size is dictated by the current theme.
 double getMax()
          Gets the biggest possible value in Sliders range.
 double getMin()
          Gets the minimum value in Sliders range.
 int getOrientation()
          Get the current orientation of the Slider (horizontal or vertical).
 int getResolution()
          Get the current resolution of the Slider.
 int getSize()
          Deprecated. use standard getWidth/getHeight instead
 Class getType()
          Returns the type of the Property.
 void paintContent(PaintTarget target)
          Paints any needed component-specific things to the given UIDL stream.
 void setHandleSize(int handleSize)
          Deprecated. The size is dictated by the current theme.
 void setMax(double max)
          Set the maximum value of the Slider.
 void setMin(double min)
          Set the minimum value of the Slider.
 void setOrientation(int orientation)
          Set the orientation of the Slider.
 void setResolution(int resolution)
          Set a new resolution for the Slider.
 void setSize(int size)
          Deprecated. use standard setWidth/setHeight instead
 void setValue(double value)
          Set the value of this Slider.
 void setValue(Double value)
          Set the value of this Slider.
 void setValue(Double value, boolean repaintIsNotNeeded)
          Set the value of this Slider.
 
Methods inherited from class com.vaadin.ui.AbstractField
addListener, addListener, addShortcutListener, addValidator, attach, commit, constructField, detach, discard, fireReadOnlyStatusChange, fireValueChange, focus, getActionManager, getErrorMessage, getPropertyDataSource, getRequiredError, getTabIndex, getValidators, getValue, isEmpty, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isRequired, isValid, isValidationVisible, isWriteThrough, removeListener, removeListener, removeShortcutListener, removeValidator, setCurrentBufferedSourceException, setInternalValue, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setReadThrough, setRequired, setRequiredError, setTabIndex, setValidationVisible, setValue, setValue, setWriteThrough, toString, validate, valueChange
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addListener, addStyleName, childRequestedRepaint, fireComponentErrorEvent, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getHeight, getHeightUnits, getIcon, getLocale, getParent, getStyle, getStyleName, getTag, getWidth, getWidthUnits, getWindow, handleError, isEnabled, isImmediate, isVisible, paint, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeStyleName, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setHeight, setHeight, setHeightUnits, setIcon, setImmediate, setLocale, setParent, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidth, setWidth, setWidth, setWidthUnits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.Field
getDescription, setCaption, setDescription
 

Field Detail

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

STYLE_SCROLLBAR

@Deprecated
public static final String STYLE_SCROLLBAR
Deprecated. 
Style constant representing a scrollbar styled slider. Use this with AbstractComponent.addStyleName(String). Default styling usually represents a common slider found e.g. in Adobe Photoshop. The client side implementation dictates how different styles will look.

See Also:
Constant Field Values
Constructor Detail

Slider

public Slider()
Default Slider constructor. Sets all values to defaults and the slide handle at minimum value.


Slider

public Slider(String caption)
Create a new slider with the caption given as parameter. All slider values set to defaults.

Parameters:
caption - The caption for this Slider (e.g. "Volume").

Slider

public Slider(double min,
              double max,
              int resolution)
Create a new slider with given range and resolution

Parameters:
min -
max -
resolution -

Slider

public Slider(int min,
              int max)
Create a new slider with given range

Parameters:
min -
max -

Slider

public Slider(String caption,
              int min,
              int max)
Create a new slider with given caption and range

Parameters:
caption -
min -
max -
Method Detail

getMax

public double getMax()
Gets the biggest possible value in Sliders range.

Returns:
the biggest value slider can have

setMax

public void setMax(double max)
Set the maximum value of the Slider. If the current value of the Slider is out of new bounds, the value is set to new minimum.

Parameters:
max - New maximum value of the Slider.

getMin

public double getMin()
Gets the minimum value in Sliders range.

Returns:
the smalles value slider can have

setMin

public void setMin(double min)
Set the minimum value of the Slider. If the current value of the Slider is out of new bounds, the value is set to new minimum.

Parameters:
min - New minimum value of the Slider.

getOrientation

public int getOrientation()
Get the current orientation of the Slider (horizontal or vertical).

Returns:
orientation

setOrientation

public void setOrientation(int orientation)
Set the orientation of the Slider.

Parameters:
int - new orientation

getResolution

public int getResolution()
Get the current resolution of the Slider.

Returns:
resolution

setResolution

public void setResolution(int resolution)
Set a new resolution for the Slider.

Parameters:
resolution -

setValue

public void setValue(Double value,
                     boolean repaintIsNotNeeded)
              throws Slider.ValueOutOfBoundsException
Set the value of this Slider.

Parameters:
value - New value of Slider. Must be within Sliders range (min - max), otherwise throws an exception.
repaintIsNotNeeded - If true, client-side is not requested to repaint itself.
Throws:
Slider.ValueOutOfBoundsException

setValue

public void setValue(Double value)
              throws Slider.ValueOutOfBoundsException
Set the value of this Slider.

Parameters:
value - New value of Slider. Must be within Sliders range (min - max), otherwise throws an exception.
Throws:
Slider.ValueOutOfBoundsException

setValue

public void setValue(double value)
              throws Slider.ValueOutOfBoundsException
Set the value of this Slider.

Parameters:
value - New value of Slider. Must be within Sliders range (min - max), otherwise throws an exception.
Throws:
Slider.ValueOutOfBoundsException

getSize

@Deprecated
public int getSize()
Deprecated. use standard getWidth/getHeight instead

Get the current Slider size.

Returns:
size in pixels or -1 for auto sizing.

setSize

@Deprecated
public void setSize(int size)
Deprecated. use standard setWidth/setHeight instead

Set the size for this Slider.

Parameters:
size - in pixels, or -1 auto sizing.

getHandleSize

@Deprecated
public int getHandleSize()
Deprecated. The size is dictated by the current theme.

Get the handle size of this Slider.

Returns:
handle size in percentages.

setHandleSize

@Deprecated
public void setHandleSize(int handleSize)
Deprecated. The size is dictated by the current theme.

Set the handle size of this Slider.

Parameters:
handleSize - in percentages relative to slider base size.

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Description copied from class: AbstractComponent
Paints any needed component-specific things to the given UIDL stream. The more general AbstractComponent.paint(PaintTarget) method handles all general attributes common to all components, and it calls this method to paint any component-specific attributes to the UIDL stream.

Overrides:
paintContent in class AbstractField
Parameters:
target - the target UIDL stream where the component should paint itself to
Throws:
PaintException - if the paint operation failed.

changeVariables

public void changeVariables(Object source,
                            Map variables)
Invoked when the value of a variable has changed. Slider listeners are notified if the slider value has changed.

Specified by:
changeVariables in interface VariableOwner
Overrides:
changeVariables in class AbstractField
Parameters:
source -
variables -

getType

public Class getType()
Description copied from interface: Property
Returns the type of the Property. The methods getValue and setValue must be compatible with this type: one must be able to safely cast the value returned from getValue to the given type and pass any variable assignable to this type as an argument to setValue.

Specified by:
getType in interface Property
Specified by:
getType in class AbstractField
Returns:
type of the Property


Copyright © 2000-2010 IT Mill Ltd. All Rights Reserved.