GTKColorChooserPanel.java revision 2362
2362N/A * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A color chooser panel mimicking that of GTK's: a color wheel showing 0N/A * hue and a triangle that varies saturation and brightness. 0N/A * @author Scott Violet 0N/A // The colors are mirrored to avoid creep in adjusting an individual 0N/A * Convenience method to transfer focus to the next child of component. 0N/A // PENDING: remove this when a variant of this is added to awt. 0N/A * Returns a user presentable description of this GTKColorChooserPane. 0N/A * Returns the mnemonic to use with <code>getDisplayName</code>. 0N/A * Character to underline that represents the mnemonic. 0N/A "GTKColorChooserPanel.displayedMnemonicIndex");
0N/A * Builds and configures the widgets for the GTKColorChooserPanel. 0N/A // PENDING: when we straighten out user setting opacity, this should 0N/A // PENDING: when we straighten out user setting opacity, this should 0N/A "GTKColorChooserPanel.saturationSpinner");
0N/A * Configures the spinner. 0N/A * Adds the widget creating a JLabel with the specified name. 0N/A * Refreshes the display from the model. 0N/A * Resets the red component of the selected color. 0N/A * Resets the green component of the selected color. 0N/A * Resets the blue component of the selected color. 0N/A * Sets the hue of the selected color and updates the display if 0N/A * Returns the current amount of hue. 0N/A * Resets the saturation. 0N/A * Returns the saturation. 0N/A * Sets the brightness. 0N/A * Returns the brightness. 0N/A * Sets the saturation and brightness and updates the display if 0N/A * Resets the rgb values. 0N/A * Resets the hsb values. 0N/A private void setHSB(
float h,
float s,
float b) {
0N/A * @param color new Color 0N/A * @param updateSpinners whether or not to update the spinners. 0N/A * @param updateHSB if true, the hsb fields are updated based on the 0N/A * @param updateModel if true, the model is set. 0N/A // Force Integer to pad the string with 0's by adding 0x1000000 and 0N/A // then removing the first character. 0N/A * ChangeListener method, updates the necessary display widgets. 0N/A * Flag indicating the angle, or hue, has changed and the triangle 0N/A * needs to be recreated. 0N/A * Indicates the wheel is being dragged. 0N/A * Indicates the triangle is being dragged. 0N/A * Indicates a color is being set and we should ignore setColor 0N/A * Indicates the wheel has focus. 0N/A * Indicates the triangle has focus. 0N/A * Class responsible for rendering a color wheel and color triangle. 0N/A * Cached image of the wheel. 0N/A * Cached image of the triangle. 0N/A * Angle triangle is rotated by. 0N/A * X location of selected color indicator. 0N/A * Y location of selected color indicator. 0N/A // We want to handle tab ourself. 0N/A // PENDING: this should come from the style. 0N/A "GTKColorChooserPanel.actionMap");
0N/A "GTKColorChooserPanel.actionMap",
map);
0N/A * Returns the GTKColorChooserPanel. 0N/A * Gives focus to the wheel. 0N/A * Gives focus to the triangle. 0N/A * Returns true if the wheel currently has focus. 0N/A * Resets the selected color. 0N/A * Returns the selected color. 0N/A * Returns the x location of the selected color indicator. 0N/A * Returns the y location of the selected color indicator. 0N/A // Assign focus to either the wheel or triangle and attempt 0N/A // to drag either the wheel or triangle. 0N/A // Reset the flags to indicate no one has focus 0N/A // Gained focus, reassign focus to the wheel if no one 0N/A // currently has focus. 0N/A // Draw the wheel and triangle 0N/A // Draw the focus indicator for the wheel 0N/A // Draw a line on the wheel indicating the selected hue. 0N/A // Draw the focus indicator on the triangle 0N/A // Draw the selected color indicator. 0N/A * Returns an image representing the triangle and wheel. 0N/A * Returns a color wheel image for the specified size. 0N/A * @param size Integer giving size of color wheel. 0N/A * @return Color wheel image 0N/A * Adjusts the saturation and brightness. <code>x</code> and 0N/A * <code>y</code> give the location to adjust to and are relative 0N/A * @param x X coordinate on the triangle to adjust to 0N/A * @param y Y coordinate on the triangle to adjust to 0N/A * @param checkLoc if true the location is checked to make sure 0N/A * it is contained in the triangle, if false the location is 0N/A * constrained to fit in the triangle. 0N/A * @return true if the location is valid 0N/A // Rotate to origin and and verify x is valid. 0N/A // Verify y location is valid. 0N/A // Rotate again to determine value and scale 0N/A * Sets the saturation and brightness. 0N/A * Sets the saturation and brightness. 0N/A * Adjusts the hue based on the passed in location. 0N/A * @param x X location to adjust to, relative to the origin of the 0N/A * @param y Y location to adjust to, relative to the origin of the 0N/A * @param check if true the location is checked to make sure 0N/A * it is contained in the wheel, if false the location is 0N/A * constrained to fit in the wheel 0N/A * @return true if the location is valid. 0N/A // Map the location to an angle and reset hue 0N/A * Rotates the triangle to accomodate the passed in hue. 0N/A * Sets the angle representing the hue. 0N/A * Returns the size of the color indicator. 0N/A * Returns the circumscribed radius of the triangle. 0N/A * Returns the x origin of the wheel and triangle. 0N/A * Returns y origin of the wheel and triangle. 0N/A * Returns the width of the wheel. 0N/A * Sets the focus to one of: 0 no one, 1 the wheel or 2 the triangle. 0N/A * Returns the radius of the wheel. 0N/A // As far as I can tell, GTK doesn't allow stretching this 0N/A * Updates the flags bitmask. 0N/A * Returns true if a particular flag has been set. 0N/A * Returns the RGB color to use for the specified location. The 0N/A * passed in point must be on the color wheel and be relative to the 0N/A * origin of the color wheel. 0N/A * @param x X location to get color for 0N/A * @param y Y location to get color for 0N/A * @param rad Radius from center of color wheel 820N/A * @return integer with red, green and blue components 0N/A * Increments the hue. 0N/A * Action class used for colors.