Author: lbernardo
Date: Mon Aug 11 14:03:51 2014
New Revision: 1617286

URL: http://svn.apache.org/r1617286
Log:
merged svg12color branch

Added:
    xmlgraphics/batik/trunk/lib/LICENSE.xmlgraphics-commons.txt
      - copied unchanged from r1617277, 
xmlgraphics/batik/branches/svgcolor12/lib/LICENSE.xmlgraphics-commons.txt
    xmlgraphics/batik/trunk/lib/NOTICE.xmlgraphics-commons.txt
      - copied, changed from r1617277, 
xmlgraphics/batik/branches/svgcolor12/lib/NOTICE.xmlgraphics-commons.txt
    xmlgraphics/batik/trunk/lib/xmlgraphics-commons-svn-trunk.jar   (with props)
    xmlgraphics/batik/trunk/samples/tests/spec12/paints/colorFunctions.svg
      - copied unchanged from r1617277, 
xmlgraphics/batik/branches/svgcolor12/samples/tests/spec12/paints/colorFunctions.svg
    xmlgraphics/batik/trunk/samples/tests/spec12/paints/colorFunctionsDevice.svg
      - copied unchanged from r1617277, 
xmlgraphics/batik/branches/svgcolor12/samples/tests/spec12/paints/colorFunctionsDevice.svg
    xmlgraphics/batik/trunk/samples/tests/spec12/paints/ncp-example.icc
      - copied unchanged from r1617277, 
xmlgraphics/batik/branches/svgcolor12/samples/tests/spec12/paints/ncp-example.icc
    
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg12/AbstractCIEColor.java
      - copied unchanged from r1617277, 
xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/css/engine/value/svg12/AbstractCIEColor.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg12/CIELCHColor.java
      - copied unchanged from r1617277, 
xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/css/engine/value/svg12/CIELCHColor.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg12/CIELabColor.java
      - copied unchanged from r1617277, 
xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/css/engine/value/svg12/CIELabColor.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg12/DeviceColor.java
      - copied unchanged from r1617277, 
xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/css/engine/value/svg12/DeviceColor.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg12/ICCNamedColor.java
      - copied unchanged from r1617277, 
xmlgraphics/batik/branches/svgcolor12/sources/org/apache/batik/css/engine/value/svg12/ICCNamedColor.java
Modified:
    xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/CSSUtilities.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/PaintServer.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGColorProfileElementBridge.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGImageElementBridge.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/svg12/SVGSolidColorElementBridge.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg/ICCColor.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg/SVGColorManager.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/color/ICCColorSpaceExt.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/color/NamedProfileCache.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/renderable/ProfileRable.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/rendered/ProfileRed.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/spi/ImageTagRegistry.java
    
xmlgraphics/batik/trunk/sources/org/apache/batik/util/SoftReferenceCache.java

Copied: xmlgraphics/batik/trunk/lib/NOTICE.xmlgraphics-commons.txt (from 
r1617277, 
xmlgraphics/batik/branches/svgcolor12/lib/NOTICE.xmlgraphics-commons.txt)
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/lib/NOTICE.xmlgraphics-commons.txt?p2=xmlgraphics/batik/trunk/lib/NOTICE.xmlgraphics-commons.txt&p1=xmlgraphics/batik/branches/svgcolor12/lib/NOTICE.xmlgraphics-commons.txt&r1=1617277&r2=1617286&rev=1617286&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svgcolor12/lib/NOTICE.xmlgraphics-commons.txt 
(original)
+++ xmlgraphics/batik/trunk/lib/NOTICE.xmlgraphics-commons.txt Mon Aug 11 
14:03:51 2014
@@ -1,5 +1,5 @@
 Apache XML Graphics Commons
-Copyright 2006-2010 The Apache Software Foundation
+Copyright 2006-2007 The Apache Software Foundation
 
 This product includes software developed at
 The Apache Software Foundation (http://www.apache.org/).

Added: xmlgraphics/batik/trunk/lib/xmlgraphics-commons-svn-trunk.jar
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/lib/xmlgraphics-commons-svn-trunk.jar?rev=1617286&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/batik/trunk/lib/xmlgraphics-commons-svn-trunk.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: 
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/CSSUtilities.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/CSSUtilities.java?rev=1617286&r1=1617285&r2=1617286&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/CSSUtilities.java 
(original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/CSSUtilities.java 
Mon Aug 11 14:03:51 2014
@@ -31,7 +31,6 @@ import org.apache.batik.css.engine.CSSSt
 import org.apache.batik.css.engine.SVGCSSEngine;
 import org.apache.batik.css.engine.value.ListValue;
 import org.apache.batik.css.engine.value.Value;
-import org.apache.batik.css.engine.value.svg.ICCColor;
 import org.apache.batik.dom.svg.SVGOMDocument;
 import org.apache.batik.ext.awt.MultipleGradientPaint;
 import org.apache.batik.ext.awt.image.renderable.ClipRable;
@@ -815,7 +814,7 @@ public abstract class CSSUtilities
             return PaintServer.convertColor(v, 1);
         } else {
             return PaintServer.convertRGBICCColor
-                (e, v.item(0), (ICCColor)v.item(1), 1, ctx);
+                (e, v.item(0), v.item(1), 1, ctx);
         }
     }
 
@@ -838,7 +837,7 @@ public abstract class CSSUtilities
             return PaintServer.convertColor(v, f);
         } else {
             return PaintServer.convertRGBICCColor
-                (e, v.item(0), (ICCColor)v.item(1), f, ctx);
+                (e, v.item(0), v.item(1), f, ctx);
         }
     }
 
@@ -864,7 +863,7 @@ public abstract class CSSUtilities
             return PaintServer.convertColor(v, opacity);
         } else {
             return PaintServer.convertRGBICCColor
-                (e, v.item(0), (ICCColor)v.item(1), opacity, ctx);
+                (e, v.item(0), v.item(1), opacity, ctx);
         }
     }
 

Modified: 
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/PaintServer.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/PaintServer.java?rev=1617286&r1=1617285&r2=1617286&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/PaintServer.java 
(original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/PaintServer.java 
Mon Aug 11 14:03:51 2014
@@ -23,11 +23,15 @@ import java.awt.Color;
 import java.awt.Paint;
 import java.awt.Shape;
 import java.awt.Stroke;
+import java.awt.color.ICC_Profile;
+import java.io.IOException;
 
 import org.apache.batik.css.engine.SVGCSSEngine;
 import org.apache.batik.css.engine.value.Value;
 import org.apache.batik.css.engine.value.svg.ICCColor;
-import org.apache.batik.ext.awt.color.ICCColorSpaceExt;
+import org.apache.batik.css.engine.value.svg12.CIELabColor;
+import org.apache.batik.css.engine.value.svg12.DeviceColor;
+import org.apache.batik.css.engine.value.svg12.ICCNamedColor;
 import org.apache.batik.gvt.CompositeShapePainter;
 import org.apache.batik.gvt.FillShapePainter;
 import org.apache.batik.gvt.GraphicsNode;
@@ -38,6 +42,16 @@ import org.apache.batik.gvt.ShapePainter
 import org.apache.batik.gvt.StrokeShapePainter;
 import org.apache.batik.util.CSSConstants;
 import org.apache.batik.util.SVGConstants;
+
+import org.apache.xmlgraphics.java2d.color.CIELabColorSpace;
+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.ICCColorSpaceWithIntent;
+import org.apache.xmlgraphics.java2d.color.NamedColorSpace;
+import org.apache.xmlgraphics.java2d.color.profile.NamedColorProfile;
+import org.apache.xmlgraphics.java2d.color.profile.NamedColorProfileParser;
+
 import org.w3c.dom.Element;
 import org.w3c.dom.css.CSSPrimitiveValue;
 import org.w3c.dom.css.CSSValue;
@@ -271,7 +285,7 @@ public abstract class PaintServer
             switch (v.getPrimitiveType()) {
             case CSSPrimitiveValue.CSS_RGBCOLOR:
                 return convertRGBICCColor(paintedElement, v,
-                                          (ICCColor)paintDef.item(1),
+                                          paintDef.item(1),
                                           opacity, ctx);
 
             case CSSPrimitiveValue.CSS_URI: {
@@ -290,7 +304,7 @@ public abstract class PaintServer
                         return convertColor(v, opacity);
                     } else {
                         return convertRGBICCColor(paintedElement, v,
-                                                  (ICCColor)paintDef.item(2),
+                                                  paintDef.item(2),
                                                   opacity, ctx);
                     }
                 default:
@@ -376,12 +390,20 @@ public abstract class PaintServer
      */
     public static Color convertRGBICCColor(Element paintedElement,
                                            Value colorDef,
-                                           ICCColor iccColor,
+                                           Value iccColor,
                                            float opacity,
                                            BridgeContext ctx) {
         Color color = null;
-        if (iccColor != null){
-            color = convertICCColor(paintedElement, iccColor, opacity, ctx);
+        if (iccColor != null) {
+            if (iccColor instanceof ICCColor) {
+                color = convertICCColor(paintedElement, (ICCColor)iccColor, 
opacity, ctx);
+            } else if (iccColor instanceof ICCNamedColor) {
+                color = convertICCNamedColor(paintedElement, 
(ICCNamedColor)iccColor, opacity, ctx);
+            } else if (iccColor instanceof CIELabColor) {
+                color = convertCIELabColor(paintedElement, 
(CIELabColor)iccColor, opacity, ctx);
+            } else if (iccColor instanceof DeviceColor) {
+                color = convertDeviceColor(paintedElement, colorDef, 
(DeviceColor)iccColor, opacity, ctx);
+            }
         }
         if (color == null){
             color = convertColor(colorDef, opacity);
@@ -402,7 +424,7 @@ public abstract class PaintServer
     public static Color convertICCColor(Element e,
                                         ICCColor c,
                                         float opacity,
-                                        BridgeContext ctx){
+                                        BridgeContext ctx) {
         // Get ICC Profile's name
         String iccProfileName = c.getColorProfile();
         if (iccProfileName == null){
@@ -416,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
         }
@@ -434,10 +456,129 @@ public abstract class PaintServer
 
         // Convert values to RGB
         float[] rgb = profileCS.intendedToRGB(colorValue);
+        //TODO Preserve original ICC color 
value!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
         return new Color(rgb[0], rgb[1], rgb[2], opacity);
     }
 
     /**
+     * Returns a Color object that corresponds to the input Paint's
+     * ICC named color value or null if the related color profile could not
+     * be used or loaded for any reason.
+     *
+     * @param e the element using the color
+     * @param c the ICC named color definition
+     * @param opacity the opacity
+     * @param ctx the bridge context to use
+     */
+    public static Color convertICCNamedColor(Element e,
+                                        ICCNamedColor c,
+                                        float opacity,
+                                        BridgeContext ctx) {
+        // Get ICC Profile's name
+        String iccProfileName = c.getColorProfile();
+        if (iccProfileName == null){
+            return null;
+        }
+        // Ask the bridge to map the ICC profile name to an  ICC_Profile object
+        SVGColorProfileElementBridge profileBridge
+            = (SVGColorProfileElementBridge)
+            ctx.getBridge(SVG_NAMESPACE_URI, SVG_COLOR_PROFILE_TAG);
+        if (profileBridge == null){
+            return null; // no bridge for color profile
+        }
+
+        ICCColorSpaceWithIntent profileCS
+            = profileBridge.createICCColorSpaceWithIntent(ctx, e, 
iccProfileName);
+        if (profileCS == null){
+            return null; // no profile
+        }
+        ICC_Profile iccProfile = profileCS.getProfile();
+
+        String iccProfileSrc = null; //TODO Fill me!
+
+        if (NamedColorProfileParser.isNamedColorProfile(iccProfile)) {
+            NamedColorProfileParser parser = new NamedColorProfileParser();
+            NamedColorProfile ncp;
+            try {
+                ncp = parser.parseProfile(iccProfile, iccProfileName, 
iccProfileSrc);
+            } catch (IOException ioe) {
+                return null;
+            }
+            NamedColorSpace ncs = ncp.getNamedColor(c.getColorName());
+            if (ncs != null) {
+                Color specColor
+                    = new ColorWithAlternatives(ncs, new float[] {1.0f}, 
opacity, null);
+                return specColor;
+            } else {
+                /*
+                log.warn("Color '" + colorName
+                        + "' does not exist in named color profile: " + 
iccProfileSrc);
+                */
+            }
+        } else {
+            //log.warn("ICC profile is no named color profile: " + 
iccProfileSrc);
+        }
+
+        return null;
+    }
+
+    /**
+     * Returns a Color object that corresponds to the input Paint's
+     * CIE Lab color value.
+     *
+     * @param e the element using the color
+     * @param c the CIE Lab color definition
+     * @param opacity the opacity
+     * @param ctx the bridge context to use
+     */
+    public static Color convertCIELabColor(Element e,
+                                        CIELabColor c,
+                                        float opacity,
+                                        BridgeContext ctx) {
+        CIELabColorSpace cs = new CIELabColorSpace(c.getWhitePoint());
+        float[] lab = c.getColorValues();
+        Color specColor = cs.toColor(lab[0], lab[1], lab[2], opacity);
+        return specColor;
+    }
+
+    /**
+     * Returns a Color object that corresponds to the input Paint's
+     * device-specific color value.
+     *
+     * @param e the element using the color
+     * @param srgb the sRGB fallback color
+     * @param c the device-specific color definition
+     * @param opacity the opacity
+     * @param ctx the bridge context to use
+     */
+    public static Color convertDeviceColor(Element e,
+                                        Value srgb,
+                                        DeviceColor c,
+                                        float opacity,
+                                        BridgeContext ctx) {
+        int r = resolveColorComponent(srgb.getRed());
+        int g = resolveColorComponent(srgb.getGreen());
+        int b = resolveColorComponent(srgb.getBlue());
+        if (c.isNChannel()) {
+            return convertColor(srgb, opacity); //NYI
+        } else {
+            if (c.getNumberOfColors() == 4) {
+                DeviceCMYKColorSpace cmykCs = 
ColorSpaces.getDeviceCMYKColorSpace();
+                float[] comps = new float[4];
+                for (int i = 0; i < 4; i++) {
+                    comps[i] = c.getColor(i);
+                }
+                Color cmyk = new ColorWithAlternatives(cmykCs, comps, opacity, 
null);
+                Color specColor = new ColorWithAlternatives(r, g, b, 
Math.round(opacity * 255f),
+                        new Color[] {cmyk});
+                return specColor;
+            } else {
+                return convertColor(srgb, opacity); //NYI
+            }
+        }
+    }
+
+    /**
      * Converts the given Value and opacity to a Color object.
      * @param c The CSS color to convert.
      * @param opacity The opacity value (0 &lt;= o &lt;= 1).

Modified: 
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGColorProfileElementBridge.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGColorProfileElementBridge.java?rev=1617286&r1=1617285&r2=1617286&view=diff
==============================================================================
--- 
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGColorProfileElementBridge.java
 (original)
+++ 
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGColorProfileElementBridge.java
 Mon Aug 11 14:03:51 2014
@@ -23,10 +23,11 @@ import java.io.IOException;
 
 import org.apache.batik.dom.AbstractNode;
 import org.apache.batik.dom.util.XLinkSupport;
-import org.apache.batik.ext.awt.color.ICCColorSpaceExt;
 import org.apache.batik.ext.awt.color.NamedProfileCache;
 import org.apache.batik.util.ParsedURL;
 
+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;
@@ -55,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;
         }
@@ -79,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;
@@ -92,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
@@ -107,19 +113,27 @@ public class SVGColorProfileElementBridg
             }
 
             ParsedURL purl = new ParsedURL(pDocURL, href);
-            if (!purl.complete())
-                throw new BridgeException(ctx, paintedElement, 
ERR_URI_MALFORMED,
-                                          new Object[] {href});
+            if (!purl.complete()) {
+                BridgeException be = new BridgeException(ctx, paintedElement, 
ERR_URI_MALFORMED,
+                        new Object[] {href});
+                ctx.getUserAgent().displayError(be);
+                return null; //Don't throw. Continue without the profile
+            }
             try {
                 ctx.getUserAgent().checkLoadExternalResource(purl, pDocURL);
                 p = ICC_Profile.getInstance(purl.openStream());
             } catch (IOException ioEx) {
-                throw new BridgeException(ctx, paintedElement, ioEx, 
ERR_URI_IO,
+                BridgeException be = new BridgeException(ctx, paintedElement, 
ioEx, ERR_URI_IO,
                                           new Object[] {href});
+                ctx.getUserAgent().displayError(be);
+                return null; //Don't throw. Continue without the profile
                 // ??? IS THAT AN ERROR FOR THE SVG SPEC ???
             } catch (SecurityException secEx) {
-                throw new BridgeException(ctx, paintedElement, secEx, 
ERR_URI_UNSECURE,
-                                          new Object[] {href});
+                BridgeException be = new BridgeException(ctx, paintedElement, 
secEx,
+                        ERR_URI_UNSECURE,
+                        new Object[] {href});
+                ctx.getUserAgent().displayError(be);
+                return null; //Don't throw. Continue without the profile
             }
         }
         if (p == null) {
@@ -127,36 +141,36 @@ public class SVGColorProfileElementBridg
         }
 
         // Extract the rendering intent from profile element
-        int intent = convertIntent(profile, ctx);
-        cs = new ICCColorSpaceExt(p, intent);
+        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/trunk/sources/org/apache/batik/bridge/SVGImageElementBridge.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGImageElementBridge.java?rev=1617286&r1=1617285&r2=1617286&view=diff
==============================================================================
--- 
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGImageElementBridge.java
 (original)
+++ 
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGImageElementBridge.java
 Mon Aug 11 14:03:51 2014
@@ -42,7 +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.ext.awt.color.ICCColorSpaceExt;
+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;
@@ -58,6 +58,9 @@ import org.apache.batik.util.MimeTypeCon
 import org.apache.batik.util.ParsedURL;
 import org.apache.batik.util.XMLConstants;
 
+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.events.DocumentEvent;
@@ -204,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
@@ -956,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);
+                 RenderingIntent.AUTO, "sRGB", null);
 
         } else if (!CSS_AUTO_VALUE.equalsIgnoreCase(colorProfileProperty)
                    && !"".equalsIgnoreCase(colorProfileProperty)){
@@ -978,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/trunk/sources/org/apache/batik/bridge/svg12/SVGSolidColorElementBridge.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/svg12/SVGSolidColorElementBridge.java?rev=1617286&r1=1617285&r2=1617286&view=diff
==============================================================================
--- 
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/svg12/SVGSolidColorElementBridge.java
 (original)
+++ 
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/svg12/SVGSolidColorElementBridge.java
 Mon Aug 11 14:03:51 2014
@@ -34,7 +34,6 @@ import org.apache.batik.css.engine.CSSEn
 import org.apache.batik.css.engine.CSSStylableElement;
 import org.apache.batik.css.engine.StyleMap;
 import org.apache.batik.css.engine.value.Value;
-import org.apache.batik.css.engine.value.svg.ICCColor;
 import org.apache.batik.dom.svg.SVGOMDocument;
 import org.apache.batik.dom.util.XLinkSupport;
 import org.apache.batik.gvt.GraphicsNode;
@@ -156,7 +155,7 @@ public class SVGSolidColorElementBridge 
                 } else {
                     return PaintServer.convertRGBICCColor
                         (paintElement, colorDef.item(0),
-                         (ICCColor)colorDef.item(1),
+                         colorDef.item(1),
                          opacity, ctx);
                 }
             }

Modified: 
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg/ICCColor.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg/ICCColor.java?rev=1617286&r1=1617285&r2=1617286&view=diff
==============================================================================
--- 
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg/ICCColor.java
 (original)
+++ 
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg/ICCColor.java
 Mon Aug 11 14:03:51 2014
@@ -30,6 +30,8 @@ import org.w3c.dom.css.CSSValue;
  */
 public class ICCColor extends AbstractValue {
 
+    public static final String ICC_COLOR_FUNCTION = "icc-color";
+
     /**
      * The color profile.
      */
@@ -86,7 +88,7 @@ public class ICCColor extends AbstractVa
      */
     public String getCssText() {
         StringBuffer sb = new StringBuffer( count * 8 );
-        sb.append("icc-color(");
+        sb.append(ICC_COLOR_FUNCTION).append('(');
         sb.append(colorProfile);
         for (int i = 0; i < count; i++) {
             sb.append(", ");
@@ -107,4 +109,9 @@ public class ICCColor extends AbstractVa
         }
         colors[count++] = c;
     }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return getCssText();
+    }
 }

Modified: 
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg/SVGColorManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg/SVGColorManager.java?rev=1617286&r1=1617285&r2=1617286&view=diff
==============================================================================
--- 
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg/SVGColorManager.java
 (original)
+++ 
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/value/svg/SVGColorManager.java
 Mon Aug 11 14:03:51 2014
@@ -24,6 +24,10 @@ import org.apache.batik.css.engine.Style
 import org.apache.batik.css.engine.value.ListValue;
 import org.apache.batik.css.engine.value.Value;
 import org.apache.batik.css.engine.value.ValueManager;
+import org.apache.batik.css.engine.value.svg12.CIELCHColor;
+import org.apache.batik.css.engine.value.svg12.CIELabColor;
+import org.apache.batik.css.engine.value.svg12.DeviceColor;
+import org.apache.batik.css.engine.value.svg12.ICCNamedColor;
 import org.apache.batik.util.CSSConstants;
 import org.apache.batik.util.SVGTypes;
 
@@ -100,7 +104,7 @@ public class SVGColorManager extends Col
         return property;
     }
 
-    
+
     /**
      * Implements {@link
      * org.apache.batik.css.engine.value.ValueManager#getDefaultValue()}.
@@ -108,7 +112,7 @@ public class SVGColorManager extends Col
     public Value getDefaultValue() {
         return defaultValue;
     }
-    
+
     /**
      * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
      */
@@ -125,36 +129,162 @@ public class SVGColorManager extends Col
         if (lu == null) {
             return v;
         }
-        if (lu.getLexicalUnitType() != LexicalUnit.SAC_FUNCTION ||
-            !lu.getFunctionName().equalsIgnoreCase("icc-color")) {
-            throw createInvalidLexicalUnitDOMException
-                (lu.getLexicalUnitType());
-        }
-        lu = lu.getParameters();
-        if (lu.getLexicalUnitType() != LexicalUnit.SAC_IDENT) {
+
+        //If we have more content here, there is a color function after the 
sRGB color.
+        if (lu.getLexicalUnitType() != LexicalUnit.SAC_FUNCTION) {
             throw createInvalidLexicalUnitDOMException
                 (lu.getLexicalUnitType());
         }
+
         ListValue result = new ListValue(' ');
         result.append(v);
 
+        Value colorValue = parseColorFunction(lu, v);
+        if (colorValue != null) {
+            result.append(colorValue);
+        } else {
+            return v; //use sRGB fallback if an unsupported color function is 
encountered
+        }
+        return result;
+    }
+
+    private Value parseColorFunction(LexicalUnit lu, Value v) {
+        String functionName = lu.getFunctionName();
+        if (functionName.equalsIgnoreCase(ICCColor.ICC_COLOR_FUNCTION)) {
+            return createICCColorValue(lu, v);
+        }
+        return parseColor12Function(lu, v);
+    }
+
+    private Value parseColor12Function(LexicalUnit lu, Value v) {
+        String functionName = lu.getFunctionName();
+        if 
(functionName.equalsIgnoreCase(ICCNamedColor.ICC_NAMED_COLOR_FUNCTION)) {
+            return createICCNamedColorValue(lu, v);
+        } else if 
(functionName.equalsIgnoreCase(CIELabColor.CIE_LAB_COLOR_FUNCTION)) {
+            return createCIELabColorValue(lu, v);
+        } else if 
(functionName.equalsIgnoreCase(CIELCHColor.CIE_LCH_COLOR_FUNCTION)) {
+            return createCIELCHColorValue(lu, v);
+        } else if 
(functionName.equalsIgnoreCase(DeviceColor.DEVICE_CMYK_COLOR_FUNCTION)) {
+            return createDeviceColorValue(lu, v, 4);
+        } else if 
(functionName.equalsIgnoreCase(DeviceColor.DEVICE_RGB_COLOR_FUNCTION)) {
+            return createDeviceColorValue(lu, v, 3);
+        } else if 
(functionName.equalsIgnoreCase(DeviceColor.DEVICE_GRAY_COLOR_FUNCTION)) {
+            return createDeviceColorValue(lu, v, 1);
+        } else if 
(functionName.equalsIgnoreCase(DeviceColor.DEVICE_NCHANNEL_COLOR_FUNCTION)) {
+            return createDeviceColorValue(lu, v, 0);
+        }
+        return null;
+    }
+
+    private Value createICCColorValue(LexicalUnit lu, Value v) {
+        lu = lu.getParameters();
+        expectIdent(lu);
+
         ICCColor icc = new ICCColor(lu.getStringValue());
-        result.append(icc);
 
         lu = lu.getNextLexicalUnit();
         while (lu != null) {
-            if (lu.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
-                throw createInvalidLexicalUnitDOMException
-                    (lu.getLexicalUnitType());
-            }
+            expectComma(lu);
             lu = lu.getNextLexicalUnit();
-            if (lu == null) {
-                throw createInvalidLexicalUnitDOMException((short)-1);
-            }
             icc.append(getColorValue(lu));
             lu = lu.getNextLexicalUnit();
         }
-        return result;
+        return icc;
+    }
+
+    private Value createICCNamedColorValue(LexicalUnit lu, Value v) {
+        lu = lu.getParameters();
+        expectIdent(lu);
+        String profileName = lu.getStringValue();
+
+        lu = lu.getNextLexicalUnit();
+        expectComma(lu);
+        lu = lu.getNextLexicalUnit();
+        expectIdent(lu);
+        String colorName = lu.getStringValue();
+
+        ICCNamedColor icc = new ICCNamedColor(profileName, colorName);
+
+        lu = lu.getNextLexicalUnit();
+        return icc;
+    }
+
+    private Value createCIELabColorValue(LexicalUnit lu, Value v) {
+        lu = lu.getParameters();
+        float l = getColorValue(lu);
+        lu = lu.getNextLexicalUnit();
+        expectComma(lu);
+        lu = lu.getNextLexicalUnit();
+        float a = getColorValue(lu);
+        lu = lu.getNextLexicalUnit();
+        expectComma(lu);
+        lu = lu.getNextLexicalUnit();
+        float b = getColorValue(lu);
+
+        CIELabColor icc = new CIELabColor(l, a, b);
+
+        lu = lu.getNextLexicalUnit();
+        return icc;
+    }
+
+    private Value createCIELCHColorValue(LexicalUnit lu, Value v) {
+        lu = lu.getParameters();
+        float l = getColorValue(lu);
+        lu = lu.getNextLexicalUnit();
+        expectComma(lu);
+        lu = lu.getNextLexicalUnit();
+        float c = getColorValue(lu);
+        lu = lu.getNextLexicalUnit();
+        expectComma(lu);
+        lu = lu.getNextLexicalUnit();
+        float h = getColorValue(lu);
+
+        CIELCHColor icc = new CIELCHColor(l, c, h);
+
+        lu = lu.getNextLexicalUnit();
+        return icc;
+    }
+
+    private Value createDeviceColorValue(LexicalUnit lu, Value v, int 
expectedComponents) {
+        lu = lu.getParameters();
+
+        boolean nChannel = (expectedComponents <= 0);
+        DeviceColor col = new DeviceColor(nChannel);
+
+        col.append(getColorValue(lu));
+        LexicalUnit lastUnit = lu;
+        lu = lu.getNextLexicalUnit();
+        while (lu != null) {
+            expectComma(lu);
+            lu = lu.getNextLexicalUnit();
+            col.append(getColorValue(lu));
+            lastUnit = lu;
+            lu = lu.getNextLexicalUnit();
+        }
+        if (!nChannel && expectedComponents != col.getNumberOfColors()) {
+            throw 
createInvalidLexicalUnitDOMException(lastUnit.getLexicalUnitType());
+        }
+        return col;
+    }
+
+    private void expectIdent(LexicalUnit lu) {
+        if (lu.getLexicalUnitType() != LexicalUnit.SAC_IDENT) {
+            throw createInvalidLexicalUnitDOMException
+                (lu.getLexicalUnitType());
+        }
+    }
+
+    private void expectComma(LexicalUnit lu) {
+        if (lu.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
+            throw createInvalidLexicalUnitDOMException
+                (lu.getLexicalUnitType());
+        }
+    }
+
+    private void expectNonNull(LexicalUnit lu) {
+        if (lu == null) {
+            throw createInvalidLexicalUnitDOMException((short)-1);
+        }
     }
 
     /**
@@ -192,6 +322,7 @@ public class SVGColorManager extends Col
      * Creates a float value usable as a component of an RGBColor.
      */
     protected float getColorValue(LexicalUnit lu) {
+        expectNonNull(lu);
         switch (lu.getLexicalUnitType()) {
         case LexicalUnit.SAC_INTEGER:
             return lu.getIntegerValue();

Modified: 
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/color/ICCColorSpaceExt.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/color/ICCColorSpaceExt.java?rev=1617286&r1=1617285&r2=1617286&view=diff
==============================================================================
--- 
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/color/ICCColorSpaceExt.java
 (original)
+++ 
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/color/ICCColorSpaceExt.java
 Mon Aug 11 14:03:51 2014
@@ -30,6 +30,7 @@ import java.awt.color.ICC_Profile;
  *
  * @author <a href="mailto:[email protected]";>Vincent Hardy</a>
  * @version $Id$
+ * @deprecated use the version from XML Graphics Commons instead
  */
 public class ICCColorSpaceExt extends ICC_ColorSpace {
     public static final int PERCEPTUAL = 0;

Modified: 
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/color/NamedProfileCache.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/color/NamedProfileCache.java?rev=1617286&r1=1617285&r2=1617286&view=diff
==============================================================================
--- 
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/color/NamedProfileCache.java
 (original)
+++ 
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/color/NamedProfileCache.java
 Mon Aug 11 14:03:51 2014
@@ -21,9 +21,11 @@ package org.apache.batik.ext.awt.color;
 
 import org.apache.batik.util.SoftReferenceCache;
 
+import org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent;
+
 /**
  * This class manages a cache of soft references to named profiles that
- * we have already loaded. 
+ * we have already loaded.
  *
  * @author <a href="mailto:[email protected]";>Vincent Hardy</a>
  * @version $Id$
@@ -37,7 +39,9 @@ public class NamedProfileCache extends S
     /**
      * Let people create there own caches.
      */
-    public NamedProfileCache() { }
+    public NamedProfileCache() {
+        super(true);
+    }
 
     /**
      * Check if <code>request(profileName)</code> will return with a 
ICCColorSpaceExt
@@ -45,7 +49,7 @@ public class NamedProfileCache extends S
      * that this will return true but between this call and the call
      * to request the soft-reference will be cleared.  So it
      * is still possible for request to return NULL, just much less
-     * likely (you can always call 'clear' in that case). 
+     * likely (you can always call 'clear' in that case).
      */
     public synchronized boolean isPresent(String profileName) {
         return super.isPresentImpl(profileName);
@@ -64,9 +68,11 @@ public class NamedProfileCache extends S
     /**
      * If this returns null then you are now 'on the hook'.
      * to put the ICCColorSpaceExt associated with String into the
-     * cache.  */
-    public synchronized ICCColorSpaceExt request(String profileName) {
-        return (ICCColorSpaceExt)super.requestImpl(profileName);
+     * cache.
+     * @param the profile name
+     */
+    public synchronized ICCColorSpaceWithIntent request(String profileName) {
+        return (ICCColorSpaceWithIntent)super.requestImpl(profileName);
     }
 
     /**
@@ -85,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/trunk/sources/org/apache/batik/ext/awt/image/renderable/ProfileRable.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/renderable/ProfileRable.java?rev=1617286&r1=1617285&r2=1617286&view=diff
==============================================================================
--- 
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/renderable/ProfileRable.java
 (original)
+++ 
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/renderable/ProfileRable.java
 Mon Aug 11 14:03:51 2014
@@ -21,11 +21,12 @@ package org.apache.batik.ext.awt.image.r
 import java.awt.image.RenderedImage;
 import java.awt.image.renderable.RenderContext;
 
-import org.apache.batik.ext.awt.color.ICCColorSpaceExt;
 import org.apache.batik.ext.awt.image.GraphicsUtil;
 import org.apache.batik.ext.awt.image.rendered.CachableRed;
 import org.apache.batik.ext.awt.image.rendered.ProfileRed;
 
+import org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent;
+
 /**
  * Implements the interface expected from a color matrix
  * operation
@@ -34,14 +35,14 @@ import org.apache.batik.ext.awt.image.re
  * @version $Id$
  */
 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;
     }
@@ -63,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;
     }
@@ -71,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/trunk/sources/org/apache/batik/ext/awt/image/rendered/ProfileRed.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/rendered/ProfileRed.java?rev=1617286&r1=1617285&r2=1617286&view=diff
==============================================================================
--- 
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/rendered/ProfileRed.java
 (original)
+++ 
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/rendered/ProfileRed.java
 Mon Aug 11 14:03:51 2014
@@ -35,8 +35,7 @@ import java.awt.image.Raster;
 import java.awt.image.RenderedImage;
 import java.awt.image.WritableRaster;
 
-import org.apache.batik.ext.awt.color.ICCColorSpaceExt;
-
+import org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent;
 
 /**
  * This implementation of rendered image forces a color profile
@@ -58,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
@@ -67,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/trunk/sources/org/apache/batik/ext/awt/image/spi/ImageTagRegistry.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/spi/ImageTagRegistry.java?rev=1617286&r1=1617285&r2=1617286&view=diff
==============================================================================
--- 
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/spi/ImageTagRegistry.java
 (original)
+++ 
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/spi/ImageTagRegistry.java
 Mon Aug 11 14:03:51 2014
@@ -28,13 +28,14 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
 
-import org.apache.batik.ext.awt.color.ICCColorSpaceExt;
 import org.apache.batik.ext.awt.image.URLImageCache;
 import org.apache.batik.ext.awt.image.renderable.Filter;
 import org.apache.batik.ext.awt.image.renderable.ProfileRable;
 import org.apache.batik.util.ParsedURL;
 import org.apache.batik.util.Service;
 
+import org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent;
+
 /**
  * This class handles the registered Image tag handlers.  These are
  * instances of RegistryEntry in this package.
@@ -82,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);
 
@@ -107,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())
@@ -229,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);

Modified: 
xmlgraphics/batik/trunk/sources/org/apache/batik/util/SoftReferenceCache.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/util/SoftReferenceCache.java?rev=1617286&r1=1617285&r2=1617286&view=diff
==============================================================================
--- 
xmlgraphics/batik/trunk/sources/org/apache/batik/util/SoftReferenceCache.java 
(original)
+++ 
xmlgraphics/batik/trunk/sources/org/apache/batik/util/SoftReferenceCache.java 
Mon Aug 11 14:03:51 2014
@@ -53,10 +53,23 @@ public class SoftReferenceCache {
      */
     protected final Map map = new HashMap();
 
+    private final boolean synchronous;
+
     /**
      * Let people create their own caches.
      */
-    protected SoftReferenceCache() { }
+    protected SoftReferenceCache() {
+        this(false);
+    }
+
+    /**
+     * Constructs a soft reference cache.
+     * @param synchronous true to enable synchronous mode, false to enable 
waiting on requestImpl()
+     *          until another thread adds the missing object
+     */
+    protected SoftReferenceCache(boolean synchronous) {
+        this.synchronous = synchronous;
+    }
 
     /**
      * Let people flush the cache (remove any cached data).  Pending
@@ -126,6 +139,9 @@ public class SoftReferenceCache {
 
             Object o = map.get(key);
             while(o == null) {
+                if (synchronous) {
+                    return null; //Noone will add the value asynchronously, so 
don't wait()
+                }
                 try {
                     // When something is cleared or put we will be notified.
                     wait();


Reply via email to