Class BaseTileBoard

  • All Implemented Interfaces:
    IColorPicker, org.eclipse.swt.graphics.Drawable
    Direct Known Subclasses:
    CustomTileBoardWidget, PredefinedTileBoardWidget

    public class BaseTileBoard
    extends org.eclipse.swt.widgets.Canvas
    implements IColorPicker
    This is a base class for a concrete tile board. It renders the provided array of colors as a board filled with color tiles. It deals mouse selection events and keyboard navigation events. The widget informs its clients with ColorChangedEvent on color selection. Alternatively, one can use JFace data binding. Then, perhaps ColorObservables#observeColorWidget(IColorPicker) will be useful.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Integer[] rgbColors
      The colors in integer form that fill the board of tiles
      protected int selectedIdx
      Index into rgbColors, which tracks the selection
      • Fields inherited from class org.eclipse.swt.widgets.Control

        handle
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected BaseTileBoard​(org.eclipse.swt.widgets.Composite parent, int style, Integer[] rgbColors, int columns)
      Constructs a new instance of BaseTileBoard with the given array of colors and number of columns
    • 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.
      org.eclipse.swt.graphics.Point computeSize​(int wHint, int hHint, boolean changed)
      Calculates the space necessary to display the widget, according to the length of rgbColors and columns
      protected ColorChangedEvent createColorChangedEvent()
      Creates a new event to notify controls clients of a color change.
      void fillColorArray​(Integer[] newValues)
      Redefines the displayed colors
      org.eclipse.swt.graphics.RGB getValue()
      Returns the color of currently selected tile.
      void removeColorChangedEventListener​(ColorChangedEventListener eventListener)  
      protected void select​(int value)
      Sets selectedIdx to the given value.
      void setValue​(org.eclipse.swt.graphics.RGB rgb)
      Tries to select a tile with the color given in rgb argument.
      • 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, 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
      • Methods inherited from interface org.eclipse.swt.graphics.Drawable

        isAutoScalable
    • Field Detail

      • rgbColors

        protected final Integer[] rgbColors
        The colors in integer form that fill the board of tiles
      • selectedIdx

        protected int selectedIdx
        Index into rgbColors, which tracks the selection
    • Constructor Detail

      • BaseTileBoard

        protected BaseTileBoard​(org.eclipse.swt.widgets.Composite parent,
                                int style,
                                Integer[] rgbColors,
                                int columns)
        Constructs a new instance of BaseTileBoard with the given array of colors and number of columns
        Parameters:
        parent - described in Canvas
        style - described in Canvas
        rgbColors - the colors that have to be shown
        columns - number of columns the tile board must have
    • Method Detail

      • computeSize

        public org.eclipse.swt.graphics.Point computeSize​(int wHint,
                                                          int hHint,
                                                          boolean changed)
        Calculates the space necessary to display the widget, according to the length of rgbColors and columns
        Overrides:
        computeSize in class org.eclipse.swt.widgets.Control
      • getValue

        public org.eclipse.swt.graphics.RGB getValue()
        Returns the color of currently selected tile. Or black, if it is impossible.
        Specified by:
        getValue in interface IColorPicker
      • setValue

        public void setValue​(org.eclipse.swt.graphics.RGB rgb)
        Tries to select a tile with the color given in rgb argument. If none is was found, selection is lost.
        Specified by:
        setValue in interface IColorPicker
      • addColorChangedEventListener

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

        public void fillColorArray​(Integer[] newValues)
        Redefines the displayed colors
        Parameters:
        tmpArray - the array that contains new colors
      • select

        protected void select​(int value)
        Sets selectedIdx to the given value. Causes the necessary redrawing.
      • createColorChangedEvent

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