Class ColorWheelPanel

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener

    public class ColorWheelPanel
    extends RadianceColorChooserPanel
    implements java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, javax.swing.event.ChangeListener
    A color wheel showing a Red, Yellow, Blue color model traditionally used by graphic artists. $Revision: 2254 $
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  ColorWheelPanel.ColorDocumentListener  
      (package private) class  ColorWheelPanel.ColorWheel
      A class that wraps the image of the color wheel and draws markers for the selected color scheme
      • Nested classes/interfaces inherited from class javax.swing.JPanel

        javax.swing.JPanel.AccessibleJPanel
      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Constructor Summary

      Constructors 
      Constructor Description
      ColorWheelPanel()
      Creates a new instance of ColorWheelPanel
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent e)
      Respond to action events for the edit fields
      void addChangeListener​(javax.swing.event.ChangeListener l)
      Add a listener for changes in the selected color
      protected void buildChooser()  
      int getAdjustWheel()
      Get the adjust color wheel flag.
      private int getAngle​(java.awt.Point pt)  
      int getBrightness()
      Get the selected colors brightness
      ModelColor getChooserColour()
      Get the chooser color
      java.awt.Color getColor()
      Get the selected color
      java.lang.String getDisplayName()  
      RadianceIcon getHiDpiAwareIcon​(int size, RadianceColorScheme colorScheme)  
      int getHue()
      Get the selected colors hue
      private static java.lang.String getLabel​(java.lang.String labelName, java.lang.String defaultValue)  
      java.awt.Dimension getPreferredSize()  
      boolean getRollover()
      Get the adjust rollover color flag.
      int getSaturation()
      Get the selected colors saturation
      java.awt.Color getSystemColor​(java.lang.String temp)
      Get the named system color
      void installChooserPanel​(javax.swing.JColorChooser enclosingChooser)  
      void mouseClicked​(java.awt.event.MouseEvent e)
      Invoked when the mouse button has been clicked (pressed and released) on a component.
      void mouseDragged​(java.awt.event.MouseEvent e)
      Invoked when the mouse exits a component.
      void mouseEntered​(java.awt.event.MouseEvent e)
      Invoked when the mouse enters a component.
      void mouseExited​(java.awt.event.MouseEvent e)
      Invoked when the mouse exits a component.
      void mouseMoved​(java.awt.event.MouseEvent e)
      Invoked when the mouse exits a component.
      void mousePressed​(java.awt.event.MouseEvent e)
      Invoked when a mouse button has been pressed on a component.
      void mouseReleased​(java.awt.event.MouseEvent e)
      Invoked when a mouse button has been released on a component.
      void mouseWheelMoved​(java.awt.event.MouseWheelEvent e)
      Move the sliders in rsponse to the mouse wheel
      (package private) boolean moveHue​(java.awt.Point pt)
      Change the hue to match the angle identified by the point (in the inner circle).
      void removeChangeListener​(javax.swing.event.ChangeListener l)
      Remove a change listener
      private void resetColor()
      Reset the displayed color to the color specified by the edit fields
      void resetColorWheel()
      Reset the brightness and saturation multipliers for the ColorWheel.
      void setAdjustWheel​(int state)
      Set the adjust color wheel flag.
      private void setBrightness()
      Set the value of the brightness edit to match the current color
      void setColor​(java.awt.Color c)  
      void setColorScheme​(int scheme)
      Set the Itten color scheme to use
      void setDisplayScheme​(boolean disp)
      Set the display of the color scheme markers.
      private void setHue()
      Set the value of the hue edit to match the current color
      void setHue​(int h)
      Set the selected hue
      static void setLabelBundle​(java.util.ResourceBundle labelBundle)  
      void setRollover​(boolean state)
      Set the adjust rollover color flag.
      private void setSaturation()
      Set the value of the saturation edit to match the current color
      void setSelectedColors​(ModelColor[] clrs)
      Set the reference to the selected colours for the colour scheme
      private boolean shouldAdjustWheel()
      Should the color wheel's colors be adjusted
      private void showSystemColorList​(java.awt.Point p)
      Show a popup menu with the list of system colors
      void stateChanged​(javax.swing.event.ChangeEvent e)
      Invoked when the target of the listener has changed its state.
      void updateChooser()  
      boolean useDecimalRGB()
      Has the user selected the use decimal rgb checkbox?
      boolean useWebColors()
      Has the user selected the use web safe colors checkbox?
      • Methods inherited from class javax.swing.colorchooser.AbstractColorChooserPanel

        getColorFromModel, getColorSelectionModel, getDisplayedMnemonicIndex, getMnemonic, isColorTransparencySelectionEnabled, paint, setColorTransparencySelectionEnabled, uninstallChooserPanel
      • Methods inherited from class javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

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

      • hueEdit

        protected javax.swing.JTextField hueEdit
      • satEdit

        protected javax.swing.JTextField satEdit
      • brightEdit

        protected javax.swing.JTextField brightEdit
      • baseColorEdit

        protected javax.swing.JTextField baseColorEdit
      • pickerImage

        protected java.awt.image.BufferedImage pickerImage
      • fixedPanel

        protected javax.swing.JPanel fixedPanel
      • resetBtn

        protected javax.swing.JButton resetBtn
      • brightnessSlider

        protected javax.swing.JSlider brightnessSlider
      • saturationSlider

        protected javax.swing.JSlider saturationSlider
      • baseColorLabel

        protected javax.swing.JLabel baseColorLabel
      • innerCircle

        protected java.awt.geom.Ellipse2D innerCircle
      • outerCircle

        protected java.awt.geom.Ellipse2D outerCircle
      • borderCircle

        protected java.awt.geom.Ellipse2D borderCircle
      • useWebColors

        protected javax.swing.JCheckBox useWebColors
      • decimalRGB

        protected javax.swing.JCheckBox decimalRGB
      • fontSmall

        protected java.awt.Font fontSmall
      • selectedIttenColours

        protected ModelColor[] selectedIttenColours
      • values

        private float[] values
      • h

        private double h
      • s

        private double s
      • b

        private double b
      • colorScheme

        private int colorScheme
      • busy

        private boolean busy
      • displayScheme

        private boolean displayScheme
      • hasChooser

        private boolean hasChooser
      • changeListeners

        private java.util.ArrayList<javax.swing.event.ChangeListener> changeListeners
      • arcDelta

        private static double[] arcDelta
      • ringThickness

        private double ringThickness
      • paths

        private java.awt.geom.GeneralPath[] paths
      • labelBundle

        private static java.util.ResourceBundle labelBundle
      • rolloverPath

        private java.awt.geom.GeneralPath rolloverPath
      • selectedPath

        private java.awt.geom.GeneralPath selectedPath
      • showRollovers

        private boolean showRollovers
      • rolloverColor

        private java.awt.Color rolloverColor
      • selectedColor

        private java.awt.Color selectedColor
      • systemColor

        private java.awt.Color systemColor
      • fontFamily

        private java.lang.String fontFamily
      • adjustWheel

        private int adjustWheel
      • adjustRollover

        private boolean adjustRollover
      • ctrlKeyDown

        private boolean ctrlKeyDown
      • saturationMultipler

        private double saturationMultipler
      • brightnessMultipler

        private double brightnessMultipler
    • Constructor Detail

      • ColorWheelPanel

        public ColorWheelPanel()
        Creates a new instance of ColorWheelPanel
    • Method Detail

      • setSelectedColors

        public void setSelectedColors​(ModelColor[] clrs)
        Set the reference to the selected colours for the colour scheme
        Parameters:
        clrs - the colors
      • addChangeListener

        public void addChangeListener​(javax.swing.event.ChangeListener l)
        Add a listener for changes in the selected color
        Parameters:
        l - the change listener to add
      • removeChangeListener

        public void removeChangeListener​(javax.swing.event.ChangeListener l)
        Remove a change listener
        Parameters:
        l - the change listener to remove
      • useDecimalRGB

        public boolean useDecimalRGB()
        Has the user selected the use decimal rgb checkbox?
        Returns:
        true if decimal rgb values are to be shown
      • useWebColors

        public boolean useWebColors()
        Has the user selected the use web safe colors checkbox?
        Returns:
        true if only web safe colors are to be shown
      • setDisplayScheme

        public void setDisplayScheme​(boolean disp)
        Set the display of the color scheme markers.
        Parameters:
        disp - true to display the color scheme markers.
      • getHue

        public int getHue()
        Get the selected colors hue
        Returns:
        the selected hue in the range 0-255
      • setHue

        public void setHue​(int h)
        Set the selected hue
        Parameters:
        h - the selected hue in the range 0-255
      • getSaturation

        public int getSaturation()
        Get the selected colors saturation
        Returns:
        the selected saturation in the range 0-255
      • getBrightness

        public int getBrightness()
        Get the selected colors brightness
        Returns:
        the selected brightness in the range 0-255
      • setColorScheme

        public void setColorScheme​(int scheme)
        Set the Itten color scheme to use
        Parameters:
        scheme -
        • -1 for no scheme display
        • 0 for a monchromatic color scheme: MONOCHROMATIC_SCHEME
        • 1 for a contrasting color scheme: CONTRASTING_SCHEME
        • 2 for a soft-contrasting color scheme: SOFT_CONTRAST_SCHEME
        • 3 for a double contrasting color scheme: DOUBLE_CONTRAST_SCHEME
        • 4 for a analogical color scheme: ANALOGIC_SCHEME
      • moveHue

        boolean moveHue​(java.awt.Point pt)
        Change the hue to match the angle identified by the point (in the inner circle).
        Parameters:
        pt - the point within the inner circle
      • getAngle

        private int getAngle​(java.awt.Point pt)
      • setColor

        public void setColor​(java.awt.Color c)
      • getColor

        public java.awt.Color getColor()
        Get the selected color
        Returns:
        the color
      • getChooserColour

        public ModelColor getChooserColour()
        Get the chooser color
        Returns:
        the chooser color
      • setHue

        private void setHue()
        Set the value of the hue edit to match the current color
      • setSaturation

        private void setSaturation()
        Set the value of the saturation edit to match the current color
      • setBrightness

        private void setBrightness()
        Set the value of the brightness edit to match the current color
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Respond to action events for the edit fields
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
      • resetColor

        private void resetColor()
        Reset the displayed color to the color specified by the edit fields
      • mouseClicked

        public void mouseClicked​(java.awt.event.MouseEvent e)
        Invoked when the mouse button has been clicked (pressed and released) on a component.
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent e)
        Invoked when a mouse button has been pressed on a component.
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent e)
        Invoked when a mouse button has been released on a component.
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
      • mouseEntered

        public void mouseEntered​(java.awt.event.MouseEvent e)
        Invoked when the mouse enters a component.
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent e)
        Invoked when the mouse exits a component.
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
      • mouseMoved

        public void mouseMoved​(java.awt.event.MouseEvent e)
        Invoked when the mouse exits a component.
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
      • mouseWheelMoved

        public void mouseWheelMoved​(java.awt.event.MouseWheelEvent e)
        Move the sliders in rsponse to the mouse wheel
        Specified by:
        mouseWheelMoved in interface java.awt.event.MouseWheelListener
      • mouseDragged

        public void mouseDragged​(java.awt.event.MouseEvent e)
        Invoked when the mouse exits a component.
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
      • stateChanged

        public void stateChanged​(javax.swing.event.ChangeEvent e)
        Invoked when the target of the listener has changed its state.
        Specified by:
        stateChanged in interface javax.swing.event.ChangeListener
        Parameters:
        e - a ChangeEvent object
      • buildChooser

        protected void buildChooser()
        Specified by:
        buildChooser in class javax.swing.colorchooser.AbstractColorChooserPanel
      • getDisplayName

        public java.lang.String getDisplayName()
        Specified by:
        getDisplayName in class javax.swing.colorchooser.AbstractColorChooserPanel
      • getPreferredSize

        public java.awt.Dimension getPreferredSize()
        Overrides:
        getPreferredSize in class javax.swing.JComponent
      • updateChooser

        public void updateChooser()
        Specified by:
        updateChooser in class javax.swing.colorchooser.AbstractColorChooserPanel
      • installChooserPanel

        public void installChooserPanel​(javax.swing.JColorChooser enclosingChooser)
        Overrides:
        installChooserPanel in class javax.swing.colorchooser.AbstractColorChooserPanel
      • setLabelBundle

        public static void setLabelBundle​(java.util.ResourceBundle labelBundle)
      • getLabel

        private static java.lang.String getLabel​(java.lang.String labelName,
                                                 java.lang.String defaultValue)
      • showSystemColorList

        private void showSystemColorList​(java.awt.Point p)
        Show a popup menu with the list of system colors
        Parameters:
        p - the location to display the popup
      • getSystemColor

        public java.awt.Color getSystemColor​(java.lang.String temp)
        Get the named system color
        Parameters:
        temp - the color name
        Returns:
        the color value or null if the name is not recognized
      • shouldAdjustWheel

        private boolean shouldAdjustWheel()
        Should the color wheel's colors be adjusted
        Returns:
        true if the colors should change to match the brightness and saturation
      • getAdjustWheel

        public int getAdjustWheel()
        Get the adjust color wheel flag.
        Returns:
        the adjustment mode
      • setAdjustWheel

        public void setAdjustWheel​(int state)
        Set the adjust color wheel flag.
        Parameters:
        state - the color wheel's new adjustment mode ( CTRL_ADJUST | ALWAYS_ADJUST | NEVER_ADJUST );
      • getRollover

        public boolean getRollover()
        Get the adjust rollover color flag.
        Returns:
        the adjustment mode
      • setRollover

        public void setRollover​(boolean state)
        Set the adjust rollover color flag.
        Parameters:
        state - the rollover's new adjustment mode ( true | false );
      • resetColorWheel

        public void resetColorWheel()
        Reset the brightness and saturation multipliers for the ColorWheel.