You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by je...@apache.org on 2010/12/13 15:37:37 UTC

svn commit: r1045137 - in /xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik: bridge/ ext/awt/color/ ext/awt/image/renderable/ ext/awt/image/rendered/ ext/awt/image/spi/

Author: jeremias
Date: Mon Dec 13 14:37:37 2010
New Revision: 1045137

URL: http://svn.apache.org/viewvc?rev=1045137&view=rev
Log:
Adjustments to changes in Apache XML Graphics Commons, mainly for our custom ColorSpace subclass.

Modified:
    xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/PaintServer.java
    xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/SVGColorProfileElementBridge.java
    xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/SVGImageElementBridge.java
    xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/color/NamedProfileCache.java
    xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/renderable/ProfileRable.java
    xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/rendered/ProfileRed.java
    xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/spi/ImageTagRegistry.java

Modified: xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/PaintServer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/PaintServer.java?rev=1045137&r1=1045136&r2=1045137&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/PaintServer.java (original)
+++ xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/PaintServer.java Mon Dec 13 14:37:37 2010
@@ -47,7 +47,7 @@ import org.apache.xmlgraphics.java2d.col
 import org.apache.xmlgraphics.java2d.color.ColorSpaces;
 import org.apache.xmlgraphics.java2d.color.ColorWithAlternatives;
 import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace;
-import org.apache.xmlgraphics.java2d.color.ICCColorSpaceExt;
+import org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent;
 import org.apache.xmlgraphics.java2d.color.NamedColorSpace;
 import org.apache.xmlgraphics.java2d.color.profile.NamedColorProfile;
 import org.apache.xmlgraphics.java2d.color.profile.NamedColorProfileParser;
@@ -438,8 +438,8 @@ public abstract class PaintServer
             return null; // no bridge for color profile
         }
 
-        ICCColorSpaceExt profileCS
-            = profileBridge.createICCColorSpaceExt(ctx, e, iccProfileName);
+        ICCColorSpaceWithIntent profileCS
+            = profileBridge.createICCColorSpaceWithIntent(ctx, e, iccProfileName);
         if (profileCS == null){
             return null; // no profile
         }
@@ -487,8 +487,8 @@ public abstract class PaintServer
             return null; // no bridge for color profile
         }
 
-        ICCColorSpaceExt profileCS
-            = profileBridge.createICCColorSpaceExt(ctx, e, iccProfileName);
+        ICCColorSpaceWithIntent profileCS
+            = profileBridge.createICCColorSpaceWithIntent(ctx, e, iccProfileName);
         if (profileCS == null){
             return null; // no profile
         }

Modified: xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/SVGColorProfileElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/SVGColorProfileElementBridge.java?rev=1045137&r1=1045136&r2=1045137&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/SVGColorProfileElementBridge.java (original)
+++ xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/SVGColorProfileElementBridge.java Mon Dec 13 14:37:37 2010
@@ -26,8 +26,8 @@ import org.apache.batik.dom.util.XLinkSu
 import org.apache.batik.ext.awt.color.NamedProfileCache;
 import org.apache.batik.util.ParsedURL;
 
-import org.apache.xmlgraphics.java2d.color.ICCColorSpaceExt;
-
+import org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent;
+import org.apache.xmlgraphics.java2d.color.RenderingIntent;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -56,18 +56,22 @@ public class SVGColorProfileElementBridg
 
     /**
      * Creates an ICC_ColorSpace according to the specified parameters.
+     * <p>
+     * If a color profile cannot be located an error message will be sent to the user agent
+     * and the method returns null. In this case, Batik will later fall back to sRGB.
      *
      * @param ctx the bridge context to use
      * @param paintedElement element on which the color is painted
      * @param iccProfileName name of the profile that should be loaded
      *        that could be a color-profile element or an @color-profile
      *        CSS rule
+     * @return the ICC color profile (or null if the color profile could not be located)
      */
-    public ICCColorSpaceExt createICCColorSpaceExt(BridgeContext ctx,
+    public ICCColorSpaceWithIntent createICCColorSpaceWithIntent(BridgeContext ctx,
                                                    Element paintedElement,
                                                    String iccProfileName) {
         // Check if there is one if the cache.
-        ICCColorSpaceExt cs = cache.request(iccProfileName.toLowerCase()); // todo locale??
+        ICCColorSpaceWithIntent cs = cache.request(iccProfileName.toLowerCase()); // todo locale??
         if (cs != null){
             return cs;
         }
@@ -80,7 +84,7 @@ public class SVGColorProfileElementBridg
 
         int n = list.getLength();
         Element profile = null;
-        for(int i=0; i<n; i++){
+        for(int i = 0; i < n; i++){
             Node node = list.item(i);
             if(node.getNodeType() == Node.ELEMENT_NODE){
                 Element profileNode = (Element)node;
@@ -93,8 +97,9 @@ public class SVGColorProfileElementBridg
             }
         }
 
-        if(profile == null)
+        if (profile == null) {
             return null;
+        }
 
         // Now that we have a profile element,
         // try to load the corresponding ICC profile xlink:href
@@ -136,36 +141,36 @@ public class SVGColorProfileElementBridg
         }
 
         // Extract the rendering intent from profile element
-        int intent = convertIntent(profile, ctx);
-        cs = new ICCColorSpaceExt(p, intent, href, iccProfileName);
+        RenderingIntent intent = convertIntent(profile, ctx);
+        cs = new ICCColorSpaceWithIntent(p, intent, href, iccProfileName);
 
         // Add profile to cache
         cache.put(iccProfileName.toLowerCase(), cs);
         return cs;
     }
 
-    private static int convertIntent(Element profile, BridgeContext ctx) {
+    private static RenderingIntent convertIntent(Element profile, BridgeContext ctx) {
 
         String intent
             = profile.getAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE);
 
         if (intent.length() == 0) {
-            return ICCColorSpaceExt.AUTO;
+            return RenderingIntent.AUTO;
         }
         if (SVG_PERCEPTUAL_VALUE.equals(intent)) {
-            return ICCColorSpaceExt.PERCEPTUAL;
+            return RenderingIntent.PERCEPTUAL;
         }
         if (SVG_AUTO_VALUE.equals(intent)) {
-            return ICCColorSpaceExt.AUTO;
+            return RenderingIntent.AUTO;
         }
         if (SVG_RELATIVE_COLORIMETRIC_VALUE.equals(intent)) {
-            return ICCColorSpaceExt.RELATIVE_COLORIMETRIC;
+            return RenderingIntent.RELATIVE_COLORIMETRIC;
         }
         if (SVG_ABSOLUTE_COLORIMETRIC_VALUE.equals(intent)) {
-            return ICCColorSpaceExt.ABSOLUTE_COLORIMETRIC;
+            return RenderingIntent.ABSOLUTE_COLORIMETRIC;
         }
         if (SVG_SATURATION_VALUE.equals(intent)) {
-            return ICCColorSpaceExt.SATURATION;
+            return RenderingIntent.SATURATION;
         }
         throw new BridgeException
             (ctx, profile, ERR_ATTRIBUTE_VALUE_MALFORMED,

Modified: xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/SVGImageElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/SVGImageElementBridge.java?rev=1045137&r1=1045136&r2=1045137&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/SVGImageElementBridge.java (original)
+++ xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/bridge/SVGImageElementBridge.java Mon Dec 13 14:37:37 2010
@@ -42,6 +42,7 @@ import org.apache.batik.dom.svg.LiveAttr
 import org.apache.batik.dom.svg.SVGOMAnimatedPreserveAspectRatio;
 import org.apache.batik.dom.svg.SVGOMDocument;
 import org.apache.batik.dom.svg.SVGOMElement;
+import org.apache.batik.dom.util.DOMUtilities;
 import org.apache.batik.ext.awt.image.renderable.ClipRable8Bit;
 import org.apache.batik.ext.awt.image.renderable.Filter;
 import org.apache.batik.ext.awt.image.spi.BrokenLinkProvider;
@@ -57,7 +58,8 @@ import org.apache.batik.util.MimeTypeCon
 import org.apache.batik.util.ParsedURL;
 import org.apache.batik.util.XMLConstants;
 
-import org.apache.xmlgraphics.java2d.color.ICCColorSpaceExt;
+import org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent;
+import org.apache.xmlgraphics.java2d.color.RenderingIntent;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -205,7 +207,7 @@ public class SVGImageElementBridge exten
 
         DocumentLoader loader = ctx.getDocumentLoader();
         ImageTagRegistry reg = ImageTagRegistry.getRegistry();
-        ICCColorSpaceExt colorspace = extractColorSpace(e, ctx);
+        ICCColorSpaceWithIntent colorspace = extractColorSpace(e, ctx);
         {
             /**
              *  Before we open the URL we see if we have the
@@ -957,19 +959,19 @@ public class SVGImageElementBridge exten
      * @param element the element with the color-profile property
      * @param ctx the bridge context
      */
-    protected static ICCColorSpaceExt extractColorSpace(Element element,
+    protected static ICCColorSpaceWithIntent extractColorSpace(Element element,
                                                         BridgeContext ctx) {
 
         String colorProfileProperty = CSSUtilities.getComputedStyle
             (element, SVGCSSEngine.COLOR_PROFILE_INDEX).getStringValue();
 
         // The only cases that need special handling are 'sRGB' and 'name'
-        ICCColorSpaceExt colorSpace = null;
+        ICCColorSpaceWithIntent colorSpace = null;
         if (CSS_SRGB_VALUE.equalsIgnoreCase(colorProfileProperty)) {
 
-            colorSpace = new ICCColorSpaceExt
+            colorSpace = new ICCColorSpaceWithIntent
                 (ICC_Profile.getInstance(ColorSpace.CS_sRGB),
-                 ICCColorSpaceExt.AUTO, "sRGB", null);
+                 RenderingIntent.AUTO, "sRGB", null);
 
         } else if (!CSS_AUTO_VALUE.equalsIgnoreCase(colorProfileProperty)
                    && !"".equalsIgnoreCase(colorProfileProperty)){
@@ -979,7 +981,7 @@ public class SVGImageElementBridge exten
                 (SVGColorProfileElementBridge) ctx.getBridge
                 (SVG_NAMESPACE_URI, SVG_COLOR_PROFILE_TAG);
             if (profileBridge != null) {
-                colorSpace = profileBridge.createICCColorSpaceExt
+                colorSpace = profileBridge.createICCColorSpaceWithIntent
                     (ctx, element, colorProfileProperty);
 
             }

Modified: xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/color/NamedProfileCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/color/NamedProfileCache.java?rev=1045137&r1=1045136&r2=1045137&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/color/NamedProfileCache.java (original)
+++ xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/color/NamedProfileCache.java Mon Dec 13 14:37:37 2010
@@ -21,7 +21,7 @@ package org.apache.batik.ext.awt.color;
 
 import org.apache.batik.util.SoftReferenceCache;
 
-import org.apache.xmlgraphics.java2d.color.ICCColorSpaceExt;
+import org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent;
 
 /**
  * This class manages a cache of soft references to named profiles that
@@ -71,8 +71,8 @@ public class NamedProfileCache extends S
      * cache.
      * @param the profile name
      */
-    public synchronized ICCColorSpaceExt request(String profileName) {
-        return (ICCColorSpaceExt)super.requestImpl(profileName);
+    public synchronized ICCColorSpaceWithIntent request(String profileName) {
+        return (ICCColorSpaceWithIntent)super.requestImpl(profileName);
     }
 
     /**
@@ -91,7 +91,7 @@ public class NamedProfileCache extends S
      * probably cleared or flushed since we were put on the hook
      * for it, so in that case we will do nothing.
      */
-    public synchronized void put(String profileName, ICCColorSpaceExt bi) {
+    public synchronized void put(String profileName, ICCColorSpaceWithIntent bi) {
         super.putImpl(profileName, bi);
     }
 }

Modified: xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/renderable/ProfileRable.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/renderable/ProfileRable.java?rev=1045137&r1=1045136&r2=1045137&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/renderable/ProfileRable.java (original)
+++ xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/renderable/ProfileRable.java Mon Dec 13 14:37:37 2010
@@ -25,7 +25,7 @@ import org.apache.batik.ext.awt.image.Gr
 import org.apache.batik.ext.awt.image.rendered.CachableRed;
 import org.apache.batik.ext.awt.image.rendered.ProfileRed;
 
-import org.apache.xmlgraphics.java2d.color.ICCColorSpaceExt;
+import org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent;
 
 /**
  * Implements the interface expected from a color matrix
@@ -36,13 +36,13 @@ import org.apache.xmlgraphics.java2d.col
  */
 public class ProfileRable extends  AbstractRable{
 
-    private ICCColorSpaceExt colorSpace;
+    private ICCColorSpaceWithIntent colorSpace;
 
     /**
      * Instances should be built through the static
      * factory methods
      */
-    public ProfileRable(Filter src, ICCColorSpaceExt colorSpace){
+    public ProfileRable(Filter src, ICCColorSpaceWithIntent colorSpace){
         super(src);
         this.colorSpace = colorSpace;
     }
@@ -64,7 +64,7 @@ public class ProfileRable extends  Abstr
     /**
      * Sets the ColorSpace of the Profile operation
      */
-    public void setColorSpace(ICCColorSpaceExt colorSpace){
+    public void setColorSpace(ICCColorSpaceWithIntent colorSpace){
         touch();
         this.colorSpace = colorSpace;
     }
@@ -72,7 +72,7 @@ public class ProfileRable extends  Abstr
     /**
      * Returns the ColorSpace of the Profile operation
      */
-    public ICCColorSpaceExt getColorSpace(){
+    public ICCColorSpaceWithIntent getColorSpace(){
         return colorSpace;
     }
 

Modified: xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/rendered/ProfileRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/rendered/ProfileRed.java?rev=1045137&r1=1045136&r2=1045137&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/rendered/ProfileRed.java (original)
+++ xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/rendered/ProfileRed.java Mon Dec 13 14:37:37 2010
@@ -35,7 +35,7 @@ import java.awt.image.Raster;
 import java.awt.image.RenderedImage;
 import java.awt.image.WritableRaster;
 
-import org.apache.xmlgraphics.java2d.color.ICCColorSpaceExt;
+import org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent;
 
 /**
  * This implementation of rendered image forces a color profile
@@ -57,7 +57,7 @@ public class ProfileRed extends Abstract
                                false,
                                DataBuffer.TYPE_INT);
 
-    private ICCColorSpaceExt colorSpace;
+    private ICCColorSpaceWithIntent colorSpace;
 
     /**
      * @param src Images on which the input ColorSpace should
@@ -66,7 +66,7 @@ public class ProfileRed extends Abstract
      *        source
      */
     public ProfileRed(CachableRed src,
-                      ICCColorSpaceExt colorSpace){
+                      ICCColorSpaceWithIntent colorSpace){
         this.colorSpace = colorSpace;
 
         init(src, src.getBounds(),

Modified: xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/spi/ImageTagRegistry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/spi/ImageTagRegistry.java?rev=1045137&r1=1045136&r2=1045137&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/spi/ImageTagRegistry.java (original)
+++ xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/ext/awt/image/spi/ImageTagRegistry.java Mon Dec 13 14:37:37 2010
@@ -34,7 +34,7 @@ import org.apache.batik.ext.awt.image.re
 import org.apache.batik.util.ParsedURL;
 import org.apache.batik.util.Service;
 
-import org.apache.xmlgraphics.java2d.color.ICCColorSpaceExt;
+import org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent;
 
 /**
  * This class handles the registered Image tag handlers.  These are
@@ -83,7 +83,7 @@ public class ImageTagRegistry implements
         imgCache.clear(purl);
     }
 
-    public Filter checkCache(ParsedURL purl, ICCColorSpaceExt colorSpace) {
+    public Filter checkCache(ParsedURL purl, ICCColorSpaceWithIntent colorSpace) {
         // I just realized that this whole thing could
         boolean needRawData = (colorSpace != null);
 
@@ -108,12 +108,12 @@ public class ImageTagRegistry implements
         return readURL(null, purl, null, true, true);
     }
 
-    public Filter readURL(ParsedURL purl, ICCColorSpaceExt colorSpace) {
+    public Filter readURL(ParsedURL purl, ICCColorSpaceWithIntent colorSpace) {
         return readURL(null, purl, colorSpace, true, true);
     }
 
     public Filter readURL(InputStream is, ParsedURL purl,
-                          ICCColorSpaceExt colorSpace,
+                          ICCColorSpaceWithIntent colorSpace,
                           boolean allowOpenStream,
                           boolean returnBrokenLink) {
         if ((is != null) && !is.markSupported())
@@ -230,7 +230,7 @@ public class ImageTagRegistry implements
         return readStream(is, null);
     }
 
-    public Filter readStream(InputStream is, ICCColorSpaceExt colorSpace) {
+    public Filter readStream(InputStream is, ICCColorSpaceWithIntent colorSpace) {
         if (!is.markSupported())
             // Doesn't support mark so wrap with BufferedInputStream that does.
             is = new BufferedInputStream(is);