]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla 50698: Changes after updating XGC JAR
authorAndreas L. Delmelle <adelmelle@apache.org>
Tue, 1 Feb 2011 20:03:46 +0000 (20:03 +0000)
committerAndreas L. Delmelle <adelmelle@apache.org>
Tue, 1 Feb 2011 20:03:46 +0000 (20:03 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1066182 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/pdf/PDFICCBasedColorSpace.java
src/java/org/apache/fop/pdf/PDFResources.java
src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
src/java/org/apache/fop/util/ColorProfileUtil.java
src/java/org/apache/fop/util/ColorSpaceCache.java

index 7511bc20d1491b2455ed69a01767186cf952f7a1..4d473bb7c1732dd1fcd5c9662f53985dbcbde9ae 100644 (file)
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil;
 
 /**
  * Represents an ICCBased color space in PDF.
@@ -134,21 +135,19 @@ public class PDFICCBasedColorSpace extends PDFObject implements PDFColorSpace {
     public static PDFICCStream setupsRGBColorProfile(PDFDocument pdfDoc) {
         ICC_Profile profile;
         PDFICCStream sRGBProfile = pdfDoc.getFactory().makePDFICCStream();
-        synchronized (PDFICCBasedColorSpace.class) {
-            InputStream in = PDFDocument.class.getResourceAsStream("sRGB Color Space Profile.icm");
-            if (in != null) {
-                try {
-                    profile = ICC_Profile.getInstance(in);
-                } catch (IOException ioe) {
-                    throw new RuntimeException(
-                            "Unexpected IOException loading the sRGB profile: " + ioe.getMessage());
-                } finally {
-                    IOUtils.closeQuietly(in);
-                }
-            } else {
-                // Fallback: Use the sRGB profile from the JRE (about 140KB)
-                profile = ICC_Profile.getInstance(ColorSpace.CS_sRGB);
+        InputStream in = PDFDocument.class.getResourceAsStream("sRGB Color Space Profile.icm");
+        if (in != null) {
+            try {
+                profile = ColorProfileUtil.getICC_Profile(in);
+            } catch (IOException ioe) {
+                throw new RuntimeException(
+                        "Unexpected IOException loading the sRGB profile: " + ioe.getMessage());
+            } finally {
+                IOUtils.closeQuietly(in);
             }
+        } else {
+            // Fallback: Use the sRGB profile from the JRE (about 140KB)
+            profile = ColorProfileUtil.getICC_Profile(ColorSpace.CS_sRGB);
         }
         sRGBProfile.setColorSpace(profile, null);
         return sRGBProfile;
index 12eca75e47c8dc49f770232b7eb804b9ab977742..99a42433ca6f851837d6e91c2ccf50b43cde6cb5 100644 (file)
@@ -25,12 +25,12 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil;
 import org.apache.fop.fonts.FontDescriptor;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.Typeface;
 import org.apache.fop.fonts.base14.Symbol;
 import org.apache.fop.fonts.base14.ZapfDingbats;
-import org.apache.fop.util.ColorProfileUtil;
 
 /**
  * class representing a /Resources object.
index 2130ef6851e7ec31cc3cc7799f7ff67cca830b54..9e20886e0966a87e6cab93d973617a90b4339ff5 100644 (file)
@@ -25,6 +25,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.apache.xmlgraphics.image.loader.Image;
+import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil;
 
 import org.apache.fop.pdf.PDFColor;
 import org.apache.fop.pdf.PDFConformanceException;
@@ -35,7 +36,6 @@ import org.apache.fop.pdf.PDFICCBasedColorSpace;
 import org.apache.fop.pdf.PDFICCStream;
 import org.apache.fop.pdf.PDFImage;
 import org.apache.fop.pdf.PDFReference;
-import org.apache.fop.util.ColorProfileUtil;
 
 /**
  * Abstract PDFImage implementation for the PDF renderer.
index ae205a1e5e830cc60a79c7c43ea87586a8c343aa..e630594725fd1579b677f33866a349972a7abadf 100644 (file)
@@ -35,6 +35,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.apache.xmlgraphics.image.loader.util.ImageUtil;
+import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil;
 import org.apache.xmlgraphics.xmp.Metadata;
 import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter;
 import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
@@ -64,7 +65,6 @@ import org.apache.fop.pdf.PDFReference;
 import org.apache.fop.pdf.PDFText;
 import org.apache.fop.pdf.PDFXMode;
 import org.apache.fop.render.pdf.extensions.PDFEmbeddedFileExtensionAttachment;
-import org.apache.fop.util.ColorProfileUtil;
 
 /**
  * Utility class which enables all sorts of features that are not directly connected to the
@@ -294,7 +294,7 @@ class PDFRenderingUtil implements PDFConfigurationConstants {
                 in = new URL(src.getSystemId()).openStream();
             }
             try {
-                profile = ICC_Profile.getInstance(in);
+                profile = ColorProfileUtil.getICC_Profile(in);
             } finally {
                 IOUtils.closeQuietly(in);
             }
index 35b6660dc82e012a2a67a68df932bcbd69bf5c0b..9ee34d2b6259b985822cc192e2b3db8e12683e52 100644 (file)
 
 package org.apache.fop.util;
 
-import java.awt.color.ColorSpace;
-import java.awt.color.ICC_ColorSpace;
 import java.awt.color.ICC_Profile;
-import java.io.UnsupportedEncodingException;
 
 /**
  * Helper methods for handling color profiles.
+ * @deprecated use org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil directly
  */
 public final class ColorProfileUtil {
 
@@ -36,21 +34,11 @@ public final class ColorProfileUtil {
      * Returns the profile description of an ICC profile
      * @param profile the profile
      * @return the description
+     * @deprecated use org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil directly
      */
     public static String getICCProfileDescription(ICC_Profile profile) {
-        byte[] data = profile.getData(ICC_Profile.icSigProfileDescriptionTag);
-        if (data == null) {
-            return null;
-        } else {
-            //Info on the data format: http://www.color.org/ICC-1_1998-09.PDF
-            int length = (data[8] << 3 * 8) | (data[9] << 2 * 8) | (data[10] << 8) | data[11];
-            length--; //Remove trailing NUL character
-            try {
-                return new String(data, 12, length, "US-ASCII");
-            } catch (UnsupportedEncodingException e) {
-                throw new UnsupportedOperationException("Incompatible VM");
-            }
-        }
+        return org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil
+                .getICCProfileDescription(profile);
     }
 
     /**
@@ -58,14 +46,10 @@ public final class ColorProfileUtil {
      * provided by the Java class library.
      * @param profile the color profile to check
      * @return true if it is the default sRGB profile
+     * @deprecated use org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil directly
      */
     public static boolean isDefaultsRGB(ICC_Profile profile) {
-        ColorSpace sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
-        ICC_Profile sRGBProfile = null;
-        if (sRGB instanceof ICC_ColorSpace) {
-            sRGBProfile = ((ICC_ColorSpace)sRGB).getProfile();
-        }
-        return profile == sRGBProfile;
+        return org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil
+                .isDefaultsRGB(profile);
     }
-
 }
index 7b3f409e0163ece0cc35f1b9f5f446ead02c3855..63d8746f7f33ba81c7e0699bc455efcd77ae8987 100644 (file)
@@ -31,6 +31,7 @@ import javax.xml.transform.stream.StreamSource;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil;
 
 /**
  * Map with cached ICC based ColorSpace objects.
@@ -40,7 +41,8 @@ public class ColorSpaceCache {
     private static Log log = LogFactory.getLog(ColorSpaceCache.class);
 
     private URIResolver resolver;
-    private Map colorSpaceMap = Collections.synchronizedMap(new java.util.HashMap());
+    private Map<String, ColorSpace> colorSpaceMap
+            = Collections.synchronizedMap(new java.util.HashMap<String, ColorSpace>());
 
     /**
      * Default constructor
@@ -74,7 +76,7 @@ public class ColorSpaceCache {
                 if (src != null && src instanceof StreamSource) {
                     // FOP URI resolver found ICC profile - create ICC profile
                     // from the Source
-                    iccProfile = ICC_Profile.getInstance(((StreamSource) src)
+                    iccProfile = ColorProfileUtil.getICC_Profile(((StreamSource) src)
                             .getInputStream());
                 } else {
                     // TODO - Would it make sense to fall back on VM ICC
@@ -102,8 +104,7 @@ public class ColorSpaceCache {
                 log.warn("Color profile '" + iccProfileSrc + "' not found.");
             }
         } else {
-            colorSpace = (ColorSpace)colorSpaceMap.get(base
-                    + iccProfileSrc);
+            colorSpace = colorSpaceMap.get(base + iccProfileSrc);
         }
         return colorSpace;
     }