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 de...@apache.org on 2006/03/23 03:46:24 UTC

svn commit: r388007 - in /xmlgraphics/batik/branches/svg11: samples/tests/spec/scripting/ sources/org/apache/batik/bridge/ sources/org/apache/batik/bridge/svg12/ sources/org/apache/batik/css/dom/ sources/org/apache/batik/ext/awt/ sources/org/apache/bat...

Author: deweese
Date: Wed Mar 22 18:46:22 2006
New Revision: 388007

URL: http://svn.apache.org/viewcvs?rev=388007&view=rev
Log:
1) 38990 - Fallthrough in CSSOMSVGColor fixed (Thanks Dieter)
    a) Most string concatenation uses are replaced with stringbuffer
    b) Added basic test of SVGColor interface.
2) Gradient Scaleback is now 0.999 rather than 0.97.
3) Major refactor of text in prep for removing TEXT_COMPOUND_DELIMITER,
   in static builds of GVT tree.
    a) Font derivation is now done in the Text Bridge.
       Needed since deriving an SVG font needs the element reference.
    b) FontFamilies are no longer attributed on string.
    c) Null TextPainterInfo (TPI) are now created/added in
       buildAttributedString (faster/cleaner).
    d) getElementStart/EndIndex now uses new fields in TPI so they
       are faster/simpler and don't rely on TEXT_COMPOUND_DELIMITER.
    e) getParentTextPaintInfo uses elemTPI and getParentNode
       to get parent TPI rather than complex/slow TEXT_COMPOUND_DELIMITER.


Added:
    xmlgraphics/batik/branches/svg11/samples/tests/spec/scripting/domSVGcolor.svg   (with props)
    xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/scripting/domSVGColor.png   (with props)
Modified:
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGSVGElementBridge.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGTextElementBridge.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/css/dom/CSSOMSVGColor.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/RadialGradientPaintContext.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/extension/svg/BatikFlowTextElementBridge.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/font/FontFamilyResolver.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/GVTAttributedCharacterIterator.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/GlyphLayout.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/TextPaintInfo.java
    xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/paints/radialGradient.png
    xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/paints/radialGradient2.png
    xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/paints/radialGradient3.png
    xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/paints/radialGradientOrientation.png
    xmlgraphics/batik/branches/svg11/test-resources/org/apache/batik/test/samplesRendering.xml

Added: xmlgraphics/batik/branches/svg11/samples/tests/spec/scripting/domSVGcolor.svg
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/samples/tests/spec/scripting/domSVGcolor.svg?rev=388007&view=auto
==============================================================================
--- xmlgraphics/batik/branches/svg11/samples/tests/spec/scripting/domSVGcolor.svg (added)
+++ xmlgraphics/batik/branches/svg11/samples/tests/spec/scripting/domSVGcolor.svg Wed Mar 22 18:46:22 2006
@@ -0,0 +1,182 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
+"http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd">
+
+<!--
+
+   Copyright 2006  The Apache Software Foundation 
+
+   Licensed 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.
+
+-->
+<!-- ====================================================================== -->
+<!-- Test of the dom SVGColor interface                                     -->
+<!--                                                                        -->
+<!-- @author deweese@apache.org                                             -->
+<!-- @version $Id: fill.svg 201374 2004-08-18 07:17:26Z vhardy $ -->
+<!-- ====================================================================== -->
+
+<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>  
+
+<svg id="body" width="450" height="500" viewBox="0 0 450 500"
+    onload="onload()"
+     xmlns="http://www.w3.org/2000/svg" 
+     xmlns:xlink="http://www.w3.org/1999/xlink" >
+    <title>Test DOM SVGColor Interface</title>
+
+    <text x="50%" y="45" class="title">Test DOM SVGColor Interface</text>
+
+    <script type="text/ecmascript"><![CDATA[
+        var UNIT_NUMBER =1;
+        var UNIT_PERCENT=2;
+        function onload() {
+           test();
+        }
+
+        function showFill(id, suff) {
+           var elem = document.getElementById(id);
+           var fill = elem.style.getPropertyCSSValue("fill");
+           var tb    = document.getElementById(id+suff);
+           tb.appendChild(document.createTextNode(fill.getCssText()));
+           return fill;
+        }   
+
+        function test() {
+           var fill, r, g, b;
+
+           fill = showFill("r1", ".b"); 
+           fill.setCssText("gold");
+           showFill("r1", ".a"); 
+
+           fill = showFill("r2", ".b"); 
+           fill.setCssText("gold");
+           showFill("r2", ".a"); 
+        
+           fill = showFill("r3", ".b"); 
+           r = fill.getRed(); r.setCssText("50");
+           showFill("r3", ".a"); 
+        
+           fill = showFill("r4", ".b"); 
+           r = fill.getRed(); r.setFloatValue(UNIT_NUMBER, 50);
+           showFill("r4", ".a"); 
+
+           fill = showFill("r5", ".b"); 
+           r = fill.getRed(); r.setFloatValue(UNIT_PERCENT, 50);
+           showFill("r5", ".a"); 
+
+           fill = showFill("r6", ".b"); 
+           g = fill.getGreen(); g.setCssText("50");
+           showFill("r6", ".a"); 
+        
+           fill = showFill("r7", ".b"); 
+           g = fill.getGreen(); g.setFloatValue(UNIT_NUMBER, 50);
+           showFill("r7", ".a"); 
+
+           fill = showFill("r8", ".b"); 
+           g = fill.getGreen(); g.setFloatValue(UNIT_PERCENT, 50);
+           showFill("r8", ".a"); 
+
+           fill = showFill("r9", ".b"); 
+           b = fill.getBlue(); b.setCssText("50");
+           showFill("r9", ".a"); 
+        
+           fill = showFill("r10", ".b"); 
+           b = fill.getBlue(); b.setFloatValue(UNIT_NUMBER, 50);
+           showFill("r10", ".a"); 
+
+           fill = showFill("r11", ".b"); 
+           b = fill.getBlue(); b.setFloatValue(UNIT_PERCENT, 50);
+           showFill("r11", ".a"); 
+        }
+    ]]></script>
+
+    <g id="test-content">
+       <g transform="translate(10, 50)">
+          <rect id="r1" x="0" y="0" width="75" height="40" 
+                style="fill:crimson"/>
+          <text x="80" y="15">Before: <tspan id="r1.b"/></text>
+          <text x="80" y="35">After: <tspan id="r1.a"/></text>
+       </g>
+
+       <g transform="translate(10, 100)">
+          <rect id="r2" x="0" y="0" width="75" height="40" 
+                style="fill:rgb(255, 0, 0)"/>
+          <text x="80" y="15">Before: <tspan id="r2.b"/></text>
+          <text x="80" y="35">After: <tspan id="r2.a"/></text>
+       </g>
+
+       <g transform="translate(10, 150)">
+          <rect id="r3" x="0" y="0" width="75" height="40" 
+                style="fill:rgb(255, 0, 128)"/>
+          <text x="80" y="15">Before: <tspan id="r3.b"/></text>
+          <text x="80" y="35">After: <tspan id="r3.a"/></text>
+       </g>
+
+       <g transform="translate(10, 200)">
+          <rect id="r4" x="0" y="0" width="75" height="40" 
+                style="fill:rgb(255, 0, 128)"/>
+          <text x="80" y="15">Before: <tspan id="r4.b"/></text>
+          <text x="80" y="35">After: <tspan id="r4.a"/></text>
+       </g>
+
+       <g transform="translate(10, 250)">
+          <rect id="r5" x="0" y="0" width="75" height="40" 
+                style="fill:rgb(255, 0, 128)"/>
+          <text x="80" y="15">Before: <tspan id="r5.b"/></text>
+          <text x="80" y="35">After: <tspan id="r5.a"/></text>
+       </g>
+
+       <g transform="translate(10, 300)">
+          <rect id="r6" x="0" y="0" width="75" height="40" 
+                style="fill:rgb(255, 0, 128)"/>
+          <text x="80" y="15">Before: <tspan id="r6.b"/></text>
+          <text x="80" y="35">After: <tspan id="r6.a"/></text>
+       </g>
+
+       <g transform="translate(10, 350)">
+          <rect id="r7" x="0" y="0" width="75" height="40" 
+                style="fill:rgb(255, 0, 128)"/>
+          <text x="80" y="15">Before: <tspan id="r7.b"/></text>
+          <text x="80" y="35">After: <tspan id="r7.a"/></text>
+       </g>
+
+       <g transform="translate(10, 400)">
+          <rect id="r8" x="0" y="0" width="75" height="40" 
+                style="fill:rgb(255, 0, 128)"/>
+          <text x="80" y="15">Before: <tspan id="r8.b"/></text>
+          <text x="80" y="35">After: <tspan id="r8.a"/></text>
+       </g>
+
+       <g transform="translate(225, 50)">
+          <rect id="r9" x="0" y="0" width="75" height="40" 
+                style="fill:rgb(255, 0, 128)"/>
+          <text x="80" y="15">Before: <tspan id="r9.b"/></text>
+          <text x="80" y="35">After: <tspan id="r9.a"/></text>
+       </g>
+
+       <g transform="translate(225, 100)">
+          <rect id="r10" x="0" y="0" width="75" height="40" 
+                style="fill:rgb(255, 0, 128)"/>
+          <text x="80" y="15">Before: <tspan id="r10.b"/></text>
+          <text x="80" y="35">After: <tspan id="r10.a"/></text>
+       </g>
+
+       <g transform="translate(225, 150)">
+          <rect id="r11" x="0" y="0" width="75" height="40" 
+                style="fill:rgb(255, 0, 128)"/>
+          <text x="80" y="15">Before: <tspan id="r11.b"/></text>
+          <text x="80" y="35">After: <tspan id="r11.a"/></text>
+       </g>
+
+    </g>
+</svg>

Propchange: xmlgraphics/batik/branches/svg11/samples/tests/spec/scripting/domSVGcolor.svg
------------------------------------------------------------------------------
    svn:executable = *

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGSVGElementBridge.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGSVGElementBridge.java?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGSVGElementBridge.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGSVGElementBridge.java Wed Mar 22 18:46:22 2006
@@ -433,10 +433,6 @@
         }
     }
 
-    public static final 
-        AttributedCharacterIterator.Attribute TEXT_COMPOUND_DELIMITER 
-        = GVTAttributedCharacterIterator.TextAttribute.TEXT_COMPOUND_DELIMITER;
-
     public List getIntersectionList(SVGRect svgRect, Element end) {
         List ret = new ArrayList();
         Rectangle2D rect = new Rectangle2D.Float(svgRect.getX(),

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGTextElementBridge.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGTextElementBridge.java?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGTextElementBridge.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGTextElementBridge.java Wed Mar 22 18:46:22 2006
@@ -56,9 +56,12 @@
 import org.apache.batik.dom.util.XMLSupport;
 import org.apache.batik.gvt.GraphicsNode;
 import org.apache.batik.gvt.TextNode;
+import org.apache.batik.gvt.font.FontFamilyResolver;
+import org.apache.batik.gvt.font.GVTFont;
 import org.apache.batik.gvt.font.GVTFontFamily;
 import org.apache.batik.gvt.font.GVTGlyphMetrics;
 import org.apache.batik.gvt.font.GVTGlyphVector;
+import org.apache.batik.gvt.font.UnresolvedFontFamily;
 import org.apache.batik.gvt.renderer.StrokingTextPainter;
 import org.apache.batik.gvt.text.GVTAttributedCharacterIterator;
 import org.apache.batik.gvt.text.Mark;
@@ -98,6 +101,25 @@
         AttributedCharacterIterator.Attribute ALT_GLYPH_HANDLER =
         GVTAttributedCharacterIterator.TextAttribute.ALT_GLYPH_HANDLER;
         
+    public static final 
+        AttributedCharacterIterator.Attribute GVT_FONT_FAMILIES 
+        = GVTAttributedCharacterIterator.TextAttribute.GVT_FONT_FAMILIES;
+
+    public static final 
+        AttributedCharacterIterator.Attribute TEXTPATH
+        = GVTAttributedCharacterIterator.TextAttribute.TEXTPATH;
+
+    public static final 
+        AttributedCharacterIterator.Attribute ANCHOR_TYPE
+        = GVTAttributedCharacterIterator.TextAttribute.ANCHOR_TYPE;
+
+    public static final 
+        AttributedCharacterIterator.Attribute GVT_FONTS
+        = GVTAttributedCharacterIterator.TextAttribute.GVT_FONTS;
+
+    public static final 
+        AttributedCharacterIterator.Attribute BASELINE_SHIFT
+        = GVTAttributedCharacterIterator.TextAttribute.BASELINE_SHIFT;
 
     protected AttributedString laidoutText;
 
@@ -499,6 +521,8 @@
                                        Element e,
                                        GraphicsNode node) {
         TextNode tn = (TextNode)node;
+        elemTPI.clear();
+
         AttributedString as = buildAttributedString(ctx, e);
         if (as == null) {
             tn.setAttributedCharacterIterator(null);
@@ -509,10 +533,6 @@
         if (ctx.isDynamic()) {
             laidoutText = new AttributedString(as.getIterator());
         }
-        elemTPI.clear();
-        // Add null TPI objects to the text (after we set it on the
-        // Text we will swap in the correct values.
-        addNullPaintAttributes(as, e, ctx);
 
         // Install the ACI in the text node.
         tn.setAttributedCharacterIterator(as.getIterator());
@@ -534,56 +554,6 @@
     }
 
     /**
-     * This creates 'dummy' TPI objects for each element and records
-     * them in the elemTPI map so we can later update them with 
-     * the correct paint attributes.
-     */
-    protected void addNullPaintAttributes(AttributedString as, 
-                                          Element element,
-                                          BridgeContext ctx) {
-        // 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
-        if ((!SVGUtilities.matchUserAgent(element, ctx.getUserAgent())) ||
-            (!CSSUtilities.convertDisplay(element))) {
-            return;
-        }
-
-        AttributedCharacterIterator aci = as.getIterator();
-
-        // calculate which chars in the string belong to this element
-        int firstChar = getElementStartIndex(aci, element);
-        if (firstChar == -1)
-            return; // Element not part of aci (no chars in elem usually)
-
-        int lastChar = getElementEndIndex(aci, element);
-        TextPaintInfo pi = new TextPaintInfo();
-        // Set some basic props so we can get bounds info for complex paints.
-        pi.visible   = true;        
-        pi.fillPaint = Color.black;
-
-        as.addAttribute(PAINT_INFO, pi, firstChar, lastChar+1);
-        elemTPI.put(element, pi);
-
-        addChildNullPaintAttributes(as, element, ctx);
-    }
-    
-    protected void addChildNullPaintAttributes(AttributedString as,
-                                               Element element,
-                                               BridgeContext ctx) {
-        // Add Paint attributres for children of text element
-        for (Node child = element.getFirstChild();
-             child != null;
-             child = child.getNextSibling()) {
-            if (child.getNodeType() != Node.ELEMENT_NODE) 
-                continue;
-
-            Element childElement = (Element)child;
-            if (isTextChild(childElement)) {
-                addNullPaintAttributes(as, childElement, ctx);
-            }
-        }
-    }
-
-    /**
      * This flag bit indicates if a new ACI has been created in
      * response to a CSSEngineEvent.
      * Avoid creating one ShapePainter per CSS property change
@@ -726,8 +696,7 @@
             //and only update the section of the AtrtibutedString of
             //the child
             TextPaintInfo parentPI;
-            parentPI = getParentTextPaintInfo
-                (tn.getAttributedCharacterIterator(), cssProceedElement);
+            parentPI = getParentTextPaintInfo(cssProceedElement);
             pi = getTextPaintInfo(cssProceedElement, tn, parentPI, ctx);
             oldPI = (TextPaintInfo)elemTPI.get(cssProceedElement);
         }
@@ -740,36 +709,16 @@
                 (tn.getAttributedCharacterIterator());
     }
 
-    int getElementStartIndex
-        (AttributedCharacterIterator aci, Element element) {
-        if (aci == null) return -1;
-
-        // calculate which chars in the string belong to this element
-        for (int i = 0; i < aci.getEndIndex();) {
-            aci.setIndex(i);
-            Element delimeter;
-            delimeter = (Element)aci.getAttribute(TEXT_COMPOUND_DELIMITER);
-            if (delimeter == element || nodeAncestorOf(element, delimeter))
-                return i;
-            i = aci.getRunLimit(TEXT_COMPOUND_DELIMITER);
-        }
-        return -1;  
+    int getElementStartIndex(Element element) {
+        TextPaintInfo tpi = (TextPaintInfo)elemTPI.get(element);
+        if (tpi == null) return -1;
+        return tpi.startChar;
     }
 
-    int getElementEndIndex
-        (AttributedCharacterIterator aci, Element element) {
-        if (aci == null) return -1;
-
-        // calculate which chars in the string belong to this element
-        for (int i = aci.getEndIndex()-1; i >= 0;) {
-            aci.setIndex(i);
-            Element delimeter;
-            delimeter = (Element)aci.getAttribute(TEXT_COMPOUND_DELIMITER);
-            if (delimeter == element || nodeAncestorOf(element, delimeter))
-                return i;
-            i = aci.getRunStart(TEXT_COMPOUND_DELIMITER)-1;
-        }
-        return -1;  
+    int getElementEndIndex(Element element) {
+        TextPaintInfo tpi = (TextPaintInfo)elemTPI.get(element);
+        if (tpi == null) return -1;
+        return tpi.endChar;
     }
 
     // -----------------------------------------------------------------------
@@ -821,6 +770,7 @@
         boolean preserve = s.equals(SVG_PRESERVE_VALUE);
         boolean prevEndsWithSpace;
         Element nodeElement = element;
+        int elementStartChar = asb.length();
 
         if (top)
             endLimit = 0;
@@ -882,9 +832,15 @@
                     s = TextUtilities.getElementContent(ref);
                     s = normalizeString(s, preserve, prevEndsWithSpace);
                     if (s != null) {
+                        int trefStart = asb.length();
                         Map m = getAttributeMap(ctx, nodeElement, 
                                                 textPath, bidiLevel);
                         asb.append(s, m);
+                        int trefEnd = asb.length()-1;
+                        TextPaintInfo tpi;
+                        tpi = (TextPaintInfo)elemTPI.get(nodeElement);
+                        tpi.startChar = trefStart;
+                        tpi.endChar   = trefEnd;
                     }
                 } else if (ln.equals(SVG_A_TAG)) {
                     EventTarget target = (EventTarget)nodeElement;
@@ -912,9 +868,27 @@
         }
 
         if (top) {
-            while ((endLimit < asb.length()) && (asb.getLastChar() == ' '))
+            boolean strippedSome = false;
+            while ((endLimit < asb.length()) && (asb.getLastChar() == ' ')) {
                 asb.stripLast();
+                strippedSome = true;
+            }
+            if (strippedSome) {
+                Iterator iter = elemTPI.values().iterator();
+                while (iter.hasNext()) {
+                    TextPaintInfo tpi = (TextPaintInfo)iter.next();
+                    if (tpi.endChar >= asb.length()) {
+                        tpi.endChar = asb.length()-1;
+                        if (tpi.startChar > tpi.endChar)
+                            tpi.startChar = tpi.endChar;
+                    }
+                }
+            }
         }
+        int elementEndChar = asb.length()-1;
+        TextPaintInfo tpi = (TextPaintInfo)elemTPI.get(element);
+        tpi.startChar = elementStartChar;
+        tpi.endChar   = elementEndChar;
     }
 
     /**
@@ -1184,11 +1158,11 @@
         AttributedCharacterIterator aci = as.getIterator();
 
         // calculate which chars in the string belong to this element
-        int firstChar = getElementStartIndex(aci, element);
+        int firstChar = getElementStartIndex(element);
         // No match so no chars to annotate.
         if (firstChar == -1) return;
 
-        int lastChar = getElementEndIndex(aci, element);
+        int lastChar = getElementEndIndex(element);
 
         // get all of the glyph position attribute values
         String xAtt      = element.getAttributeNS(null, SVG_X_ATTRIBUTE);
@@ -1318,8 +1292,9 @@
             return;
         }
         Object o = elemTPI.get(element);
-        if (o == null) return;
-        node.swapTextPaintInfo(pi, (TextPaintInfo)o);
+        if (o != null) {
+            node.swapTextPaintInfo(pi, (TextPaintInfo)o);
+        }
         addChildPaintAttributes(as, element, node, pi, ctx);
     }
 
@@ -1352,16 +1327,20 @@
         map.put(TEXT_COMPOUND_DELIMITER, element);
 
         // Font size.
-        map.put(TextAttribute.SIZE, TextUtilities.convertFontSize(element));
+        map.put(TextAttribute.SIZE, 
+                TextUtilities.convertFontSize(element));
 
         // Font stretch
-        map.put(TextAttribute.WIDTH, TextUtilities.convertFontStretch(element));
+        map.put(TextAttribute.WIDTH, 
+                TextUtilities.convertFontStretch(element));
 
         // Font weight
-        map.put(TextAttribute.WEIGHT, TextUtilities.convertFontWeight(element));
+        map.put(TextAttribute.WEIGHT, 
+                TextUtilities.convertFontWeight(element));
 
         // Font style
-        map.put(TextAttribute.POSTURE, TextUtilities.convertFontStyle(element));
+        map.put(TextAttribute.POSTURE, 
+                TextUtilities.convertFontStyle(element));
 
         return map;
     }
@@ -1385,30 +1364,53 @@
                        new SVGAltGlyphHandler(ctx, element));
         }
 
+        // Add null TPI objects to the text (after we set it on the
+        // Text we will swap in the correct values.
+        TextPaintInfo pi = new TextPaintInfo();
+        // Set some basic props so we can get bounds info for complex paints.
+        pi.visible   = true;        
+        pi.fillPaint = Color.black;
+        result.put(PAINT_INFO, pi);
+        elemTPI.put(element, pi);
+
         if (textPath != null) {
-            result.put(GVTAttributedCharacterIterator.TextAttribute.TEXTPATH,
-                       textPath);
+            result.put(TEXTPATH, textPath);
         }
 
         // Text-anchor
         TextNode.Anchor a = TextUtilities.convertTextAnchor(element);
-        result.put(GVTAttributedCharacterIterator.TextAttribute.ANCHOR_TYPE,
-                   a);
+        result.put(ANCHOR_TYPE, a);
 
         // get font size/width/weight/posture properties
         getFontProperties(ctx, element, result);
 
         // Font family
         List fontFamilyList = getFontFamilyList(element, ctx);
-        result.put
-            (GVTAttributedCharacterIterator.TextAttribute.GVT_FONT_FAMILIES,
-             fontFamilyList);
+        // result.put(GVT_FONT_FAMILIES, fontFamilyList);
+
+        List fonts = new ArrayList(fontFamilyList.size());
+        Iterator iter = fontFamilyList.iterator();
+        float fontSize = 12;
+        Float fsFloat = (Float)result.get(TextAttribute.SIZE);
+        if (fsFloat != null) {
+            fontSize = fsFloat.floatValue();
+        }
+        while (iter.hasNext()) {
+            GVTFontFamily ff = (GVTFontFamily)iter.next();
+            if (ff instanceof UnresolvedFontFamily) {
+                ff = FontFamilyResolver.resolve((UnresolvedFontFamily)ff);
+            }
+            if (ff == null) continue;
+            GVTFont ft = ff.deriveFont(fontSize, result);
+            fonts.add(ft);
+        }
+        result.put(GVT_FONTS, fonts);
+
 
         // Text baseline adjustment.
         Object bs = TextUtilities.convertBaselineShift(element);
         if (bs != null) {
-            result.put(GVTAttributedCharacterIterator.
-                       TextAttribute.BASELINE_SHIFT, bs);
+            result.put(BASELINE_SHIFT, bs);
         }
 
         // Unicode-bidi mode
@@ -1665,34 +1667,13 @@
      * @param child an <code>Element</code> value
      * @return a <code>TextDecoration</code> value
      */
-    protected TextPaintInfo getParentTextPaintInfo
-        (AttributedCharacterIterator aci, Element child) {
-        if (aci == null)
-            return new TextPaintInfo();
-
-        Element parent = null;
-        // calculate which chars in the string belong to the parent
-        int firstChar = -1;
-        for (int i = 0; i < aci.getEndIndex();) {
-            aci.setIndex(i);
-            Element delimeter;
-            delimeter = (Element)aci.getAttribute(TEXT_COMPOUND_DELIMITER);
-            if (nodeAncestorOf(delimeter,child) &&
-                ((parent == null) || nodeAncestorOf(parent, delimeter))) {
-                parent = delimeter;
-                firstChar = i;
-            }
-            if (delimeter == child || nodeAncestorOf(child, delimeter)) {
-                break;
-            }
-            i = aci.getRunLimit(TEXT_COMPOUND_DELIMITER);
+    protected TextPaintInfo getParentTextPaintInfo(Element child) {
+        Node parent = child.getParentNode();
+        while (parent != null) {
+            TextPaintInfo tpi = (TextPaintInfo)elemTPI.get(parent);
+            if (tpi != null) return tpi;
         }
-
-        if ( parent == null)
-            return new TextPaintInfo(); //no parent
-
-        aci.setIndex(firstChar);
-        return (TextPaintInfo)aci.getAttribute(PAINT_INFO);
+        return null;
     }
 
     /**
@@ -1702,13 +1683,13 @@
      */
     protected TextPaintInfo getTextPaintInfo(Element element,
                                              GraphicsNode node,
-                                             TextPaintInfo parent,
+                                             TextPaintInfo parentTPI,
                                              BridgeContext ctx) {
         // Force the engine to update stuff..
         Value val = CSSUtilities.getComputedStyle
             (element, SVGCSSEngine.TEXT_DECORATION_INDEX);
 
-        TextPaintInfo pi = new TextPaintInfo(parent);
+        TextPaintInfo pi = new TextPaintInfo(parentTPI);
 
         // Was text-decoration explicity set on this element?
         StyleMap sm = ((CSSStylableElement)element).getComputedStyleMap(null);
@@ -2176,12 +2157,12 @@
 
         //get the index in the aci for the first character
         //of the element
-        int firstChar = getElementStartIndex(aci,element);
+        int firstChar = getElementStartIndex(element);
 
         if (firstChar == -1)
             return 0; // Element not part of aci (no chars in elem usually)
 
-        int lastChar = getElementEndIndex(aci,element);
+        int lastChar = getElementEndIndex(element);
 
         return( lastChar - firstChar + 1 );
     }
@@ -2197,7 +2178,7 @@
         aci = ((TextNode)node).getAttributedCharacterIterator();
         if (aci == null) return null;
 
-        int firstChar = getElementStartIndex(aci,element);
+        int firstChar = getElementStartIndex(element);
 
         if ( firstChar == -1 )
             return null;
@@ -2255,7 +2236,7 @@
         if (aci == null) 
             return null;
 
-        int firstChar = getElementStartIndex(aci,element);
+        int firstChar = getElementStartIndex(element);
         if ( firstChar == -1 )
             return null;
 
@@ -2306,7 +2287,7 @@
         if (aci == null)
             return null;
 
-        int firstChar = getElementStartIndex(aci,element);
+        int firstChar = getElementStartIndex(element);
         if ( firstChar == -1 )
             return null;
 
@@ -2359,7 +2340,7 @@
             return 0;
 
         //first the first character for the element
-        int firstChar = getElementStartIndex(aci,element);
+        int firstChar = getElementStartIndex(element);
         if ( firstChar == -1 )
             return 0;
 
@@ -2440,7 +2421,7 @@
             return -1;
 
         TextNode textNode = (TextNode)node;
-        int firstChar = getElementStartIndex(aci,element);
+        int firstChar = getElementStartIndex(element);
 
         if ( firstChar == -1 )
             return -1;
@@ -2576,14 +2557,14 @@
             return;
 
         TextNode textNode = (TextNode)node;
-        int firstChar = getElementStartIndex(aci,element);
+        int firstChar = getElementStartIndex(element);
 
         if ( firstChar == -1 )
             return;
 
         List list = getTextRuns(textNode);
 
-        int lastChar = getElementEndIndex(aci,element);
+        int lastChar = getElementEndIndex(element);
 
         CharacterInformation firstInfo, lastInfo;
         firstInfo = getCharacterInformation(list, firstChar,charnum,aci);
@@ -2628,8 +2609,8 @@
 
 
         //found an hit, check if it belong to the element
-        int first = getElementStartIndex( aci, e );
-        int last  = getElementEndIndex( aci, e );
+        int first = getElementStartIndex( e );
+        int last  = getElementEndIndex( e );
 
         int hitIndex = hit.getCharIndex();
 

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java Wed Mar 22 18:46:22 2006
@@ -18,6 +18,7 @@
 
 package org.apache.batik.bridge.svg12;
 
+import java.awt.Color;
 import java.awt.RenderingHints;
 import java.awt.Shape;
 import java.awt.font.TextAttribute;
@@ -68,6 +69,7 @@
 import org.apache.batik.gvt.flow.TextLineBreaks;
 
 import org.apache.batik.gvt.text.GVTAttributedCharacterIterator;
+import org.apache.batik.gvt.text.TextPaintInfo;
 import org.apache.batik.gvt.text.TextPath;
 
 import org.apache.batik.util.SVG12Constants;
@@ -405,6 +407,12 @@
 
     protected AttributedString gatherFlowPara
         (BridgeContext ctx, Element div) {
+        TextPaintInfo divTPI = new TextPaintInfo();
+        // Set some basic props so we can get bounds info for complex paints.
+        divTPI.visible   = true;        
+        divTPI.fillPaint = Color.black;
+        elemTPI.put(div, divTPI);
+
         AttributedStringBuffer asb = new AttributedStringBuffer();
         List paraEnds  = new ArrayList();
         List paraElems = new ArrayList();
@@ -428,6 +436,8 @@
                 paraEnds.add(new Integer(asb.length()));
             }
         }
+        divTPI.startChar = 0;
+        divTPI.endChar   = asb.length()-1;
 
         // Layer in the PARAGRAPH/LINE_BREAK Attributes so we can
         // break up text chunks.
@@ -549,6 +559,7 @@
         boolean preserve = s.equals(SVG_PRESERVE_VALUE);
         boolean prevEndsWithSpace;
         Element nodeElement = element;
+        int elementStartChar = asb.length();
 
         if (top)
             endLimit = startLen = asb.length();
@@ -639,9 +650,15 @@
                     s = TextUtilities.getElementContent(ref);
                     s = normalizeString(s, preserve, prevEndsWithSpace);
                     if (s != null) {
+                        int trefStart = asb.length();
                         Map m = getAttributeMap(ctx, nodeElement, null, 
                                                 bidiLevel);
                         asb.append(s, m);
+                        int trefEnd = asb.length()-1;
+                        TextPaintInfo tpi;
+                        tpi = (TextPaintInfo)elemTPI.get(nodeElement);
+                        tpi.startChar = trefStart;
+                        tpi.endChar   = trefEnd;
                     }
                 }
                 break;
@@ -657,6 +674,7 @@
         }
 
         if (top) {
+            boolean strippedSome = false;
             while ((endLimit < asb.length()) && (asb.getLastChar() == ' ')) {
                 int idx = lnLocs.size()-1;
                 int len = asb.length();
@@ -676,8 +694,25 @@
                     }
                 }
                 asb.stripLast();
+                strippedSome = true;
+            }
+            if (strippedSome) {
+                Iterator iter = elemTPI.values().iterator();
+                while (iter.hasNext()) {
+                    TextPaintInfo tpi = (TextPaintInfo)iter.next();
+                    if (tpi.endChar >= asb.length()) {
+                        tpi.endChar = asb.length()-1;
+                        if (tpi.startChar > tpi.endChar)
+                            tpi.startChar = tpi.endChar;
+                    }
+                }
             }
         }
+
+        int elementEndChar = asb.length()-1;
+        TextPaintInfo tpi = (TextPaintInfo)elemTPI.get(element);
+        tpi.startChar = elementStartChar;
+        tpi.endChar   = elementEndChar;
     }
 
     /**

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/css/dom/CSSOMSVGColor.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/css/dom/CSSOMSVGColor.java?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/css/dom/CSSOMSVGColor.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/css/dom/CSSOMSVGColor.java Wed Mar 22 18:46:22 2006
@@ -634,27 +634,30 @@
          * Called when the red value text has changed.
          */
         public void redTextChanged(String text) throws DOMException {
+            StringBuffer sb = new StringBuffer(40);
             switch (getColorType()) {
             case SVG_COLORTYPE_RGBCOLOR:
-                text = "rgb(" +
-                    text + ", " +
-                    getValue().getGreen().getCssText() + ", " +
-                    getValue().getBlue().getCssText() + ")";
+                sb.append("rgb(");
+                sb.append(text); sb.append(',');
+                sb.append(getValue().getGreen().getCssText()); sb.append(',');
+                sb.append(getValue().getBlue().getCssText()); sb.append(')');
                 break;
 
             case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
-                text = "rgb(" +
-                    text + ", " +
-                    getValue().item(0).getGreen().getCssText() + ", " +
-                    getValue().item(0).getBlue().getCssText() + ") " +
-                    getValue().item(1).getCssText();
+                sb.append("rgb(");
+                sb.append(text); sb.append(',');
+                sb.append(getValue().item(0).getGreen().getCssText()); 
+                sb.append(',');
+                sb.append(getValue().item(0).getBlue().getCssText()); 
+                sb.append(')');
+                sb.append(getValue().item(1).getCssText());
                 break;
-
+            
             default:
                 throw new DOMException
                     (DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
             }
-            textChanged(text);
+            textChanged(sb.toString());
         }
 
         /**
@@ -662,55 +665,62 @@
          */
         public void redFloatValueChanged(short unit, float value)
             throws DOMException {
-            String text;
+            StringBuffer sb = new StringBuffer(40);
             switch (getColorType()) {
             case SVG_COLORTYPE_RGBCOLOR:
-                text = "rgb(" +
-                    FloatValue.getCssText(unit, value) + ", " +
-                    getValue().getGreen().getCssText() + ", " +
-                    getValue().getBlue().getCssText() + ")";
+                sb.append("rgb(");
+                sb.append(FloatValue.getCssText(unit, value)); sb.append(',');
+                sb.append(getValue().getGreen().getCssText()); sb.append(',');
+                sb.append(getValue().getBlue().getCssText()); sb.append(')');
                 break;
 
             case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
-                text = "rgb(" +
-                    FloatValue.getCssText(unit, value) + ", " +
-                    getValue().item(0).getGreen().getCssText() + ", " +
-                    getValue().item(0).getBlue().getCssText() + ") " +
-                    getValue().item(1).getCssText();
+                sb.append("rgb(");
+                sb.append(FloatValue.getCssText(unit, value)); 
+                sb.append(',');
+                sb.append(getValue().item(0).getGreen().getCssText()); 
+                sb.append(',');
+                sb.append(getValue().item(0).getBlue().getCssText()); 
+                sb.append(')');
+                sb.append(getValue().item(1).getCssText());
                 break;
 
             default:
                 throw new DOMException
                     (DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
             }
-            textChanged(text);
+            textChanged(sb.toString());
         }
 
         /**
          * Called when the green value text has changed.
          */
         public void greenTextChanged(String text) throws DOMException {
+            StringBuffer sb = new StringBuffer(40);
             switch (getColorType()) {
             case SVG_COLORTYPE_RGBCOLOR:
-                text = "rgb(" +
-                    getValue().getRed().getCssText() + ", " +
-                    text + ", " +
-                    getValue().getBlue().getCssText() + ")";
+                sb.append("rgb(");
+                sb.append(getValue().getRed().getCssText()); sb.append(',');
+                sb.append(text); sb.append(',');
+                sb.append(getValue().getBlue().getCssText()); sb.append(')');
                 break;
 
             case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
-                text = "rgb(" +
-                    getValue().item(0).getRed().getCssText() + ", " +
-                    text + ", " +
-                    getValue().item(0).getBlue().getCssText() + ") " +
-                    getValue().item(1).getCssText();
+                sb.append("rgb(");
+                sb.append(getValue().item(0).getRed().getCssText()); 
+                sb.append(',');
+                sb.append(text); 
+                sb.append(',');
+                sb.append(getValue().item(0).getBlue().getCssText()); 
+                sb.append(')');
+                sb.append(getValue().item(1).getCssText());
                 break;
 
             default:
                 throw new DOMException
                     (DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
             }
-            textChanged(text);
+            textChanged(sb.toString());
         }
 
         /**
@@ -718,54 +728,62 @@
          */
         public void greenFloatValueChanged(short unit, float value)
             throws DOMException {
-            String text;
+            StringBuffer sb = new StringBuffer(40);
             switch (getColorType()) {
             case SVG_COLORTYPE_RGBCOLOR:
-                text = "rgb(" +
-                    getValue().getRed().getCssText() + ", " +
-                    FloatValue.getCssText(unit, value) + ", " +
-                    getValue().getBlue().getCssText() + ")";
+                sb.append("rgb(");
+                sb.append(getValue().getRed().getCssText()); sb.append(',');
+                sb.append(FloatValue.getCssText(unit, value)); sb.append(',');
+                sb.append(getValue().getBlue().getCssText()); sb.append(')');
                 break;
 
             case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
-                text = "rgb(" +
-                    getValue().item(0).getRed().getCssText() + ", " +
-                    FloatValue.getCssText(unit, value) + ", " +
-                    getValue().item(0).getBlue().getCssText() + ") " +
-                    getValue().item(1).getCssText();
+                sb.append("rgb(");
+                sb.append(getValue().item(0).getRed().getCssText()); 
+                sb.append(',');
+                sb.append(FloatValue.getCssText(unit, value)); 
+                sb.append(',');
+                sb.append(getValue().item(0).getBlue().getCssText()); 
+                sb.append(')');
+                sb.append(getValue().item(1).getCssText());
                 break;
 
             default:
                 throw new DOMException
                     (DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
             }
-            textChanged(text);
+            textChanged(sb.toString());
         }
 
         /**
          * Called when the blue value text has changed.
          */
         public void blueTextChanged(String text) throws DOMException {
+            StringBuffer sb = new StringBuffer(40);
             switch (getColorType()) {
             case SVG_COLORTYPE_RGBCOLOR:
-                text = "rgb(" +
-                    getValue().getRed().getCssText() + ", " +
-                    getValue().getGreen().getCssText() + ", " +
-                    text + ")";
+                sb.append("rgb(");
+                sb.append(getValue().getRed().getCssText()); sb.append(',');
+                sb.append(getValue().getGreen().getCssText()); sb.append(',');
+                sb.append(text); sb.append(')');
                 break;
 
             case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
-                text = "rgb(" +
-                    getValue().item(0).getRed().getCssText() + ", " +
-                    getValue().item(0).getGreen().getCssText() + ", " +
-                    text + ") " +
-                    getValue().item(1).getCssText();
+                sb.append("rgb(");
+                sb.append(getValue().item(0).getRed().getCssText()); 
+                sb.append(',');
+                sb.append(getValue().item(0).getGreen().getCssText()); 
+                sb.append(',');
+                sb.append(text); 
+                sb.append(')');
+                sb.append(getValue().item(1).getCssText());
+                break;
 
             default:
                 throw new DOMException
                     (DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
             }
-            textChanged(text);
+            textChanged(sb.toString());
         }
 
         /**
@@ -773,28 +791,31 @@
          */
         public void blueFloatValueChanged(short unit, float value)
             throws DOMException {
-            String text;
+            StringBuffer sb = new StringBuffer(40);
             switch (getColorType()) {
             case SVG_COLORTYPE_RGBCOLOR:
-                text = "rgb(" +
-                    getValue().getRed().getCssText() + ", " +
-                    getValue().getGreen().getCssText() + ", " +
-                    FloatValue.getCssText(unit, value) + ")";
+                sb.append("rgb(");
+                sb.append(getValue().getRed().getCssText()); sb.append(',');
+                sb.append(getValue().getGreen().getCssText()); sb.append(',');
+                sb.append(FloatValue.getCssText(unit, value)); sb.append(')');
                 break;
 
             case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
-                text = "rgb(" +
-                    getValue().item(0).getRed().getCssText() + ", " +
-                    getValue().item(0).getGreen().getCssText() + ", " +
-                    FloatValue.getCssText(unit, value) + ") " +
-                    getValue().item(1).getCssText();
+                sb.append("rgb(");
+                sb.append(getValue().item(0).getRed().getCssText()); 
+                sb.append(',');
+                sb.append(getValue().item(0).getGreen().getCssText()); 
+                sb.append(',');
+                sb.append(FloatValue.getCssText(unit, value)); 
+                sb.append(')');
+                sb.append(getValue().item(1).getCssText());
                 break;
 
             default:
                 throw new DOMException
                     (DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
             }
-            textChanged(text);
+            textChanged(sb.toString());
         }
         
         /**
@@ -867,10 +888,10 @@
                 sb.append(cp);
                 ICCColor iccc = (ICCColor)getValue().item(1);
                 for (int i = 0; i < iccc.getLength(); i++) {
-                    sb.append(",");
+                    sb.append(',');
                     sb.append(iccc.getColor(i));
                 }
-                sb.append(")");
+                sb.append(')');
                 textChanged(sb.toString());
                 break;
 
@@ -891,7 +912,7 @@
                 sb.append(" icc-color(");
                 ICCColor iccc = (ICCColor)getValue().item(1);
                 sb.append(iccc.getColorProfile());
-                sb.append(")");
+                sb.append(')');
                 textChanged(sb.toString());
                 break;
 
@@ -912,9 +933,9 @@
                 sb.append(" icc-color(");
                 ICCColor iccc = (ICCColor)getValue().item(1);
                 sb.append(iccc.getColorProfile());
-                sb.append(",");
+                sb.append(',');
                 sb.append(f);
-                sb.append(")");
+                sb.append(')');
                 textChanged(sb.toString());
                 break;
 
@@ -936,16 +957,16 @@
                 ICCColor iccc = (ICCColor)getValue().item(1);
                 sb.append(iccc.getColorProfile());
                 for (int i = 0; i < idx; i++) {
-                    sb.append(",");
+                    sb.append(',');
                     sb.append(iccc.getColor(i));
                 }
-                sb.append(",");
+                sb.append(',');
                 sb.append(f);
                 for (int i = idx; i < iccc.getLength(); i++) {
-                    sb.append(",");
+                    sb.append(',');
                     sb.append(iccc.getColor(i));
                 }
-                sb.append(")");
+                sb.append(')');
                 textChanged(sb.toString());
                 break;
 
@@ -967,16 +988,16 @@
                 ICCColor iccc = (ICCColor)getValue().item(1);
                 sb.append(iccc.getColorProfile());
                 for (int i = 0; i < idx; i++) {
-                    sb.append(",");
+                    sb.append(',');
                     sb.append(iccc.getColor(i));
                 }
-                sb.append(",");
+                sb.append(',');
                 sb.append(f);
                 for (int i = idx + 1; i < iccc.getLength(); i++) {
-                    sb.append(",");
+                    sb.append(',');
                     sb.append(iccc.getColor(i));
                 }
-                sb.append(")");
+                sb.append(')');
                 textChanged(sb.toString());
                 break;
 
@@ -998,14 +1019,14 @@
                 ICCColor iccc = (ICCColor)getValue().item(1);
                 sb.append(iccc.getColorProfile());
                 for (int i = 0; i < idx; i++) {
-                    sb.append(",");
+                    sb.append(',');
                     sb.append(iccc.getColor(i));
                 }
                 for (int i = idx + 1; i < iccc.getLength(); i++) {
-                    sb.append(",");
+                    sb.append(',');
                     sb.append(iccc.getColor(i));
                 }
-                sb.append(")");
+                sb.append(')');
                 textChanged(sb.toString());
                 break;
 
@@ -1027,12 +1048,12 @@
                 ICCColor iccc = (ICCColor)getValue().item(1);
                 sb.append(iccc.getColorProfile());
                 for (int i = 0; i < iccc.getLength(); i++) {
-                    sb.append(",");
+                    sb.append(',');
                     sb.append(iccc.getColor(i));
                 }
-                sb.append(",");
+                sb.append(',');
                 sb.append(f);
-                sb.append(")");
+                sb.append(')');
                 textChanged(sb.toString());
                 break;
 

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/RadialGradientPaintContext.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/RadialGradientPaintContext.java?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/RadialGradientPaintContext.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/RadialGradientPaintContext.java Wed Mar 22 18:46:22 2006
@@ -69,7 +69,7 @@
     private int fillMethod;
     
     /** Amount for offset when clamping focus. */
-    private static final float SCALEBACK = .97f;
+    private static final float SCALEBACK = .999f;
     
     /** 
      * Constructor for RadialGradientPaintContext.

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/extension/svg/BatikFlowTextElementBridge.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/extension/svg/BatikFlowTextElementBridge.java?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/extension/svg/BatikFlowTextElementBridge.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/extension/svg/BatikFlowTextElementBridge.java Wed Mar 22 18:46:22 2006
@@ -18,6 +18,7 @@
 
 package org.apache.batik.extension.svg;
 
+import java.awt.Color;
 import java.awt.font.TextAttribute;
 import java.awt.geom.Point2D;
 import java.text.AttributedCharacterIterator;
@@ -203,63 +204,6 @@
         }
     }
 
-    protected void addNullPaintAttributes(AttributedString as, 
-                                          Element element,
-                                          BridgeContext ctx) {
-        if (element.getNodeType() != Node.ELEMENT_NODE) return;
-        String eNS = element.getNamespaceURI();
-        if ((!eNS.equals(getNamespaceURI())) &&
-            (!eNS.equals(SVG_NAMESPACE_URI)))
-            return;
-        if (element.getLocalName()    != BATIK_EXT_FLOW_TEXT_TAG) {
-            // System.out.println("Elem: " + element);
-            super.addNullPaintAttributes(as, element, ctx);
-            return;
-        }
-
-        for (Node n = element.getFirstChild();
-             n != null; n = n.getNextSibling()) {
-            if (n.getNodeType()     != Node.ELEMENT_NODE) continue;
-            if (!getNamespaceURI().equals(n.getNamespaceURI())) continue;
-            Element e = (Element)n;
-            String ln = e.getLocalName();
-            if (ln.equals(BATIK_EXT_FLOW_DIV_TAG)) {
-                // System.out.println("D Elem: " + e);
-                super.addNullPaintAttributes(as, e, ctx);
-                return;
-            }
-        }
-    }
-
-
-    protected void addChildNullPaintAttributes(AttributedString as,
-                                               Element element,
-                                               BridgeContext ctx) {
-        // Add Paint attributres for children of text element
-        for (Node child = element.getFirstChild();
-             child != null;
-             child = child.getNextSibling()) {
-            if (child.getNodeType() != Node.ELEMENT_NODE) {
-                continue;
-            }
-            String cNS = child.getNamespaceURI();
-            if ((!getNamespaceURI().equals(cNS)) &&
-                (!SVG_NAMESPACE_URI.equals(cNS))) {
-                continue;
-            }
-            String ln = child.getLocalName();
-            if (ln.equals(BATIK_EXT_FLOW_PARA_TAG) ||
-                ln.equals(BATIK_EXT_FLOW_REGION_BREAK_TAG) ||
-                ln.equals(BATIK_EXT_FLOW_LINE_TAG) ||
-                ln.equals(BATIK_EXT_FLOW_SPAN_TAG) ||
-                ln.equals(SVG_A_TAG) ||
-                ln.equals(SVG_TREF_TAG)) {
-                Element childElement = (Element)child;
-                addNullPaintAttributes(as, childElement, ctx);
-            }
-        }
-    }
-
     /**
      * Adds painting attributes to an AttributedString.
      */
@@ -343,6 +287,12 @@
 
     protected AttributedString gatherFlowPara
         (BridgeContext ctx, Element div) {
+        TextPaintInfo divTPI = new TextPaintInfo();
+        // Set some basic props so we can get bounds info for complex paints.
+        divTPI.visible   = true;        
+        divTPI.fillPaint = Color.black;
+        elemTPI.put(div, divTPI);
+
         AttributedStringBuffer asb = new AttributedStringBuffer();
         List paraEnds  = new ArrayList();
         List paraElems = new ArrayList();
@@ -366,6 +316,8 @@
                 paraEnds.add(new Integer(asb.length()));
             }
         }
+        divTPI.startChar = 0;
+        divTPI.endChar   = asb.length()-1;
 
         // Layer in the PARAGRAPH/LINE_BREAK Attributes so we can
         // break up text chunks.
@@ -544,17 +496,18 @@
         boolean preserve = s.equals(SVG_PRESERVE_VALUE);
         boolean prevEndsWithSpace;
         Element nodeElement = element;
+        int elementStartChar = asb.length();
 
         if (top)
             endLimit = 0;
         if (preserve)
             endLimit = asb.length();
         
-	Map map = getAttributeMap(ctx, element, null, bidiLevel);
-	Object o = map.get(TextAttribute.BIDI_EMBEDDING);
+        Map map = getAttributeMap(ctx, element, null, bidiLevel);
+        Object o = map.get(TextAttribute.BIDI_EMBEDDING);
         Integer subBidiLevel = bidiLevel;
-	if (o != null)
-	    subBidiLevel = (Integer)o;
+        if (o != null)
+            subBidiLevel = (Integer)o;
 
         for (Node n = element.getFirstChild();
              n != null;
@@ -583,7 +536,7 @@
                 if (ln.equals(BATIK_EXT_FLOW_LINE_TAG)) {
                     fillAttributedStringBuffer(ctx, nodeElement, 
                                                false, subBidiLevel, 
-					       asb, lnLocs);
+                                               asb, lnLocs);
                     // System.out.println("Line: " + asb.length() + 
                     //                    " - '" +  asb + "'");
                     lnLocs.add(new Integer(asb.length()));
@@ -591,7 +544,7 @@
                            ln.equals(SVG_ALT_GLYPH_TAG)) {
                     fillAttributedStringBuffer(ctx, nodeElement,
                                                false, subBidiLevel, 
-					       asb, lnLocs);
+                                               asb, lnLocs);
                 } else if (ln.equals(SVG_A_TAG)) {
                     if (ctx.isInteractive()) {
                         EventTarget target = (EventTarget)nodeElement;
@@ -621,9 +574,15 @@
                     s = TextUtilities.getElementContent(ref);
                     s = normalizeString(s, preserve, prevEndsWithSpace);
                     if (s != null) {
+                        int trefStart = asb.length();
                         Map m = getAttributeMap(ctx, nodeElement, null, 
-						bidiLevel);
+                                                bidiLevel);
                         asb.append(s, m);
+                        int trefEnd = asb.length()-1;
+                        TextPaintInfo tpi;
+                        tpi = (TextPaintInfo)elemTPI.get(nodeElement);
+                        tpi.startChar = trefStart;
+                        tpi.endChar   = trefEnd;
                     }
                 } 
                 break;
@@ -639,9 +598,27 @@
         }
 
         if (top) {
-            while ((endLimit < asb.length()) && (asb.getLastChar() == ' '))
+            boolean strippedSome = false;;
+            while ((endLimit < asb.length()) && (asb.getLastChar() == ' ')) {
                 asb.stripLast();
+                strippedSome = true;
+            }
+            if (strippedSome) {
+                Iterator iter = elemTPI.values().iterator();
+                while (iter.hasNext()) {
+                    TextPaintInfo tpi = (TextPaintInfo)iter.next();
+                    if (tpi.endChar >= asb.length()) {
+                        tpi.endChar = asb.length()-1;
+                        if (tpi.startChar > tpi.endChar)
+                            tpi.startChar = tpi.endChar;
+                    }
+                }
+            }
         }
+        int elementEndChar = asb.length()-1;
+        TextPaintInfo tpi = (TextPaintInfo)elemTPI.get(element);
+        tpi.startChar = elementStartChar;
+        tpi.endChar   = elementEndChar;
     }
 
     /**

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/font/FontFamilyResolver.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/font/FontFamilyResolver.java?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/font/FontFamilyResolver.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/font/FontFamilyResolver.java Wed Mar 22 18:46:22 2006
@@ -137,20 +137,21 @@
         if (resolvedFontFamilies == null) {
             resolvedFontFamilies = new HashMap();
         }
+        familyName = familyName.toLowerCase();
 
         // first see if this font family has already been resolved
         GVTFontFamily resolvedFF = 
-            (GVTFontFamily)resolvedFontFamilies.get(familyName.toLowerCase());
+            (GVTFontFamily)resolvedFontFamilies.get(familyName);
 
         if (resolvedFF == null) { // hasn't been resolved yet
             // try to find a matching family name in the list of
             // available fonts
-            String awtFamilyName = (String)fonts.get(familyName.toLowerCase());
+            String awtFamilyName = (String)fonts.get(familyName);
             if (awtFamilyName != null) {
                 resolvedFF = new AWTFontFamily(awtFamilyName);
             }
 
-            resolvedFontFamilies.put(familyName.toLowerCase(), resolvedFF);
+            resolvedFontFamilies.put(familyName, resolvedFF);
         }
 
         //  if (resolvedFF != null) {

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java Wed Mar 22 18:46:22 2006
@@ -46,7 +46,6 @@
 import org.apache.batik.gvt.font.GVTFontFamily;
 import org.apache.batik.gvt.font.GVTGlyphMetrics;
 import org.apache.batik.gvt.font.GVTLineMetrics;
-import org.apache.batik.gvt.font.UnresolvedFontFamily;
 import org.apache.batik.gvt.text.AttributedCharacterSpanIterator;
 import org.apache.batik.gvt.text.BidiAttributedCharacterIterator;
 import org.apache.batik.gvt.text.GVTAttributedCharacterIterator;
@@ -92,8 +91,8 @@
         = GVTAttributedCharacterIterator.TextAttribute.GVT_FONT;
 
     public static final 
-        AttributedCharacterIterator.Attribute GVT_FONT_FAMILIES 
-        = GVTAttributedCharacterIterator.TextAttribute.GVT_FONT_FAMILIES;
+        AttributedCharacterIterator.Attribute GVT_FONTS
+        = GVTAttributedCharacterIterator.TextAttribute.GVT_FONTS;
 
     public static final 
         AttributedCharacterIterator.Attribute BIDI_LEVEL
@@ -226,7 +225,7 @@
             // reorderTime += t1-t0;
             // t0=t1;
             chunkACIs    [i] = createModifiedACIForFontMatching
-                (node, chunkACIs[i]);
+                (chunkACIs[i]);
             
             chunkStart += (chunkACIs[i].getEndIndex()-
                            chunkACIs[i].getBeginIndex());
@@ -410,8 +409,8 @@
      *
      * @return The new modified aci.  
      */
-    protected AttributedCharacterIterator createModifiedACIForFontMatching
-        (TextNode node, AttributedCharacterIterator aci) {
+    protected static AttributedCharacterIterator createModifiedACIForFontMatching
+        (AttributedCharacterIterator aci) {
 
         aci.first();
         AttributedString as = null; 
@@ -424,39 +423,21 @@
             end = aci.getRunLimit(TEXT_COMPOUND_DELIMITER);
             int aciLength = end-start;
 
-            List fontFamilies;
-            fontFamilies = (List)aci.getAttributes().get(GVT_FONT_FAMILIES);
-
-            if (fontFamilies == null ) {
-                // no font families set this chunk so just increment...
-                asOff += aciLength;
-                moreChunks = (aci.setIndex(end) != AttributedCharacterIterator.DONE);
-                continue;
-            }
-
-            // resolve any unresolved font families in the list
-            List resolvedFontFamilies = new ArrayList(fontFamilies.size());
-            for (int i = 0; i < fontFamilies.size(); i++) {
-                GVTFontFamily fontFamily = (GVTFontFamily)fontFamilies.get(i);
-                if (fontFamily instanceof UnresolvedFontFamily) {
-                    fontFamily = FontFamilyResolver.resolve
-                        ((UnresolvedFontFamily)fontFamily);
-                }
-                if (fontFamily != null) // Add font family if resolved
-                    resolvedFontFamilies.add(fontFamily);
-            }
+            List fonts;
+            fonts = (List)aci.getAttributes().get(GVT_FONTS);
 
-            // if could not resolve at least one of the fontFamilies
-            // then use the default font
-            if (resolvedFontFamilies.size() == 0) {
-                resolvedFontFamilies.add(FontFamilyResolver.defaultFont);
-            }
 
-            // create a list of fonts of the correct size
             float fontSize = 12;
             Float fsFloat = (Float)aci.getAttributes().get(TextAttribute.SIZE);
-            if (fsFloat != null) {
+            if (fsFloat != null)
                 fontSize = fsFloat.floatValue();
+
+            // if could not resolve at least one of the fontFamilies
+            // then use the default font
+            if (fonts.size() == 0) {
+                // create a list of fonts of the correct size
+                fonts.add(FontFamilyResolver.defaultFont.deriveFont
+                    (fontSize, aci));
             }
 
             // now for each char or group of chars in the string,
@@ -470,16 +451,14 @@
             int numSet=0;
             int firstUnset=start;
             boolean firstUnsetSet;
-            for (int i = 0; i < resolvedFontFamilies.size(); i++) {
+            for (int i = 0; i < fonts.size(); i++) {
                 // assign this font to all characters it can display if it has
                 // not already been assigned
                 int currentIndex = firstUnset;
                 firstUnsetSet = false;
                 aci.setIndex(currentIndex);
 
-                GVTFontFamily ff;
-                ff = ((GVTFontFamily)resolvedFontFamilies.get(i));
-                GVTFont font = ff.deriveFont(fontSize, aci);
+                GVTFont font = (GVTFont)fonts.get(i);
                 if (defaultFont == null)
                     defaultFont = font;
 

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/GVTAttributedCharacterIterator.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/GVTAttributedCharacterIterator.java?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/GVTAttributedCharacterIterator.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/GVTAttributedCharacterIterator.java Wed Mar 22 18:46:22 2006
@@ -320,6 +320,8 @@
 
         public final static TextAttribute GVT_FONT_FAMILIES =
                                           new TextAttribute("GVT_FONT_FAMILIES");
+        public final static TextAttribute GVT_FONTS =
+                                          new TextAttribute("GVT_FONTS");
 
         public final static TextAttribute GVT_FONT =
                                           new TextAttribute("GVT_FONT");

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/GlyphLayout.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/GlyphLayout.java?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/GlyphLayout.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/GlyphLayout.java Wed Mar 22 18:46:22 2006
@@ -105,10 +105,6 @@
         = GVTAttributedCharacterIterator.TextAttribute.LINE_HEIGHT;
 
     public static final AttributedCharacterIterator.Attribute 
-        TEXT_COMPOUND_DELIMITER 
-        = GVTAttributedCharacterIterator.TextAttribute.TEXT_COMPOUND_DELIMITER;
-
-    public static final AttributedCharacterIterator.Attribute 
         VERTICAL_ORIENTATION 
         = GVTAttributedCharacterIterator.TextAttribute.VERTICAL_ORIENTATION;
 

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/TextPaintInfo.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/TextPaintInfo.java?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/TextPaintInfo.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/text/TextPaintInfo.java Wed Mar 22 18:46:22 2006
@@ -49,6 +49,8 @@
     public Paint  strikethroughStrokePaint;
     public Stroke strikethroughStroke;
 
+    public int    startChar, endChar;
+
     public TextPaintInfo() { }
     
     public TextPaintInfo(TextPaintInfo pi) {

Modified: xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/paints/radialGradient.png
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/paints/radialGradient.png?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
Binary files - no diff available.

Modified: xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/paints/radialGradient2.png
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/paints/radialGradient2.png?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
Binary files - no diff available.

Modified: xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/paints/radialGradient3.png
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/paints/radialGradient3.png?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
Binary files - no diff available.

Modified: xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/paints/radialGradientOrientation.png
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/paints/radialGradientOrientation.png?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
Binary files - no diff available.

Added: xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/scripting/domSVGColor.png
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/scripting/domSVGColor.png?rev=388007&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/scripting/domSVGColor.png
------------------------------------------------------------------------------
    svn:executable = *

Propchange: xmlgraphics/batik/branches/svg11/test-references/samples/tests/spec/scripting/domSVGColor.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: xmlgraphics/batik/branches/svg11/test-resources/org/apache/batik/test/samplesRendering.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/test-resources/org/apache/batik/test/samplesRendering.xml?rev=388007&r1=388006&r2=388007&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/test-resources/org/apache/batik/test/samplesRendering.xml (original)
+++ xmlgraphics/batik/branches/svg11/test-resources/org/apache/batik/test/samplesRendering.xml Wed Mar 22 18:46:22 2006
@@ -362,6 +362,7 @@
         <test id="samples/tests/spec/scripting/bbox.svg" />
         <test id="samples/tests/spec/scripting/circle.svg" />
         <test id="samples/tests/spec/scripting/display.svg" />
+        <test id="samples/tests/spec/scripting/domSVGColor.svg" />
         <test id="samples/tests/spec/scripting/ellipse.svg" />
         <test id="samples/tests/spec/scripting/enclosureList.svg" />
         <test id="samples/tests/spec/scripting/enclosureList2.svg" />