Class NebulaSlider
- 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.nebulaslider.NebulaSlider
-
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class NebulaSlider extends org.eclipse.swt.widgets.Canvas
Instances of this class are selectable user interface objects that represent a range of positive, numeric values. It is like an horizontal slider- Styles:
- (None)
- Events:
- Selection
-
-
Field Summary
Fields Modifier and Type Field Description private org.eclipse.swt.graphics.Color
arrowColor
private static int
BAR_HEIGHT
private org.eclipse.swt.graphics.Color
barBorderColor
private org.eclipse.swt.graphics.Color
barInsideColor
private org.eclipse.swt.graphics.Color
barSelectionColor
private static int
H_MARGIN
private int
maximum
private int
minimum
private int
mouseDeltaX
private boolean
moving
private java.util.List<org.eclipse.swt.events.SelectionListener>
selectionListeners
private static int
SELECTOR_HEIGHT
private static int
SELECTOR_WIDTH
private org.eclipse.swt.graphics.Color
selectorColor
private org.eclipse.swt.graphics.Color
selectorColorBorder
private org.eclipse.swt.graphics.Color
selectorTextColor
private org.eclipse.swt.graphics.Font
textFont
private int
value
private int
xPosition
-
Constructor Summary
Constructors Constructor Description NebulaSlider(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(int eventType, org.eclipse.swt.widgets.Listener listener)
private void
addMouseListeners()
void
addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in theSelectionListener
interface.private static int
checkStyle(int style)
org.eclipse.swt.graphics.Point
computeSize(int wHint, int hHint, boolean changed)
private int
computeXPosition()
private org.eclipse.swt.graphics.Font
createTextFont()
private void
drawBar(org.eclipse.swt.graphics.GC gc)
private void
drawSelectionPart(org.eclipse.swt.graphics.GC gc)
private void
drawSelector(org.eclipse.swt.graphics.GC gc)
private void
fireSelectionEvent()
private org.eclipse.swt.graphics.Color
getAndDisposeColor(int r, int g, int b)
int
getMaximum()
Returns the maximum value which the receiver will allow.int
getMinimum()
Returns the minimum value which the receiver will allow.int
getValue()
Returns the receiver's value.private void
paintControl(org.eclipse.swt.graphics.GC gc)
void
removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the control is selected by the user.void
setMaximum(int maximum)
Sets the maximum value.void
setMinimum(int minimum)
Sets the minimum value.void
setValue(int value)
Sets the receiver's value.-
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
-
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, isAutoScalable, 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, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
-
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
-
-
-
-
Field Detail
-
H_MARGIN
private static final int H_MARGIN
- See Also:
- Constant Field Values
-
SELECTOR_WIDTH
private static final int SELECTOR_WIDTH
- See Also:
- Constant Field Values
-
BAR_HEIGHT
private static final int BAR_HEIGHT
- See Also:
- Constant Field Values
-
SELECTOR_HEIGHT
private static final int SELECTOR_HEIGHT
- See Also:
- Constant Field Values
-
barInsideColor
private final org.eclipse.swt.graphics.Color barInsideColor
-
barBorderColor
private final org.eclipse.swt.graphics.Color barBorderColor
-
barSelectionColor
private final org.eclipse.swt.graphics.Color barSelectionColor
-
selectorColor
private final org.eclipse.swt.graphics.Color selectorColor
-
selectorColorBorder
private final org.eclipse.swt.graphics.Color selectorColorBorder
-
selectorTextColor
private final org.eclipse.swt.graphics.Color selectorTextColor
-
arrowColor
private final org.eclipse.swt.graphics.Color arrowColor
-
minimum
private int minimum
-
maximum
private int maximum
-
value
private int value
-
xPosition
private int xPosition
-
mouseDeltaX
private int mouseDeltaX
-
selectionListeners
private final java.util.List<org.eclipse.swt.events.SelectionListener> selectionListeners
-
textFont
private final org.eclipse.swt.graphics.Font textFont
-
moving
private boolean moving
-
-
Constructor Detail
-
NebulaSlider
public NebulaSlider(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- 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
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
- See Also:
Widget.getStyle()
-
-
Method Detail
-
checkStyle
private static int checkStyle(int style)
-
getAndDisposeColor
private org.eclipse.swt.graphics.Color getAndDisposeColor(int r, int g, int b)
-
createTextFont
private org.eclipse.swt.graphics.Font createTextFont()
-
paintControl
private void paintControl(org.eclipse.swt.graphics.GC gc)
-
drawBar
private void drawBar(org.eclipse.swt.graphics.GC gc)
-
drawSelectionPart
private void drawSelectionPart(org.eclipse.swt.graphics.GC gc)
-
computeXPosition
private int computeXPosition()
-
drawSelector
private void drawSelector(org.eclipse.swt.graphics.GC gc)
-
addMouseListeners
private void addMouseListeners()
-
fireSelectionEvent
private void fireSelectionEvent()
-
addListener
public void addListener(int eventType, org.eclipse.swt.widgets.Listener listener)
- Overrides:
addListener
in classorg.eclipse.swt.widgets.Widget
- See Also:
Widget.addListener(int, org.eclipse.swt.widgets.Listener)
-
addSelectionListener
public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in theSelectionListener
interface.widgetDefaultSelected
is not called.- Parameters:
listener
- the listener which should be notified when the control is selected by the user,- 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)
,SelectionEvent
-
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)
-
removeSelectionListener
public void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the control is selected by the user.- 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)
-
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
-
setMinimum
public void setMinimum(int minimum)
Sets the minimum value. If this value is greater than the maximum, an exception is thrown- Parameters:
value
- the new 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
-
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
-
setMaximum
public void setMaximum(int maximum)
Sets the maximum value. If this value is lower than the minimum, an exception is thrown- Parameters:
value
- the new 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
-
getValue
public int getValue()
Returns the receiver's value.- 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
-
setValue
public void setValue(int value)
Sets the receiver's value. If the value is lower to minimum or greater than the maximum, an exception is thrown- Parameters:
value
- the new selection (must be zero or greater)- 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
-
-