xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r682748 - in /xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/examples/plan/src/org/apache/fop/plan: PreloaderPlan.java SimplePlanDrawer.java
Date Tue, 05 Aug 2008 15:20:54 GMT
Author: jeremias
Date: Tue Aug  5 08:20:54 2008
New Revision: 682748

URL: http://svn.apache.org/viewvc?rev=682748&view=rev
Log:
Fix for plan reloader when the namespace doesn't match.
Added a viewBox attribute to the generated SVG so scaling is done properly when embedded in
another SVG file.

Modified:
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java?rev=682748&r1=682747&r2=682748&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java
(original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java
Tue Aug  5 08:20:54 2008
@@ -66,7 +66,7 @@
         return info;
     }
 
-    private ImageInfo getImage(String uri, Source src, ImageContext context) {
+    private ImageInfo getImage(String uri, Source src, ImageContext context) throws IOException
{
 
         InputStream in = new UnclosableInputStream(ImageUtil.needInputStream(src));
         try {
@@ -76,9 +76,16 @@
             DOMResult res = new DOMResult();
             transformer.transform(source, res);
 
+            Document planDoc = (Document)res.getNode();
+            if (!PlanElementMapping.NAMESPACE.equals(
+                    planDoc.getDocumentElement().getNamespaceURI())) {
+                in.reset();
+                return null;
+            }
+
             //Have to render the plan to know its size
             PlanRenderer pr = new PlanRenderer();
-            Document svgDoc = pr.createSVGDocument((Document)res.getNode());
+            Document svgDoc = pr.createSVGDocument(planDoc);
             float width = pr.getWidth();
             float height = pr.getHeight();
 

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java?rev=682748&r1=682747&r2=682748&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java
(original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java
Tue Aug  5 08:20:54 2008
@@ -29,6 +29,7 @@
 import org.w3c.dom.Element;
 
 import org.apache.batik.dom.svg.SVGDOMImplementation;
+
 import org.apache.fop.svg.SVGUtilities;
 
 /**
@@ -83,13 +84,15 @@
 
         String title = "";
 
-        DOMImplementation impl =
-            SVGDOMImplementation.getDOMImplementation();
+        DOMImplementation impl
+            = SVGDOMImplementation.getDOMImplementation();
         Document doc = impl.createDocument(SVG_NAMESPACE, "svg", null);
 
         Element svgRoot = doc.getDocumentElement();
-        svgRoot.setAttributeNS(null, "width", "" + width);
-        svgRoot.setAttributeNS(null, "height", "" + height);
+        svgRoot.setAttributeNS(null, "width", Float.toString(width));
+        svgRoot.setAttributeNS(null, "height", Float.toString(height));
+        svgRoot.setAttributeNS(null, "viewBox",
+                "0 0 " + Float.toString(width) + " " + Float.toString(height));
         svgRoot.setAttributeNS(null, "style",
                                "font-size:" + 8
                                    + ";font-family:"
@@ -99,8 +102,8 @@
                                   java.awt.Font.PLAIN, (int)fontSize);
 
         if (bord) {
-            Element border =
-                SVGUtilities.createRect(doc, 0, 0, width, height);
+            Element border
+                = SVGUtilities.createRect(doc, 0, 0, width, height);
             border.setAttributeNS(null, "style", "stroke:black;fill:none");
             svgRoot.appendChild(border);
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message