public abstract class SliderBar extends com.google.gwt.user.client.ui.FocusPanel implements ResizableWidget, SourcesSliderEvents
Modifier and Type | Class and Description |
---|---|
protected class |
SliderBar.KeyTimer
The timer used to continue to shift the knob as the user holds down one of
the left/right arrow keys.
|
static class |
SliderBar.LabelFormatter
A formatter used to format the labels displayed in the widget.
|
Modifier and Type | Field and Description |
---|---|
protected double |
curValue
The current value.
|
protected com.google.gwt.user.client.ui.AbstractImagePrototype[] |
images
The images used with the sliding bar.
|
protected SliderBar.KeyTimer |
keyTimer
The timer used to continue to shift the knob if the user holds down a key.
|
protected com.google.gwt.user.client.ui.Image |
knobImage
The knob that slides across the line.
|
protected List |
labelElements
The elements used to display labels above the ticks.
|
protected SliderBar.LabelFormatter |
labelFormatter
The formatter used to generate label text.
|
protected com.google.gwt.user.client.Element |
lineElement
The line that the knob moves over.
|
protected int |
lineOffset
The offset between the edge of the shell and the line.
|
protected double |
maxValue
The maximum slider value.
|
protected double |
minValue
The minimum slider value.
|
protected int |
numLabels
The number of labels to show.
|
protected int |
numTicks
The number of tick marks to show.
|
protected SliderListenerCollection |
sliderListeners
A collection of widgets to notify on slider events.
|
protected boolean |
slidingKeyboard
A bit indicating whether or not we are currently sliding the slider bar due
to keyboard events.
|
protected boolean |
slidingMouse
A bit indicating whether or not we are currently sliding the slider bar due
to mouse events.
|
protected double |
stepSize
The size of the increments between knob positions.
|
protected String |
styleBaseName
The base name from which CSS style names for the slider are derived.
|
protected List |
tickElements
The elements used to display tick marks, which are the vertical lines along
the slider bar.
|
Constructor and Description |
---|
SliderBar() |
Modifier and Type | Method and Description |
---|---|
void |
addSliderListener(SliderListener listener)
Adds a listener interface to receive slider events.
|
protected abstract void |
drawKnob()
Draw the knob where it is supposed to be relative to the line.
|
protected abstract void |
drawLabels()
Draw the labels along the line.
|
protected abstract void |
drawTicks()
Draw the tick along the line.
|
protected String |
formatLabel(double value)
Format the label to display above the ticks
Override this method in a subclass to customize the format.
|
double |
getCurrentValue()
Return the current value.
|
protected double |
getKnobPercent()
Get the percentage of the knob's position relative to the size of the line.
|
SliderBar.LabelFormatter |
getLabelFormatter()
Return the label formatter.
|
double |
getMaxValue()
Return the max value.
|
double |
getMinValue()
Return the minimum value.
|
int |
getNumLabels()
Return the number of labels.
|
int |
getNumTicks()
Return the number of ticks.
|
double |
getStepSize()
Return the step size.
|
double |
getTotalRange()
Return the total range between the minimum and maximum values.
|
protected void |
highlight()
Highlight this widget.
|
protected void |
onLoad()
This method is called immediately after a widget becomes attached to the
browser's document.
|
void |
redraw()
Redraw the progress bar when something changes the layout.
|
void |
removeSliderListener(SliderListener listener)
Removes a previously added listener interface.
|
protected void |
resetCurrentValue()
Reset the progress to constrain the progress to the current range and
redraw the knob as needed.
|
void |
setCurrentValue(double curValue)
Set the current value and fire the onValueChange event.
|
void |
setCurrentValue(double curValue,
boolean fireEvent)
Set the current value and optionally fire the onValueChange event.
|
void |
setLabelFormatter(SliderBar.LabelFormatter labelFormatter)
Set the label formatter.
|
void |
setMaxValue(double maxValue)
Set the max value.
|
void |
setMinValue(double minValue)
Set the minimum value.
|
void |
setNumLabels(int numLabels)
Set the number of labels to show on the line.
|
void |
setNumTicks(int numTicks)
Set the number of ticks to show on the line.
|
void |
setStepSize(double stepSize)
Set the step size.
|
protected abstract void |
startSliding(boolean highlight,
boolean fireEvent)
Start sliding the knob.
|
protected abstract void |
stopSliding(boolean unhighlight,
boolean fireEvent)
Stop sliding the knob.
|
protected void |
unhighlight()
Unhighlight this widget.
|
addBlurHandler, addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addFocusHandler, addFocusListener, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addKeyboardListener, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, getTabIndex, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener, setAccessKey, setFocus, setTabIndex
add, getContainerElement, getWidget, iterator, remove, setWidget, setWidget
add, adopt, clear, doAttachChildren, doDetachChildren, orphan, remove
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getElement, isAttached, onResize
forEach, spliterator
protected double curValue
protected com.google.gwt.user.client.ui.AbstractImagePrototype[] images
protected com.google.gwt.user.client.ui.Image knobImage
protected SliderBar.KeyTimer keyTimer
protected List labelElements
protected SliderBar.LabelFormatter labelFormatter
protected com.google.gwt.user.client.Element lineElement
protected int lineOffset
protected double maxValue
protected double minValue
protected int numLabels
protected int numTicks
protected boolean slidingKeyboard
protected SliderListenerCollection sliderListeners
protected boolean slidingMouse
protected double stepSize
protected String styleBaseName
protected List tickElements
public void addSliderListener(SliderListener listener)
SourcesSliderEvents
addSliderListener
in interface SourcesSliderEvents
listener
- the listener interface to addpublic double getCurrentValue()
public SliderBar.LabelFormatter getLabelFormatter()
public double getMaxValue()
public double getMinValue()
public int getNumLabels()
public int getNumTicks()
public double getStepSize()
public double getTotalRange()
public void redraw()
public void removeSliderListener(SliderListener listener)
SourcesSliderEvents
removeSliderListener
in interface SourcesSliderEvents
listener
- the listener interface to removepublic void setCurrentValue(double curValue)
curValue
- the current valuepublic void setCurrentValue(double curValue, boolean fireEvent)
curValue
- the current valuefireEvent
- fire the onValue change event if truepublic void setLabelFormatter(SliderBar.LabelFormatter labelFormatter)
labelFormatter
- the label formatterpublic void setMaxValue(double maxValue)
maxValue
- the current valuepublic void setMinValue(double minValue)
minValue
- the current valuepublic void setNumLabels(int numLabels)
numLabels
- the number of labels to showpublic void setNumTicks(int numTicks)
numTicks
- the number of ticks to showpublic void setStepSize(double stepSize)
stepSize
- the current valueprotected abstract void drawKnob()
protected abstract void drawLabels()
protected abstract void drawTicks()
protected String formatLabel(double value)
value
- the value at the labelprotected double getKnobPercent()
protected void onLoad()
onLoad
in class com.google.gwt.user.client.ui.Widget
protected void highlight()
protected void resetCurrentValue()
protected abstract void startSliding(boolean highlight, boolean fireEvent)
highlight
- true to change the stylefireEvent
- true to fire the eventprotected abstract void stopSliding(boolean unhighlight, boolean fireEvent)
unhighlight
- true to change the stylefireEvent
- true to fire the eventprotected void unhighlight()
Copyright © 2017. All Rights Reserved.