org.gwtbootstrap3.extras.slider.client.ui.base
Class SliderBase<T>

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by org.gwtbootstrap3.extras.slider.client.ui.base.SliderBase<T>
Type Parameters:
T - slider value type
All Implemented Interfaces:
IsEditor<LeafValueEditor<T>>, HasAttachHandlers, HasValueChangeHandlers<T>, HasHandlers, EventListener, TakesValue<T>, HasEnabled, HasValue<T>, HasVisibility, IsWidget, org.gwtbootstrap3.client.ui.base.HasId, org.gwtbootstrap3.client.ui.base.HasResponsiveness, HasAllSlideHandlers<T>, HasSlideDisabledHandlers, HasSlideEnabledHandlers, HasSlideHandlers<T>, HasSlideStartHandlers<T>, HasSlideStopHandlers<T>
Direct Known Subclasses:
RangeSlider, Slider

public abstract class SliderBase<T>
extends Widget
implements HasValue<T>, IsEditor<LeafValueEditor<T>>, HasEnabled, org.gwtbootstrap3.client.ui.base.HasId, org.gwtbootstrap3.client.ui.base.HasResponsiveness, HasAllSlideHandlers<T>

Author:
Xiaodong Sun
See Also:
https://github.com/seiyria/bootstrap-slider

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Fields inherited from interface org.gwtbootstrap3.extras.slider.client.ui.base.event.HasAllSlideHandlers
SLIDE_CHANGE_EVENT, SLIDE_DISABLED_EVENT, SLIDE_ENABLED_EVENT, SLIDE_EVENT, SLIDE_START_EVENT, SLIDE_STOP_EVENT
 
Constructor Summary
protected SliderBase()
           
 
Method Summary
 HandlerRegistration addSlideDisabledHandler(SlideDisabledHandler handler)
          Adds a SlideDisabledEvent handler.
 HandlerRegistration addSlideEnabledHandler(SlideEnabledHandler handler)
          Adds a SlideEnabledEvent handler.
 HandlerRegistration addSlideHandler(SlideHandler<T> handler)
          Adds a SlideEvent handler.
 HandlerRegistration addSlideStartHandler(SlideStartHandler<T> handler)
          Adds a SlideStartEvent handler.
 HandlerRegistration addSlideStopHandler(SlideStopHandler<T> handler)
          Adds a SlideStopEvent handler.
 HandlerRegistration addValueChangeHandler(ValueChangeHandler<T> handler)
           
 LeafValueEditor<T> asEditor()
           
protected abstract  T convertValue(String value)
          Converts the value of the SliderOption.VALUE attribute to the slider value.
protected  void fireChangeEvent(T value)
          Fires a ValueChangeEvent event.
protected  void fireSlideEvent(T value)
          Fires a SlideEvent event.
protected  void fireSlideStartEvent(T value)
          Fires a SlideStartEvent event.
protected  void fireSlideStopEvent(T value)
          Fires a SlideStopEvent event.
 HandleType getHandle()
           
 String getId()
           
 double getMax()
           
 double getMin()
           
 OrientationType getOrientation()
           
 double getPrecision()
           
 ScaleType getScale()
           
 SelectionType getSelection()
           
 double getStep()
           
 List<Double> getTicks()
           
 List<String> getTicksLabels()
           
 double getTicksSnapBounds()
           
 TooltipType getTooltip()
           
 T getValue()
           
protected abstract  T getValue(Element e)
          Returns the value by invoking the JSNI getValue command.
 boolean isEnabled()
           
 boolean isNaturalArrowKeys()
           
protected  boolean isRange()
           
 boolean isReversed()
           
 boolean isTooltipSplit()
           
 boolean isVisible()
           
protected  void onLoad()
           
protected abstract  void onSlide(Event event)
          Called when a SlideEvent is fired.
protected abstract  void onSlideChange(Event event)
          Called when a ValueChangeEvent is fired.
protected abstract  void onSlideStart(Event event)
          Called when a SlideStartEvent is fired.
protected abstract  void onSlideStop(Event event)
          Called when a SlideStopEvent is fired.
protected  void onUnload()
           
 void refresh()
          Refreshes the current slider.
 void relayout()
          Renders the tool-tip again, after initialization.
 void setEnabled(boolean enabled)
           
 void setFormatter(FormatterCallback formatterCallback)
          Sets the formatter callback.
 void setHandle(HandleType handle)
          Sets the handle shape.
 void setHiddenOn(org.gwtbootstrap3.client.ui.constants.DeviceSize deviceSize)
           
 void setId(String id)
          Sets the id of the slider element when it's created.
 void setMax(double max)
          Sets the maximum possible value.
 void setMin(double min)
          Sets the minimum possible value.
 void setNaturalArrowKeys(boolean naturalArrowKeys)
          The natural order is used for the arrow keys.
 void setOrientation(OrientationType orientation)
          Sets the orientation.
 void setPrecision(double precision)
          Sets the number of digits shown after the decimal.

Defaults to the number of digits after the decimal of step value.
protected  void setRange(boolean range)
          Make range slider if set to true.
 void setReversed(boolean reversed)
          Sets whether or not the slider should be reversed.
 void setScale(ScaleType scale)
          Sets the slider scale type.
 void setSelection(SelectionType selection)
          Sets the selection type.
 void setStep(double step)
          Sets the increment step.
 void setTicks(List<Double> ticks)
          Sets the values of ticks.
 void setTicksLabels(List<String> ticksLabels)
          Sets the labels below the tick marks.

Accepts HTML input.
 void setTicksSnapBounds(double ticksSnapBounds)
          Sets the snap bounds of a tick.
 void setTooltip(TooltipType tooltip)
          Sets the tool-tip type.
 void setTooltipSplit(boolean tooltipSplit)
          Show one too-tip if set to false, otherwise show two tool-tips one for each handler.
protected abstract  void setValue(Element e, T value)
          Sets the given value to the slider.
 void setValue(T value)
           
 void setValue(T value, boolean fireEvents)
           
 void setVisible(boolean visible)
           
 void setVisibleOn(org.gwtbootstrap3.client.ui.constants.DeviceSize deviceSize)
           
 void toggle()
          Toggles the slider between enabled and disabled.
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setWidth, sinkBitlessEvent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Constructor Detail

SliderBase

protected SliderBase()
Method Detail

onLoad

protected void onLoad()
Overrides:
onLoad in class Widget

onUnload

protected void onUnload()
Overrides:
onUnload in class Widget

setId

public void setId(String id)
Sets the id of the slider element when it's created.

Specified by:
setId in interface org.gwtbootstrap3.client.ui.base.HasId

getId

public String getId()
Specified by:
getId in interface org.gwtbootstrap3.client.ui.base.HasId

getMin

public double getMin()

setMin

public void setMin(double min)
Sets the minimum possible value.

Parameters:
min -

getMax

public double getMax()

setMax

public void setMax(double max)
Sets the maximum possible value.

Parameters:
max -

getStep

public double getStep()

setStep

public void setStep(double step)
Sets the increment step.

Parameters:
step -

getPrecision

public double getPrecision()

setPrecision

public void setPrecision(double precision)
Sets the number of digits shown after the decimal.

Defaults to the number of digits after the decimal of step value.

Parameters:
precision -

getOrientation

public OrientationType getOrientation()

setOrientation

public void setOrientation(OrientationType orientation)
Sets the orientation.

Parameters:
orientation -
See Also:
OrientationType

isRange

protected boolean isRange()

setRange

protected void setRange(boolean range)
Make range slider if set to true. If initial value is scalar, max will be used for second value.

Parameters:
range -

getSelection

public SelectionType getSelection()

setSelection

public void setSelection(SelectionType selection)
Sets the selection type.

Parameters:
selection -
See Also:
SelectionType

getTooltip

public TooltipType getTooltip()

setTooltip

public void setTooltip(TooltipType tooltip)
Sets the tool-tip type.

Parameters:
tooltip -
See Also:
TooltipType

isTooltipSplit

public boolean isTooltipSplit()

setTooltipSplit

public void setTooltipSplit(boolean tooltipSplit)
Show one too-tip if set to false, otherwise show two tool-tips one for each handler.

Parameters:
tooltipSplit -

getHandle

public HandleType getHandle()

setHandle

public void setHandle(HandleType handle)
Sets the handle shape.

Parameters:
handle -
See Also:
HandleType

isReversed

public boolean isReversed()

setReversed

public void setReversed(boolean reversed)
Sets whether or not the slider should be reversed.

Parameters:
reversed -

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface HasEnabled

setEnabled

public void setEnabled(boolean enabled)
Specified by:
setEnabled in interface HasEnabled

setFormatter

public void setFormatter(FormatterCallback formatterCallback)
Sets the formatter callback.

Parameters:
formatterCallback -

isNaturalArrowKeys

public boolean isNaturalArrowKeys()

setNaturalArrowKeys

public void setNaturalArrowKeys(boolean naturalArrowKeys)
The natural order is used for the arrow keys. Arrow up select the upper slider value for vertical sliders, arrow right the righter slider value for a horizontal slider ; no matter if the slider was reversed or not.

By default the arrow keys are oriented by arrow up/right to the higher slider value, arrow down/left to the lower slider value.

Parameters:
naturalArrowKeys -

getTicks

public List<Double> getTicks()

setTicks

public void setTicks(List<Double> ticks)
Sets the values of ticks. Tick marks are indicators to denote special values in the range.

This option overwrites min and max options.

Parameters:
ticks -

getTicksLabels

public List<String> getTicksLabels()

setTicksLabels

public void setTicksLabels(List<String> ticksLabels)
Sets the labels below the tick marks.

Accepts HTML input.

Parameters:
ticksLabels -

getTicksSnapBounds

public double getTicksSnapBounds()

setTicksSnapBounds

public void setTicksSnapBounds(double ticksSnapBounds)
Sets the snap bounds of a tick. Snaps to the tick if value is within these bounds.

Parameters:
ticksSnapBounds -

getScale

public ScaleType getScale()

setScale

public void setScale(ScaleType scale)
Sets the slider scale type.

Parameters:
scale -
See Also:
ScaleType

setVisible

public void setVisible(boolean visible)
Specified by:
setVisible in interface HasVisibility
Overrides:
setVisible in class UIObject

isVisible

public boolean isVisible()
Specified by:
isVisible in interface HasVisibility
Overrides:
isVisible in class UIObject

setVisibleOn

public void setVisibleOn(org.gwtbootstrap3.client.ui.constants.DeviceSize deviceSize)
Specified by:
setVisibleOn in interface org.gwtbootstrap3.client.ui.base.HasResponsiveness

setHiddenOn

public void setHiddenOn(org.gwtbootstrap3.client.ui.constants.DeviceSize deviceSize)
Specified by:
setHiddenOn in interface org.gwtbootstrap3.client.ui.base.HasResponsiveness

setValue

public void setValue(T value)
Specified by:
setValue in interface TakesValue<T>
Specified by:
setValue in interface HasValue<T>

setValue

public void setValue(T value,
                     boolean fireEvents)
Specified by:
setValue in interface HasValue<T>

setValue

protected abstract void setValue(Element e,
                                 T value)
Sets the given value to the slider. This method is only relevant if the slider has been initialized and it will NOT fire the slide event.

Parameters:
e -
value -

getValue

public T getValue()
Specified by:
getValue in interface TakesValue<T>
Specified by:
getValue in interface HasValue<T>

getValue

protected abstract T getValue(Element e)
Returns the value by invoking the JSNI getValue command.

Parameters:
e -
Returns:

convertValue

protected abstract T convertValue(String value)
Converts the value of the SliderOption.VALUE attribute to the slider value.

Parameters:
value -
Returns:

toggle

public void toggle()
Toggles the slider between enabled and disabled.


refresh

public void refresh()
Refreshes the current slider. This method does nothing if the slider has not been initialized.


relayout

public void relayout()
Renders the tool-tip again, after initialization. Useful in situations when the slider and tool-tip are initially hidden.


asEditor

public LeafValueEditor<T> asEditor()
Specified by:
asEditor in interface IsEditor<LeafValueEditor<T>>

addValueChangeHandler

public HandlerRegistration addValueChangeHandler(ValueChangeHandler<T> handler)
Specified by:
addValueChangeHandler in interface HasValueChangeHandlers<T>

addSlideHandler

public HandlerRegistration addSlideHandler(SlideHandler<T> handler)
Description copied from interface: HasSlideHandlers
Adds a SlideEvent handler.

Specified by:
addSlideHandler in interface HasSlideHandlers<T>
Parameters:
handler - the handler
Returns:
the registration for the event

addSlideStartHandler

public HandlerRegistration addSlideStartHandler(SlideStartHandler<T> handler)
Description copied from interface: HasSlideStartHandlers
Adds a SlideStartEvent handler.

Specified by:
addSlideStartHandler in interface HasSlideStartHandlers<T>
Parameters:
handler - the handler
Returns:
the registration for the event

addSlideStopHandler

public HandlerRegistration addSlideStopHandler(SlideStopHandler<T> handler)
Description copied from interface: HasSlideStopHandlers
Adds a SlideStopEvent handler.

Specified by:
addSlideStopHandler in interface HasSlideStopHandlers<T>
Parameters:
handler - the handler
Returns:
the registration for the event

addSlideEnabledHandler

public HandlerRegistration addSlideEnabledHandler(SlideEnabledHandler handler)
Description copied from interface: HasSlideEnabledHandlers
Adds a SlideEnabledEvent handler.

Specified by:
addSlideEnabledHandler in interface HasSlideEnabledHandlers
Parameters:
handler - the handler
Returns:
the registration for the event

addSlideDisabledHandler

public HandlerRegistration addSlideDisabledHandler(SlideDisabledHandler handler)
Description copied from interface: HasSlideDisabledHandlers
Adds a SlideDisabledEvent handler.

Specified by:
addSlideDisabledHandler in interface HasSlideDisabledHandlers
Parameters:
handler - the handler
Returns:
the registration for the event

onSlide

protected abstract void onSlide(Event event)
Called when a SlideEvent is fired.

Parameters:
event - the native event

fireSlideEvent

protected void fireSlideEvent(T value)
Fires a SlideEvent event.

Parameters:
value - the new slide value

onSlideStart

protected abstract void onSlideStart(Event event)
Called when a SlideStartEvent is fired.

Parameters:
event - the native event

fireSlideStartEvent

protected void fireSlideStartEvent(T value)
Fires a SlideStartEvent event.

Parameters:
value - the new slide value

onSlideStop

protected abstract void onSlideStop(Event event)
Called when a SlideStopEvent is fired.

Parameters:
event - the native event

fireSlideStopEvent

protected void fireSlideStopEvent(T value)
Fires a SlideStopEvent event.

Parameters:
value - the new slide value

onSlideChange

protected abstract void onSlideChange(Event event)
Called when a ValueChangeEvent is fired.

Parameters:
event - the native event

fireChangeEvent

protected void fireChangeEvent(T value)
Fires a ValueChangeEvent event.

Parameters:
value - the new slide value


Copyright © 2015. All rights reserved.