96 comp = policy.getComponentBefore(rootAncestor, container);
97 }
98 if (comp != null) {
99 comp.requestFocus();
100 return;
101 }
102 }
103 }
104 component.requestFocus();
105 }
106
107
108 /**
109 * Returns a user presentable description of this GTKColorChooserPane.
110 */
111 public String getDisplayName() {
112 return (String)UIManager.get("GTKColorChooserPanel.nameText");
113 }
114
115 /**
116 * Returns the mnemonic to use with <code>getDisplayName</code>.
117 */
118 public int getMnemonic() {
119 String m = (String)UIManager.get("GTKColorChooserPanel.mnemonic");
120
121 if (m != null) {
122 try {
123 int value = Integer.parseInt(m);
124
125 return value;
126 } catch (NumberFormatException nfe) {}
127 }
128 return -1;
129 }
130
131 /**
132 * Character to underline that represents the mnemonic.
133 */
134 public int getDisplayedMnemonicIndex() {
135 String m = (String)UIManager.get(
136 "GTKColorChooserPanel.displayedMnemonicIndex");
861 BufferedImage image = new BufferedImage(doubleSize, doubleSize,
862 BufferedImage.TYPE_INT_ARGB);
863
864 for (int y = -size; y < size; y++) {
865 int ySquared = y * y;
866 for (int x = -size; x < size; x++) {
867 double rad = Math.sqrt(ySquared + x * x);
868
869 if (rad < size && rad > minSize) {
870 int rgb = colorWheelLocationToRGB(x, y, rad) |
871 0xFF000000;
872 image.setRGB(x + size, y + size, rgb);
873 }
874 }
875 }
876 wheelImage = image;
877 return wheelImage;
878 }
879
880 /**
881 * Adjusts the saturation and brightness. <code>x</code> and
882 * <code>y</code> give the location to adjust to and are relative
883 * to the origin of the wheel/triangle.
884 *
885 * @param x X coordinate on the triangle to adjust to
886 * @param y Y coordinate on the triangle to adjust to
887 * @param checkLoc if true the location is checked to make sure
888 * it is contained in the triangle, if false the location is
889 * constrained to fit in the triangle.
890 * @return true if the location is valid
891 */
892 boolean adjustSB(int x, int y, boolean checkLoc) {
893 int innerR = getWheelRadius() - getWheelWidth();
894 boolean resetXY = false;
895 // Invert the axis.
896 y = -y;
897 if (checkLoc && (x < -innerR || x > innerR || y < -innerR ||
898 y > innerR)) {
899 return false;
900 }
901 // Rotate to origin and verify x is valid.
902 int triangleSize = innerR * 3 / 2;
|
96 comp = policy.getComponentBefore(rootAncestor, container);
97 }
98 if (comp != null) {
99 comp.requestFocus();
100 return;
101 }
102 }
103 }
104 component.requestFocus();
105 }
106
107
108 /**
109 * Returns a user presentable description of this GTKColorChooserPane.
110 */
111 public String getDisplayName() {
112 return (String)UIManager.get("GTKColorChooserPanel.nameText");
113 }
114
115 /**
116 * Returns the mnemonic to use with {@code getDisplayName}.
117 */
118 public int getMnemonic() {
119 String m = (String)UIManager.get("GTKColorChooserPanel.mnemonic");
120
121 if (m != null) {
122 try {
123 int value = Integer.parseInt(m);
124
125 return value;
126 } catch (NumberFormatException nfe) {}
127 }
128 return -1;
129 }
130
131 /**
132 * Character to underline that represents the mnemonic.
133 */
134 public int getDisplayedMnemonicIndex() {
135 String m = (String)UIManager.get(
136 "GTKColorChooserPanel.displayedMnemonicIndex");
861 BufferedImage image = new BufferedImage(doubleSize, doubleSize,
862 BufferedImage.TYPE_INT_ARGB);
863
864 for (int y = -size; y < size; y++) {
865 int ySquared = y * y;
866 for (int x = -size; x < size; x++) {
867 double rad = Math.sqrt(ySquared + x * x);
868
869 if (rad < size && rad > minSize) {
870 int rgb = colorWheelLocationToRGB(x, y, rad) |
871 0xFF000000;
872 image.setRGB(x + size, y + size, rgb);
873 }
874 }
875 }
876 wheelImage = image;
877 return wheelImage;
878 }
879
880 /**
881 * Adjusts the saturation and brightness. {@code x} and
882 * {@code y} give the location to adjust to and are relative
883 * to the origin of the wheel/triangle.
884 *
885 * @param x X coordinate on the triangle to adjust to
886 * @param y Y coordinate on the triangle to adjust to
887 * @param checkLoc if true the location is checked to make sure
888 * it is contained in the triangle, if false the location is
889 * constrained to fit in the triangle.
890 * @return true if the location is valid
891 */
892 boolean adjustSB(int x, int y, boolean checkLoc) {
893 int innerR = getWheelRadius() - getWheelWidth();
894 boolean resetXY = false;
895 // Invert the axis.
896 y = -y;
897 if (checkLoc && (x < -innerR || x > innerR || y < -innerR ||
898 y > innerR)) {
899 return false;
900 }
901 // Rotate to origin and verify x is valid.
902 int triangleSize = innerR * 3 / 2;
|