Class 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
    • 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 the SelectionListener 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • 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 the int "|" operator) two or more of those SWT 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 class org.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 the SelectionListener 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 class org.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