Class ColorDiagramCanvas
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
com.iizigo.prop.editor.color.swt.ColorDiagramCanvas
- All Implemented Interfaces:
Drawable
A color diagram on a Canvas (CC-COLOR-CHOOSER-SWT-PANELS, 2026-10-10): the two-dimensional plane of two channels of a color model (saturation across, value or lightness up) at the current value of the third, or the one-dimensional vertical strip of the third channel (the hue). The image is computed from a plane function per zoom through an
ImageDataProvider, so a monitor at 200 % gets a 200 % image rather than a scaled one; it is rebuilt when the function changes (another hue) or the canvas is resized.A marker shows the position, a light ring between two dark ones in the theme's marker pair (ChooserColors, CC-FIX-COLOR-CHOOSER-DARK): a contrast pair over any color of the plane. Mouse button 1 and dragging move it and report the position; the arrow keys nudge it by a hundredth (Page Up and Down by a tenth); Tab leaves the canvas. Positions are in [0,1], y=0 at the bottom.
- Author:
- Christopher Mindus
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe function of the diagram.static interfaceA listener of position changes made by the user.Field Summary
Constructor Summary
ConstructorsConstructorDescriptionColorDiagramCanvas(Composite parent, ColorDiagramCanvas.IPlane plane, boolean isStrip, int width, int height, ChooserColors colors) Creates the diagram.Method Summary
Modifier and TypeMethodDescriptionvoidAdds a position listener.buildImageData(int width, int height, int zoom) Builds the image data of the diagram at a zoom.computeSize(int wHint, int hHint, boolean changed) floatgetX()Gets the marker position across,[0,1].floatgetY()Gets the marker position up,[0,1], 0 at the bottom.voidRebuilds the image at the next paint: the function's result changed (another hue).booleanisStrip()Checks if this is a strip.voidmoveTo(float x, float y) Moves the marker as the user does and notifies the listeners.voidRemoves a position listener.voidSets the function and rebuilds the image.voidsetPosition(float x, float y) Sets the marker position without notifying the listeners (the model changed elsewhere).voidsetPreferredSize(int width, int height) Sets the preferred size in points; the parent must lay out again.Methods inherited from class Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIMEMethods inherited from class Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, redraw, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toStringMethods inherited from class Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar, setScrollbarsModeMethods inherited from class 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, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setAutoscalingMode, 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, updateMethods inherited from class Widget
addDisposeListener, addListener, addTypedListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, getTypedListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, removeListener, removeTypedListener, reskin, setData, setDataMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Drawable
isAutoScalable
Constructor Details
ColorDiagramCanvas
public ColorDiagramCanvas(Composite parent, ColorDiagramCanvas.IPlane plane, boolean isStrip, int width, int height, ChooserColors colors) Creates the diagram.- Parameters:
parent- The parent.plane- The function.isStrip- true for a vertical one-dimensional strip, false for a plane.width- The preferred width in points.height- The preferred height in points.colors- The theme colors: the marker's light and dark rings.
Method Details
isStrip
public boolean isStrip()Checks if this is a strip.setPlane
Sets the function and rebuilds the image.invalidateImage
public void invalidateImage()Rebuilds the image at the next paint: the function's result changed (another hue).setPreferredSize
public void setPreferredSize(int width, int height) Sets the preferred size in points; the parent must lay out again.computeSize
- Overrides:
computeSizein classComposite
getX
public float getX()Gets the marker position across,[0,1].getY
public float getY()Gets the marker position up,[0,1], 0 at the bottom.setPosition
public void setPosition(float x, float y) Sets the marker position without notifying the listeners (the model changed elsewhere).addPositionListener
Adds a position listener.removePositionListener
Removes a position listener.moveTo
public void moveTo(float x, float y) Moves the marker as the user does and notifies the listeners.buildImageData
Builds the image data of the diagram at a zoom. Public for the test fragment, which is hosted by another bundle and so cannot see package-private members.- Parameters:
width- The width in points.height- The height in points.zoom- The zoom in percent.