Class ColorWheelWidget

  • All Implemented Interfaces:
    IColorPicker, org.eclipse.swt.graphics.Drawable

    public class ColorWheelWidget
    extends org.eclipse.swt.widgets.Canvas
    implements IColorPicker
    The class is an SWT widget for picking color from HSB space. It contains a color wheel for choosing hue and saturation and a slider for choosing brightness.
    The control provides the picked color in RGB form via getValue(). Also, it can be initialized or updated using an RGB object with ColorWheelWidget#setValue().
    To respond to a color selection (pick) one may use addColorChangedEventListener(ColorChangedEventListener).
    Alternatively, one can use JFace data binding. Then, perhaps ColorObservables#observeColorWidget(IColorPicker) will be useful.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  ColorWheelWidget.HSB
      The class represents a color using Hue, Saturation, Brightness color scheme.
      protected class  ColorWheelWidget.Slider
      This class represents brightness slider to pick a color from.
      protected class  ColorWheelWidget.Wheel
      This class represents hue and saturation color wheel to pick a color from.
    • Field Summary

      • Fields inherited from class org.eclipse.swt.widgets.Control

        handle
    • Constructor Summary

      Constructors 
      Constructor Description
      ColorWheelWidget​(org.eclipse.swt.widgets.Composite parent, int style, int radius)
      Constructs a new instance of ColorWheelWidget
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addColorChangedEventListener​(ColorChangedEventListener eventListener)
      Adds a listener to the color selection event.
      protected ColorChangedEvent createColorChangedEvent()
      Creates a new event to notify controls clients of a color change.
      protected ColorWheelWidget.Slider createSlider​(int wheelSize)
      Creates a slider representation to pick brightness from.
      protected ColorWheelWidget.Wheel createWheel​(int radius)
      Creates a color wheel representation to pick Hue and Saturation from.
      org.eclipse.swt.graphics.RGB getValue()
      Retrieves a Color object representing current value of the control.
      void removeColorChangedEventListener​(ColorChangedEventListener eventListener)  
      void setBackground​(org.eclipse.swt.graphics.Color color)  
      void setValue​(org.eclipse.swt.graphics.RGB rgb)
      Updates the recently selected color to the provided 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, 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, 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, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
      • Methods inherited from interface org.eclipse.swt.graphics.Drawable

        isAutoScalable
    • Constructor Detail

      • ColorWheelWidget

        public ColorWheelWidget​(org.eclipse.swt.widgets.Composite parent,
                                int style,
                                int radius)
        Constructs a new instance of ColorWheelWidget
        Parameters:
        radius - the radius of the color wheel; the sliders size is accommodated to wheels diameter
    • Method Detail

      • getValue

        public org.eclipse.swt.graphics.RGB getValue()
        Description copied from interface: IColorPicker
        Retrieves a Color object representing current value of the control.
        Specified by:
        getValue in interface IColorPicker
        Returns:
        the recently selected color in RGB form.
      • setValue

        public void setValue​(org.eclipse.swt.graphics.RGB rgb)
        Updates the recently selected color to the provided value. The method should be used to initialize the control or to update its value.
        Specified by:
        setValue in interface IColorPicker
      • addColorChangedEventListener

        public void addColorChangedEventListener​(ColorChangedEventListener eventListener)
        Adds a listener to the color selection event. The listener is notified when user changes the recent color using color wheel or slider.
      • setBackground

        public void setBackground​(org.eclipse.swt.graphics.Color color)
        Overrides:
        setBackground in class org.eclipse.swt.widgets.Control
      • createColorChangedEvent

        protected ColorChangedEvent createColorChangedEvent()
        Creates a new event to notify controls clients of a color change.
        Returns:
        a ColorChangedEvent object
      • createWheel

        protected ColorWheelWidget.Wheel createWheel​(int radius)
        Creates a color wheel representation to pick Hue and Saturation from.
        Parameters:
        radius - of the created wheel, in pixels
      • createSlider

        protected ColorWheelWidget.Slider createSlider​(int wheelSize)
        Creates a slider representation to pick brightness from.
        Parameters:
        wheelSize - size of the color wheel