xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r1044394 - in /xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color: ICCColorSpaceExt.java ICCColorSpaceWithIntent.java RenderingIntent.java
Date Fri, 10 Dec 2010 15:07:47 GMT
Author: jeremias
Date: Fri Dec 10 15:07:47 2010
New Revision: 1044394

URL: http://svn.apache.org/viewvc?rev=1044394&view=rev
Log:
Renamed ICCColorSpaceExt to ICCColorSpaceWithIntent as per Vincent's suggestion.
Converted rendering intent from int to an enum.

Added:
    xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ICCColorSpaceWithIntent.java
      - copied, changed from r1028215, xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ICCColorSpaceExt.java
    xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/RenderingIntent.java
  (with props)
Removed:
    xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ICCColorSpaceExt.java

Copied: xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ICCColorSpaceWithIntent.java
(from r1028215, xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ICCColorSpaceExt.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ICCColorSpaceWithIntent.java?p2=xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ICCColorSpaceWithIntent.java&p1=xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ICCColorSpaceExt.java&r1=1028215&r2=1044394&rev=1044394&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ICCColorSpaceExt.java
(original)
+++ xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ICCColorSpaceWithIntent.java
Fri Dec 10 15:07:47 2010
@@ -30,58 +30,36 @@ import java.awt.color.ICC_Profile;
  * relative colorimetric. It also additionally holds the name
  * and source URI of the color profile.
  */
-public class ICCColorSpaceExt extends ICC_ColorSpace implements ColorSpaceOrigin {
+public class ICCColorSpaceWithIntent extends ICC_ColorSpace implements ColorSpaceOrigin {
 
     private static final long serialVersionUID = -3338065900662625221L;
 
-    /** Constant for the perceptual rendering intent. Typical use: scanned images. */
-    public static final int PERCEPTUAL = 0;
-    /** Constant for the relative colorimetric rendering intent. Typical use: vector graphics.
*/
-    public static final int RELATIVE_COLORIMETRIC = 1;
-    /**
-     * Constant for the absolute colorimetric rendering intent.
-     * Typical use: logos and solid colors.
-     */
-    public static final int ABSOLUTE_COLORIMETRIC = 2;
-    /** Constant for the saturation rendering intent. Typical use: business graphics. */
-    public static final int SATURATION = 3;
-    /** Automatic rendering intent. The color profile's intent isn't overridden. */
-    public static final int AUTO = 4;
-
     static final ColorSpace SRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
 
-    private int intent;
+    private RenderingIntent intent;
     private String profileName;
     private String profileURI;
 
     /**
      * Creates a new ICC-based color space.
      * @param p the color profile
-     * @param intent the overriding rendering intent (use {@link #AUTO} no preserve the profile's)
+     * @param intent the overriding rendering intent (use {@link RenderingIntent#AUTO}
+     *          to preserve the profile's)
      * @param profileName the color profile name
      * @param profileURI the source URI of the color profile
      */
-    public ICCColorSpaceExt(ICC_Profile p, int intent, String profileName, String profileURI)
{
+    public ICCColorSpaceWithIntent(ICC_Profile p, RenderingIntent intent,
+            String profileName, String profileURI) {
         super(p);
 
         this.intent = intent;
-        switch(intent) {
-        case AUTO:
-        case RELATIVE_COLORIMETRIC:
-        case ABSOLUTE_COLORIMETRIC:
-        case SATURATION:
-        case PERCEPTUAL:
-            break;
-        default:
-            throw new IllegalArgumentException();
-        }
 
         /**
          * Apply the requested intent into the profile
          */
-        if (intent != AUTO) {
+        if (intent != RenderingIntent.AUTO) {
             byte[] hdr = p.getData(ICC_Profile.icSigHead);
-            hdr[ICC_Profile.icHdrRenderingIntent] = (byte)intent;
+            hdr[ICC_Profile.icHdrRenderingIntent] = (byte)intent.getIntegerValue();
         }
 
         this.profileName = profileName;
@@ -97,16 +75,16 @@ public class ICCColorSpaceExt extends IC
      */
     public float[] intendedToRGB(float[] values) {
         switch(intent) {
-            case ABSOLUTE_COLORIMETRIC:
+        case ABSOLUTE_COLORIMETRIC:
             return absoluteColorimetricToRGB(values);
-            case PERCEPTUAL:
-            case AUTO:
+        case PERCEPTUAL:
+        case AUTO:
             return perceptualToRGB(values);
-            case RELATIVE_COLORIMETRIC:
+        case RELATIVE_COLORIMETRIC:
             return relativeColorimetricToRGB(values);
-            case SATURATION:
+        case SATURATION:
             return saturationToRGB(values);
-            default:
+        default:
             throw new Error("invalid intent:" + intent );
         }
     }
@@ -117,7 +95,7 @@ public class ICCColorSpaceExt extends IC
      * @param values the color values in the local color space
      * @return the sRGB values
      */
-    public float[] perceptualToRGB(float[] values) {
+    private float[] perceptualToRGB(float[] values) {
         return toRGB(values);
     }
 
@@ -127,7 +105,7 @@ public class ICCColorSpaceExt extends IC
      * @param values the color values in the local color space
      * @return the sRGB values
      */
-    public float[] relativeColorimetricToRGB(float[] values) {
+    private float[] relativeColorimetricToRGB(float[] values) {
         float[] ciexyz = toCIEXYZ(values);
         return SRGB.fromCIEXYZ(ciexyz);
     }
@@ -138,7 +116,7 @@ public class ICCColorSpaceExt extends IC
      * @param values the color values in the local color space
      * @return the sRGB values
      */
-    public float[] absoluteColorimetricToRGB(float[] values) {
+    private float[] absoluteColorimetricToRGB(float[] values) {
         return perceptualToRGB(values);
     }
 
@@ -148,7 +126,7 @@ public class ICCColorSpaceExt extends IC
      * @param values the color values in the local color space
      * @return the sRGB values
      */
-    public float[] saturationToRGB(float[] values) {
+    private float[] saturationToRGB(float[] values) {
         return perceptualToRGB(values);
     }
 

Added: xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/RenderingIntent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/RenderingIntent.java?rev=1044394&view=auto
==============================================================================
--- xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/RenderingIntent.java
(added)
+++ xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/RenderingIntent.java
Fri Dec 10 15:07:47 2010
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.java2d.color;
+
+/**
+ * Enumeration for rendering intents.
+ */
+public enum RenderingIntent {
+
+    /** Perceptual rendering intent. Typical use: scanned images. */
+    PERCEPTUAL(0),
+    /** Relative colorimetric rendering intent. Typical use: vector graphics. */
+    RELATIVE_COLORIMETRIC(1),
+    /** Absolute colorimetric rendering intent. Typical use: logos and solid colors. */
+    ABSOLUTE_COLORIMETRIC(2),
+    /** Saturation rendering intent. Typical use: business graphics. */
+    SATURATION(3),
+    /** Automatic rendering intent. The color profile's intent isn't overridden. */
+    AUTO(4);
+
+    private int intValue;
+
+    private RenderingIntent(int value) {
+        this.intValue = value;
+    }
+
+    /**
+     * Returns an integer value identifying the rendering intent. This is the same value
defined
+     * by the ICC specification (0..3) plus one for "auto" (4).
+     * @return the integer value
+     */
+    public int getIntegerValue() {
+        return this.intValue;
+    }
+
+}

Propchange: xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/RenderingIntent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/RenderingIntent.java
------------------------------------------------------------------------------
    svn:keywords = Id



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Mime
View raw message