@@ -328,8 +328,6 @@ private static void testColorValueRange(int r, int g, int b, int a) {
328328// * @param g the Green component
329329// * @param b the Blue component
330330// *
331- // * @j2sIgnore
332- // *
333331// **/
334332// private static void testColorValueRange(float r, float g, float b, float a) {
335333// boolean rangeError = false;
@@ -380,7 +378,7 @@ public Color() {
380378 *
381379 */
382380 public Color (int r , int g , int b ) {
383- setColor4 (r , g , b , 255 );
381+ this (r , g , b , 255 );
384382 }
385383
386384 /**
@@ -402,10 +400,6 @@ public Color(int r, int g, int b) {
402400 *
403401 */
404402 public Color (int r , int g , int b , int a ) {
405- setColor4 (r , g , b , a );
406- }
407-
408- private void setColor4 (int r , int g , int b , int a ) {
409403 value = ((a & 0xFF ) << 24 ) |
410404 ((r & 0xFF ) << 16 ) |
411405 ((g & 0xFF ) << 8 ) |
@@ -477,54 +471,44 @@ public Color(int rgba, boolean hasalpha) {
477471 * @see #getBlue
478472 * @see #getRGB
479473 *
480- * @deprecated
481- * use Color.getColorF4 instead
482474 */
483475
484476 public Color (float r , float g , float b ) {
485- setFloat (r , g , b , 1f );
477+ this (r , g , b , 1f );
486478 }
487479
488- private void setFloat (float r , float g , float b , float f ) {
489- setColor4 ((int ) (r *255 +0.5 ), (int ) (g *255 +0.5 ), (int ) (b *255 +0.5 ), (int ) (f *255 +0.5 ));
490- frgbvalue = new float [3 ];
491- frgbvalue [0 ] = r ;
492- frgbvalue [1 ] = g ;
493- frgbvalue [2 ] = b ;
494- falpha = f ;
495- //fvalue = frgbvalue;
496- }
497-
498- /**
499- * Creates an sRGB color with the specified red, green, blue, and
500- * alpha values in the range (0.0 - 1.0). The actual color
501- * used in rendering depends on finding the best match given the
502- * color space available for a particular output device.
503- * @throws IllegalArgumentException if <code>r</code>, <code>g</code>
504- * <code>b</code> or <code>a</code> are outside of the range
505- * 0.0 to 1.0, inclusive
506- * @param r the red component
507- * @param g the green component
508- * @param b the blue component
509- * @param a the alpha component
510- * @see #getRed
511- * @see #getGreen
512- * @see #getBlue
513- * @see #getAlpha
514- * @see #getRGB
515- *
516- * @deprecated
517- * use getColorF4 instead
518- */
519- public Color (float r , float g , float b , float a ) {
520- setFloat (r , g , b , a );
521- }
522-
523- public static Color getColorF4 (float r , float g , float b , float a ) {
524- Color c = new Color ();
525- c .setFloat (r , g , b , a );
526- return c ;
527- }
480+ /**
481+ * Creates an sRGB color with the specified red, green, blue, and alpha
482+ * values in the range (0.0 - 1.0). The actual color used in rendering
483+ * depends on finding the best match given the color space available for a
484+ * particular output device.
485+ *
486+ * @throws IllegalArgumentException
487+ * if <code>r</code>, <code>g</code> <code>b</code> or
488+ * <code>a</code> are outside of the range 0.0 to 1.0, inclusive
489+ * @param r
490+ * the red component
491+ * @param g
492+ * the green component
493+ * @param b
494+ * the blue component
495+ * @param a
496+ * the alpha component
497+ * @see #getRed
498+ * @see #getGreen
499+ * @see #getBlue
500+ * @see #getAlpha
501+ * @see #getRGB
502+ *
503+ */
504+ public Color (float r , float g , float b , float a ) {
505+ this ((int ) (r * 255 + 0.5 ), (int ) (g * 255 + 0.5 ), (int ) (b * 255 + 0.5 ), (int ) (a * 255 + 0.5 ));
506+ frgbvalue = new float [3 ];
507+ frgbvalue [0 ] = r ;
508+ frgbvalue [1 ] = g ;
509+ frgbvalue [2 ] = b ;
510+ falpha = a ;
511+ }
528512
529513
530514// /**
@@ -546,7 +530,6 @@ public static Color getColorF4(float r, float g, float b, float a) {
546530// * @see #getColorComponents
547531// *
548532// *
549- // * @j2sIgnore
550533// */
551534// public Color(ColorSpace cspace, float components[], float alpha) {
552535// boolean rangeError = false;
@@ -1054,41 +1037,39 @@ public float[] getRGBColorComponents(float[] compArray) {
10541037 return f ;
10551038 }
10561039
1057- // /**
1058- // * Returns a <code>float</code> array containing the color and alpha
1059- // * components of the <code>Color</code>, in the
1060- // * <code>ColorSpace</code> of the <code>Color</code>.
1061- // * If <code>compArray</code> is <code>null</code>, an array with
1062- // * length equal to the number of components in the associated
1063- // * <code>ColorSpace</code> plus one is created for
1064- // * the return value. Otherwise, <code>compArray</code> must have at
1065- // * least this length and it is filled in with the components and
1066- // * returned.
1067- // * @param compArray an array that this method fills with the color and
1068- // * alpha components of this <code>Color</code> in its
1069- // * <code>ColorSpace</code> and returns
1070- // * @return the color and alpha components in a <code>float</code>
1071- // * array.
1072- // *
1073- // * @j2sIgnore
1074- // *
1075- // */
1076- // public float[] getComponents(float[] compArray) {
1077- // if (fvalue == null)
1078- // return getRGBComponents(compArray);
1079- // float[] f;
1080- // int n = fvalue.length;
1081- // if (compArray == null) {
1082- // f = new float[n + 1];
1083- // } else {
1084- // f = compArray;
1085- // }
1086- // for (int i = 0; i < n; i++) {
1087- // f[i] = fvalue[i];
1088- // }
1089- // f[n] = falpha;
1090- // return f;
1091- // }
1040+ /**
1041+ * Returns a <code>float</code> array containing the color and alpha
1042+ * components of the <code>Color</code>, in the
1043+ * <code>ColorSpace</code> of the <code>Color</code>.
1044+ * If <code>compArray</code> is <code>null</code>, an array with
1045+ * length equal to the number of components in the associated
1046+ * <code>ColorSpace</code> plus one is created for
1047+ * the return value. Otherwise, <code>compArray</code> must have at
1048+ * least this length and it is filled in with the components and
1049+ * returned.
1050+ * @param compArray an array that this method fills with the color and
1051+ * alpha components of this <code>Color</code> in its
1052+ * <code>ColorSpace</code> and returns
1053+ * @return the color and alpha components in a <code>float</code>
1054+ * array.
1055+ *
1056+ */
1057+ public float [] getComponents (float [] compArray ) {
1058+ if (frgbvalue == null )
1059+ return getRGBComponents (compArray );
1060+ float [] f ;
1061+ int n = frgbvalue .length ;
1062+ if (compArray == null ) {
1063+ f = new float [n + 1 ];
1064+ } else {
1065+ f = compArray ;
1066+ }
1067+ for (int i = 0 ; i < n ; i ++) {
1068+ f [i ] = frgbvalue [i ];
1069+ }
1070+ f [n ] = falpha ;
1071+ return f ;
1072+ }
10921073//
10931074// /**
10941075// * Returns a <code>float</code> array containing only the color
@@ -1137,7 +1118,6 @@ public float[] getRGBColorComponents(float[] compArray) {
11371118// * @return the color and alpha components in a <code>float</code>
11381119// * array.
11391120// *
1140- // * @j2sIgnore
11411121// */
11421122// public float[] getComponents(ColorSpace cspace, float[] compArray) {
11431123// if (cs == null) {
@@ -1184,7 +1164,6 @@ public float[] getRGBColorComponents(float[] compArray) {
11841164// * @return the color components in a <code>float</code> array.
11851165// *
11861166// *
1187- // * @j2sIgnore
11881167// */
11891168// public float[] getColorComponents(ColorSpace cspace, float[] compArray) {
11901169// if (cs == null) {
@@ -1213,7 +1192,6 @@ public float[] getRGBColorComponents(float[] compArray) {
12131192// /**
12141193// * Returns the <code>ColorSpace</code> of this <code>Color</code>.
12151194// * @return this <code>Color</code> object's <code>ColorSpace</code>.
1216- // * @j2sIgnore
12171195// */
12181196// public ColorSpace getColorSpace() {
12191197// if (cs == null) {
0 commit comments