Class RangeSlider
java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.swt.widgets.Canvas
org.eclipse.nebula.widgets.opal.rangeslider.RangeSlider
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class RangeSlider
extends org.eclipse.swt.widgets.Canvas
Instances of this class provide a slider with two thumbs to control lower and
upper integer values.
- Styles:
- BORDER
- HORIZONTAL
- VERTICAL
- CONTROL - Allow key and mouse manipulation to control both lower and upper value thumbs simultaneously
- ON - Indicates that selection listeners are notified continuously during thumb drag events. Otherwise, notification occurs only after the drag event terminates.
- HIGH - Indicates high quality tick marks are generated dynamically to a factor of the pageIncrement or increment. Otherwise, tick marks divide the scale evenly into ten parts.
- SMOOTH - Indicates mouse manipulation of upper and lower values are computed smoothly from the exact mouse cursor position disregarding the increment value. Otherwise, values are constrained to an incremental value.
- Events:
- Selection
Note: Styles HORIZONTAL and VERTICAL are mutually exclusive.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description RangeSlider(org.eclipse.swt.widgets.Composite parent, int style)
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance. -
Method Summary
Modifier and Type Method Description void
addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Adds the listener to the collection of listeners who will be notified when the user changes the receiver's value, by sending it one of the messages defined in theSelectionListener
interface.org.eclipse.swt.graphics.Point
computeSize(int wHint, int hHint, boolean changed)
int
getIncrement()
Returns the amount that the selected receiver's value will be modified by when the up/down (or right/left) arrows are pressed.int
getLowerValue()
Returns the 'lower selection', which is the lower receiver's position.int
getMaximum()
Returns the maximum value which the receiver will allow.int
getMinimum()
Returns the minimum value which the receiver will allow.int
getPageIncrement()
Returns the amount that the selected receiver's value will be modified by when the page increment/decrement areas are selected.int[]
getSelection()
Returns the 'selection', which is an array where the first element is the lower selection, and the second element is the upper selectionint
getStyle()
int
getUpperValue()
Returns the 'upper selection', which is the upper receiver's position.void
removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the user changes the receiver's value.void
setExtrema(int min, int max)
Sets the minimum and maximum values that the receiver will allow.void
setIncrement(int increment)
Sets the amount that the selected receiver's value will be modified by when the up/down (or right/left) arrows are pressed to the argument, which must be at least one.void
setLowerValue(int value)
Sets the 'lower selection', which is the receiver's lower value, to the input argument which must be less than or equal to the current 'upper selection' and greater or equal to the minimum.void
setMaximum(int value)
Sets the maximum value that the receiver will allow.void
setMinimum(int value)
Sets the minimum value that the receiver will allow.void
setPageIncrement(int pageIncrement)
Sets the amount that the receiver's value will be modified by when the page increment/decrement areas are selected to the argument, which must be at least one.void
setSelection(int[] values)
Sets the 'selection', which is the receiver's value.void
setSelection(int lowerValue, int upperValue)
Sets the 'selection', which is the receiver's value.protected void
setTickFactors()
reset the tickDivisions, tickFactor, and stride values according to current size. if the current size is less than 40, no tick marks are produced.protected void
setTickFactors(float breadth)
reset the tickDivisions, tickFactor, and stride values according to the input breadth. we generate at least ten divisions, but fewer if the ticks are too compact. some factor of pageIncrement is the preferred tick division. if too few ticks are generated from pageIncrement then increment is used. if too few ticks are generated from increment some smaller value is used if style is SMOOTH.void
setToolTipFormatter(java.text.Format formatter)
a formatter for displaying a tool tip when hovering over the scale and during thumb modification events.void
setToolTipText(java.lang.String string)
void
setUpperValue(int value)
Sets the 'upper selection', which is the upper receiver's value, to the input argument which must be greater than or equal to the current 'lower selection' and less or equal to the maximum.Methods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIME
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toString
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData
-
Constructor Details
-
RangeSlider
public RangeSlider(org.eclipse.swt.widgets.Composite parent, int style)Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.The style value is either one of the style constants defined in class
SWT
which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using theint
"|" operator) two or more of thoseSWT
style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.- Parameters:
parent
- a composite control which will be the parent of the new instance (cannot be null)style
- the style of control to construct. Default style is HORIZONTAL- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.SWTException
-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- See Also:
SWT.HORIZONTAL
,SWT.VERTICAL
,Widget.getStyle()
-
-
Method Details
-
setTickFactors
protected void setTickFactors()reset the tickDivisions, tickFactor, and stride values according to current size. if the current size is less than 40, no tick marks are produced. -
setTickFactors
protected void setTickFactors(float breadth)reset the tickDivisions, tickFactor, and stride values according to the input breadth. we generate at least ten divisions, but fewer if the ticks are too compact. some factor of pageIncrement is the preferred tick division. if too few ticks are generated from pageIncrement then increment is used. if too few ticks are generated from increment some smaller value is used if style is SMOOTH. -
getStyle
public int getStyle()- Overrides:
getStyle
in classorg.eclipse.swt.widgets.Widget
-
setToolTipFormatter
public void setToolTipFormatter(java.text.Format formatter)a formatter for displaying a tool tip when hovering over the scale and during thumb modification events. TheFormat.format(Object, StringBuffer, java.text.FieldPosition)
method is invoked to retrieve the text for the tooltip where the inputObject
is anInteger
with a value within the minimum and maximum.- Parameters:
formatter
-
-
setToolTipText
public void setToolTipText(java.lang.String string)- Overrides:
setToolTipText
in classorg.eclipse.swt.widgets.Control
-
addSelectionListener
public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)Adds the listener to the collection of listeners who will be notified when the user changes the receiver's value, by sending it one of the messages defined in theSelectionListener
interface.widgetSelected
is called when the user changes the receiver's value.widgetDefaultSelected
is not called.- Parameters:
listener
- the listener which should be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
SelectionListener
,removeSelectionListener(org.eclipse.swt.events.SelectionListener)
-
computeSize
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)- Overrides:
computeSize
in classorg.eclipse.swt.widgets.Control
- See Also:
Control.computeSize(int, int, boolean)
-
getIncrement
public int getIncrement()Returns the amount that the selected receiver's value will be modified by when the up/down (or right/left) arrows are pressed.- Returns:
- the increment
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getLowerValue
public int getLowerValue()Returns the 'lower selection', which is the lower receiver's position.- Returns:
- the selection
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getMaximum
public int getMaximum()Returns the maximum value which the receiver will allow.- Returns:
- the maximum
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getMinimum
public int getMinimum()Returns the minimum value which the receiver will allow.- Returns:
- the minimum
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getPageIncrement
public int getPageIncrement()Returns the amount that the selected receiver's value will be modified by when the page increment/decrement areas are selected.- Returns:
- the page increment
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getSelection
public int[] getSelection()Returns the 'selection', which is an array where the first element is the lower selection, and the second element is the upper selection- Returns:
- the selection
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getUpperValue
public int getUpperValue()Returns the 'upper selection', which is the upper receiver's position.- Returns:
- the selection
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
removeSelectionListener
public void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)Removes the listener from the collection of listeners who will be notified when the user changes the receiver's value.- Parameters:
listener
- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
SelectionListener
,addSelectionListener(org.eclipse.swt.events.SelectionListener)
-
setIncrement
public void setIncrement(int increment)Sets the amount that the selected receiver's value will be modified by when the up/down (or right/left) arrows are pressed to the argument, which must be at least one.- Parameters:
increment
- the new increment (must be greater than zero)- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setLowerValue
public void setLowerValue(int value)Sets the 'lower selection', which is the receiver's lower value, to the input argument which must be less than or equal to the current 'upper selection' and greater or equal to the minimum. If either condition fails, no action is taken.- Parameters:
value
- the new lower selection- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
getUpperValue()
,getMinimum()
,setSelection(int, int)
-
setMaximum
public void setMaximum(int value)Sets the maximum value that the receiver will allow. This new value will be ignored if it is not greater than the receiver's current minimum value. If the new maximum is applied then the receiver's selection value will be adjusted if necessary to fall within its new range.- Parameters:
value
- the new maximum, which must be greater than the current minimum- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
setExtrema(int, int)
-
setMinimum
public void setMinimum(int value)Sets the minimum value that the receiver will allow. This new value will be ignored if it is negative or is not less than the receiver's current maximum value. If the new minimum is applied then the receiver's selection value will be adjusted if necessary to fall within its new range.- Parameters:
value
- the new minimum, which must be nonnegative and less than the current maximum- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
setExtrema(int, int)
-
setExtrema
public void setExtrema(int min, int max)Sets the minimum and maximum values that the receiver will allow. The new values will be ignored if either are negative or the min value is not less than the max. The receiver's selection values will be adjusted if necessary to fall within the new range.- Parameters:
min
- the new minimum, which must be nonnegative and less than the maxmax
- the new maximum, which must be greater than the min- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setPageIncrement
public void setPageIncrement(int pageIncrement)Sets the amount that the receiver's value will be modified by when the page increment/decrement areas are selected to the argument, which must be at least one.- Parameters:
pageIncrement
- the page increment (must be greater than zero)- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setSelection
public void setSelection(int[] values)Sets the 'selection', which is the receiver's value. The lower value must be less than or equal to the upper value. Additionally, both values must be inclusively between the slider minimum and maximum. If either condition fails, no action is taken.- Parameters:
value
- the new selection (first value is lower value, second value is upper value)- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setSelection
public void setSelection(int lowerValue, int upperValue)Sets the 'selection', which is the receiver's value. The lower value must be less than or equal to the upper value. Additionally, both values must be inclusively between the slider minimum and maximum. If either condition fails, no action is taken.- Parameters:
lowerValue
- the new lower selectionupperValue
- the new upper selection- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
getMinimum()
,getMaximum()
-
setUpperValue
public void setUpperValue(int value)Sets the 'upper selection', which is the upper receiver's value, to the input argument which must be greater than or equal to the current 'lower selection' and less or equal to the maximum. If either condition fails, no action is taken.- Parameters:
value
- the new upper selection- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
getLowerValue()
,getMaximum()
,setSelection(int, int)
-