Skip to content
Permalink
Browse files
8263051: Modernize the code in the java.awt.color package
Reviewed-by: azvegint
  • Loading branch information
mrserb committed Mar 9, 2021
1 parent 5b9b170 commit 5bfc5fd38b257663d00a1756c9ab06d3a30da5cd
@@ -112,7 +112,7 @@
/**
* Lazy-initialized names of components in the color space.
*/
private transient volatile String [] compName;
private transient volatile String[] compName;

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

@@ -36,6 +36,7 @@
package java.awt.color;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serial;

import sun.java2d.cmm.CMSManager;
@@ -130,18 +131,18 @@
* @throws IllegalArgumentException if profile is inappropriate for
* representing a {@code ColorSpace}
*/
public ICC_ColorSpace (ICC_Profile profile) {
super (profile.getColorSpaceType(), profile.getNumComponents());
public ICC_ColorSpace(ICC_Profile profile) {
super(profile.getColorSpaceType(), profile.getNumComponents());

int profileClass = profile.getProfileClass();

/* REMIND - is NAMEDCOLOR OK? */
if ((profileClass != ICC_Profile.CLASS_INPUT) &&
(profileClass != ICC_Profile.CLASS_DISPLAY) &&
(profileClass != ICC_Profile.CLASS_OUTPUT) &&
(profileClass != ICC_Profile.CLASS_COLORSPACECONVERSION) &&
(profileClass != ICC_Profile.CLASS_NAMEDCOLOR) &&
(profileClass != ICC_Profile.CLASS_ABSTRACT)) {
if (profileClass != ICC_Profile.CLASS_INPUT
&& profileClass != ICC_Profile.CLASS_DISPLAY
&& profileClass != ICC_Profile.CLASS_OUTPUT
&& profileClass != ICC_Profile.CLASS_COLORSPACECONVERSION
&& profileClass != ICC_Profile.CLASS_NAMEDCOLOR
&& profileClass != ICC_Profile.CLASS_ABSTRACT) {
throw new IllegalArgumentException("Invalid profile type");
}

@@ -158,9 +159,8 @@ public ICC_ColorSpace (ICC_Profile profile) {
* @throws IOException if an I/O error occurs
*/
@Serial
private void readObject(java.io.ObjectInputStream s)
throws ClassNotFoundException, java.io.IOException {

private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException {
s.defaultReadObject();
if (thisProfile == null) {
thisProfile = ICC_Profile.getInstance(ColorSpace.CS_sRGB);
@@ -222,7 +222,7 @@ public ICC_Profile getProfile() {
((colorvalue[i] - minVal[i]) * invDiffMinMax[i] + 0.5f);
}
tmp = this2srgb.colorConvert(tmp, null);
float[] result = new float [3];
float[] result = new float[3];
for (int i = 0; i < 3; i++) {
result[i] = ((float) (tmp[i] & 0xffff)) / 65535.0f;
}
@@ -273,7 +273,7 @@ public ICC_Profile getProfile() {
}
tmp = srgb2this.colorConvert(tmp, null);
int nc = this.getNumComponents();
float[] result = new float [nc];
float[] result = new float[nc];
for (int i = 0; i < nc; i++) {
result[i] = (((float) (tmp[i] & 0xffff)) / 65535.0f) *
diffMinMax[i] + minVal[i];
@@ -414,7 +414,7 @@ public ICC_Profile getProfile() {
tmp = this2xyz.colorConvert(tmp, null);
float ALMOST_TWO = 1.0f + (32767.0f / 32768.0f);
// For CIEXYZ, min = 0.0, max = ALMOST_TWO for all components
float[] result = new float [3];
float[] result = new float[3];
for (int i = 0; i < 3; i++) {
result[i] = (((float) (tmp[i] & 0xffff)) / 65535.0f) * ALMOST_TWO;
}
@@ -554,7 +554,7 @@ public ICC_Profile getProfile() {
}
tmp = xyz2this.colorConvert(tmp, null);
int nc = this.getNumComponents();
float[] result = new float [nc];
float[] result = new float[nc];
for (int i = 0; i < nc; i++) {
result[i] = (((float) (tmp[i] & 0xffff)) / 65535.0f) *
diffMinMax[i] + minVal[i];
@@ -621,7 +621,7 @@ private void setMinMax() {
maxVal[2] = 127.0f;
} else if (type == ColorSpace.TYPE_XYZ) {
minVal[0] = minVal[1] = minVal[2] = 0.0f; // X, Y, Z
maxVal[0] = maxVal[1] = maxVal[2] = 1.0f + (32767.0f/ 32768.0f);
maxVal[0] = maxVal[1] = maxVal[2] = 1.0f + (32767.0f / 32768.0f);
} else {
for (int i = 0; i < nc; i++) {
minVal[i] = 0.0f;
@@ -642,5 +642,4 @@ private void setComponentScaling() {
}
needScaleInit = false;
}

}
Loading

1 comment on commit 5bfc5fd

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 5bfc5fd Mar 9, 2021

Please sign in to comment.