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 2005/09/25 20:00:07 UTC

svn commit: r291451 [1/22] - in /xmlgraphics/batik/branches/svg11: ./ samples/tests/resources/wmf/ samples/tests/spec/text/ sources/org/apache/batik/ext/awt/geom/ sources/org/apache/batik/svggen/ sources/org/apache/batik/transcoder/ sources/org/apache/...

Author: deweese
Date: Sun Sep 25 10:58:29 2005
New Revision: 291451

URL: http://svn.apache.org/viewcvs?rev=291451&view=rev
Log:
Patch for improved WMF & Graphics2D from Herve Girod (PR 36309).
Thanks Herve!
1) XMLWriter now tries to avoid inserting whitespace (it's added
   inside tags before the close '>').  This means that the
   DOM generated will be different.  This avoids messing up generated
   tspans.
2) WMF Transparency doesn't seem to be carried through (testCard.wmf)
3) WMF Bitmap fill doesn't seem to align quite right (testCard.wmf)
4) Polygon2D & PolyLine2D should probably share a common base class.
5) SVGGraphics2D - attributed character iterator stuff is a bit
   different (handles more cases, more correctly I think).  Also
   drops back to stroking in a fairly configurable manner.

Added:
    xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/
    xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/black_shapes.wmf   (with props)
    xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/imageWMF.wmf   (with props)
    xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/testChart.wmf   (with props)
    xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/textGreek.wmf   (with props)
    xmlgraphics/batik/branches/svg11/samples/tests/spec/text/textBiDi2.svg   (with props)
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/geom/Polygon2D.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/geom/Polyline2D.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/ToSVGAbstractTranscoder.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFPainter.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFReader.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/GdiObject.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/MetaRecord.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/TextureFactory.java   (with props)
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/WMFFont.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/WMFHeaderProperties.java   (with props)
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/package.html
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/transcoder/wmf/   (with props)
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/transcoder/wmf/black_shapes.svg   (with props)
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/transcoder/wmf/imageWMF.svg   (with props)
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/transcoder/wmf/testChart.svg   (with props)
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/transcoder/wmf/textGreek.svg   (with props)
    xmlgraphics/batik/branches/svg11/test-resources/org/apache/batik/transcoder/wmf/
    xmlgraphics/batik/branches/svg11/test-resources/org/apache/batik/transcoder/wmf/resources/
    xmlgraphics/batik/branches/svg11/test-resources/org/apache/batik/transcoder/wmf/resources/Messages.properties   (with props)
    xmlgraphics/batik/branches/svg11/test-sources/org/apache/batik/transcoder/wmf/
    xmlgraphics/batik/branches/svg11/test-sources/org/apache/batik/transcoder/wmf/Messages.java   (with props)
    xmlgraphics/batik/branches/svg11/test-sources/org/apache/batik/transcoder/wmf/WMFAccuracyTest.java   (with props)
Modified:
    xmlgraphics/batik/branches/svg11/build.xml
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/DOMGroupManager.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/SVGFont.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/SVGGraphics2D.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/XmlWriter.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/WMFConstants.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/RecordStore.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/WMFPainter.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/WMFRecordStore.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/WMFTranscoder.java
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ATransform.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/AttributedCharacterIterator.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/BStroke.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/BasicShapes.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/BasicShapes2.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/Bug17965.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/Bug4389.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/Bug4945.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/Bug6535.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/Clip.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/Color1.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/Color2.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextATransform.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextAttributedCharacterIterator.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextBStroke.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextBasicShapes.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextBasicShapes2.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextBug17965.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextBug4389.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextBug4945.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextBug6535.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextClip.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextColor1.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextColor2.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextDrawImage.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextFont1.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextFont2.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextGVector.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextGradient.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextGraphicObjects.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextIdentityTest.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextLookup.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextNegativeLengths.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextPaints.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextRHints.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextRescale.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextShearTest.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextTextSpacePreserve.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextTexture.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ContextTransformCollapse.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/DrawImage.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/Font1.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/Font2.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/GVector.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/Gradient.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/GraphicObjects.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/IdentityTest.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/Lookup.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/NegativeLengths.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/Paints.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/RHints.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/Rescale.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/ShearTest.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/TextSpacePreserve.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/Texture.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/TransformCollapse.svg
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/rendering/AttributedCharacterIterator.png
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/rendering/ContextAttributedCharacterIterator.png
    xmlgraphics/batik/branches/svg11/test-references/org/apache/batik/svggen/rendering/ContextBug4945.png
    xmlgraphics/batik/branches/svg11/test-resources/org/apache/batik/transcoder/unitTesting.xml
    xmlgraphics/batik/branches/svg11/test-sources/org/apache/batik/svggen/AttributedCharacterIterator.java
    xmlgraphics/batik/branches/svg11/test-sources/org/apache/batik/svggen/SVGAccuracyTest.java

Modified: xmlgraphics/batik/branches/svg11/build.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/build.xml?rev=291451&r1=291450&r2=291451&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/build.xml (original)
+++ xmlgraphics/batik/branches/svg11/build.xml Sun Sep 25 10:58:29 2005
@@ -1116,6 +1116,7 @@
     <mkdir dir="${test-references}/svgbe/accepted-variation"/>
     <mkdir dir="${test-references}/svgbe/candidate-variation"/>
     <mkdir dir="${test-references}/svgbe/candidate-reference"/>
+    <mkdir dir="${test-references}/org/apache/batik/transcoder/wmf/candidate"/>
     <mkdir dir="${test-references}/org/apache/batik/svggen/candidate-ref" />
     <mkdir dir="${test-references}/org/apache/batik/svggen/rendering/candidate-variation" />
     <mkdir dir="${test-references}/org/apache/batik/svggen/rendering/candidate-reference" />

Added: xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/black_shapes.wmf
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/black_shapes.wmf?rev=291451&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/black_shapes.wmf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/imageWMF.wmf
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/imageWMF.wmf?rev=291451&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/imageWMF.wmf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/testChart.wmf
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/testChart.wmf?rev=291451&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/testChart.wmf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/textGreek.wmf
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/textGreek.wmf?rev=291451&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/batik/branches/svg11/samples/tests/resources/wmf/textGreek.wmf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/batik/branches/svg11/samples/tests/spec/text/textBiDi2.svg
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/samples/tests/spec/text/textBiDi2.svg?rev=291451&view=auto
==============================================================================
--- xmlgraphics/batik/branches/svg11/samples/tests/spec/text/textBiDi2.svg (added)
+++ xmlgraphics/batik/branches/svg11/samples/tests/spec/text/textBiDi2.svg Sun Sep 25 10:58:29 2005
@@ -0,0 +1,57 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
+"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+
+<!--
+
+   Copyright 2001-2003,2005  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 mixing text directions with X/Y attrs.                            -->
+<!--                                                                        -->
+<!-- @author deweese@apache.org                                             -->
+<!-- @version $Id: textBiDi.svg 201374 2004-08-18 07:17:26Z vhardy $        -->
+<!-- ====================================================================== -->
+<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
+
+<svg width="450" height="500" viewBox="0 0 450 500"
+     xmlns="http://www.w3.org/2000/svg" 
+     xmlns:xlink="http://www.w3.org/1999/xlink" >
+    <!-- ============================================================= -->
+    <!-- Test content                                                  -->
+    <!-- ============================================================= -->
+
+    <g id="testContent">
+        <text class="title" x="50%" y="10%" font-size="15" text-anchor="middle" >
+            BiDi Text / International Text 2</text>
+
+      <g font-family="dialog" font-size="15" text-anchor="start">
+        <text id="HE" fill="DarkOliveGreen" x="40" y="110"
+         >&#x5d0;&#x5d1;&#x5d2; ABC</text>
+        <text id="EH" fill="DarkOliveGreen" x="225" y="110"
+         >ABC &#x5d0;&#x5d1;&#x5d2;</text>
+        <text id="EHE" fill="DarkOliveGreen" x="40" y="140"
+         >ABC &#x5d0;&#x5d1;&#x5d2; ABC</text>
+        <text id="HEH" fill="DarkOliveGreen" x="225" y="140"
+         >&#x5d0;&#x5d1;&#x5d2;&#x5d3; ABCD &#x5d0;&#x5d1;&#x5d2;&#x5d3;</text>
+      </g>
+   </g>
+    <!-- ============================================================= -->
+    <!-- Batik sample mark                                             -->
+    <!-- ============================================================= -->
+    <use xlink:href="../../../batikLogo.svg#Batik_Tag_Box" />
+    
+</svg>

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

Added: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/geom/Polygon2D.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/geom/Polygon2D.java?rev=291451&view=auto
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/geom/Polygon2D.java (added)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/geom/Polygon2D.java Sun Sep 25 10:58:29 2005
@@ -0,0 +1,461 @@
+/*
+
+   Copyright 2005  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.
+
+*/
+
+package org.apache.batik.ext.awt.geom;
+
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.Polygon;
+import java.awt.Point;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * This class is a Polygon with float coordinates.
+ *
+ */
+public class Polygon2D implements Shape, Cloneable, java.io.Serializable {
+
+    /**
+     * The total number of points.  The value of <code>npoints</code>
+     * represents the number of valid points in this <code>Polygon</code>.
+     *
+     */
+    public int npoints;
+
+    /**
+     * The array of <i>x</i> coordinates. The value of {@link #npoints npoints} is equal to the
+     * number of points in this <code>Polygon2D</code>.
+     *
+     */
+    public float xpoints[];
+
+    /**
+     * The array of <i>x</i> coordinates. The value of {@link #npoints npoints} is equal to the
+     * number of points in this <code>Polygon2D</code>.
+     *
+     */
+    public float ypoints[];
+    
+    /**
+     * Bounds of the Polygon2D.
+     * @see #getBounds()
+     */
+    protected Rectangle2D bounds;
+    
+    private GeneralPath path;
+    private GeneralPath closedPath;
+    
+    /**
+     * Creates an empty Polygon2D.
+     */
+    public Polygon2D() {
+	xpoints = new float[4];
+	ypoints = new float[4];
+    }
+    
+    /**
+     * Constructs and initializes a <code>Polygon2D</code> from the specified 
+     * Rectangle2D. 
+     * @param rec the Rectangle2D
+     * @exception  NullPointerException rec is <code>null</code>.
+     */
+    public Polygon2D(Rectangle2D rec) {
+    	if (rec == null) {
+    		throw new IndexOutOfBoundsException("null Rectangle");
+    	}
+	this.npoints = 4;
+	this.xpoints = new float[4];
+	this.ypoints = new float[4];
+        xpoints[0] = (float)rec.getMinX();
+        ypoints[0] = (float)rec.getMinY();
+        xpoints[1] = (float)rec.getMaxX();
+        ypoints[1] = (float)rec.getMinY();
+        xpoints[2] = (float)rec.getMaxX();
+        ypoints[2] = (float)rec.getMaxY();
+        xpoints[3] = (float)rec.getMinX();
+        ypoints[3] = (float)rec.getMaxY();
+        calculatePath();
+    }    
+
+    /**
+     * Constructs and initializes a <code>Polygon2D</code> from the specified 
+     * Polygon. 
+     * @param pol the Polygon
+     * @exception  NullPointerException pol is <code>null</code>.
+     */
+    public Polygon2D(Polygon pol) {
+    	if (pol == null) {
+    		throw new IndexOutOfBoundsException("null Polygon");
+    	}
+	this.npoints = pol.npoints;
+	this.xpoints = new float[pol.npoints];
+	this.ypoints = new float[pol.npoints];
+        for (int i = 0; i < pol.npoints; i++) {
+            xpoints[i] = (float)pol.xpoints[i];
+            ypoints[i] = (float)pol.ypoints[i];
+        }
+        calculatePath();
+    }        
+    
+    /**
+     * Constructs and initializes a <code>Polygon2D</code> from the specified 
+     * parameters. 
+     * @param xpoints an array of <i>x</i> coordinates
+     * @param ypoints an array of <i>y</i> coordinates
+     * @param npoints the total number of points in the <code>Polygon2D</code>
+     * @exception  NegativeArraySizeException if the value of
+     *                       <code>npoints</code> is negative.
+     * @exception  IndexOutOfBoundsException if <code>npoints</code> is
+     *             greater than the length of <code>xpoints</code>
+     *             or the length of <code>ypoints</code>.
+     * @exception  NullPointerException if <code>xpoints</code> or
+     *             <code>ypoints</code> is <code>null</code>.
+     */
+    public Polygon2D(float xpoints[], float ypoints[], int npoints) {
+    	if (npoints > xpoints.length || npoints > ypoints.length) {
+    		throw new IndexOutOfBoundsException("npoints > xpoints.length || npoints > ypoints.length");
+    	}
+	this.npoints = npoints;
+	this.xpoints = new float[npoints];
+	this.ypoints = new float[npoints];
+	System.arraycopy(xpoints, 0, this.xpoints, 0, npoints);
+	System.arraycopy(ypoints, 0, this.ypoints, 0, npoints);
+        calculatePath();
+    }
+
+    /**
+     * Constructs and initializes a <code>Polygon2D</code> from the specified 
+     * parameters. 
+     * @param xpoints an array of <i>x</i> coordinates
+     * @param ypoints an array of <i>y</i> coordinates
+     * @param npoints the total number of points in the <code>Polygon2D</code>
+     * @exception  NegativeArraySizeException if the value of
+     *                       <code>npoints</code> is negative.
+     * @exception  IndexOutOfBoundsException if <code>npoints</code> is
+     *             greater than the length of <code>xpoints</code>
+     *             or the length of <code>ypoints</code>.
+     * @exception  NullPointerException if <code>xpoints</code> or
+     *             <code>ypoints</code> is <code>null</code>.
+     */
+    public Polygon2D(int xpoints[], int ypoints[], int npoints) {
+    	if (npoints > xpoints.length || npoints > ypoints.length) {
+    		throw new IndexOutOfBoundsException("npoints > xpoints.length || npoints > ypoints.length");
+    	}
+	this.npoints = npoints;
+	this.xpoints = new float[npoints];
+	this.ypoints = new float[npoints];
+        for (int i = 0; i < npoints; i++) {
+            this.xpoints[i] = (float)xpoints[i];
+            this.ypoints[i] = (float)ypoints[i];
+        }    
+        calculatePath();
+    }    
+    
+    /**
+     * Resets this <code>Polygon</code> object to an empty polygon.
+     */
+    public void reset() {
+	npoints = 0;
+	bounds = null;
+        path = new GeneralPath();
+        closedPath = null;
+    }
+    
+    public Object clone() {
+        Polygon2D pol = new Polygon2D();
+        for (int i = 0; i < npoints; i++) {
+            pol.addPoint(xpoints[i], ypoints[i]);
+        }
+        return pol;
+    }
+    
+    private void calculatePath() {
+        path = new GeneralPath();
+        path.moveTo(xpoints[0], ypoints[0]);
+        for (int i = 1; i < npoints; i++) {
+            path.lineTo(xpoints[i], ypoints[i]);
+        }
+        bounds = path.getBounds2D();
+        closedPath = null;    
+    }
+    
+    private void updatePath(float x, float y) {
+        closedPath = null;        
+        if (path == null) {
+            path = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
+            path.moveTo(x, y);
+            bounds = new Rectangle2D.Float(x, y, 0, 0);
+        } else {
+            path.lineTo(x, y);
+            float _xmax = (float)bounds.getMaxX();
+            float _ymax = (float)bounds.getMaxY();
+            float _xmin = (float)bounds.getMinX();
+            float _ymin = (float)bounds.getMinY();
+            if (x < _xmin) _xmin = x;
+            else if (x > _xmax) _xmax = x;
+            if (y < _ymin) _ymin = y;
+            else if (y > _ymax) _ymax = y; 
+            bounds = new Rectangle2D.Float(_xmin, _ymin, _xmax - _xmin, _ymax - _ymin);            
+        }
+    }
+    
+    /* get the associated {@link Polyline2D}.
+     */    
+    public Polyline2D getPolyline2D() {
+        Polyline2D pol = new Polyline2D();
+        for (int i = 0; i < npoints; i++) {
+           pol.addPoint((float)xpoints[i], (float)ypoints[i]); 
+        }
+        pol.addPoint((float)xpoints[0], (float)ypoints[0]);
+        
+        return pol;
+    }        
+        
+    public Polygon getPolygon() {
+        int[] _xpoints = new int[npoints];
+        int[] _ypoints = new int[npoints];
+        for (int i = 0; i < npoints; i++) {
+            _xpoints[i] = (int)xpoints[i];
+            _ypoints[i] = (int)ypoints[i];
+        }
+        
+        return new Polygon(_xpoints, _ypoints, npoints);
+    }
+
+    public void addPoint(Point2D p) {
+        addPoint((float)p.getX(), (float)p.getY());
+    }
+
+    /**
+     * Appends the specified coordinates to this <code>Polygon2D</code>. 
+     * @param       x the specified x coordinate
+     * @param       y the specified y coordinate
+     */
+    public void addPoint(float x, float y) {
+	if (npoints == xpoints.length) {
+	    float tmp[];
+
+	    tmp = new float[npoints * 2];
+	    System.arraycopy(xpoints, 0, tmp, 0, npoints);
+	    xpoints = tmp;
+
+	    tmp = new float[npoints * 2];
+	    System.arraycopy(ypoints, 0, tmp, 0, npoints);
+	    ypoints = tmp;
+	}
+	xpoints[npoints] = x;
+	ypoints[npoints] = y;
+	npoints++;
+	updatePath(x, y);
+    }
+
+    /**
+     * Determines whether the specified {@link Point} is inside this 
+     * <code>Polygon</code>.
+     * @param p the specified <code>Point</code> to be tested
+     * @return <code>true</code> if the <code>Polygon</code> contains the
+     * 			<code>Point</code>; <code>false</code> otherwise.
+     * @see #contains(double, double)
+     */
+    public boolean contains(Point p) {
+	return contains(p.x, p.y);
+    }
+
+    /**
+     * Determines whether the specified coordinates are inside this 
+     * <code>Polygon</code>.   
+     * <p>
+     * @param x the specified x coordinate to be tested
+     * @param y the specified y coordinate to be tested
+     * @return  <code>true</code> if this <code>Polygon</code> contains
+     * 			the specified coordinates, (<i>x</i>,&nbsp;<i>y</i>);  
+     * 			<code>false</code> otherwise.
+     */
+    public boolean contains(int x, int y) {
+	return contains((double) x, (double) y);
+    }
+
+    /**
+     * Returns the high precision bounding box of the {@link Shape}.
+     * @return a {@link Rectangle2D} that precisely
+     *		bounds the <code>Shape</code>.
+     */
+    public Rectangle2D getBounds2D() {
+	return bounds;
+    }
+    
+    public Rectangle getBounds() {
+        if (bounds == null) return null;
+        else return bounds.getBounds();
+    }
+
+    /**
+     * Determines if the specified coordinates are inside this 
+     * <code>Polygon</code>.  For the definition of
+     * <i>insideness</i>, see the class comments of {@link Shape}.
+     * @param x the specified x coordinate
+     * @param y the specified y coordinate
+     * @return <code>true</code> if the <code>Polygon</code> contains the
+     * specified coordinates; <code>false</code> otherwise.
+     */
+    public boolean contains(double x, double y) {
+        if (npoints <= 2 || !bounds.contains(x, y)) {
+	    return false;
+	}
+        updateComputingPath();
+
+        return closedPath.contains(x, y);
+    }
+    
+    private void updateComputingPath() {
+        if (npoints >= 1) {
+            if (closedPath == null) {
+                closedPath = (GeneralPath)path.clone();
+                closedPath.closePath();            
+            }   
+        }
+    }
+
+    /**
+     * Tests if a specified {@link Point2D} is inside the boundary of this 
+     * <code>Polygon</code>.
+     * @param p a specified <code>Point2D</code>
+     * @return <code>true</code> if this <code>Polygon</code> contains the 
+     * 		specified <code>Point2D</code>; <code>false</code>
+     *          otherwise.
+     * @see #contains(double, double)
+     */
+    public boolean contains(Point2D p) {
+	return contains(p.getX(), p.getY());
+    }
+
+    /**
+     * Tests if the interior of this <code>Polygon</code> intersects the 
+     * interior of a specified set of rectangular coordinates.
+     * @param x the x coordinate of the specified rectangular
+     *			shape's top-left corner
+     * @param y the y coordinate of the specified rectangular
+     *			shape's top-left corner
+     * @param w the width of the specified rectangular shape
+     * @param h the height of the specified rectangular shape
+     * @return <code>true</code> if the interior of this 
+     *			<code>Polygon</code> and the interior of the
+     *			specified set of rectangular 
+     * 			coordinates intersect each other;
+     *			<code>false</code> otherwise.
+     */
+    public boolean intersects(double x, double y, double w, double h) {
+	if (npoints <= 0 || !bounds.intersects(x, y, w, h)) {
+	    return false;
+	}
+        updateComputingPath();
+        return closedPath.intersects(x, y, w, h);
+    }
+
+    /**
+     * Tests if the interior of this <code>Polygon</code> intersects the
+     * interior of a specified <code>Rectangle2D</code>.
+     * @param r a specified <code>Rectangle2D</code>
+     * @return <code>true</code> if this <code>Polygon</code> and the
+     * 			interior of the specified <code>Rectangle2D</code>
+     * 			intersect each other; <code>false</code>
+     * 			otherwise.
+     */
+    public boolean intersects(Rectangle2D r) {
+	return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
+    }
+
+    /**
+     * Tests if the interior of this <code>Polygon</code> entirely
+     * contains the specified set of rectangular coordinates.
+     * @param x the x coordinate of the top-left corner of the
+     * 			specified set of rectangular coordinates
+     * @param y the y coordinate of the top-left corner of the
+     * 			specified set of rectangular coordinates
+     * @param w the width of the set of rectangular coordinates
+     * @param h the height of the set of rectangular coordinates
+     * @return <code>true</code> if this <code>Polygon</code> entirely
+     * 			contains the specified set of rectangular
+     * 			coordinates; <code>false</code> otherwise.
+     */
+    public boolean contains(double x, double y, double w, double h) {
+	if (npoints <= 0 || !bounds.intersects(x, y, w, h)) {
+	    return false;
+	}
+
+        updateComputingPath();
+        return closedPath.contains(x, y, w, h);
+    }
+
+    /**
+     * Tests if the interior of this <code>Polygon</code> entirely
+     * contains the specified <code>Rectangle2D</code>.
+     * @param r the specified <code>Rectangle2D</code>
+     * @return <code>true</code> if this <code>Polygon</code> entirely
+     * 			contains the specified <code>Rectangle2D</code>;
+     *			<code>false</code> otherwise.
+     * @see #contains(double, double, double, double)
+     */
+    public boolean contains(Rectangle2D r) {
+	return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());
+    }
+
+    /**
+     * Returns an iterator object that iterates along the boundary of this 
+     * <code>Polygon</code> and provides access to the geometry
+     * of the outline of this <code>Polygon</code>.  An optional
+     * {@link AffineTransform} can be specified so that the coordinates 
+     * returned in the iteration are transformed accordingly.
+     * @param at an optional <code>AffineTransform</code> to be applied to the
+     * 		coordinates as they are returned in the iteration, or 
+     *		<code>null</code> if untransformed coordinates are desired
+     * @return a {@link PathIterator} object that provides access to the
+     *		geometry of this <code>Polygon</code>.      
+     */
+    public PathIterator getPathIterator(AffineTransform at) {
+        updateComputingPath();
+        if (closedPath == null) return null;
+        else return closedPath.getPathIterator(at);        
+    }
+
+    /**
+     * Returns an iterator object that iterates along the boundary of
+     * the <code>Polygon2D</code> and provides access to the geometry of the 
+     * outline of the <code>Shape</code>.  Only SEG_MOVETO, SEG_LINETO, and 
+     * SEG_CLOSE point types are returned by the iterator.
+     * Since polygons are already flat, the <code>flatness</code> parameter
+     * is ignored.
+     * @param at an optional <code>AffineTransform</code> to be applied to the
+     * 		coordinates as they are returned in the iteration, or 
+     *		<code>null</code> if untransformed coordinates are desired
+     * @param flatness the maximum amount that the control points
+     * 		for a given curve can vary from colinear before a subdivided
+     *		curve is replaced by a straight line connecting the 
+     * 		endpoints.  Since polygons are already flat the
+     * 		<code>flatness</code> parameter is ignored.
+     * @return a <code>PathIterator</code> object that provides access to the
+     * 		<code>Shape</code> object's geometry.
+     */
+    public PathIterator getPathIterator(AffineTransform at, double flatness) {
+	return getPathIterator(at);
+    }
+}
\ No newline at end of file

Added: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/geom/Polyline2D.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/geom/Polyline2D.java?rev=291451&view=auto
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/geom/Polyline2D.java (added)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/geom/Polyline2D.java Sun Sep 25 10:58:29 2005
@@ -0,0 +1,423 @@
+/*
+
+   Copyright 2005  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.
+
+*/
+
+package org.apache.batik.ext.awt.geom;
+
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.Polygon;
+import java.awt.Point;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.Line2D;
+
+/**
+ * This class has the same behavior than {@link Polygon2D}, except that
+ * the figure is not closed.
+ */
+public class Polyline2D implements Shape, Cloneable, java.io.Serializable {
+    private static final float ASSUME_ZERO = 0.001f;   
+
+    /**
+     * The total number of points.  The value of <code>npoints</code>
+     * represents the number of points in this <code>Polyline2D</code>.
+     *
+     */
+    public int npoints;
+
+    /**
+     * The array of <i>x</i> coordinates. The value of {@link #npoints npoints} is equal to the
+     * number of points in this <code>Polyline2D</code>.
+     *
+     */
+    public float xpoints[];
+
+    /**
+     * The array of <i>x</i> coordinates. The value of {@link #npoints npoints} is equal to the
+     * number of points in this <code>Polyline2D</code>.
+     *
+     */
+    public float ypoints[];
+    
+    /**
+     * Bounds of the Polyline2D.
+     * @see #getBounds()
+     */
+    protected Rectangle2D bounds;
+    
+    private GeneralPath path;
+    private GeneralPath closedPath;    
+
+    /**
+     * Creates an empty Polyline2D.
+     */
+    public Polyline2D() {
+	xpoints = new float[4];
+	ypoints = new float[4];
+    }
+
+    /**
+     * Constructs and initializes a <code>Polyline2D</code> from the specified 
+     * parameters. 
+     * @param xpoints an array of <i>x</i> coordinates
+     * @param ypoints an array of <i>y</i> coordinates
+     * @param npoints the total number of points in the    
+     *				<code>Polyline2D</code>
+     * @exception  NegativeArraySizeException if the value of
+     *                       <code>npoints</code> is negative.
+     * @exception  IndexOutOfBoundsException if <code>npoints</code> is
+     *             greater than the length of <code>xpoints</code>
+     *             or the length of <code>ypoints</code>.
+     * @exception  NullPointerException if <code>xpoints</code> or
+     *             <code>ypoints</code> is <code>null</code>.
+     */
+    public Polyline2D(float[] xpoints, float[] ypoints, int npoints) {
+    	if (npoints > xpoints.length || npoints > ypoints.length) {
+    		throw new IndexOutOfBoundsException("npoints > xpoints.length || npoints > ypoints.length");
+    	}
+	this.npoints = npoints;
+	this.xpoints = new float[npoints];
+	this.ypoints = new float[npoints];
+	System.arraycopy(xpoints, 0, this.xpoints, 0, npoints);
+	System.arraycopy(ypoints, 0, this.ypoints, 0, npoints);
+        calculatePath();
+    }
+    
+    /**
+     * Constructs and initializes a <code>Polyline2D</code> from the specified 
+     * parameters. 
+     * @param xpoints an array of <i>x</i> coordinates
+     * @param ypoints an array of <i>y</i> coordinates
+     * @param npoints the total number of points in the <code>Polyline2D</code>
+     * @exception  NegativeArraySizeException if the value of
+     *                       <code>npoints</code> is negative.
+     * @exception  IndexOutOfBoundsException if <code>npoints</code> is
+     *             greater than the length of <code>xpoints</code>
+     *             or the length of <code>ypoints</code>.
+     * @exception  NullPointerException if <code>xpoints</code> or
+     *             <code>ypoints</code> is <code>null</code>.
+     */
+    public Polyline2D(int xpoints[], int ypoints[], int npoints) {
+    	if (npoints > xpoints.length || npoints > ypoints.length) {
+    		throw new IndexOutOfBoundsException("npoints > xpoints.length || npoints > ypoints.length");
+    	}
+	this.npoints = npoints;
+	this.xpoints = new float[npoints];
+	this.ypoints = new float[npoints];
+        for (int i = 0; i < npoints; i++) {
+            this.xpoints[i] = (float)xpoints[i];
+            this.ypoints[i] = (float)ypoints[i];
+        }        
+        calculatePath();
+    }        
+
+    public Polyline2D(Line2D line) {
+        this.npoints = 2;
+        this.xpoints = new float[2];
+        this.ypoints = new float[2];
+        xpoints[0] = (float)line.getX1();
+        xpoints[1] = (float)line.getX2();
+        ypoints[0] = (float)line.getY1();
+        ypoints[1] = (float)line.getY2();   
+        calculatePath();
+    }
+
+    /**
+     * Resets this <code>Polyline2D</code> object to an empty polygon.
+     * The coordinate arrays and the data in them are left untouched
+     * but the number of points is reset to zero to mark the old
+     * vertex data as invalid and to start accumulating new vertex
+     * data at the beginning.
+     * All internally-cached data relating to the old vertices
+     * are discarded.
+     * Note that since the coordinate arrays from before the reset
+     * are reused, creating a new empty <code>Polyline2D</code> might
+     * be more memory efficient than resetting the current one if
+     * the number of vertices in the new polyline data is significantly
+     * smaller than the number of vertices in the data from before the
+     * reset.
+     */
+    public void reset() {
+	npoints = 0;
+	bounds = null;
+        path = new GeneralPath();
+        closedPath = null;        
+    }
+    
+    public Object clone() {
+        Polyline2D pol = new Polyline2D();
+        for (int i = 0; i < npoints; i++) {
+            pol.addPoint(xpoints[i], ypoints[i]);
+        }
+        return pol;
+    }    
+    
+    private void calculatePath() {
+        path = new GeneralPath();
+        path.moveTo(xpoints[0], ypoints[0]);
+        for (int i = 1; i < npoints; i++) {
+            path.lineTo(xpoints[i], ypoints[i]);
+        }
+        bounds = path.getBounds2D();
+        closedPath = null;    
+    }    
+    
+    private void updatePath(float x, float y) {
+        closedPath = null;        
+        if (path == null) {
+            path = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
+            path.moveTo(x, y);
+            bounds = new Rectangle2D.Float(x, y, 0, 0);
+        } else {
+            path.lineTo(x, y);
+            float _xmax = (float)bounds.getMaxX();
+            float _ymax = (float)bounds.getMaxY();
+            float _xmin = (float)bounds.getMinX();
+            float _ymin = (float)bounds.getMinY();
+            if (x < _xmin) _xmin = x;
+            else if (x > _xmax) _xmax = x;
+            if (y < _ymin) _ymin = y;
+            else if (y > _ymax) _ymax = y; 
+            bounds = new Rectangle2D.Float(_xmin, _ymin, _xmax - _xmin, _ymax - _ymin);            
+        }
+    }        
+    
+    public void addPoint(Point2D p) {
+        addPoint((float)p.getX(), (float)p.getY());
+    }    
+
+    /**
+     * Appends the specified coordinates to this <code>Polyline2D</code>. 
+     * <p>
+     * If an operation that calculates the bounding box of this     
+     * <code>Polyline2D</code> has already been performed, such as  
+     * <code>getBounds</code> or <code>contains</code>, then this 
+     * method updates the bounding box. 
+     * @param       x the specified x coordinate
+     * @param       y the specified y coordinate
+     * @see         java.awt.Polygon#getBounds
+     * @see         java.awt.Polygon#contains
+     */
+    public void addPoint(float x, float y) {
+	if (npoints == xpoints.length) {
+	    float tmp[];
+
+	    tmp = new float[npoints * 2];
+	    System.arraycopy(xpoints, 0, tmp, 0, npoints);
+	    xpoints = tmp;
+
+	    tmp = new float[npoints * 2];
+	    System.arraycopy(ypoints, 0, tmp, 0, npoints);
+	    ypoints = tmp;
+	}
+	xpoints[npoints] = x;
+	ypoints[npoints] = y;
+	npoints++;
+        updatePath(x, y);
+    }
+
+    /**
+     * Gets the bounding box of this <code>Polyline2D</code>. 
+     * The bounding box is the smallest {@link Rectangle} whose
+     * sides are parallel to the x and y axes of the 
+     * coordinate space, and can completely contain the <code>Polyline2D</code>.
+     * @return a <code>Rectangle</code> that defines the bounds of this 
+     * <code>Polyline2D</code>.
+     */
+    public Rectangle getBounds() {
+        if (bounds == null) return null;
+        else return bounds.getBounds();
+    }
+    
+    private void updateComputingPath() {
+        if (npoints >= 1) {
+            if (closedPath == null) {
+                closedPath = (GeneralPath)path.clone();
+                closedPath.closePath();            
+            }   
+        }
+    }  
+
+    /**
+     * Determines whether the specified {@link Point} is inside this 
+     * <code>Polyline2D</code>.
+     * This method is required to implement the Shape interface, 
+     * but in the case of Line2D objects it always returns false since a line contains no area.
+     */
+    public boolean contains(Point p) {
+	return false;
+    }
+
+    /**
+     * Determines if the specified coordinates are inside this 
+     * <code>Polyline2D</code>.
+     * This method is required to implement the Shape interface, 
+     * but in the case of Line2D objects it always returns false since a line contains no area.
+     */
+    public boolean contains(double x, double y) {
+        return false;
+    }
+    
+    /**
+     * Determines whether the specified coordinates are inside this 
+     * <code>Polyline2D</code>.   
+     * This method is required to implement the Shape interface, 
+     * but in the case of Line2D objects it always returns false since a line contains no area.
+     */
+    public boolean contains(int x, int y) {
+	return false;
+    }
+
+    /**
+     * Returns the high precision bounding box of the {@link Shape}.
+     * @return a {@link Rectangle2D} that precisely
+     *		bounds the <code>Shape</code>.
+     */
+    public Rectangle2D getBounds2D() {
+	return bounds;
+    }
+
+    /**
+     * Tests if a specified {@link Point2D} is inside the boundary of this 
+     * <code>Polyline2D</code>.
+     * This method is required to implement the Shape interface, 
+     * but in the case of Line2D objects it always returns false since a line contains no area.
+     */
+    public boolean contains(Point2D p) {
+	return false;
+    }
+
+    /**
+     * Tests if the interior of this <code>Polygon</code> intersects the 
+     * interior of a specified set of rectangular coordinates.
+     * @param x the x coordinate of the specified rectangular
+     *			shape's top-left corner
+     * @param y the y coordinate of the specified rectangular
+     *			shape's top-left corner
+     * @param w the width of the specified rectangular shape
+     * @param h the height of the specified rectangular shape
+     * @return <code>true</code> if the interior of this 
+     *			<code>Polygon</code> and the interior of the
+     *			specified set of rectangular 
+     * 			coordinates intersect each other;
+     *			<code>false</code> otherwise.
+     */
+    public boolean intersects(double x, double y, double w, double h) {
+	if (npoints <= 0 || !bounds.intersects(x, y, w, h)) {
+	    return false;
+	}
+        updateComputingPath();
+        return closedPath.intersects(x, y, w, h);
+    }
+
+    /**
+     * Tests if the interior of this <code>Polygon</code> intersects the
+     * interior of a specified <code>Rectangle2D</code>.
+     * @param r a specified <code>Rectangle2D</code>
+     * @return <code>true</code> if this <code>Polygon</code> and the
+     * 			interior of the specified <code>Rectangle2D</code>
+     * 			intersect each other; <code>false</code>
+     * 			otherwise.
+     */
+    public boolean intersects(Rectangle2D r) {
+	return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
+    }
+
+    /**
+     * Tests if the interior of this <code>Polyline2D</code> entirely
+     * contains the specified set of rectangular coordinates.
+     * This method is required to implement the Shape interface, 
+     * but in the case of Line2D objects it always returns false since a line contains no area.
+     */
+    public boolean contains(double x, double y, double w, double h) {
+	return false;
+    }
+
+    /**
+     * Tests if the interior of this <code>Polyline2D</code> entirely
+     * contains the specified <code>Rectangle2D</code>.
+     * This method is required to implement the Shape interface, 
+     * but in the case of Line2D objects it always returns false since a line contains no area.
+     */
+    public boolean contains(Rectangle2D r) {
+	return false;
+    }
+
+    /**
+     * Returns an iterator object that iterates along the boundary of this 
+     * <code>Polygon</code> and provides access to the geometry
+     * of the outline of this <code>Polygon</code>.  An optional
+     * {@link AffineTransform} can be specified so that the coordinates 
+     * returned in the iteration are transformed accordingly.
+     * @param at an optional <code>AffineTransform</code> to be applied to the
+     * 		coordinates as they are returned in the iteration, or 
+     *		<code>null</code> if untransformed coordinates are desired
+     * @return a {@link PathIterator} object that provides access to the
+     *		geometry of this <code>Polygon</code>.      
+     */
+    public PathIterator getPathIterator(AffineTransform at) {
+        if (path == null) return null;
+        else return path.getPathIterator(at);
+    }
+
+    /* get the associated {@link Polygon2D}.
+     * This method take care that may be the last point can
+     * be equal to the first. In that case it must not be included in the Polygon,
+     * as polygons declare their first point only once.
+     */    
+    public Polygon2D getPolygon2D() {
+        Polygon2D pol = new Polygon2D();
+        for (int i = 0; i < npoints - 1; i++) {
+           pol.addPoint((float)xpoints[i], (float)ypoints[i]); 
+        }
+        Point2D.Double p0 = 
+            new Point2D.Double(xpoints[0], ypoints[0]);
+        Point2D.Double p1 = 
+            new Point2D.Double(xpoints[npoints-1], ypoints[npoints-1]); 
+
+        if (p0.distance(p1) > ASSUME_ZERO)
+            pol.addPoint((float)xpoints[npoints-1], (float)ypoints[npoints-1]);
+        
+        return pol;
+    }
+
+    /**
+     * Returns an iterator object that iterates along the boundary of
+     * the <code>Shape</code> and provides access to the geometry of the 
+     * outline of the <code>Shape</code>.  Only SEG_MOVETO and SEG_LINETO, point types 
+     * are returned by the iterator.
+     * Since polylines are already flat, the <code>flatness</code> parameter
+     * is ignored. 
+     * @param at an optional <code>AffineTransform</code> to be applied to the
+     * 		coordinates as they are returned in the iteration, or 
+     *		<code>null</code> if untransformed coordinates are desired
+     * @param flatness the maximum amount that the control points
+     * 		for a given curve can vary from colinear before a subdivided
+     *		curve is replaced by a straight line connecting the 
+     * 		endpoints.  Since polygons are already flat the
+     * 		<code>flatness</code> parameter is ignored.
+     * @return a <code>PathIterator</code> object that provides access to the
+     * 		<code>Shape</code> object's geometry.
+     */
+    public PathIterator getPathIterator(AffineTransform at, double flatness) {
+	return path.getPathIterator(at);
+    }
+}

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/DOMGroupManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/DOMGroupManager.java?rev=291451&r1=291450&r2=291451&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/DOMGroupManager.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/DOMGroupManager.java Sun Sep 25 10:58:29 2005
@@ -260,8 +260,8 @@
      * in gc that are different from the values in referenceGc will be
      * present in the delta. Other values will no.
      */
-    protected SVGGraphicContext processDeltaGC(SVGGraphicContext gc,
-                                             SVGGraphicContext referenceGc) {
+    static SVGGraphicContext processDeltaGC(SVGGraphicContext gc,
+                                            SVGGraphicContext referenceGc) {
         Map groupDelta = processDeltaMap(gc.getGroupContext(),
                                          referenceGc.getGroupContext());
         Map graphicElementDelta = gc.getGraphicElementContext();
@@ -311,7 +311,7 @@
      * are different from values in referenceMap are place in the
      * returned delta Map.
      */
-    protected Map processDeltaMap(Map map, Map referenceMap) {
+    static Map processDeltaMap(Map map, Map referenceMap) {
         // no need to be synch => HashMap
         Map mapDelta = new HashMap();
         Iterator iter = map.keySet().iterator();

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/SVGFont.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/SVGFont.java?rev=291451&r1=291450&r2=291451&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/SVGFont.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/SVGFont.java Sun Sep 25 10:58:29 2005
@@ -162,14 +162,16 @@
      */
     public void recordFontUsage(String string, Font font) {
 
-        Font commonSizeFont = createCommonSizeFont(font);
-        String fontKey = commonSizeFont.getFamily() + commonSizeFont.getStyle();
+        Font   commonSizeFont = createCommonSizeFont(font);
+        String fontKey        = (commonSizeFont.getFamily() + 
+                                 commonSizeFont.getStyle());
         String textUsingFont = (String)fontStringMap.get(fontKey);
         if (textUsingFont == null) {
             // font has not been used before
             textUsingFont = "";
         }
         // append any new characters to textUsingFont
+        // FIXX: This is horribly inefficent, consider binary tree, Set, etc.
         char ch;
         for (int i = 0; i < string.length(); i++) {
             ch = string.charAt(i);
@@ -188,6 +190,8 @@
     private static Font createCommonSizeFont(Font font) {
         HashMap attributes = new HashMap(font.getAttributes());
         attributes.put(TextAttribute.SIZE, new Float(COMMON_FONT_SIZE));
+        // Remove Transform from font otherwise it will be applied twice.
+        attributes.remove(TextAttribute.TRANSFORM);
         return new Font(attributes);
     }
 
@@ -213,6 +217,11 @@
      * @return description of attribute values that describe the font
      */
     public SVGFontDescriptor toSVG(Font font, FontRenderContext frc) {
+        // Remove affine from FRC otherwise it will be applied twice.
+        FontRenderContext localFRC;
+        localFRC = new FontRenderContext(new AffineTransform(), 
+                                         frc.isAntiAliased(), 
+                                         frc.usesFractionalMetrics());
 
         String fontSize = "" + doubleString(font.getSize2D());
         String fontWeight = weightToSVG(font);
@@ -220,7 +229,8 @@
         String fontFamilyStr = familyToSVG(font);
 
         Font commonSizeFont = createCommonSizeFont(font);
-        String fontKey = commonSizeFont.getFamily() + commonSizeFont.getStyle();
+        String fontKey = (commonSizeFont.getFamily() + 
+                          commonSizeFont.getStyle());
 
         String textUsingFont = (String)fontStringMap.get(fontKey);
 
@@ -257,7 +267,8 @@
             Element fontFace = domFactory.createElementNS(SVG_NAMESPACE_URI,
                                                           SVG_FONT_FACE_TAG);
             String svgFontFamilyString = fontFamilyStr;
-            if (fontFamilyStr.startsWith("'") && fontFamilyStr.endsWith("'")) {
+            if (fontFamilyStr.startsWith("'") && 
+                fontFamilyStr.endsWith("'")) {
                 // get rid of the quotes
                 svgFontFamilyString
                     = fontFamilyStr.substring(1, fontFamilyStr.length()-1);
@@ -281,7 +292,8 @@
 
             int missingGlyphCode[] = new int[1];
             missingGlyphCode[0] = commonSizeFont.getMissingGlyphCode();
-            GlyphVector gv = commonSizeFont.createGlyphVector(frc, missingGlyphCode);
+            GlyphVector gv;
+            gv = commonSizeFont.createGlyphVector(localFRC, missingGlyphCode);
             Shape missingGlyphShape = gv.getGlyphOutline(0);
             GlyphMetrics gm = gv.getGlyphMetrics(0);
 
@@ -301,7 +313,7 @@
             fontDef.setAttributeNS(null, SVG_HORIZ_ADV_X_ATTRIBUTE,  "" + gm.getAdvance());
 
             // set the ascent and descent attributes
-            LineMetrics lm = commonSizeFont.getLineMetrics("By", frc);
+            LineMetrics lm = commonSizeFont.getLineMetrics("By", localFRC);
             fontFace.setAttributeNS(null, SVG_ASCENT_ATTRIBUTE, "" + lm.getAscent());
             fontFace.setAttributeNS(null, SVG_DESCENT_ATTRIBUTE, "" + lm.getDescent());
 
@@ -339,7 +351,8 @@
                     = domFactory.createElementNS(SVG_NAMESPACE_URI,
                                                  SVG_GLYPH_TAG);
 
-                GlyphVector gv = commonSizeFont.createGlyphVector(frc, ""+c);
+                GlyphVector gv;
+                gv = commonSizeFont.createGlyphVector(localFRC, ""+c);
                 Shape glyphShape = gv.getGlyphOutline(0);
                 GlyphMetrics gm = gv.getGlyphMetrics(0);
 

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/SVGGraphics2D.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/SVGGraphics2D.java?rev=291451&r1=291450&r2=291451&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/SVGGraphics2D.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/SVGGraphics2D.java Sun Sep 25 10:58:29 2005
@@ -15,6 +15,7 @@
    limitations under the License.
 
  */
+
 package org.apache.batik.svggen;
 
 import java.awt.BasicStroke;
@@ -26,9 +27,11 @@
 import java.awt.Graphics2D;
 import java.awt.GraphicsConfiguration;
 import java.awt.Image;
+import java.awt.Paint;
 import java.awt.Shape;
 import java.awt.Stroke;
 import java.awt.font.GlyphVector;
+import java.awt.font.TextAttribute;
 import java.awt.font.TextLayout;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.NoninvertibleTransformException;
@@ -42,10 +45,16 @@
 import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.text.AttributedCharacterIterator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
 
 import org.apache.batik.ext.awt.g2d.AbstractGraphics2D;
 import org.apache.batik.ext.awt.g2d.GraphicContext;
 import org.apache.batik.util.XMLConstants;
+import org.apache.batik.util.CSSConstants;
+import org.apache.batik.util.SVGConstants;
 import org.w3c.dom.Document;
 import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.Element;
@@ -81,7 +90,7 @@
  * @see                org.w3c.dom.Document
  */
 public class SVGGraphics2D extends AbstractGraphics2D
-    implements Cloneable, SVGSyntax, XMLConstants, ErrorConstants {
+    implements Cloneable, SVGSyntax, XMLConstants, ErrorConstants, CSSConstants {
     /*
      * Constants definitions
      */
@@ -161,7 +170,7 @@
     public final void setSVGCanvasSize(Dimension svgCanvasSize) {
         this.svgCanvasSize = new Dimension(svgCanvasSize);
     }
-
+    
     /**
      * @return the SVGGeneratorContext used by this SVGGraphics2D instance.
      */
@@ -418,29 +427,42 @@
     /**
      * @param writer used to writer out the SVG content
      * @param useCss defines whether the output SVG should use CSS
+     * @param escaped defines if the characters will be escaped
      * style properties as opposed to plain attributes.
      */
-    public void stream(Writer writer, boolean useCss)
+    public void stream(Writer writer, boolean useCss, boolean escaped)
         throws SVGGraphics2DIOException {
         Element svgRoot = getRoot();
-        stream(svgRoot, writer, useCss);
+        stream(svgRoot, writer, useCss, escaped);
     }
 
     /**
+     * @param writer used to writer out the SVG content
+     * @param useCss defines whether the output SVG should use CSS
+     * style properties as opposed to plain attributes.
+     */
+    public void stream(Writer writer, boolean useCss)
+        throws SVGGraphics2DIOException {
+        Element svgRoot = getRoot();
+        stream(svgRoot, writer, useCss, false);
+    }    
+    
+    /**
      * @param svgRoot root element to stream out
      */
     public void stream(Element svgRoot, Writer writer)
         throws SVGGraphics2DIOException {
-        stream(svgRoot, writer, false);
+        stream(svgRoot, writer, false, false);
     }
 
     /**
      * @param svgRoot root element to stream out
      * @param writer output
      * @param useCss defines whether the output SVG should use CSS style
+     * @param escaped defines if the characters will be escaped
      * properties as opposed to plain attributes.
      */
-    public void stream(Element svgRoot, Writer writer, boolean useCss)
+    public void stream(Element svgRoot, Writer writer, boolean useCss, boolean escaped)
         throws SVGGraphics2DIOException {
         Node rootParent = svgRoot.getParentNode();
         Node nextSibling = svgRoot.getNextSibling();
@@ -465,7 +487,7 @@
             if (useCss)
                 SVGCSSStyler.style(svgDocument);
 
-            XmlWriter.writeXml(svgDocument, writer);
+            XmlWriter.writeXml(svgDocument, writer, escaped);
             writer.flush();
         } catch (SVGGraphics2DIOException e) {
             // this catch prevents from catching an SVGGraphics2DIOException
@@ -589,7 +611,7 @@
         generatorCtx.errorHandler.
             handleError(new SVGGraphics2DRuntimeException(ERR_XOR));
     }
-
+    
     /**
      * Gets the font metrics for the specified font.
      * @return    the font metrics for the specified font.
@@ -1163,58 +1185,62 @@
      * @see #setClip
      */
     public void drawString(String s, float x, float y) {
-        if (!textAsShapes) {
-
-            if (generatorCtx.svgFont) {
-                // record that the font is being used to draw this string, this is
-                // so that the SVG Font element will only create glyphs for the
-                // characters that are needed
-                domTreeManager.gcConverter.getFontConverter().recordFontUsage(s, getFont());
-            }
-
-            Font font = getFont();
-
-            // Account for the font transform if there is one
-            AffineTransform txtTxf = null;
-            AffineTransform savTxf = getTransform();
-
-            if (font != null){
-                txtTxf = font.getTransform();
-                if (txtTxf != null && !txtTxf.isIdentity()){
-                    // 
-                    // The additional transform applies about the text's origin
-                    //
-                    AffineTransform t = new AffineTransform();
-                    t.translate(x, y);
-                    t.concatenate(txtTxf);
-                    t.translate(-x, -y);
-                    this.transform(t);
-                } else {
-                    txtTxf = null;
-                }
-            }
-
-            Element text =
-                getDOMFactory().createElementNS(SVG_NAMESPACE_URI, SVG_TEXT_TAG);
-            text.setAttributeNS(null, SVG_X_ATTRIBUTE,
-                                generatorCtx.doubleString(x));
-            text.setAttributeNS(null, SVG_Y_ATTRIBUTE,
-                                generatorCtx.doubleString(y));
-            text.setAttributeNS(XML_NAMESPACE_URI,
-                                XML_SPACE_ATTRIBUTE,
-                                XML_PRESERVE_VALUE);
-            text.appendChild(getDOMFactory().createTextNode(s));
-            domGroupManager.addElement(text, DOMGroupManager.FILL);
-
-            if (txtTxf != null){
-                this.setTransform(savTxf);
-            }
-                
-        } else {
+        if (textAsShapes)  {
             GlyphVector gv = getFont().
                 createGlyphVector(getFontRenderContext(), s);
             drawGlyphVector(gv, x, y);
+            return;
         }
+
+        if (generatorCtx.svgFont) {
+            // record that the font is being used to draw this
+            // string, this is so that the SVG Font element will
+            // only create glyphs for the characters that are
+            // needed
+            domTreeManager.gcConverter.
+                getFontConverter().recordFontUsage(s, getFont());
+        }
+
+        Font font = getFont();            
+        // Account for the font transform if there is one           
+        AffineTransform savTxf = getTransform();
+        AffineTransform txtTxf = transformText(x, y);            
+
+        Element text =
+            getDOMFactory().createElementNS(SVG_NAMESPACE_URI, SVG_TEXT_TAG);
+        text.setAttributeNS(null, SVG_X_ATTRIBUTE, generatorCtx.doubleString(x));
+        text.setAttributeNS(null, SVG_Y_ATTRIBUTE, generatorCtx.doubleString(y));
+            
+        text.setAttributeNS(XML_NAMESPACE_URI,
+                            XML_SPACE_ATTRIBUTE,
+                            XML_PRESERVE_VALUE);
+        text.appendChild(getDOMFactory().createTextNode(s));
+        domGroupManager.addElement(text, DOMGroupManager.FILL);
+            
+        if (txtTxf != null){
+            this.setTransform(savTxf);
+        }                            
+    }
+    
+    private AffineTransform transformText(float x, float y) {
+        AffineTransform txtTxf = null;       
+        Font font = getFont();
+        if (font != null){
+            txtTxf = font.getTransform();
+            if (txtTxf != null && !txtTxf.isIdentity()){
+                // 
+                // The additional transform applies about the text's origin
+                //
+                AffineTransform t = new AffineTransform();
+                t.translate(x, y);
+                t.concatenate(txtTxf);
+                t.translate(-x, -y);
+                this.transform(t);
+            } else {
+                txtTxf = null;
+            }
+        }
+        return txtTxf;
     }
 
     /**
@@ -1231,11 +1257,7 @@
      * the glyphs can be rendered from right to left, in which case the
      * coordinate supplied is the location of the leftmost character
      * on the baseline.<br />
-     * 
-     * <b>Note</b>: The current implementation turns a drawString call
-     * into shapes. Therefore, the generated SVG file will be sub-optimal
-     * in terms of size and will have lost semantic (i.e., text is no
-     * longer text but shapes), but it is graphically accurate.
+     *
      *
      * @param iterator the iterator whose text is to be rendered
      * @param x the x coordinate where the iterator's text is to be rendered
@@ -1246,13 +1268,113 @@
      * @see #setComposite
      * @see #setClip
      */
-    public void drawString(AttributedCharacterIterator iterator,
-                           float x, float y) {
-        TextLayout layout = new TextLayout(iterator, getFontRenderContext());
-        layout.draw(this, x, y);
-    }
+    public void drawString(AttributedCharacterIterator ati, float x, float y) {
+        if ((textAsShapes) || (usesUnsupportedAttributes(ati))) {
+            TextLayout layout = new TextLayout(ati, getFontRenderContext());
+            layout.draw(this, x, y);
+            return;
+        }
+        // first we want if there is more than one run in this
+        // ati. This will be used to decide if we create tspan
+        // Elements under the text Element or not
+        boolean multiSpans = false;
+        if (ati.getRunLimit() < ati.getEndIndex()) multiSpans = true;        
+        Font font = getFont();        
+        
+        // create the parent text Element
+        Element text = getDOMFactory().createElementNS(SVG_NAMESPACE_URI, 
+                                                       SVG_TEXT_TAG);
+        text.setAttributeNS(null, SVG_X_ATTRIBUTE, 
+                            generatorCtx.doubleString(x));
+        text.setAttributeNS(null, SVG_Y_ATTRIBUTE, 
+                            generatorCtx.doubleString(y));
+        
+        Font  baseFont  = getFont();
+        Paint basePaint = getPaint();
 
+        // now iterate through all the runs
+        char ch = ati.first();
 
+        setTextElementFill   (ati);
+        setTextFontAttributes(ati, baseFont);
+
+        SVGGraphicContext textGC;
+        textGC = domTreeManager.getGraphicContextConverter().toSVG(gc);
+        domGroupManager.addElement(text, DOMGroupManager.FILL);
+        textGC.getContext().put(SVG_STROKE_ATTRIBUTE, SVG_NONE_VALUE);
+        textGC.getGroupContext().put(SVG_STROKE_ATTRIBUTE, SVG_NONE_VALUE);
+
+        boolean firstSpan = true;
+        AffineTransform savTxf = getTransform();
+        AffineTransform txtTxf = null;        
+        while (ch != AttributedCharacterIterator.DONE) {
+            // first get the text Element or create a child Element if
+            // we used tspans
+            Element tspan = text;
+            if (multiSpans) {
+                tspan = getDOMFactory().createElementNS
+                    (SVG_NAMESPACE_URI, SVG_TSPAN_TAG);
+                text.appendChild(tspan);
+            }
+            
+            // decorate the tspan Element : 
+            setTextElementFill(ati);
+            boolean resetTransform = setTextFontAttributes(ati, baseFont);
+
+            // management of font attributes                       
+            if (resetTransform || firstSpan) {
+                // Account for the font transform if there is one
+                txtTxf = transformText(x, y);
+                firstSpan = false;
+            }            
+
+            // retrieve the current span of text for the run
+            StringBuffer buf = new StringBuffer();
+            buf.append(ch);
+            int start = ati.getIndex();
+            int end   = ati.getRunLimit()-1;
+            for (int i=start; i<end; i++) {
+                ch = ati.next();
+                buf.append(ch);
+            }
+
+            String s = buf.toString();
+            if (generatorCtx.isEmbeddedFontsOn()) {
+                // record that the font is being used to draw this
+                // string, this is so that the SVG Font element will
+                // only create glyphs for the characters that are
+                // needed
+                getDOMTreeManager().getGraphicContextConverter().
+                    getFontConverter().recordFontUsage(s, getFont());
+            }            
+
+            // This must come after registering font usage other
+            // wise it doesn't know what chars were used.
+            SVGGraphicContext elementGC;
+            elementGC = domTreeManager.gcConverter.toSVG(gc);
+            elementGC.getGroupContext().put(SVG_STROKE_ATTRIBUTE, 
+                                            SVG_NONE_VALUE);
+
+            SVGGraphicContext deltaGC;
+            deltaGC = DOMGroupManager.processDeltaGC(elementGC, textGC);
+
+            // management of underline, strike attributes, etc..
+            setTextElementAttributes(deltaGC, ati);
+            
+            domTreeManager.getStyleHandler().
+                setStyle(tspan, deltaGC.getContext(),
+                         domTreeManager.getGeneratorContext());
+
+            tspan.appendChild(getDOMFactory().createTextNode(s));
+            if ((resetTransform || firstSpan) && (txtTxf != null)) {
+                this.setTransform(savTxf);
+            }                                
+            ch = ati.next();  // get first char of next run.
+        }
+        setFont(baseFont);
+        setPaint(basePaint);
+    }
+    
     /**
      * Fills the interior of a <code>Shape</code> using the settings of the
      * <code>Graphics2D</code> context. The rendering attributes applied
@@ -1273,6 +1395,101 @@
             domGroupManager.addElement(svgShape, DOMGroupManager.FILL);
         }
     }
+    
+    /** Set the Element Font and Size attributes, depending on the 
+     * AttributedCharacterIterator attributes.
+     */
+    private boolean setTextFontAttributes(AttributedCharacterIterator ati,
+                                          Font baseFont) {
+        boolean resetTransform = false;
+        if ((ati.getAttribute(TextAttribute.FONT) != null) ||
+            (ati.getAttribute(TextAttribute.FAMILY) != null) ||
+            (ati.getAttribute(TextAttribute.WEIGHT) != null) ||
+            (ati.getAttribute(TextAttribute.POSTURE) != null) ||
+            (ati.getAttribute(TextAttribute.SIZE) != null)) {
+            Map m = ati.getAttributes();
+            Font f = baseFont.deriveFont(m);
+            setFont(f);
+            resetTransform = true;
+        }
+
+        return resetTransform;
+    }
+    
+    /** Set the Element attributes, depending on the AttributedCharacterIterator attributes.
+     *  The following attributes are set :
+     *  <ul>
+     *  <li>underline</li>
+     *  <li>weight (bold or plain)</li>
+     *  <li>style (italic or normal)</li>
+     *  <li>justification (start, end, or middle)</li>
+     *  </ul>
+     */
+    private void setTextElementFill(AttributedCharacterIterator ati) {
+        if (ati.getAttribute(TextAttribute.FOREGROUND) != null) {
+            Color color = (Color)ati.getAttribute(TextAttribute.FOREGROUND);
+            setPaint(color);
+        }
+    }
+
+    private void setTextElementAttributes(SVGGraphicContext tspanGC, 
+                                          AttributedCharacterIterator ati) {
+        String decoration = "";
+        if (isUnderline(ati))
+            decoration += CSS_UNDERLINE_VALUE + " ";
+        if (isStrikeThrough(ati))
+            decoration += CSS_LINE_THROUGH_VALUE + " ";
+        int len = decoration.length();
+        if (len != 0)
+            tspanGC.getContext().put(CSS_TEXT_DECORATION_PROPERTY, 
+                                     decoration.substring(0, len-1));
+    }
+   
+    /** Return true if the AttributedCharacterIterator is bold (at its current position).
+     */         
+    private boolean isBold(AttributedCharacterIterator ati) {
+        Object weight = ati.getAttribute(TextAttribute.WEIGHT);
+        if (weight == null) 
+            return false;
+        if (weight.equals(TextAttribute.WEIGHT_REGULAR))
+            return false;
+        if (weight.equals(TextAttribute.WEIGHT_DEMILIGHT))
+            return false;
+        if (weight.equals(TextAttribute.WEIGHT_EXTRA_LIGHT))
+            return false;
+        if (weight.equals(TextAttribute.WEIGHT_LIGHT))
+            return false;
+        return true;
+    }
+    
+    /** Return true if the AttributedCharacterIterator is italic (at
+     * its current position).
+     */ 
+    private boolean isItalic(AttributedCharacterIterator ati) {
+        Object attr = ati.getAttribute(TextAttribute.POSTURE);
+        if (TextAttribute.POSTURE_OBLIQUE.equals(attr)) return true;
+        return false;
+    }
+
+    /** Return true if the AttributedCharacterIterator is underlined
+     * (at its current position).
+     */     
+    private boolean isUnderline(AttributedCharacterIterator ati) {
+        Object attr = ati.getAttribute(TextAttribute.UNDERLINE);
+        if (TextAttribute.UNDERLINE_ON.equals(attr)) return true;
+        // What to do about UNDERLINE_LOW_*?  Right now we don't
+        // draw them since we can't really model them...
+        else return false;
+    }
+
+    /** Return true if the AttributedCharacterIterator is striked
+     * through (at its current position).
+     */         
+    private boolean isStrikeThrough(AttributedCharacterIterator ati) {
+        Object attr = ati.getAttribute(TextAttribute.STRIKETHROUGH);
+        if (TextAttribute.STRIKETHROUGH_ON.equals(attr)) return true;
+        return false;
+    }
 
     /**
      * Returns the device configuration associated with this
@@ -1281,6 +1498,54 @@
     public GraphicsConfiguration getDeviceConfiguration(){
         // TO BE DONE.
         return null;
+    }
+
+    /* This is the list of attributes that can't currently be
+     * supported by drawString(AttributedCharacterIterator).
+     * For accuracy if any of these are present then the
+     * text is drawn as outlines.
+     */
+    protected Set unsupportedAttributes;
+    {
+        unsupportedAttributes = new HashSet();
+        unsupportedAttributes.add(TextAttribute.BACKGROUND);
+        unsupportedAttributes.add(TextAttribute.BIDI_EMBEDDING);
+        unsupportedAttributes.add(TextAttribute.CHAR_REPLACEMENT);
+        unsupportedAttributes.add(TextAttribute.JUSTIFICATION);
+        unsupportedAttributes.add(TextAttribute.RUN_DIRECTION);
+        unsupportedAttributes.add(TextAttribute.SUPERSCRIPT);
+        unsupportedAttributes.add(TextAttribute.SWAP_COLORS);
+        unsupportedAttributes.add(TextAttribute.TRANSFORM);
+        unsupportedAttributes.add(TextAttribute.WIDTH);
+    }
+
+    /**
+     * This method let's users indicate that they don't care that
+     * certain text attributes will not be properly converted to
+     * SVG, in exchange when those attributes are used they will 
+     * get real SVG text instead of paths.
+     *
+     * @param attrs The set of attrs to treat as unsupported, and
+     *              if present cause text to be drawn as paths.
+     *              If null ACI text will be rendered as text
+     *              (unless 'textAsShapes' is set).
+     */
+    public void setUnsupportedAttributes(Set attrs) {
+        if (attrs == null) unsupportedAttributes = null;
+        else               unsupportedAttributes = new HashSet(attrs);
+    }
+
+    public boolean usesUnsupportedAttributes(AttributedCharacterIterator aci){
+        if (unsupportedAttributes == null) return false;
+
+        Set      allAttrs = aci.getAllAttributeKeys();
+        Iterator iter     = allAttrs.iterator();
+        while (iter.hasNext()) {
+            if (unsupportedAttributes.contains(iter.next())) {
+                return true;
+            }
+        }
+        return false;
     }
 
 }