harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r441981 - in /incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color: ColorSpace.java ICC_ColorSpace.java ICC_Profile.java ICC_ProfileGray.java ICC_ProfileRGB.java ICC_ProfileStub.java
Date Sun, 10 Sep 2006 18:45:56 GMT
Author: ndbeyer
Date: Sun Sep 10 11:45:56 2006
New Revision: 441981

URL: http://svn.apache.org/viewvc?view=rev&rev=441981
Log:
Code cleanup for 'java.awt.color'; add braces, remove compiler warnings, add documentation,
etc

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ColorSpace.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ColorSpace.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_Profile.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileGray.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileRGB.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileStub.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ColorSpace.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ColorSpace.java?view=diff&rev=441981&r1=441980&r2=441981
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ColorSpace.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ColorSpace.java
Sun Sep 10 11:45:56 2006
@@ -103,11 +103,12 @@
     }
 
     public String getName(int idx) {
-        if (idx < 0 || idx > numComponents - 1)
-          throw new IllegalArgumentException(
-                    "Invalid component index: " + idx);
+        if (idx < 0 || idx > numComponents - 1) {
+            throw new IllegalArgumentException(
+                        "Invalid component index: " + idx);
+        }
 
-      return new String("Unnamed color component #" + idx);
+      return "Unnamed color component #" + idx;
     }
 
     public abstract float[] toRGB(float[] colorvalue);
@@ -119,16 +120,18 @@
     public abstract float[] fromCIEXYZ(float[] colorvalue);
 
     public float getMinValue(int component) {
-        if (component < 0 || component > numComponents - 1)
+        if (component < 0 || component > numComponents - 1) {
             throw new IllegalArgumentException(
                     "Invalid component index: " + component);
+        }
         return 0;
     }
 
     public float getMaxValue(int component) {
-        if (component < 0 || component > numComponents - 1)
+        if (component < 0 || component > numComponents - 1) {
             throw new IllegalArgumentException(
                     "Invalid component index: " + component);
+        }
         return 1;
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ColorSpace.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ColorSpace.java?view=diff&rev=441981&r1=441980&r2=441981
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ColorSpace.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ColorSpace.java
Sun Sep 10 11:45:56 2006
@@ -96,6 +96,7 @@
         return profile;
     }
 
+    @Override
     public float[] toRGB(float[] colorvalue) {
         if (toRGBTransform == null) {
             ICC_Profile sRGBProfile =
@@ -118,13 +119,14 @@
         // unscale to sRGB
         float[] res = new float[3];
 
-        res[0] = ((float) (converted[0] & 0xFFFF)) * INV_MAX_SHORT;
-        res[1] = ((float) (converted[1] & 0xFFFF)) * INV_MAX_SHORT;
-        res[2] = ((float) (converted[2] & 0xFFFF)) * INV_MAX_SHORT;
+        res[0] = ((converted[0] & 0xFFFF)) * INV_MAX_SHORT;
+        res[1] = ((converted[1] & 0xFFFF)) * INV_MAX_SHORT;
+        res[2] = ((converted[2] & 0xFFFF)) * INV_MAX_SHORT;
 
         return res;
     }
 
+    @Override
     public float[] toCIEXYZ(float[] colorvalue) {
         if (toXYZTransform == null) {
             ICC_Profile xyzProfile =
@@ -155,13 +157,14 @@
         // unscale to XYZ
         float[] res = new float[3];
 
-        res[0] = ((float) (converted[0] & 0xFFFF)) * SHORT2XYZ_FACTOR;
-        res[1] = ((float) (converted[1] & 0xFFFF)) * SHORT2XYZ_FACTOR;
-        res[2] = ((float) (converted[2] & 0xFFFF)) * SHORT2XYZ_FACTOR;
+        res[0] = ((converted[0] & 0xFFFF)) * SHORT2XYZ_FACTOR;
+        res[1] = ((converted[1] & 0xFFFF)) * SHORT2XYZ_FACTOR;
+        res[2] = ((converted[2] & 0xFFFF)) * SHORT2XYZ_FACTOR;
 
         return res;
     }
 
+    @Override
     public float[] fromRGB(float[] rgbvalue) {
         if (fromRGBTransform == null) {
             ICC_Profile sRGBProfile =
@@ -190,6 +193,7 @@
         return res;
     }
 
+    @Override
     public float[] fromCIEXYZ(float[] xyzvalue) {
         if (fromXYZTransform == null) {
             ICC_Profile xyzProfile =
@@ -226,6 +230,7 @@
         return res;
     }
 
+    @Override
     public float getMinValue(int component) {
         if ((component < 0) || (component > this.getNumComponents() - 1)) {
             throw new IllegalArgumentException("Component index out of range");
@@ -234,6 +239,7 @@
         return minValues[component];
     }
 
+    @Override
     public float getMaxValue(int component) {
         if ((component < 0) || (component > this.getNumComponents() - 1)) {
             throw new IllegalArgumentException("Component index out of range");

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_Profile.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_Profile.java?view=diff&rev=441981&r1=441980&r2=441981
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_Profile.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_Profile.java
Sun Sep 10 11:45:56 2006
@@ -382,8 +382,9 @@
     public void setData(int tagSignature, byte[] tagData) {
         NativeCMM.cmmSetProfileElement(profileHandle, tagSignature, tagData);
         // Remove cached header data if header is modified
-        if (tagSignature == icSigHead)
+        if (tagSignature == icSigHead) {
             headerData = null;
+        }
     }
 
     public byte[] getData(int tagSignature) {
@@ -411,9 +412,11 @@
         return data;
     }
 
+    @Override
     protected void finalize() {
-        if (profileHandle!=0 && !handleStolen)
+        if (profileHandle!=0 && !handleStolen) {
             NativeCMM.cmmCloseProfile(profileHandle);
+        }
 
         // Always remove because key no more exist
         // when object is destroyed
@@ -527,8 +530,9 @@
     private static FileInputStream tryPath(String path, String fileName) {
         FileInputStream fiStream = null;
 
-        if (path == null)
+        if (path == null) {
             return null;
+        }
 
         StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
 
@@ -536,8 +540,9 @@
             String pathEntry = st.nextToken();
             try {
                 fiStream = new FileInputStream(pathEntry + File.separatorChar + fileName);
-                if (fiStream != null)
+                if (fiStream != null) {
                     return fiStream;
+                }
             } catch (FileNotFoundException e) {}
         }
 
@@ -547,42 +552,47 @@
     public static ICC_Profile getInstance(String fileName) throws IOException {
         final String fName = fileName; // to use in the privileged block
 
-        FileInputStream fiStream = (FileInputStream) AccessController.doPrivileged(
-                new PrivilegedAction() {
-                    public Object run() {
+        FileInputStream fiStream = AccessController.doPrivileged(
+                new PrivilegedAction<FileInputStream>() {
+                    public FileInputStream run() {
                         FileInputStream fiStream = null;
 
                         // Open absolute path
                         try {
                             fiStream = new FileInputStream(fName);
-                            if (fiStream != null)
+                            if (fiStream != null) {
                                 return fiStream;
+                            }
                         } catch (FileNotFoundException e) {}
 
                         // Check java.iccprofile.path entries
                         fiStream = tryPath(System.getProperty("java.iccprofile.path"), fName);
-                        if (fiStream != null)
+                        if (fiStream != null) {
                             return fiStream;
+                        }
 
                         // Check java.class.path entries
                         fiStream = tryPath(System.getProperty("java.class.path"), fName);
-                        if (fiStream != null)
+                        if (fiStream != null) {
                             return fiStream;
+                        }
 
                         // Check directory with java sample profiles
                         String home = System.getProperty("java.home");
-                        if (home != null)
+                        if (home != null) {
                             fiStream = tryPath(
                                     home + File.separatorChar +
                                     "lib" + File.separatorChar + "cmm", fName
                             );
+                        }
 
                         return fiStream;
                     }
                 });
 
-        if (fiStream == null)
+        if (fiStream == null) {
             throw new IOException("Unable to open file " + fileName);
+        }
 
         ICC_Profile pf = getInstance(fiStream);
         fiStream.close();
@@ -663,28 +673,33 @@
       switch (cspace) {
 
       case ColorSpace.CS_sRGB:
-        if (sRGBProfile == null)
-          sRGBProfile = getInstance("sRGB.pf");
+        if (sRGBProfile == null) {
+            sRGBProfile = getInstance("sRGB.pf");
+        }
         return sRGBProfile;
 
       case ColorSpace.CS_CIEXYZ:
-        if (xyzProfile == null)
-          xyzProfile = getInstance("CIEXYZ.pf");
+        if (xyzProfile == null) {
+            xyzProfile = getInstance("CIEXYZ.pf");
+        }
         return xyzProfile;
 
       case ColorSpace.CS_GRAY:
-        if (grayProfile == null)
-          grayProfile = getInstance("GRAY.pf");
+        if (grayProfile == null) {
+            grayProfile = getInstance("GRAY.pf");
+        }
         return grayProfile;
 
       case ColorSpace.CS_PYCC:
-        if (pyccProfile == null)
-          pyccProfile = getInstance("PYCC.pf");
+        if (pyccProfile == null) {
+            pyccProfile = getInstance("PYCC.pf");
+        }
         return pyccProfile;
 
       case ColorSpace.CS_LINEAR_RGB:
-        if (linearRGBProfile == null)
-          linearRGBProfile = getInstance("LINEAR_RGB.pf");
+        if (linearRGBProfile == null) {
+            linearRGBProfile = getInstance("LINEAR_RGB.pf");
+        }
         return linearRGBProfile;
       }
 
@@ -841,12 +856,14 @@
 
         dataTRC = null;
 
-        if (trcSize == 0)
+        if (trcSize == 0) {
             return 1.0f;
+        }
 
-        if (trcSize == 1)
+        if (trcSize == 1) {
             // Cast from ICC u8Fixed8Number to float
             return ICC_ProfileHelper.getShortFromByteArray(data, icCurveData) / 256.f;
+        }
 
         // TRC is a table
         dataTRC = new short[trcSize];
@@ -860,20 +877,20 @@
         short[] dataTRC = null;
         float gamma = getGammaOrTRC(tagSignature, dataTRC);
 
-        if (dataTRC == null)
+        if (dataTRC == null) {
             return gamma;
-        else
-            throw new ProfileDataException("TRC is not a simple gamma value.");
+        }
+        throw new ProfileDataException("TRC is not a simple gamma value.");
     }
 
     short[] getTRC(int tagSignature) {
         short[] dataTRC = null;
         getGammaOrTRC(tagSignature, dataTRC);
 
-        if (dataTRC == null)
+        if (dataTRC == null) {
             throw new ProfileDataException("TRC is a gamma value, not a table.");
-        else
-            return dataTRC;
+        }
+        return dataTRC;
     }
 }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileGray.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileGray.java?view=diff&rev=441981&r1=441980&r2=441981
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileGray.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileGray.java
Sun Sep 10 11:45:56 2006
@@ -30,6 +30,7 @@
         return super.getTRC(icSigGrayTRCTag);
     }
 
+    @Override
     public float[] getMediaWhitePoint() {
         return super.getMediaWhitePoint();
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileRGB.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileRGB.java?view=diff&rev=441981&r1=441980&r2=441981
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileRGB.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileRGB.java
Sun Sep 10 11:45:56 2006
@@ -36,6 +36,7 @@
         "Unknown component. Must be REDCOMPONENT, " +
         "GREENCOMPONENT or BLUECOMPONENT.";
 
+    @Override
     public short[] getTRC(int component) {
         switch (component) {
             case REDCOMPONENT:
@@ -50,6 +51,7 @@
         throw new IllegalArgumentException(UNKNOWN_COMPONENT_MSG);
     }
 
+    @Override
     public float getGamma(int component) {
         switch (component) {
             case REDCOMPONENT:
@@ -86,6 +88,7 @@
         return m;
     }
 
+    @Override
     public float[] getMediaWhitePoint() {
         return super.getMediaWhitePoint();
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileStub.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileStub.java?view=diff&rev=441981&r1=441980&r2=441981
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileStub.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/color/ICC_ProfileStub.java
Sun Sep 10 11:45:56 2006
@@ -44,6 +44,7 @@
         colorspace = csSpecifier;
     }
 
+    @Override
     public void write(String fileName) throws IOException {
         throw new UnsupportedOperationException("Stub cannot perform this operation");
     }
@@ -57,33 +58,41 @@
         return loadProfile();
     }
 
+    @Override
     public void write(OutputStream s) throws IOException {
         throw new UnsupportedOperationException("Stub cannot perform this operation");
     }
 
+    @Override
     public void setData(int tagSignature, byte[] tagData) {
         throw new UnsupportedOperationException("Stub cannot perform this operation");
     }
 
+    @Override
     public byte[] getData(int tagSignature) {
         throw new UnsupportedOperationException("Stub cannot perform this operation");
     }
 
+    @Override
     public byte[] getData() {
         throw new UnsupportedOperationException("Stub cannot perform this operation");
     }
 
+    @Override
     protected void finalize() {
     }
 
+    @Override
     public int getProfileClass() {
         return CLASS_COLORSPACECONVERSION;
     }
 
+    @Override
     public int getPCSType() {
         throw new UnsupportedOperationException("Stub cannot perform this operation");
     }
 
+    @Override
     public int getNumComponents() {
         switch (colorspace) {
             case ColorSpace.CS_sRGB:
@@ -98,14 +107,17 @@
         }
     }
 
+    @Override
     public int getMinorVersion() {
         throw new UnsupportedOperationException("Stub cannot perform this operation");
     }
 
+    @Override
     public int getMajorVersion() {
         throw new UnsupportedOperationException("Stub cannot perform this operation");
     }
 
+    @Override
     public int getColorSpaceType() {
         switch (colorspace) {
             case ColorSpace.CS_sRGB:



Mime
View raw message