Skip to content

Commit 5bfc5fd

Browse files
committed
8263051: Modernize the code in the java.awt.color package
Reviewed-by: azvegint
1 parent 5b9b170 commit 5bfc5fd

File tree

4 files changed

+165
-411
lines changed

4 files changed

+165
-411
lines changed

src/java.desktop/share/classes/java/awt/color/ColorSpace.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public abstract class ColorSpace implements Serializable {
112112
/**
113113
* Lazy-initialized names of components in the color space.
114114
*/
115-
private transient volatile String [] compName;
115+
private transient volatile String[] compName;
116116

117117
/**
118118
* The lazy cache of singletons for the predefined built-in color spaces.
@@ -327,7 +327,7 @@ public static ColorSpace getInstance(int cspace) {
327327
* @return {@code true} if this is a {@code CS_sRGB} color space,
328328
* {@code false} if it is not
329329
*/
330-
public boolean isCS_sRGB () {
330+
public boolean isCS_sRGB() {
331331
return this == BuiltInSpace.SRGB;
332332
}
333333

src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
package java.awt.color;
3737

3838
import java.io.IOException;
39+
import java.io.ObjectInputStream;
3940
import java.io.Serial;
4041

4142
import sun.java2d.cmm.CMSManager;
@@ -130,18 +131,18 @@ public class ICC_ColorSpace extends ColorSpace {
130131
* @throws IllegalArgumentException if profile is inappropriate for
131132
* representing a {@code ColorSpace}
132133
*/
133-
public ICC_ColorSpace (ICC_Profile profile) {
134-
super (profile.getColorSpaceType(), profile.getNumComponents());
134+
public ICC_ColorSpace(ICC_Profile profile) {
135+
super(profile.getColorSpaceType(), profile.getNumComponents());
135136

136137
int profileClass = profile.getProfileClass();
137138

138139
/* REMIND - is NAMEDCOLOR OK? */
139-
if ((profileClass != ICC_Profile.CLASS_INPUT) &&
140-
(profileClass != ICC_Profile.CLASS_DISPLAY) &&
141-
(profileClass != ICC_Profile.CLASS_OUTPUT) &&
142-
(profileClass != ICC_Profile.CLASS_COLORSPACECONVERSION) &&
143-
(profileClass != ICC_Profile.CLASS_NAMEDCOLOR) &&
144-
(profileClass != ICC_Profile.CLASS_ABSTRACT)) {
140+
if (profileClass != ICC_Profile.CLASS_INPUT
141+
&& profileClass != ICC_Profile.CLASS_DISPLAY
142+
&& profileClass != ICC_Profile.CLASS_OUTPUT
143+
&& profileClass != ICC_Profile.CLASS_COLORSPACECONVERSION
144+
&& profileClass != ICC_Profile.CLASS_NAMEDCOLOR
145+
&& profileClass != ICC_Profile.CLASS_ABSTRACT) {
145146
throw new IllegalArgumentException("Invalid profile type");
146147
}
147148

@@ -158,9 +159,8 @@ public ICC_ColorSpace (ICC_Profile profile) {
158159
* @throws IOException if an I/O error occurs
159160
*/
160161
@Serial
161-
private void readObject(java.io.ObjectInputStream s)
162-
throws ClassNotFoundException, java.io.IOException {
163-
162+
private void readObject(ObjectInputStream s)
163+
throws ClassNotFoundException, IOException {
164164
s.defaultReadObject();
165165
if (thisProfile == null) {
166166
thisProfile = ICC_Profile.getInstance(ColorSpace.CS_sRGB);
@@ -222,7 +222,7 @@ public float[] toRGB(float[] colorvalue) {
222222
((colorvalue[i] - minVal[i]) * invDiffMinMax[i] + 0.5f);
223223
}
224224
tmp = this2srgb.colorConvert(tmp, null);
225-
float[] result = new float [3];
225+
float[] result = new float[3];
226226
for (int i = 0; i < 3; i++) {
227227
result[i] = ((float) (tmp[i] & 0xffff)) / 65535.0f;
228228
}
@@ -273,7 +273,7 @@ public float[] fromRGB(float[] rgbvalue) {
273273
}
274274
tmp = srgb2this.colorConvert(tmp, null);
275275
int nc = this.getNumComponents();
276-
float[] result = new float [nc];
276+
float[] result = new float[nc];
277277
for (int i = 0; i < nc; i++) {
278278
result[i] = (((float) (tmp[i] & 0xffff)) / 65535.0f) *
279279
diffMinMax[i] + minVal[i];
@@ -414,7 +414,7 @@ public float[] toCIEXYZ(float[] colorvalue) {
414414
tmp = this2xyz.colorConvert(tmp, null);
415415
float ALMOST_TWO = 1.0f + (32767.0f / 32768.0f);
416416
// For CIEXYZ, min = 0.0, max = ALMOST_TWO for all components
417-
float[] result = new float [3];
417+
float[] result = new float[3];
418418
for (int i = 0; i < 3; i++) {
419419
result[i] = (((float) (tmp[i] & 0xffff)) / 65535.0f) * ALMOST_TWO;
420420
}
@@ -554,7 +554,7 @@ public float[] fromCIEXYZ(float[] colorvalue) {
554554
}
555555
tmp = xyz2this.colorConvert(tmp, null);
556556
int nc = this.getNumComponents();
557-
float[] result = new float [nc];
557+
float[] result = new float[nc];
558558
for (int i = 0; i < nc; i++) {
559559
result[i] = (((float) (tmp[i] & 0xffff)) / 65535.0f) *
560560
diffMinMax[i] + minVal[i];
@@ -621,7 +621,7 @@ private void setMinMax() {
621621
maxVal[2] = 127.0f;
622622
} else if (type == ColorSpace.TYPE_XYZ) {
623623
minVal[0] = minVal[1] = minVal[2] = 0.0f; // X, Y, Z
624-
maxVal[0] = maxVal[1] = maxVal[2] = 1.0f + (32767.0f/ 32768.0f);
624+
maxVal[0] = maxVal[1] = maxVal[2] = 1.0f + (32767.0f / 32768.0f);
625625
} else {
626626
for (int i = 0; i < nc; i++) {
627627
minVal[i] = 0.0f;
@@ -642,5 +642,4 @@ private void setComponentScaling() {
642642
}
643643
needScaleInit = false;
644644
}
645-
646645
}

0 commit comments

Comments
 (0)