]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
renders svg to the awt viewer using batik
authorKeiron Liddle <keiron@apache.org>
Tue, 13 Mar 2001 05:28:27 +0000 (05:28 +0000)
committerKeiron Liddle <keiron@apache.org>
Tue, 13 Mar 2001 05:28:27 +0000 (05:28 +0000)
doesn't handle all svg due to lack of property handling

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_17_0_batikSVG@194156 13f79535-47bb-0310-9956-ffa450edef68

lib/batik.jar
src/codegen/elements.dtd
src/codegen/elements.xsl
src/codegen/svgelements.xml
src/codegen/svgproperties.xml
src/org/apache/fop/render/awt/AWTRenderer.java
src/org/apache/fop/svg/SVG.java
src/org/apache/fop/svg/SVGObj.java

index 169b4c636e3b28c5b087f42306fe3c52d3d5674c..d05c85bbd774312a92ea2441c1450607a0757e87 100644 (file)
Binary files a/lib/batik.jar and b/lib/batik.jar differ
index 427bce70fa8a8b9f2db70fe9efb534c0959fcf6e..2ae37e2eb3fd0d6347c81ff9a95ea97338f93b99 100644 (file)
@@ -4,11 +4,17 @@ DTD for svgelements.xml
 -->
 
 <!DOCTYPE elements [
-<!ELEMENT elements (element+) >
+<!ELEMENT elements (commonAttributes+, element+) >
 <!ATTLIST elements
     prefix CDATA #REQUIRED
     ns CDATA #REQUIRED>
 <!ELEMENT element (tagname, attributes) >
 <!ELEMENT tagname (#PCDATA) >
-<!ELEMENT attributes (attribute+) >
+<!ELEMENT attributes ((attribute | includeAttributes)+) >
+<!ELEMENT commonAttributes ((attribute | includeAttributes)+) >
+<!ATTLIST commonAttributes
+    ref CDATA #REQUIRED>
 <!ELEMENT attribute (#PCDATA) >
+<!ELEMENT includeAttributes (#PCDATA) >
+<!ATTLIST includeAttributes
+    ref CDATA #REQUIRED>
index b8bcbafa51a2e868c6620a3f86caf0406282e9fe..9c0e3cdd73707e5fc04d265661316e84d7da7587 100644 (file)
   </xsl:choose>
 </xsl:template>
 
+<xsl:template match="attributes"><xsl:apply-templates/></xsl:template>
+
+<xsl:template match="includeAttributes">
+<xsl:variable name="attr-ref">
+  <xsl:value-of select="@ref"/>
+</xsl:variable>
+<xsl:for-each select="/elements/commonAttributes">
+  <xsl:choose>
+    <xsl:when test="@ref = $attr-ref">
+    <xsl:apply-templates/>
+    </xsl:when>
+  </xsl:choose>
+</xsl:for-each>
+</xsl:template>
+
+<xsl:template match="attribute">"<xsl:apply-templates/>"<xsl:if test="not(position()=last())">, </xsl:if></xsl:template>
+
 <xsl:template match="elements">
     <xsl:apply-templates select="element"/>
 </xsl:template>
@@ -77,17 +94,17 @@ import org.w3c.dom.Element;
 public class <xsl:value-of select="$classname"/> extends SVGObj {
 
     /**
-     * inner class for making A objects.
+     * inner class for making <xsl:apply-templates select="tagname"/> objects.
      */
     public static class Maker extends FObj.Maker {
 
         /**
-         * make a A object.
+         * make a <xsl:apply-templates select="tagname"/> object.
          *
          * @param parent the parent formatting object
          * @param propertyList the explicit properties of this object
          *
-         * @return the A object
+         * @return the <xsl:apply-templates select="tagname"/> object
          */
         public FObj make(FObj parent,
                          PropertyList propertyList) throws FOPException {
@@ -98,14 +115,14 @@ public class <xsl:value-of select="$classname"/> extends SVGObj {
     /**
      * returns the maker for this object.
      *
-     * @return the maker for A objects
+     * @return the maker for <xsl:apply-templates select="tagname"/> objects
      */
     public static FObj.Maker maker() {
         return new <xsl:value-of select="$classname"/>.Maker();
     }
 
     /**
-     * constructs a A object (called by Maker).
+     * constructs a <xsl:apply-templates select="tagname"/> object (called by Maker).
      *
      * @param parent the parent formatting object
      * @param propertyList the explicit properties of this object
@@ -114,11 +131,7 @@ public class <xsl:value-of select="$classname"/> extends SVGObj {
         super(parent, propertyList);
         this.name = "<xsl:value-of select="//@prefix"/>:<xsl:value-of select="$name"/>";
         tagName = "<xsl:value-of select="$name"/>";
-        props = new String[] {
-            <xsl:for-each select="attributes/attribute">
-                "<xsl:apply-templates/>"<xsl:if test="not(position()=last())">, </xsl:if>
-            </xsl:for-each>
-        };
+        props = new String[] {<xsl:apply-templates select="attributes"/>};
     }
 
 <xsl:if test="@addText">
index 2f9936d9493e02d01e2e0b23be3bb0db3548073e..a279114c628f8c52a1193c24f537e91939220011 100644 (file)
@@ -1,5 +1,114 @@
 <?xml version="1.0" ?>
-<elements prefix="svg" ns="http:">
+<elements prefix="svg" ns="http://www.w3.org/2000/svg">
+    <commonAttributes ref="stdAttrs">
+        <attribute>id</attribute>
+        <attribute>class</attribute>
+    </commonAttributes>
+    <commonAttributes ref="langSpaceAttrs">
+        <attribute>xml:lang</attribute>
+        <attribute>xml:space</attribute>
+    </commonAttributes>
+    <commonAttributes ref="testAttrs">
+        <attribute>requiredFeatures</attribute>
+        <attribute>requiredExtensions</attribute>
+        <attribute>systemLanguage</attribute>
+    </commonAttributes>
+    <commonAttributes ref="PresentationAttributes-All">
+        <includeAttributes ref="PresentationAttributes-Containers"/>
+        <includeAttributes ref="PresentationAttributes-feFlood"/>
+        <includeAttributes ref="PresentationAttributes-FillStroke"/>
+        <includeAttributes ref="PresentationAttributes-FontSpecification"/>
+        <includeAttributes ref="PresentationAttributes-Gradients"/>
+        <includeAttributes ref="PresentationAttributes-Graphics"/>
+        <includeAttributes ref="PresentationAttributes-Images"/>
+        <includeAttributes ref="PresentationAttributes-LightingEffects"/>
+        <includeAttributes ref="PresentationAttributes-Markers"/>
+        <includeAttributes ref="PresentationAttributes-TextContentElements"/>
+        <includeAttributes ref="PresentationAttributes-TextElements"/>
+        <includeAttributes ref="PresentationAttributes-Viewports"/>
+    </commonAttributes>
+    <commonAttributes ref="PresentationAttributes-Containers">
+        <attribute>enable-background</attribute>
+    </commonAttributes>
+    <commonAttributes ref="PresentationAttributes-feFlood">
+        <attribute>flood-color</attribute>
+        <attribute>flood-opacity</attribute>
+    </commonAttributes>
+    <commonAttributes ref="PresentationAttributes-FillStroke">
+        <attribute>fill</attribute>
+        <attribute>fill-opacity</attribute>
+        <attribute>fill-rule</attribute>
+        <attribute>stroke</attribute>
+        <attribute>stroke-dasharray</attribute>
+        <attribute>stroke-dashoffset</attribute>
+        <attribute>stroke-linecap</attribute>
+        <attribute>stroke-linejoin</attribute>
+        <attribute>stroke-miterlimit</attribute>
+        <attribute>stroke-opacity</attribute>
+        <attribute>stroke-width</attribute>
+    </commonAttributes>
+    <commonAttributes ref="PresentationAttributes-FontSpecification">
+        <attribute>font-family</attribute>
+        <attribute>font-size</attribute>
+        <attribute>font-size-adjust</attribute>
+        <attribute>font-stretch</attribute>
+        <attribute>font-style</attribute>
+        <attribute>font-variant</attribute>
+        <attribute>font-weight</attribute>
+    </commonAttributes>
+    <commonAttributes ref="PresentationAttributes-Gradients">
+        <attribute>stop-color</attribute>
+        <attribute>stop-opacity</attribute>
+    </commonAttributes>
+    <commonAttributes ref="PresentationAttributes-Graphics">
+        <attribute>clip-path</attribute>
+        <attribute>clip-rule</attribute>
+        <attribute>color</attribute>
+        <attribute>color-interpolation</attribute>
+        <attribute>color-rendering</attribute>
+        <attribute>cursor</attribute>
+        <attribute>display</attribute>
+        <attribute>filter</attribute>
+        <attribute>image-rendering</attribute>
+        <attribute>mask</attribute>
+        <attribute>opacity</attribute>
+        <attribute>pointer-events</attribute>
+        <attribute>space-rendering</attribute>
+        <attribute>text-rendering</attribute>
+        <attribute>visibility</attribute>
+    </commonAttributes>
+    <commonAttributes ref="PresentationAttributes-Images">
+        <attribute>color-profile</attribute>
+    </commonAttributes>
+    <commonAttributes ref="PresentationAttributes-LightingEffects">
+        <attribute>lighting-color</attribute>
+    </commonAttributes>
+    <commonAttributes ref="PresentationAttributes-Markers">
+        <attribute>marker-start</attribute>
+        <attribute>marker-mid</attribute>
+        <attribute>marker-end</attribute>
+    </commonAttributes>
+    <commonAttributes ref="PresentationAttributes-TextContentElements">
+        <attribute>alignment-baseline</attribute>
+        <attribute>baseline-shift</attribute>
+        <attribute>direction</attribute>
+        <attribute>glyph-orientation-horizontal</attribute>
+        <attribute>glyph-orientation-vertical</attribute>
+        <attribute>kerning</attribute>
+        <attribute>letter-spacing</attribute>
+        <attribute>text-decoration</attribute>
+        <attribute>unicode-bidi</attribute>
+        <attribute>word-spacing</attribute>
+    </commonAttributes>
+    <commonAttributes ref="PresentationAttributes-TextElements">
+        <attribute>writing-mode</attribute>
+        <attribute>text-anchor</attribute>
+        <attribute>dominant-baseline</attribute>
+    </commonAttributes>
+    <commonAttributes ref="PresentationAttributes-Viewports">
+        <attribute>clip</attribute>
+        <attribute>overflow</attribute>
+    </commonAttributes>
     <element>
         <tagname>a</tagname>
         <attributes>
@@ -9,6 +118,9 @@
     <element>
         <tagname>circle</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
+            <includeAttributes ref="PresentationAttributes-FillStroke"/>
+            <includeAttributes ref="PresentationAttributes-Graphics"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>transform</attribute>
     <element>
         <tagname>altGlyph</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>animate</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>animateColor</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>animateMotion</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>animateTransform</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>clipPath</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>clipPathUnits</attribute>
     <element>
         <tagname>cursor</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>defs</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element addText="true">
     <element>
         <tagname>ellipse</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>transform</attribute>
     <element>
         <tagname>filter</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>font</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>g</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>transform</attribute>
     <element>
         <tagname>glyph</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>hkern</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>image</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>transform</attribute>
     <element>
         <tagname>line</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>transform</attribute>
     <element>
         <tagname>linearGradient</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>transform</attribute>
     <element>
         <tagname>marker</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>mask</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
         </attributes>
     <element>
         <tagname>missing-glyph</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>path</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>transform</attribute>
     <element>
         <tagname>pattern</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>transform</attribute>
     <element>
         <tagname>polygon</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>transform</attribute>
     <element>
         <tagname>polyline</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>transform</attribute>
     <element>
         <tagname>radialGradient</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>transform</attribute>
     <element>
         <tagname>rect</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
+            <includeAttributes ref="PresentationAttributes-FillStroke"/>
+            <includeAttributes ref="PresentationAttributes-Graphics"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>transform</attribute>
     <element>
         <tagname>set</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>stop</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>offset</attribute>
     <element addText="true">
         <tagname>style</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>switch</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>requiredFeatures</attribute>
             <attribute>requiredExtensions</attribute>
     <element>
         <tagname>symbol</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>viewBox</attribute>
     <element>
         <tagname>tref</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>xlink:href</attribute>
     <element addText="true">
         <tagname>tspan</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>x</attribute>
     <element addText="true">
         <tagname>text</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>transform</attribute>
     <element addText="true">
         <tagname>textPath</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>xlink:href</attribute>
     <element addText="true">
         <tagname>title</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
     <element>
         <tagname>use</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
             <attribute>id</attribute>
             <attribute>style</attribute>
             <attribute>transform</attribute>
     <element>
         <tagname>vkern</tagname>
         <attributes>
+            <includeAttributes ref="stdAttrs"/>
         </attributes>
     </element>
 </elements>
index 11f4397e167a81a46feab0dd1b2b042370c3919b..a242b0d0b22a19752a69409d14cf85007d870a33 100644 (file)
@@ -90,7 +90,6 @@
     <name>offset</name>
     <use-generic ispropclass="true">SVGStringProperty</use-generic>
   </property>
-
   <property>
     <name>style</name>
     <use-generic ispropclass="true">SVGStringProperty</use-generic>
     <name>points</name>
     <use-generic ispropclass="true">SVGStringProperty</use-generic>
   </property>
+  <property>
+    <name>fill</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>fill-opacity</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>fill-rule</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>stroke</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>stroke-dasharray</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>stroke-dashoffset</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>stroke-linecap</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>stroke-linejoin</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>stroke-miterlimit</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>stroke-opacity</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>stroke-width</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>clip-path</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>clip-rule</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>color</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>color-interpolation</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>color-rendering</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>cursor</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>display</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>filter</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>image-rendering</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>opacity</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>mask</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>space-rendering</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>text-rendering</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>pointer-events</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
+  <property>
+    <name>visibility</name>
+    <use-generic ispropclass="true">SVGStringProperty</use-generic>
+  </property>
 
   <property type="ref" family="fo">
     <name>font-family</name>
index 0f3c7e1a1157be3536e78299a5356be39ed265b6..e2ff10226b397d98e5b932538b7b82149e10c8d1 100644 (file)
@@ -21,6 +21,13 @@ import org.apache.fop.apps.*;
 
 import org.w3c.dom.svg.*;
 
+import org.apache.batik.bridge.*;
+import org.apache.batik.swing.svg.*;
+import org.apache.batik.swing.gvt.*;
+import org.apache.batik.gvt.*;
+import org.apache.batik.gvt.renderer.*;
+import org.apache.batik.gvt.filter.*;
+
 import java.awt.*;
 import java.awt.Image;
 import java.awt.image.*;
@@ -627,8 +634,13 @@ public class AWTRenderer implements Renderer, Printable, Pageable {
 
         Enumeration e = area.getChildren().elements();
         while (e.hasMoreElements()) {
-            org.apache.fop.layout.Box b =
-              (org.apache.fop.layout.Box) e.nextElement();
+            org.apache.fop.layout.Box b = (org.apache.fop.layout.Box) e.nextElement();
+            if(b instanceof InlineArea) {
+                InlineArea ia = (InlineArea)b;
+                this.currentYPosition = ry - ia.getYOffset();
+            } else {
+                this.currentYPosition = ry - area.getPlacementOffset();
+            }
             b.render(this);
         }
 
@@ -660,18 +672,99 @@ public class AWTRenderer implements Renderer, Printable, Pageable {
        this.currentXPosition += area.getContentWidth();
   }
 
-
     public void renderSVGArea(SVGArea area) {
 
-        int x = this.currentAreaContainerXPosition;
+        int x = this.currentXPosition;
         int y = this.currentYPosition;
         int w = area.getContentWidth();
         int h = area.getHeight();
 
-        this.currentYPosition -= h;
+//        this.currentYPosition -= h;
+
+        SVGDocument doc = area.getSVGDocument();
+
+        UserAgent userAgent = new MUserAgent(new AffineTransform());
 
+        GVTBuilder builder = new GVTBuilder();
+        GraphicsNodeRenderContext rc = getRenderContext();
+        BridgeContext ctx = new BridgeContext(userAgent, rc);
+        GraphicsNode root;
+        try {
+            root = builder.build(ctx, doc);
+            //rc.setTransform(new AffineTransform(1, 0, x, 0, 1, y));
+            graphics.translate(x / 1000f, pageHeight - y / 1000f);
+            root.paint(graphics, rc);
+            graphics.translate(-x / 1000f, y / 1000f - pageHeight);
+        } catch(Exception e) {
+            e.printStackTrace();
+        }
+        this.currentXPosition += area.getContentWidth();
+
+/*        final JSVGComponent svgComponent = new JSVGComponent(userAgent, true, true);
+//        JFrame frame = new JFrame();
+//        frame.setSize(300, 300);
+//        frame.getContentPane().add(svgComponent);
+//        frame.setVisible(true);
+        svgComponent.setSVGDocument(doc);
+
+        svgComponent.addGVTTreeRendererListener(new GVTTreeRendererListener() {
+            public void gvtRenderingPrepare(GVTTreeRendererEvent e)
+            {
+                System.out.println("rendering prepare:" + e);
+            }
+
+            public void gvtRenderingStarted(GVTTreeRendererEvent e)
+            {
+                System.out.println("rendering started:" + e);
+            }
+
+            public void gvtRenderingCancelled(GVTTreeRendererEvent e)
+            {
+            }
+
+            public void gvtRenderingFailed(GVTTreeRendererEvent e)
+            {
+            }
+
+            public void gvtRenderingCompleted(GVTTreeRendererEvent e)
+            {
+                System.out.println("rendering complete:" + e);
+                Object src = e.getSource();
+                Image im = e.getImage();
+                svgComponent.paint(graphics);
+            }
+        });*/
     }
 
+    public GraphicsNodeRenderContext getRenderContext() {
+        GraphicsNodeRenderContext nodeRenderContext = null;
+        if (nodeRenderContext == null) {
+            RenderingHints hints = new RenderingHints(null);
+            hints.put(RenderingHints.KEY_ANTIALIASING,
+                  RenderingHints.VALUE_ANTIALIAS_ON);
+
+            hints.put(RenderingHints.KEY_INTERPOLATION,
+                  RenderingHints.VALUE_INTERPOLATION_BILINEAR);
+
+            FontRenderContext fontRenderContext =
+                new FontRenderContext(new AffineTransform(), true, true);
+
+            TextPainter textPainter = new StrokingTextPainter();
+
+            GraphicsNodeRableFactory gnrFactory =
+                new ConcreteGraphicsNodeRableFactory();
+
+            nodeRenderContext =
+                new GraphicsNodeRenderContext(new AffineTransform(),
+                                          null,
+                                          hints,
+                                          fontRenderContext,
+                                          textPainter,
+                                          gnrFactory);
+            }
+
+        return nodeRenderContext;
+    }
 
 
     public void setProducer(String producer) {
@@ -776,7 +869,98 @@ public class AWTRenderer implements Renderer, Printable, Pageable {
         area.getObject().render(this);
     }
 
-}
+    protected class MUserAgent implements UserAgent {
+        AffineTransform currentTransform = null;
+        /**
+         * Creates a new SVGUserAgent.
+         */
+        protected MUserAgent(AffineTransform at) {
+            currentTransform = at;
+        }
+
+        /**
+         * Displays an error message.
+         */
+        public void displayError(String message) {
+            System.err.println(message);
+        }
+    
+        /**
+         * Displays an error resulting from the specified Exception.
+         */
+        public void displayError(Exception ex) {
+            ex.printStackTrace(System.err);
+        }
+
+        /**
+         * Displays a message in the User Agent interface.
+         * The given message is typically displayed in a status bar.
+         */
+        public void displayMessage(String message) {
+            System.out.println(message);
+        }
+
+        /**
+         * Returns a customized the pixel to mm factor.
+         */
+        public float getPixelToMM() {
+            return 0.264583333333333333333f; // 72 dpi
+        }
+
+        /**
+         * Returns the language settings.
+         */
+        public String getLanguages() {
+            return "en";//userLanguages;
+        }
+
+        /**
+         * Returns the user stylesheet uri.
+         * @return null if no user style sheet was specified.
+         */
+        public String getUserStyleSheetURI() {
+            return null;//userStyleSheetURI;
+        }
 
+        /**
+         * Returns the class name of the XML parser.
+         */
+        public String getXMLParserClassName() {
+       String parserClassName =
+           System.getProperty("org.xml.sax.parser");
+       if (parserClassName == null) {
+           parserClassName = "org.apache.xerces.parsers.SAXParser";
+       }
+            return parserClassName;//application.getXMLParserClassName();
+        }
 
+        /**
+         * Opens a link in a new component.
+         * @param doc The current document.
+         * @param uri The document URI.
+         */
+        public void openLink(SVGAElement elt)
+        {
+            //application.openLink(uri);
+        }
 
+        public Point getClientAreaLocationOnScreen()
+        {
+            return new Point(0, 0);
+        }
+
+        public void setSVGCursor(java.awt.Cursor cursor)
+        {
+        }
+
+        public AffineTransform getTransform()
+        {
+            return currentTransform;
+        }
+
+        public Dimension2D getViewportSize()
+        {
+            return new Dimension(100, 100);
+        }
+    }
+}
index 8b7a3b3f4c2d9a3db3085705c2cabf6122eb867a..9db5ea1c2cf39aa88361d66badc9ff887ba5e528 100644 (file)
@@ -236,7 +236,7 @@ public class SVG extends SVGObj implements GraphicsCreator {
 
                 DefaultSVGContext dc = new DefaultSVGContext() {
                         public float getPixelToMM() {
-                            return 12;
+                            return 0.264583333333333333333f; // 72 dpi
                         }
                         public float getViewportWidth() {
                             return 100;
@@ -247,7 +247,7 @@ public class SVG extends SVGObj implements GraphicsCreator {
                     };
                 doc.setSVGContext(dc);
 
-                System.out.println("tag:" + tagName);
+                //System.out.println("tag:" + tagName);
                 Element topLevel = doc.createElementNS("http://www.w3.org/2000/svg", tagName);
                 for(int count = 0; count < props.length; count++) {
                     String rf = this.properties.get(props[count]).getString();
index adbd9c9ad191ff683a76e1ee6cccd22c16cb88ec..07a55d9b53f7c262581b447fc0f58b27ec0203a6 100644 (file)
@@ -84,8 +84,10 @@ public abstract class SVGObj extends FObj implements GraphicsCreator {
         Element element = doc.createElementNS("http://www.w3.org/2000/svg", tagName);
 //        Element element = doc.createElement(tagName);
         for(int count = 0; count < props.length; count++) {
-            String rf = this.properties.get(props[count]).getString();
-            element.setAttribute(props[count], rf);
+            if(this.properties.get(props[count]) != null) {
+                String rf = this.properties.get(props[count]).getString();
+                element.setAttribute(props[count], rf);
+            }
         }
         parent.appendChild(element);
         int numChildren = this.children.size();