]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
remove layout and makes all elements return an SVGElement
authorKeiron Liddle <keiron@apache.org>
Mon, 28 Aug 2000 23:54:26 +0000 (23:54 +0000)
committerKeiron Liddle <keiron@apache.org>
Mon, 28 Aug 2000 23:54:26 +0000 (23:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193674 13f79535-47bb-0310-9956-ffa450edef68

51 files changed:
src/org/apache/fop/svg/A.java
src/org/apache/fop/svg/AltGlyph.java
src/org/apache/fop/svg/Animate.java
src/org/apache/fop/svg/AnimateColor.java
src/org/apache/fop/svg/AnimateMotion.java
src/org/apache/fop/svg/AnimateTransform.java
src/org/apache/fop/svg/Circle.java
src/org/apache/fop/svg/ClipPath.java
src/org/apache/fop/svg/Cursor.java
src/org/apache/fop/svg/Defs.java
src/org/apache/fop/svg/Desc.java
src/org/apache/fop/svg/Ellipse.java
src/org/apache/fop/svg/Filter.java
src/org/apache/fop/svg/Font.java
src/org/apache/fop/svg/G.java
src/org/apache/fop/svg/Glyph.java
src/org/apache/fop/svg/GraphicsCreator.java
src/org/apache/fop/svg/HKern.java
src/org/apache/fop/svg/Image.java
src/org/apache/fop/svg/Line.java
src/org/apache/fop/svg/LinearGradient.java
src/org/apache/fop/svg/Marker.java
src/org/apache/fop/svg/Mask.java
src/org/apache/fop/svg/MissingGlyph.java
src/org/apache/fop/svg/Path.java
src/org/apache/fop/svg/Pattern.java
src/org/apache/fop/svg/Polygon.java
src/org/apache/fop/svg/Polyline.java
src/org/apache/fop/svg/RadialGradient.java
src/org/apache/fop/svg/Rect.java
src/org/apache/fop/svg/SVG.java
src/org/apache/fop/svg/SVGDriver.java [new file with mode: 0644]
src/org/apache/fop/svg/SVGElementMapping.java
src/org/apache/fop/svg/SVGLengthListProperty.java
src/org/apache/fop/svg/SVGObj.java [new file with mode: 0644]
src/org/apache/fop/svg/SVGPropertyListMapping.java
src/org/apache/fop/svg/SVGStyle.java
src/org/apache/fop/svg/SVGTransform.java
src/org/apache/fop/svg/Set.java
src/org/apache/fop/svg/Stop.java
src/org/apache/fop/svg/Style.java
src/org/apache/fop/svg/Switch.java
src/org/apache/fop/svg/Symbol.java
src/org/apache/fop/svg/TRef.java
src/org/apache/fop/svg/TSpan.java
src/org/apache/fop/svg/Text.java
src/org/apache/fop/svg/TextElement.java
src/org/apache/fop/svg/TextPath.java
src/org/apache/fop/svg/Title.java
src/org/apache/fop/svg/Use.java
src/org/apache/fop/svg/VKern.java

index 5dc0371a1008e850b6c97d85ba4bdd0e714e1eb3..8ab3ad01698e90d833fcaa324b4c7d97a58c6a2b 100644 (file)
@@ -59,11 +59,13 @@ import org.apache.fop.apps.FOPException;
 
 import org.apache.fop.dom.svg.*;
 
+import org.w3c.dom.svg.SVGElement;
+
 /**
  * class representing svg:a pseudo flow object.
  *
  */
-public class A extends FObj implements GraphicsCreator {
+public class A extends SVGObj {
 
        /**
         * inner class for making A objects.
@@ -104,7 +106,7 @@ public class A extends FObj implements GraphicsCreator {
                this.name = "svg:a";
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                String rf = this.properties.get("xlink:href").getString();
                SVGAElementImpl graphic;
@@ -115,7 +117,7 @@ public class A extends FObj implements GraphicsCreator {
                for (int i = 0; i < numChildren; i++) {
                        FONode child = (FONode) children.elementAt(i);
                        if(child instanceof GraphicsCreator) {
-                               GraphicImpl impl = ((GraphicsCreator)child).createGraphic();
+                               SVGElement impl = ((GraphicsCreator)child).createGraphic();
                                graphic.appendChild((GraphicElement)impl);
                        } else if(child instanceof Defs) {
                        }
@@ -123,26 +125,4 @@ public class A extends FObj implements GraphicsCreator {
 
                return graphic;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(createGraphic());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:a outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 08a34eefe1d57c59c983b5ee184824e4ffe5f0a4..86739386ec82ac854219526f462db8fa4016d890 100644 (file)
@@ -63,7 +63,7 @@ import org.apache.fop.dom.svg.*;
  * class representing svg:altGlyph pseudo flow object.
  *
  */
-public class AltGlyph extends FObj {
+public class AltGlyph extends SVGObj {
 
        /**
         * inner class for making AltGlyph objects.
@@ -103,26 +103,4 @@ public class AltGlyph extends FObj {
                super(parent, propertyList);
                this.name = "svg:altGlyph";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-//                     ((SVGArea) area).addGraphic(new AltGlyphGraphic(x1, y1, x2, y2));
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:altGlyph outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index d0e9ecbfa81e2b34096285b2cf085b827b353f7e..b1f79b7cafe64d92d7f5ef448f26ffdc905e2bfd 100644 (file)
@@ -63,7 +63,7 @@ import org.apache.fop.dom.svg.*;
  * class representing svg:Animate pseudo flow object.
  *
  */
-public class Animate extends FObj {
+public class Animate extends SVGObj {
 
        /**
         * inner class for making Animate objects.
@@ -103,26 +103,4 @@ public class Animate extends FObj {
                super(parent, propertyList);
                this.name = "svg:animate";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-//                     ((SVGArea) area).addGraphic(new AnimateGraphic(x1, y1, x2, y2));
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:animate outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 1e99f907c3d25ca8d7427d340044c27f242bd3a0..b25f201981feeaa86f72f978b7dcd8f91859a4cd 100644 (file)
@@ -63,7 +63,7 @@ import org.apache.fop.dom.svg.*;
  * class representing svg:AnimateColor pseudo flow object.
  *
  */
-public class AnimateColor extends FObj {
+public class AnimateColor extends SVGObj {
 
        /**
         * inner class for making AnimateColor objects.
@@ -103,26 +103,4 @@ public class AnimateColor extends FObj {
                super(parent, propertyList);
                this.name = "svg:animateColor";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a AnimateColor to the SVGArea */
-//                     ((SVGArea) area).addGraphic(new AnimateColorGraphic(x1, y1, x2, y2));
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:animateColor outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 865e59347ad4b7e685a80bf987b7808da5f99383..facb011d505db39e0ae72f841d5a27888e6fd59c 100644 (file)
@@ -63,7 +63,7 @@ import org.apache.fop.dom.svg.*;
  * class representing svg:AnimateMotion pseudo flow object.
  *
  */
-public class AnimateMotion extends FObj {
+public class AnimateMotion extends SVGObj {
 
        /**
         * inner class for making AnimateMotion objects.
@@ -103,26 +103,4 @@ public class AnimateMotion extends FObj {
                super(parent, propertyList);
                this.name = "svg:animateMotion";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a AnimateMotion to the SVGArea */
-//                     ((SVGArea) area).addGraphic(new AnimateMotionGraphic(x1, y1, x2, y2));
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:animateMotion outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 01a8f77f711008fc99c45f1462560cf1c09f60ec..a569c535a62f0c4af7a343ecb7653fe9c1c2d92a 100644 (file)
@@ -63,7 +63,7 @@ import org.apache.fop.dom.svg.*;
  * class representing svg:AnimateTransform pseudo flow object.
  *
  */
-public class AnimateTransform extends FObj {
+public class AnimateTransform extends SVGObj {
 
        /**
         * inner class for making AnimateTransform objects.
@@ -103,26 +103,4 @@ public class AnimateTransform extends FObj {
                super(parent, propertyList);
                this.name = "svg:animateTransform";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-//                     ((SVGArea) area).addGraphic(new AnimateTransformGraphic(x1, y1, x2, y2));
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:animateTransform outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 8e3690eb3dc4d1673a2fb5746d79021cc7112b32..678fd4ba7bfac69d244b53040ed96131157c0129 100644 (file)
@@ -63,11 +63,13 @@ import org.apache.fop.dom.svg.*;
 import org.apache.fop.dom.svg.SVGArea;
 
 import org.w3c.dom.svg.SVGLength;
+import org.w3c.dom.svg.SVGElement;
+
 /**
  * class representing svg:Circle pseudo flow object.
  *
  */
-public class Circle extends FObj implements GraphicsCreator {
+public class Circle extends SVGObj {
 
        /**
         * inner class for making Circle objects.
@@ -108,7 +110,7 @@ public class Circle extends FObj implements GraphicsCreator {
                this.name = "svg:circle";
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                /* retrieve properties */
                SVGLength cx = ((SVGLengthProperty)this.properties.get("cx")).getSVGLength();
@@ -119,30 +121,8 @@ public class Circle extends FObj implements GraphicsCreator {
                graph.setCy(new SVGAnimatedLengthImpl(cy));
                graph.setR(new SVGAnimatedLengthImpl(r));
                graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
-               graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+               graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
                graph.setId(this.properties.get("id").getString());
                return graph;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(createGraphic());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:circle outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 3eee2d75763c7a61c355d69e1ad071f26a439cd9..42a6f9e4a1df2b88fd27c609223380f46f582390 100644 (file)
@@ -59,11 +59,14 @@ import org.apache.fop.apps.FOPException;
 
 import org.apache.fop.dom.svg.*;
 import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
 /**
  * class representing svg:ClipPath pseudo flow object.
  *
  */
-public class ClipPath extends FObj implements GraphicsCreator {
+public class ClipPath extends SVGObj {
 
        /**
         * inner class for making ClipPath objects.
@@ -110,40 +113,18 @@ public class ClipPath extends FObj implements GraphicsCreator {
                super.addChild(child);
                if(child instanceof GraphicsCreator) {
                        GraphicsCreator gc = (GraphicsCreator)child;
-                       GraphicImpl graph = gc.createGraphic();
+                       SVGElement graph = gc.createGraphic();
                        clippath.addElement(graph);
-                       graph.setParent(clippath);
+//                     graph.setParent(clippath);
                } else {
                        // error
                }
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                clippath.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
                clippath.setId(this.properties.get("id").getString());
                return clippath;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(createGraphic());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:clipPath outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 220fcc012af16c00efd833565f91e2596d9aab33..1507ce04b436680eef3fe5ad98195956c5908f2f 100644 (file)
@@ -62,7 +62,7 @@ import org.apache.fop.dom.svg.SVGArea;
 /**
  *
  */
-public class Cursor extends FObj {
+public class Cursor extends SVGObj {
 
        /**
         * inner class for making Cursor objects.
@@ -102,27 +102,4 @@ public class Cursor extends FObj {
                super(parent, propertyList);
                this.name = "svg:cursor";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* retrieve properties */               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(new SVGCursorElementImpl());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:cursor outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 4b0100bc19a8a383d54ec6a201bdccaee79f4919..362bf8c9fcfa6f7f807e3321100e3c4569be0487 100644 (file)
@@ -59,7 +59,7 @@ import org.apache.fop.apps.FOPException;
 
 import java.util.*;
 
-import org.w3c.dom.svg.SVGElement;
+import org.w3c.dom.svg.*;
 
 import org.apache.fop.dom.svg.*;
 import org.apache.fop.dom.svg.SVGArea;
@@ -67,7 +67,7 @@ import org.apache.fop.dom.svg.SVGArea;
  * class representing svg:Defs pseudo flow object.
  *
  */
-public class Defs extends FObj {
+public class Defs extends SVGObj {
 
        /**
         * inner class for making Defs objects.
@@ -108,19 +108,21 @@ public class Defs extends FObj {
                this.name = "svg:defs";
        }
 
-       Hashtable defs = new Hashtable();
+//     Hashtable defs = new Hashtable();
 
-       public Hashtable createDefs()
+       public SVGElement createGraphic()
        {
+           SVGDefsElement defs = new SVGDefsElementImpl();
                int numChildren = this.children.size();
                for (int i = 0; i < numChildren; i++) {
                        FONode child = (FONode) children.elementAt(i);
                        if(child instanceof GraphicsCreator) {
-                               GraphicImpl gi = ((GraphicsCreator)child).createGraphic();
+                               SVGElement gi = ((GraphicsCreator)child).createGraphic();
                                if(gi instanceof SVGElement) {
+                                   defs.appendChild((SVGElement)gi);
                                        String id = ((SVGElement)gi).getId();
                                        if(!id.equals("")) {
-                                               defs.put(id, gi);
+//                                             defs.put(id, gi);
                                        } else {
                                                // no id
                                                System.err.println("WARNING No ID for defs element : " + gi);
@@ -130,26 +132,4 @@ public class Defs extends FObj {
                }
                return defs;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addDefs(createDefs());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:defs outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 7f82802822cbe741dc162cc8073d6eaec697f6aa..8bf382ccf2ef503aa7976b46f41e668d4c42b49d 100644 (file)
@@ -61,7 +61,7 @@ import org.apache.fop.apps.FOPException;
  * class representing svg:Desc pseudo flow object.
  *
  */
-public class Desc extends FObj {
+public class Desc extends SVGObj {
 
        /**
         * inner class for making Desc objects.
index 781871097fab9bdd141673293eb94fc0ef5cdbdb..d1c4e5e3b92b625be20f370fa865f4b1d4b20ca2 100644 (file)
@@ -61,11 +61,13 @@ import org.apache.fop.dom.svg.*;
 import org.apache.fop.dom.svg.SVGArea;
 
 import org.w3c.dom.svg.SVGLength;
+import org.w3c.dom.svg.SVGElement;
+
 /**
  * class representing svg:Ellipse pseudo flow object.
  *
  */
-public class Ellipse extends FObj implements GraphicsCreator {
+public class Ellipse extends SVGObj {
 
        /**
         * inner class for making Ellipse objects.
@@ -106,7 +108,7 @@ public class Ellipse extends FObj implements GraphicsCreator {
                this.name = "svg:ellipse";
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                /* retrieve properties */
                SVGLength cx = ((SVGLengthProperty)this.properties.get("cx")).getSVGLength();
@@ -119,31 +121,8 @@ public class Ellipse extends FObj implements GraphicsCreator {
                graph.setRx(new SVGAnimatedLengthImpl(rx));
                graph.setRy(new SVGAnimatedLengthImpl(ry));
                graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
-               graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+               graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
                graph.setId(this.properties.get("id").getString());
                return graph;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(createGraphic());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:ellipse outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 65dd0de0288528332d02561ebd2dc6359dc8667b..a2dc40f085fd479f34c4ebcc1f00150be69453e2 100644 (file)
@@ -63,7 +63,7 @@ import org.apache.fop.dom.svg.SVGArea;
  * class representing svg:Filter pseudo flow object.
  *
  */
-public class Filter extends FObj {
+public class Filter extends SVGObj {
 
        /**
         * inner class for making Filter objects.
@@ -103,27 +103,4 @@ public class Filter extends FObj {
                super(parent, propertyList);
                this.name = "svg:filter";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* retrieve properties */               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(new SVGFilterElementImpl());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:filter outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 072f10194fb26b9606ec29fd0d210937e103ac50..bffe590432a4c2d4a99e2c6c27cc928a523f47a4 100644 (file)
@@ -63,7 +63,7 @@ import org.apache.fop.dom.svg.SVGArea;
  * class representing svg:Font pseudo flow object.
  *
  */
-public class Font extends FObj {
+public class Font extends SVGObj {
 
        /**
         * inner class for making Font objects.
@@ -103,27 +103,4 @@ public class Font extends FObj {
                super(parent, propertyList);
                this.name = "svg:font";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* retrieve properties */               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(new SVGFontElementImpl());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:font outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 8adcdb32b4a107a2ba4db1316955b632ff84759f..f857a91f1640668faafa96f9920ee767d0ed691e 100644 (file)
@@ -59,11 +59,14 @@ import org.apache.fop.apps.FOPException;
 
 import org.apache.fop.dom.svg.*;
 import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
 /**
  * class representing svg:G pseudo flow object.
  *
  */
-public class G extends FObj implements GraphicsCreator {
+public class G extends SVGObj {
 
        /**
         * inner class for making G objects.
@@ -106,44 +109,23 @@ public class G extends FObj implements GraphicsCreator {
 
        SVGGElementImpl ggraphic = new SVGGElementImpl();
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
-               ggraphic.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+               ggraphic.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
                ggraphic.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
                ggraphic.setId(this.properties.get("id").getString());
                int numChildren = this.children.size();
                for (int i = 0; i < numChildren; i++) {
                        FONode child = (FONode) children.elementAt(i);
                        if(child instanceof GraphicsCreator) {
-                               GraphicImpl impl = ((GraphicsCreator)child).createGraphic();
-                               ggraphic.addGraphic(impl);
+                               SVGElement impl = ((GraphicsCreator)child).createGraphic();
+                               if(impl != null)
+                                       ggraphic.appendChild(impl);
                        } else if(child instanceof Defs) {
 //                             System.out.println(child);
-                               ggraphic.addDefs(((Defs)child).createDefs());
+//                             ggraphic.addDefs(((Defs)child).createDefs());
                        }
                }
                return ggraphic;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException
-       {               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a G to the SVGArea */
-                       ((SVGArea) area).addGraphic(createGraphic());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:g outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 29b90b2616cceb95522cbfff390e9dac35246f8f..8fb8b59a65d3aa4fec681acefffffaf56b26e789 100644 (file)
@@ -63,7 +63,7 @@ import org.apache.fop.dom.svg.SVGArea;
  * class representing svg:Glyph pseudo flow object.
  *
  */
-public class Glyph extends FObj {
+public class Glyph extends SVGObj {
 
        /**
         * inner class for making Glyph objects.
@@ -103,27 +103,4 @@ public class Glyph extends FObj {
                super(parent, propertyList);
                this.name = "svg:glyph";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* retrieve properties */               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(new SVGGlyphElementImpl());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:glyph outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 7ccc5dffb32f75fb8f2ccc225f3dcd3c32bc22e3..139bf7b8ae19708536ca5967d5a651b19ed2ee1a 100644 (file)
@@ -53,9 +53,11 @@ package org.apache.fop.svg;
 
 import org.apache.fop.dom.svg.*;
 
+import org.w3c.dom.svg.SVGElement;
+
 /**
  *
  */
 public interface GraphicsCreator {
-       public GraphicImpl createGraphic();
+       public SVGElement createGraphic();
 }
index a50db1d53d790151096b753da793db62260a8c23..7632c99309d2edd2de0a8917496c5876370db8a1 100644 (file)
@@ -62,7 +62,7 @@ import org.apache.fop.dom.svg.SVGArea;
 /**
  *
  */
-public class HKern extends FObj {
+public class HKern extends SVGObj {
 
        /**
         * inner class for making HKern objects.
@@ -102,27 +102,4 @@ public class HKern extends FObj {
                super(parent, propertyList);
                this.name = "svg:hkern";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* retrieve properties */               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(new SVGHKernElementImpl());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:hkern outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index cbf50f66eba55a8f147ce008db128cd844e815fd..1a02982e9a66038cf16985bea323b1231c36a918 100644 (file)
@@ -59,11 +59,14 @@ import org.apache.fop.apps.FOPException;
 
 import org.apache.fop.dom.svg.*;
 import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
 /**
  * class representing svg:Image pseudo flow object.
  *
  */
-public class Image extends FObj implements GraphicsCreator {
+public class Image extends SVGObj {
 
        /**
         * inner class for making Image objects.
@@ -104,7 +107,7 @@ public class Image extends FObj implements GraphicsCreator {
                this.name = "svg:image";
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                String link = this.properties.get("xlink:href").getString();
                float x = ((SVGLengthProperty)this.properties.get("x")).getSVGLength().getValue();
@@ -116,25 +119,4 @@ public class Image extends FObj implements GraphicsCreator {
                graph.setId(this.properties.get("id").getString());
                return graph;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a Image to the SVGArea */
-                       ((SVGArea) area).addGraphic(createGraphic());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:image outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 8118f66410aa7dbf8d7d6b57d1b4f623c6f55e08..7891f0e3b41c4b0c1bef33acde3ce2fa87947528 100644 (file)
@@ -61,13 +61,15 @@ import org.apache.fop.apps.FOPException;
 import org.w3c.dom.svg.SVGLength;
 
 import org.apache.fop.dom.svg.*;
-//import org.apache.fop.dom.svg.Graphic;
 import org.apache.fop.dom.svg.SVGLineElementImpl;
 import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
 /**
  * class representing svg:line pseudo flow object.
  */
-public class Line extends FObj implements GraphicsCreator {
+public class Line extends SVGObj {
 
        /**
         * inner class for making Line objects.
@@ -108,7 +110,7 @@ public class Line extends FObj implements GraphicsCreator {
                this.name = "svg:line";
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                /* retrieve properties */
                SVGLength x1 = ((SVGLengthProperty)this.properties.get("x1")).getSVGLength();
@@ -121,30 +123,8 @@ public class Line extends FObj implements GraphicsCreator {
                graph.setX2(new SVGAnimatedLengthImpl(x2));
                graph.setY2(new SVGAnimatedLengthImpl(y2));
                graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
-               graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+               graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
                graph.setId(this.properties.get("id").getString());
                return graph;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(createGraphic());
-               } else {
-                       /* otherwise generate a warning */
-           MessageHandler.errorln("WARNING: svg:line outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 28bf256f5f516ab98d88f7bab31d1f82e4dede71..b175a81e34eda6c9078ae83f38602ef6ee9d2778 100644 (file)
@@ -66,7 +66,7 @@ import org.w3c.dom.svg.*;
  * class representing svg:LinearGradient pseudo flow object.
  *
  */
-public class LinearGradient extends FObj implements GraphicsCreator {
+public class LinearGradient extends SVGObj {
 
        /**
         * inner class for making LinearGradient objects.
@@ -117,10 +117,10 @@ public class LinearGradient extends FObj implements GraphicsCreator {
                }
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                linear.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
-               linear.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+               linear.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
                linear.setId(this.properties.get("id").getString());
 
                linear.setX1(new SVGAnimatedLengthImpl(((SVGLengthProperty)this.properties.get("x1")).getSVGLength()));
index 34c840485cb1def5505be9449d2b7a7580a50846..7fd2887d60c0a14b95cfe0d451213374f2b43579 100644 (file)
@@ -63,7 +63,7 @@ import org.apache.fop.dom.svg.SVGArea;
  * class representing svg:Marker pseudo flow object.
  *
  */
-public class Marker extends FObj {
+public class Marker extends SVGObj {
 
        /**
         * inner class for making Marker objects.
@@ -103,27 +103,4 @@ public class Marker extends FObj {
                super(parent, propertyList);
                this.name = "svg:marker";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* retrieve properties */               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(new SVGMarkerElementImpl());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:marker outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 4e613a21605c44da8b3a08bc5dffd87bae587742..451de833aa9bf2fee77dc4bcb23be7664402617e 100644 (file)
@@ -58,11 +58,14 @@ import org.apache.fop.layout.FontState;
 import org.apache.fop.apps.FOPException;
 
 import org.apache.fop.dom.svg.*;
+
+import org.w3c.dom.svg.SVGElement;
+
 /**
  * class representing svg:Mask pseudo flow object.
  *
  */
-public class Mask extends FObj {
+public class Mask extends SVGObj {
 
        /**
         * inner class for making Mask objects.
@@ -109,38 +112,20 @@ public class Mask extends FObj {
                super.addChild(child);
                if(child instanceof GraphicsCreator) {
                        GraphicsCreator gc = (GraphicsCreator)child;
-                       GraphicImpl graph = gc.createGraphic();
-                       mask.addElement(graph);
-                       graph.setParent(mask);
+                       SVGElement graph = gc.createGraphic();
+                       if(graph != null) {
+                       mask.addElement(graph);
+//                     graph.setParent(mask);
+                   }
                } else {
                        // error
                }
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                mask.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
                mask.setId(this.properties.get("id").getString());
                return mask;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:mask outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index fc3193f8e3610248e1bbcd576a204301285ec663..5065e2b163fb4bd2279866f40da686d40b5a4844 100644 (file)
@@ -62,7 +62,7 @@ import org.apache.fop.dom.svg.SVGArea;
 /**
  *
  */
-public class MissingGlyph extends FObj {
+public class MissingGlyph extends SVGObj {
 
        /**
         * inner class for making MissingGlyph objects.
@@ -102,28 +102,4 @@ public class MissingGlyph extends FObj {
                super(parent, propertyList);
                this.name = "svg:missing-glyph";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* retrieve properties */
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(new SVGMissingGlyphElementImpl());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:missing-glyph outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 1091117b34339f8e854d06e87f5443c5bad29945..64a5b0a8cb97d4edce9d1b753cea460ab96aed86 100644 (file)
@@ -61,11 +61,14 @@ import java.util.*;
 
 import org.apache.fop.dom.svg.*;
 import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
 /**
  * class representing svg:Path pseudo flow object.
  *
  */
-public class Path extends FObj implements GraphicsCreator {
+public class Path extends SVGObj {
 
        /**
         * inner class for making Path objects.
@@ -106,35 +109,13 @@ public class Path extends FObj implements GraphicsCreator {
                this.name = "svg:path";
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                Vector pd = ((SVGD)this.properties.get("d")).getPath();
                SVGPathElementImpl graph = new SVGPathElementImpl(pd);
                graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
-               graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+               graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
                graph.setId(this.properties.get("id").getString());
                return graph;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a Path to the SVGArea */
-                       ((SVGArea) area).addGraphic(createGraphic());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:path outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index e76c3ad0b02b1610e6fbff0e6f3fd66320a60879..73ae9ae4d341cc093b277d7fb518e1dd89dd0ff4 100644 (file)
@@ -63,7 +63,7 @@ import org.apache.fop.dom.svg.SVGArea;
  * class representing svg:Pattern pseudo flow object.
  *
  */
-public class Pattern extends FObj {
+public class Pattern extends SVGObj {
 
        /**
         * inner class for making Pattern objects.
@@ -103,28 +103,4 @@ public class Pattern extends FObj {
                super(parent, propertyList);
                this.name = "svg:pattern";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* retrieve properties */
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a Pattern to the SVGArea */
-                       ((SVGArea) area).addGraphic(new SVGPatternElementImpl());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:pattern outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 8b9725b07ac18e767d7b1dbfc152f401c4ad39df..bd53fe4de56a366ac89fc5fe51af810ac9f25434 100644 (file)
@@ -61,10 +61,13 @@ import java.util.*;
 
 import org.apache.fop.dom.svg.*;
 import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
 /**
  *
  */
-public class Polygon extends FObj implements GraphicsCreator {
+public class Polygon extends SVGObj {
 
        /**
         * inner class for making Polygon objects.
@@ -105,36 +108,13 @@ public class Polygon extends FObj implements GraphicsCreator {
                this.name = "svg:polygon";
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                Vector points = ((SVGPoints)this.properties.get("points")).getPoints();
                SVGPolygonElementImpl graph =  new SVGPolygonElementImpl(points);
                graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
-               graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+               graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
                graph.setId(this.properties.get("id").getString());
                return graph;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(createGraphic());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:polygon outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index b0846b87c9e23d49798cb83e23fd8476671f2a31..05187eef1d10c7376f64d5c72a37a2d69ef51dee 100644 (file)
@@ -61,11 +61,14 @@ import java.util.*;
 
 import org.apache.fop.dom.svg.*;
 import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
 /**
  * class representing svg:Polyline pseudo flow object.
  *
  */
-public class Polyline extends FObj implements GraphicsCreator {
+public class Polyline extends SVGObj {
 
        /**
         * inner class for making Polyline objects.
@@ -106,35 +109,13 @@ public class Polyline extends FObj implements GraphicsCreator {
                this.name = "svg:polyline";
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                Vector points = ((SVGPoints)this.properties.get("points")).getPoints();
                SVGPolylineElementImpl graph =  new SVGPolylineElementImpl(points);
                graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
-               graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+               graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
                graph.setId(this.properties.get("id").getString());
                return graph;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a Polyline to the SVGArea */
-                       ((SVGArea) area).addGraphic(createGraphic());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:polyline outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index c53526086ff0de3eea1a0833e7a22fdcd29045db..ec941801da3ed33f8e34c7382d2fe1247f1417ab 100644 (file)
@@ -66,7 +66,7 @@ import org.w3c.dom.svg.*;
  * class representing svg:RadialGradient pseudo flow object.
  *
  */
-public class RadialGradient extends FObj implements GraphicsCreator {
+public class RadialGradient extends SVGObj {
 
        /**
         * inner class for making RadialGradient objects.
@@ -117,10 +117,10 @@ public class RadialGradient extends FObj implements GraphicsCreator {
                }
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                radial.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
-               radial.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+               radial.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
                radial.setId(this.properties.get("id").getString());
 
                radial.setCx(new SVGAnimatedLengthImpl(((SVGLengthProperty)this.properties.get("cx")).getSVGLength()));
@@ -130,28 +130,4 @@ public class RadialGradient extends FObj implements GraphicsCreator {
                radial.setFy(new SVGAnimatedLengthImpl(((SVGLengthProperty)this.properties.get("fy")).getSVGLength()));
                return radial;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* retrieve properties */
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a RadialGradient to the SVGArea */
-                       ((SVGArea) area).addGraphic(radial);
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:radialGradient outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index ba2d09bcf86cd7eb58e4264f7f757f40da670acc..19579470b80856e5840253301f95e089daf94dc7 100644 (file)
@@ -65,11 +65,12 @@ import org.apache.fop.dom.svg.SVGRectElementImpl;
 import org.apache.fop.dom.svg.SVGArea;
 
 import org.w3c.dom.svg.SVGLength;
+import org.w3c.dom.svg.SVGElement;
 
 /**
  * class representing svg:rect pseudo flow object.
  */
-public class Rect extends FObj implements GraphicsCreator {
+public class Rect extends SVGObj {
 
        /**
         * inner class for making Rect objects.
@@ -110,7 +111,7 @@ public class Rect extends FObj implements GraphicsCreator {
        this.name = "svg:rect";
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                /* retrieve properties */
                SVGLength width = ((SVGLengthProperty)this.properties.get("width")).getSVGLength();
@@ -127,30 +128,8 @@ public class Rect extends FObj implements GraphicsCreator {
                graph.setWidth(new SVGAnimatedLengthImpl(width));
                graph.setHeight(new SVGAnimatedLengthImpl(height));
                graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
-               graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+               graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
                graph.setId(this.properties.get("id").getString());
                return graph;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-       
-       /* if the area this is being put into is an SVGArea */
-       if (area instanceof SVGArea) {
-               /* add a rectangle to the SVGArea */
-               ((SVGArea) area).addGraphic(createGraphic());
-       } else {
-               /* otherwise generate a warning */
-           MessageHandler.errorln("WARNING: svg:rect outside svg:svg");
-       }
-
-       /* return status */
-       return new Status(Status.OK);
-       }
 }
index 660af264705afa7eb3814adbfc79856e654134a1..6ddd4d2d3acb5062af535c2c65eead690a280499 100644 (file)
@@ -60,6 +60,7 @@ import org.apache.fop.layout.FontState;
 import org.apache.fop.apps.FOPException;
 
 import org.apache.fop.dom.svg.*;
+import org.w3c.dom.svg.*;
 
 import org.apache.fop.dom.svg.SVGArea;
 /**
@@ -110,45 +111,32 @@ public class SVG extends FObj implements GraphicsCreator {
        this.name = "svg:svg";
        }
 
-/*     protected void addChild(FONode child) {
-               super.addChild(child);
-               if(svgArea != null) {
-                       Status status;
-                       try {
-                               if ((status = child.layout(svgArea)).isIncomplete()) {
-                               }
-                       } catch(FOPException fope) {
-                               fope.printStackTrace();
-                       }
-               }
-       }*/
-
-       SVGArea svgArea = null;
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
-               this.width = ((SVGLengthProperty)this.properties.get("width")).getSVGLength().getValue();
-               this.height = ((SVGLengthProperty)this.properties.get("height")).getSVGLength().getValue();
-               svgArea = new SVGArea(null, width, height);
+               SVGSVGElementImpl svgArea = null;
+               SVGLength w = ((SVGLengthProperty)this.properties.get("width")).getSVGLength();
+               SVGLength h = ((SVGLengthProperty)this.properties.get("height")).getSVGLength();
+               svgArea = new SVGSVGElementImpl();
+               SVGAnimatedLength sal;
+               sal = new SVGAnimatedLengthImpl(w);
+               sal.setBaseVal(w);
+               svgArea.setWidth(sal);
+               sal = new SVGAnimatedLengthImpl(h);
+               sal.setBaseVal(h);
+               svgArea.setHeight(sal);
                svgArea.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
-               svgArea.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
-//             svgArea.setId(this.properties.get("id").getString());
+               svgArea.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
+               svgArea.setId(this.properties.get("id").getString());
                int numChildren = this.children.size();
                for (int i = 0; i < numChildren; i++) {
                        FONode fo = (FONode) children.elementAt(i);
                        if(fo instanceof GraphicsCreator) {
-                               GraphicImpl impl = ((GraphicsCreator)fo).createGraphic();
-                               svgArea.addGraphic(impl);
-                       } else if(fo instanceof Defs) {
-                               svgArea.addDefs(((Defs)fo).createDefs());
+                               SVGElement impl = ((GraphicsCreator)fo).createGraphic();
+                               svgArea.appendChild((org.w3c.dom.Node)impl);
+//                     } else if(fo instanceof Defs) {
+//                             svgArea.addDefs(((Defs)fo).createDefs());
                        }
                        Status status;
-/*                     try {
-                               if ((status = fo.layout(svgArea)).isIncomplete()) {
-//                             return null;
-                               }
-                       } catch(FOPException fope) {
-                               fope.printStackTrace();
-                       }*/
                }
                return svgArea;
        }
@@ -162,11 +150,6 @@ public class SVG extends FObj implements GraphicsCreator {
         */
        public Status layout(Area area) throws FOPException {
        
-       if (area instanceof SVGArea) {
-               ((SVGArea) area).addGraphic(createGraphic());
-               return new Status(Status.OK);
-       }
-
        if (!(area instanceof ForeignObjectArea)) {
            // this is an error
            throw new FOPException("SVG not in fo:instream-foreign-object");
@@ -196,8 +179,8 @@ public class SVG extends FObj implements GraphicsCreator {
        /* create an SVG area */
        /* if width and height are zero, may want to get the bounds of the content. */
        SVGArea svg = new SVGArea(fs, width, height);
-       svg.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
-       svg.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+       SVGDocument doc = new SVGDocumentImpl();
+       svg.setSVGDocument(doc);
        svg.start();
 
        /* add the SVG area to the containing area */
@@ -206,16 +189,7 @@ public class SVG extends FObj implements GraphicsCreator {
        foa.setIntrinsicWidth(svg.getWidth());
        foa.setIntrinsicHeight(svg.getHeight());
 
-       /* iterate over the child formatting objects and lay them out
-          into the SVG area */
-       int numChildren = this.children.size();
-       for (int i = 0; i < numChildren; i++) {
-               FONode fo = (FONode) children.elementAt(i);
-               Status status;
-               if ((status = fo.layout(svg)).isIncomplete()) {
-               return status;
-               }
-       }
+       doc.appendChild((SVGSVGElement)createGraphic());
 
        /* finish off the SVG area */
        svg.end();
diff --git a/src/org/apache/fop/svg/SVGDriver.java b/src/org/apache/fop/svg/SVGDriver.java
new file mode 100644 (file)
index 0000000..caa5664
--- /dev/null
@@ -0,0 +1,336 @@
+/*-- $Id$ -- 
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+ 4. The names "FOP" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache 
+ Software Foundation, please see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.svg;
+
+// FOP
+import org.apache.fop.fo.*;
+import org.apache.fop.apps.*;
+import org.apache.fop.dom.svg.*;
+import org.apache.fop.fo.FOTreeBuilder;
+import org.apache.fop.fo.ElementMapping;
+import org.apache.fop.fo.PropertyListMapping;
+import org.apache.fop.layout.AreaTree;
+import org.apache.fop.layout.FontInfo;
+import org.apache.fop.render.Renderer;
+import org.apache.fop.messaging.MessageHandler;
+
+// DOM
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Attr;
+
+// SAX
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+import org.w3c.dom.svg.*;
+
+// Java
+import java.io.PrintWriter;
+import java.io.IOException;
+
+/**
+ * <P>Primary class that drives overall FOP process.
+ *
+ * <P>Once this class is instantiated, methods are called to set the
+ * Renderer to use, the (possibly multiple) ElementMapping(s) to
+ * use and the PrintWriter to use to output the results of the
+ * rendering (where applicable). In the case of the Renderer and
+ * ElementMapping(s), the Driver may be supplied either with the
+ * object itself, or the name of the class, in which case Driver will
+ * instantiate the class itself. The advantage of the latter is it
+ * enables runtime determination of Renderer and ElementMapping(s).
+ *
+ * <P>Once the Driver is set up, the buildFOTree method
+ * is called. Depending on whether DOM or SAX is being used, the
+ * invocation of the method is either buildFOTree(Document) or
+ * buildFOTree(Parser, InputSource) respectively.
+ *
+ * <P>A third possibility may be used to build the FO Tree, namely
+ * calling getDocumentHandler() and firing the SAX events yourself.
+ *
+ * <P>Once the FO Tree is built, the format() and render() methods may be
+ * called in that order.
+ *
+ * <P>Here is an example use of Driver from CommandLine.java:
+ *
+ * <PRE>
+ *   Driver driver = new Driver();
+ *   driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer", version);
+ *   driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
+ *   driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
+ *   driver.setWriter(new PrintWriter(new FileWriter(args[1])));
+ *   driver.buildFOTree(parser, fileInputSource(args[0]));
+ *   driver.format();
+ *   driver.render();
+ * </PRE>
+ */
+public class SVGDriver {
+
+    /** the FO tree builder */
+    protected SVGTreeBuilder treeBuilder;
+
+    /** the PrintWriter to use to output the results of the renderer */
+    protected PrintWriter writer;
+
+    /** create a new Driver */
+    public SVGDriver() {
+       this.treeBuilder = new SVGTreeBuilder();
+    }
+   
+    /**
+     * add the given element mapping.
+     *
+     * an element mapping maps element names to Java classes
+     */
+    public void addElementMapping(ElementMapping mapping) {
+       mapping.addToBuilder(this.treeBuilder);
+    }
+    
+    /**
+     * add the element mapping with the given class name
+     */
+    public void addElementMapping(String mappingClassName) {
+       createElementMapping(mappingClassName).addToBuilder(this.treeBuilder);
+    }
+
+    /**
+     * protected method used by addElementMapping(String) to
+     * instantiate element mapping class
+     */
+    protected ElementMapping createElementMapping(String mappingClassName) {
+    MessageHandler.logln("using element mapping " + mappingClassName);
+
+       try {
+           return (ElementMapping)
+               Class.forName(mappingClassName).newInstance();
+       } catch (ClassNotFoundException e) {
+           MessageHandler.errorln("Could not find " + mappingClassName);
+       } catch (InstantiationException e) {
+           MessageHandler.errorln("Could not instantiate "
+                              + mappingClassName);
+       } catch (IllegalAccessException e) {
+           MessageHandler.errorln("Could not access " + mappingClassName);
+       } catch (ClassCastException e) {
+           MessageHandler.errorln(mappingClassName + " is not an element mapping"); 
+       }
+       return null;
+    }
+
+    /**
+     * add the element mapping with the given class name
+     */
+    public void addPropertyList(String listClassName) {
+       createPropertyList(listClassName).addToBuilder(this.treeBuilder);
+    }
+
+    /**
+     * protected method used by addPropertyList(String) to
+     * instantiate list mapping class
+     */
+    protected PropertyListMapping createPropertyList(String listClassName) {
+    MessageHandler.logln("using property list mapping " + listClassName);
+
+       try {
+           return (PropertyListMapping)
+               Class.forName(listClassName).newInstance();
+       } catch (ClassNotFoundException e) {
+           MessageHandler.errorln("Could not find " + listClassName);
+       } catch (InstantiationException e) {
+           MessageHandler.errorln("Could not instantiate "
+                              + listClassName);
+       } catch (IllegalAccessException e) {
+           MessageHandler.errorln("Could not access " + listClassName);
+       } catch (ClassCastException e) {
+           MessageHandler.errorln(listClassName + " is not an property list"); 
+       }
+       return null;
+    }
+
+    /**
+     * return the tree builder (a SAX DocumentHandler).
+     *
+     * used in situations where SAX is used but not via a FOP-invoked
+     * SAX parser. A good example is an XSLT engine that fires SAX
+     * events but isn't a SAX Parser itself.
+     */
+    public ContentHandler getContentHandler() {
+       return this.treeBuilder;
+    }
+
+    /**
+     * build the formatting object tree using the given SAX Parser and
+     * SAX InputSource
+     */
+    public void buildSVGTree(XMLReader parser, InputSource source)
+               throws FOPException {
+
+       parser.setContentHandler(this.treeBuilder);
+       try {
+           parser.parse(source);
+       } catch (SAXException e) {
+e.printStackTrace();
+           if (e.getException() instanceof FOPException)
+               throw (FOPException) e.getException();
+           else
+               throw new FOPException(e.getMessage());
+       } catch (IOException e) {
+           throw new FOPException(e.getMessage());
+       }
+    }
+
+    /**
+     * build the formatting object tree using the given DOM Document
+     */
+    public void buildSVGTree(Document document) 
+       throws FOPException {
+
+       /* most of this code is modified from John Cowan's */
+
+       Node currentNode;
+       AttributesImpl currentAtts;
+       
+       /* temporary array for making Strings into character arrays */
+       char[] array = null;
+
+       currentAtts = new AttributesImpl();
+       
+       /* start at the document element */
+       currentNode = document;
+
+       try {
+           while (currentNode != null) {
+               switch (currentNode.getNodeType()) {
+               case Node.DOCUMENT_NODE:
+                   this.treeBuilder.startDocument();
+                   break;
+               case Node.CDATA_SECTION_NODE:
+               case Node.TEXT_NODE:
+                   String data = currentNode.getNodeValue();
+                   int datalen = data.length();
+                   if (array == null || array.length < datalen) {
+                       /* if the array isn't big enough, make a new
+                          one */
+                       array = new char[datalen];
+                   }
+                   data.getChars(0, datalen, array, 0);
+                   this.treeBuilder.characters(array, 0, datalen);
+                   break;
+               case Node.PROCESSING_INSTRUCTION_NODE:
+                   this.treeBuilder.processingInstruction(
+                       currentNode.getNodeName(),
+                       currentNode.getNodeValue());
+                   break;
+               case Node.ELEMENT_NODE:
+                   NamedNodeMap map = currentNode.getAttributes();
+                   currentAtts.clear();
+                   for (int i = map.getLength() - 1; i >= 0; i--) {
+                       Attr att = (Attr)map.item(i);
+                       currentAtts.addAttribute("",
+                         att.getName(),
+                         "",
+                         "CDATA",
+                         att.getValue());
+                   }
+                   this.treeBuilder.startElement(
+                       "", currentNode.getNodeName(), "", currentAtts);
+                   break;
+               }
+               
+               Node nextNode = currentNode.getFirstChild();
+               if (nextNode != null) {
+                   currentNode = nextNode;
+                   continue;
+               }
+               
+               while (currentNode != null) {
+                   switch (currentNode.getNodeType()) {
+                   case Node.DOCUMENT_NODE:
+                       this.treeBuilder.endDocument();
+                       break;
+                   case Node.ELEMENT_NODE:
+                       this.treeBuilder.endElement(
+                           "", currentNode.getNodeName(), "" );
+                       break;
+                   }
+                   
+                   nextNode = currentNode.getNextSibling();
+                   if (nextNode != null) {
+                       currentNode = nextNode;
+                       break;
+                   }
+                   
+                   currentNode = currentNode.getParentNode();
+               }
+           }
+       } catch (SAXException e) {
+           throw new FOPException(e.getMessage());
+       }
+    }
+
+    public SVGDocument getSVGDocument()
+    {
+        return this.treeBuilder.getSVGDocument();
+    }
+
+    /**
+     * format the formatting object tree into an area tree
+     */
+    public void format()
+       throws FOPException {
+       FontInfo fontInfo = new FontInfo();
+    }
+}
index a045a3fec110e1835a8ddfe01d4baeae016b4891..43e5ce005e2cffef7e9c28cb9f9c0b3ef4d212e6 100644 (file)
  */
 package org.apache.fop.svg;
 
+import org.apache.fop.fo.TreeBuilder;
 import org.apache.fop.fo.FOTreeBuilder;
 import org.apache.fop.fo.ElementMapping;
+import org.apache.fop.dom.svg.SVGDocumentImpl;
 
 public class SVGElementMapping implements ElementMapping {
 
-       public void addToBuilder(FOTreeBuilder builder) {
-               String uri = "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd";
+       public void addToBuilder(TreeBuilder builder) {
+               String uri = SVGDocumentImpl.namespaceURI;
                builder.addMapping(uri, "svg", SVG.maker());
                builder.addMapping(uri, "rect", Rect.maker());
                builder.addMapping(uri, "line", Line.maker());
index da2dfed5a8ccd204324db41683f723d0b658016d..7ebe0bd4470a5a71cc57a7c816337005d36658ec 100644 (file)
@@ -94,7 +94,7 @@ public class SVGLengthListProperty extends Property {
         * @param propertyList the property list the property is a member of
         */
        public Property make(PropertyList propertyList) throws FOPException {
-               return make(propertyList, "0pt");
+               return make(propertyList, "");
        }
        }
 
diff --git a/src/org/apache/fop/svg/SVGObj.java b/src/org/apache/fop/svg/SVGObj.java
new file mode 100644 (file)
index 0000000..c41b58c
--- /dev/null
@@ -0,0 +1,102 @@
+/*-- $Id$ -- 
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+ 4. The names "FOP" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache 
+ Software Foundation, please see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.svg;
+
+// FOP
+import org.apache.fop.fo.*;
+import org.apache.fop.layout.Area;
+import org.apache.fop.layout.FontState;
+import org.apache.fop.apps.FOPException;
+
+import org.apache.fop.dom.svg.*;
+
+import org.w3c.dom.svg.SVGElement;
+
+/**
+ * Since SVG objects are not layed out then this class checks
+ * that this element is not being layed out inside some incorrect
+ * element.
+ */
+public abstract class SVGObj extends FObj implements GraphicsCreator {
+
+       /**
+        *
+        * @param parent the parent formatting object
+        * @param propertyList the explicit properties of this object
+        */
+       public SVGObj(FObj parent, PropertyList propertyList) {
+               super(parent, propertyList);
+       }
+
+       public SVGElement createGraphic()
+       {
+               return null;
+       }
+
+       /**
+        * layout this formatting object.
+        *
+        * @param area the area to layout the object into
+        * @return the status of the layout
+        */
+       public Status layout(Area area) throws FOPException
+       {
+               if (area instanceof SVGArea) {
+               } else {
+                       /* otherwise generate a warning */
+                       System.err.println("WARNING: " + this.name + " outside svg:svg");
+               }
+
+               /* return status */
+               return new Status(Status.OK);
+       }
+}
index 78a096a1f9cfd0e582cc4493f43006829dfc6e4a..10d838410a5e4b267bcdd30f70fc7dbd2d051392 100644 (file)
@@ -53,14 +53,15 @@ package org.apache.fop.svg;
 
 import org.apache.fop.fo.*;
 import org.apache.fop.fo.properties.*;
+import org.apache.fop.dom.svg.SVGDocumentImpl;
 
 import java.util.Hashtable;
 
 public class SVGPropertyListMapping implements PropertyListMapping {
 
-    public void addToBuilder(FOTreeBuilder builder) {
+    public void addToBuilder(TreeBuilder builder) {
 
-       String uri = "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd";
+       String uri = SVGDocumentImpl.namespaceURI;
        Hashtable propertyTable = new Hashtable();
                propertyTable.put("height",SVGLengthProperty.maker());
                propertyTable.put("width",SVGLengthProperty.maker());
@@ -93,6 +94,7 @@ public class SVGPropertyListMapping implements PropertyListMapping {
                propertyTable.put("d",SVGD.maker());
                propertyTable.put("points",SVGPoints.maker());
 //             propertyTable.put("viewBox",SVGBox.maker());
+               propertyTable.put("xml:space",XMLSpace.maker());
 
        propertyTable.put("font-family",FontFamily.maker());
        propertyTable.put("font-style",FontStyle.maker());
index cad70c499e4c65090d5b06cd968dee6520b839c0..8bd7da0bedc0a944e003713317912f6a2344048e 100644 (file)
@@ -57,6 +57,8 @@ import org.apache.fop.apps.FOPException;
 
 import java.util.*;
 
+import org.w3c.dom.css.CSSStyleDeclaration;
+
 /**
  *
  */
@@ -122,7 +124,7 @@ public class SVGStyle extends Property {
         *
         * @return the length as a Length object
         */
-       public Hashtable getStyle()
+       public CSSStyleDeclaration getStyle()
        {
                return this.style.getStyle();
        }
index 36e2bb134fef5777f3fdcff59fda9d96fbbf673c..3c90f82d3d10357b64203bab1d40f8e94d90edf4 100644 (file)
@@ -55,6 +55,8 @@ import org.apache.fop.fo.*;
 import org.apache.fop.datatypes.*;
 import org.apache.fop.apps.FOPException;
 
+import org.w3c.dom.svg.SVGAnimatedTransformList;
+
 import java.util.*;
 
 /**
@@ -120,7 +122,7 @@ public class SVGTransform extends Property {
         *
         * @return the length as a Length object
         */
-       public Vector oldgetTransform() {
-               return this.trans.oldgetTransform();
+       public SVGAnimatedTransformList getTransform() {
+               return this.trans.getTransform();
        }
 }
index 39ecc4c95b182c7f6523bd393961e2a0ac189b7b..d35dd254f1bfb0dd13815d1ad5241158e55d82be 100644 (file)
@@ -63,7 +63,7 @@ import org.apache.fop.dom.svg.SVGArea;
  * class representing svg:Set pseudo flow object.
  *
  */
-public class Set extends FObj {
+public class Set extends SVGObj {
 
        /**
         * inner class for making Set objects.
@@ -103,28 +103,4 @@ public class Set extends FObj {
                super(parent, propertyList);
                this.name = "svg:set";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* retrieve properties */
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a Set to the SVGArea */
-                       ((SVGArea) area).addGraphic(new SVGSetElementImpl());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:set outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 7a5fafb558d70991cceed554b3212866298aa398..76f0e1af5a6f79aed5933ccb6d235e32c3119d1f 100644 (file)
@@ -67,7 +67,7 @@ import org.w3c.dom.svg.SVGLength;
  * class representing svg:Stop pseudo flow object.
  *
  */
-public class Stop extends FObj {
+public class Stop extends SVGObj {
 
        /**
         * inner class for making Stop objects.
index 8d731272981d5cc7084a8d973e3a2d9318c92fc4..0efe1e8a074ab1f0450dae1060be2908ee5bb489 100644 (file)
@@ -63,7 +63,7 @@ import org.apache.fop.dom.svg.SVGArea;
  * class representing svg:Style pseudo flow object.
  *
  */
-public class Style extends FObj {
+public class Style extends SVGObj {
 
        /**
         * inner class for making Style objects.
@@ -103,27 +103,4 @@ public class Style extends FObj {
                super(parent, propertyList);
                this.name = "svg:style";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* retrieve properties */               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a Style to the SVGArea */
-                       ((SVGArea) area).addGraphic(new SVGStyleElementImpl());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:style outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 06051a4cec2d68e8bba23d9107d7f9e9addf774c..486752f0265e6b34be485bef73515a5755f418dd 100644 (file)
@@ -65,7 +65,7 @@ import org.w3c.dom.svg.*;
 /**
  *
  */
-public class Switch extends FObj implements GraphicsCreator {
+public class Switch extends SVGObj {
 
        /**
         * inner class for making Line objects.
@@ -106,7 +106,7 @@ public class Switch extends FObj implements GraphicsCreator {
                this.name = "svg:switch";
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                /*
                 * There are two options
@@ -138,7 +138,7 @@ public class Switch extends FObj implements GraphicsCreator {
                for (int i = 0; i < numChildren; i++) {
                        FONode child = (FONode) children.elementAt(i);
                        if(child instanceof GraphicsCreator) {
-                               GraphicImpl impl = ((GraphicsCreator)child).createGraphic();
+                               SVGElement impl = ((GraphicsCreator)child).createGraphic();
                                if(impl instanceof SVGTests) {
                                        SVGTests testable = (SVGTests)impl;
                                        rf = child.getProperty("requiredFeatures").getString();
@@ -164,27 +164,4 @@ public class Switch extends FObj implements GraphicsCreator {
 
                return graphic;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* retrieve properties */
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(createGraphic());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:switch outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 1a269f450235571be7082d7e36a43bb5fb7564e0..8a859daddb792d74a40007328d1d9398c230b999 100644 (file)
@@ -62,7 +62,7 @@ import org.apache.fop.dom.svg.SVGArea;
 /**
  *
  */
-public class Symbol extends FObj {
+public class Symbol extends SVGObj {
 
        /**
         * inner class for making Symbol objects.
@@ -102,27 +102,4 @@ public class Symbol extends FObj {
                super(parent, propertyList);
                this.name = "svg:symbol";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* retrieve properties */
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(new SVGSymbolElementImpl());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:symbol outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 7bf16dec915fda5d180d6b70da9e3d1b85aa0415..4fe43ca2cdb7a871ac419e39ade44d37ba500b5f 100644 (file)
@@ -59,10 +59,13 @@ import org.apache.fop.apps.FOPException;
 
 import org.apache.fop.dom.svg.*;
 import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
 /**
  *
  */
-public class TRef extends FObj implements TextElement {
+public class TRef extends SVGObj implements TextElement {
 
        /**
         * inner class for making Line objects.
@@ -103,7 +106,7 @@ public class TRef extends FObj implements TextElement {
                this.name = "svg:tref";
        }
 
-       public GraphicImpl createTextElement()
+       public SVGElement createTextElement()
        {
                SVGTRefElementImpl tref = new SVGTRefElementImpl();
                tref.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
@@ -115,41 +118,20 @@ public class TRef extends FObj implements TextElement {
                prop = this.properties.get("x");
                // bit of a hack, but otherwise the svg:text x element could be
                // returned which is not a list
-               if(prop instanceof SVGLengthListProperty)
+//             if(prop instanceof SVGLengthListProperty)
                        tref.xlist = ((SVGLengthListProperty)prop).getSVGLengthList();
                prop = this.properties.get("y");
-               if(prop instanceof SVGLengthListProperty)
+//             if(prop instanceof SVGLengthListProperty)
                        tref.ylist = ((SVGLengthListProperty)prop).getSVGLengthList();
                prop = this.properties.get("dx");
-               if(prop instanceof SVGLengthListProperty)
+//             if(prop instanceof SVGLengthListProperty)
                        tref.dxlist = ((SVGLengthListProperty)prop).getSVGLengthList();
                prop = this.properties.get("dy");
-               if(prop instanceof SVGLengthListProperty)
+//             if(prop instanceof SVGLengthListProperty)
                        tref.dylist = ((SVGLengthListProperty)prop).getSVGLengthList();
 //             tref.dxlist = ((SVGLengthProperty)this.properties.get("dx")).getSVGLength().valueList();
                tref.ref = this.properties.get("xlink:href").getString();
                tref.setId(this.properties.get("id").getString());
                return tref;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:tref outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index a9527193e6717299797cd3dd199e3e4968bd9d2f..02f565df9ac66b85e0cebb3575b635662665f6d4 100644 (file)
@@ -59,11 +59,14 @@ import org.apache.fop.apps.FOPException;
 
 import org.apache.fop.dom.svg.*;
 import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
 /**
  * class representing svg:tspan pseudo flow object.
  *
  */
-public class TSpan extends FObj implements TextElement {
+public class TSpan extends SVGObj implements TextElement {
 
        /**
         * inner class for making tspan objects.
@@ -105,7 +108,7 @@ public class TSpan extends FObj implements TextElement {
        protected void addCharacters(char data[], int start, int length)
        {
                this.text += new String(data, start, length - start);
-               tspan.str = this.text.trim();
+               tspan.str = this.text;
        }
 
        /**
@@ -119,7 +122,7 @@ public class TSpan extends FObj implements TextElement {
                this.name = "svg:tspan";
        }
 
-       public GraphicImpl createTextElement()
+       public SVGElement createTextElement()
        {
                tspan.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
 //             tspan.dx = ((SVGLengthProperty)this.properties.get("dx")).getSVGLength().mvalue();
@@ -130,41 +133,20 @@ public class TSpan extends FObj implements TextElement {
                prop = this.properties.get("x");
                // bit of a hack, but otherwise the svg:text x element coud be
                // returned which is not a list
-               if(prop instanceof SVGLengthListProperty)
+//             if(prop instanceof SVGLengthListProperty)
                        tspan.xlist = ((SVGLengthListProperty)prop).getSVGLengthList();
                prop = this.properties.get("y");
-               if(prop instanceof SVGLengthListProperty)
+//             if(prop instanceof SVGLengthListProperty)
                        tspan.ylist = ((SVGLengthListProperty)prop).getSVGLengthList();
                prop = this.properties.get("dx");
-               if(prop instanceof SVGLengthListProperty)
+//             if(prop instanceof SVGLengthListProperty)
                        tspan.dxlist = ((SVGLengthListProperty)prop).getSVGLengthList();
                prop = this.properties.get("dy");
-               if(prop instanceof SVGLengthListProperty)
+//             if(prop instanceof SVGLengthListProperty)
                        tspan.dylist = ((SVGLengthListProperty)prop).getSVGLengthList();
 //             tspan.xlist = ((SVGLengthListProperty)this.properties.get("x")).getSVGLengthList();
 //             tspan.dxlist = ((SVGLengthProperty)this.properties.get("dx")).getSVGLength().valueList();
                tspan.setId(this.properties.get("id").getString());
                return tspan;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:tspan outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 5facce490b7f8efe7eca7f58f4040f831dc6bd10..ebb0027bf8d4a2aa4dfd9bdc76c53f63137758c2 100644 (file)
@@ -57,6 +57,7 @@ import org.apache.fop.messaging.MessageHandler;
 import org.apache.fop.layout.Area;
 import org.apache.fop.layout.FontState;
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.properties.XMLSpace;
 
 import java.util.*;
 
@@ -64,11 +65,13 @@ import org.apache.fop.dom.svg.*;
 import org.apache.fop.dom.svg.SVGTextElementImpl;
 import org.apache.fop.dom.svg.SVGArea;
 
+import org.w3c.dom.svg.SVGElement;
+
 /**
  * class representing svg:text pseudo flow object.
  *
  */
-public class Text extends FObjMixed implements GraphicsCreator {
+public class Text extends SVGObj {
 
        /**
         * inner class for making SVG Text objects.
@@ -125,52 +128,53 @@ public class Text extends FObjMixed implements GraphicsCreator {
         */
        protected void addCharacters(char data[], int start, int length)
        {
-               textList.addElement(new String(data, start, length - start).trim());
+               textList.addElement(new String(data, start, length - start));
        }
 
+       /**
+        * The children need to be added in order so that the text data
+        * is also added in order.
+        */
        protected void addChild(FONode child) {
                super.addChild(child);
                if(child instanceof TextElement) {
                        TextElement te = (TextElement)child;
-                       GraphicImpl graph = te.createTextElement();
+                       SVGElement graph = te.createTextElement();
                        textList.addElement(graph);
-                       graph.setParent(textGraph);
                } else {
                        // error
                }
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
+               int numChildren = this.textList.size();
+               for (int i = 0; i < numChildren; i++) {
+                       Object obj = textList.elementAt(i);
+                       if(obj instanceof SVGElement) {
+                               SVGElement child = (SVGElement)obj;
+                               textGraph.appendChild(child);
+                       } else if(obj instanceof String) {
+                               String str = (String)obj;
+                               // new CDATANode(str); ??
+                       }
+//                     System.out.println(child);
+               }
                /* retrieve properties */
                textGraph.x = ((SVGLengthProperty)this.properties.get("x")).getSVGLength().getValue();
                textGraph.y = ((SVGLengthProperty)this.properties.get("y")).getSVGLength().getValue();
                textGraph.textList = textList;
                textGraph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
-               textGraph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+               textGraph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
                textGraph.setId(this.properties.get("id").getString());
+               switch((this.properties.get("xml:space")).getEnum()) {
+                       case XMLSpace.DEFAULT:
+                               textGraph.setXMLspace("default");
+                       break;
+                       case XMLSpace.PRESERVE:
+                               textGraph.setXMLspace("preserve");
+                       break;
+               }
                return textGraph;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-       
-       /* if the area this is being put into is an SVGArea */
-       if (area instanceof SVGArea) {
-               /* add the text to the SVGArea */
-               ((SVGArea) area).addGraphic(createGraphic());
-       } else {
-               /* otherwise generate a warning */
-           MessageHandler.errorln("WARNING: svg:text outside svg:svg");
-       }
-
-       /* return status */
-       return new Status(Status.OK);
-       }
 }
index 34b4fcd0dd4260cc1cb3f4b71d835af061137499..92486066be3fc6a4ea216ec88bf950fc9402f6f0 100644 (file)
 package org.apache.fop.svg;
 
 import org.apache.fop.dom.svg.*;
+
+import org.w3c.dom.svg.SVGElement;
+
 /**
  *
  */
 public interface TextElement {
-       public GraphicImpl createTextElement();
+       public SVGElement createTextElement();
 }
index 9841e3dd34a7fcc83945574778d823789db21c6a..0e1c96799c9fa52dd58a71a4887a3c1b49c2b095 100644 (file)
@@ -59,11 +59,14 @@ import org.apache.fop.apps.FOPException;
 
 import org.apache.fop.dom.svg.*;
 import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
 /**
  * class representing svg:TextPath pseudo flow object.
  *
  */
-public class TextPath extends FObj implements TextElement {
+public class TextPath extends SVGObj implements TextElement {
 
        /**
         * inner class for making TextPath objects.
@@ -110,7 +113,7 @@ public class TextPath extends FObj implements TextElement {
                text += new String(data, start, length - start);
        }
 
-       public GraphicImpl createTextElement()
+       public SVGElement createTextElement()
        {
                SVGTextPathElementImpl graph = null;
                String link = this.properties.get("xlink:href").getString();
@@ -118,25 +121,4 @@ public class TextPath extends FObj implements TextElement {
                graph.setId(this.properties.get("id").getString());
                return graph;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a TextPath to the SVGArea */
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:textPath outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 15f0288c15ae0a327bf5c5e2bcf9820b6708bbab..a8f8cd89ac8f1d53b12bae8bccd164d1344ef0ae 100644 (file)
@@ -60,7 +60,7 @@ import org.apache.fop.apps.FOPException;
 /**
  *
  */
-public class Title extends FObj {
+public class Title extends SVGObj {
 
        /**
         * inner class for making Title objects.
index 60a286f30fc86102ac70774b86139c4f7a6d49d1..415512684515cbcff3e8cc683f855936fd1e8b1e 100644 (file)
@@ -59,10 +59,13 @@ import org.apache.fop.apps.FOPException;
 
 import org.apache.fop.dom.svg.*;
 import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
 /**
  *
  */
-public class Use extends FObj implements GraphicsCreator {
+public class Use extends SVGObj {
 
        /**
         * inner class for making Use objects.
@@ -103,35 +106,13 @@ public class Use extends FObj implements GraphicsCreator {
                this.name = "svg:use";
        }
 
-       public GraphicImpl createGraphic()
+       public SVGElement createGraphic()
        {
                String str = this.properties.get("xlink:href").getString();
                SVGUseElementImpl graph = new SVGUseElementImpl(str);
                graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
-               graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+               graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
                graph.setId(this.properties.get("id").getString());
                return graph;
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a line to the SVGArea */
-                       ((SVGArea) area).addGraphic(createGraphic());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:use outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }
index 2707d49a536be1ba7e9530432c42c95193b4c203..78c2f67c81ca194a6c09cc55d648c03829ba8457 100644 (file)
@@ -62,7 +62,7 @@ import org.apache.fop.dom.svg.SVGArea;
 /**
  *
  */
-public class VKern extends FObj {
+public class VKern extends SVGObj {
 
        /**
         * inner class for making VKern objects.
@@ -102,28 +102,4 @@ public class VKern extends FObj {
                super(parent, propertyList);
                this.name = "svg:vkern";
        }
-
-       /**
-        * layout this formatting object.
-        *
-        * @param area the area to layout the object into
-        *
-        * @return the status of the layout
-        */
-       public Status layout(Area area) throws FOPException {
-
-               /* retrieve properties */
-               
-               /* if the area this is being put into is an SVGArea */
-               if (area instanceof SVGArea) {
-                       /* add a VKern to the SVGArea */
-                       ((SVGArea) area).addGraphic(new SVGVKernElementImpl());
-               } else {
-                       /* otherwise generate a warning */
-                       System.err.println("WARNING: svg:vkern outside svg:svg");
-               }
-
-               /* return status */
-               return new Status(Status.OK);
-       }
 }