You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ke...@apache.org on 2002/03/08 11:12:30 UTC

cvs commit: xml-fop/contrib/plan/src/org/apache/fop/plan Main.java PlanElement.java PlanElementMapping.java

keiron      02/03/08 02:12:30

  Modified:    contrib/plan build.sh build.xml
               contrib/plan/docs plan.fo
               contrib/plan/src/org/apache/fop/plan Main.java
                        PlanElement.java PlanElementMapping.java
  Log:
  added external image handler
  
  Revision  Changes    Path
  1.2       +1 -1      xml-fop/contrib/plan/build.sh
  
  Index: build.sh
  ===================================================================
  RCS file: /home/cvs/xml-fop/contrib/plan/build.sh,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.sh	5 Mar 2002 10:58:45 -0000	1.1
  +++ build.sh	8 Mar 2002 10:12:30 -0000	1.2
  @@ -12,7 +12,7 @@
     exit 1
   fi
   LIBDIR=../../lib
  -LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:$LIBDIR/ant.jar:$LIBDIR/batik.jar:$LIBDIR/buildtools.jar:$LIBDIR/xerces-1.4.3.jar:$LIBDIR/xalan-2.2D11.jar:../../build/fop.jar
  +LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:$LIBDIR/ant.jar:$LIBDIR/batik.jar:$LIBDIR/buildtools.jar:$LIBDIR/xerces-1.4.3.jar:$LIBDIR/xalan-2.2D11.jar:../../build/fop.jar:$LIBDIR/logkit-1.0.jar
   ANT_HOME=$LIBDIR
   
   echo
  
  
  
  1.2       +1 -1      xml-fop/contrib/plan/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-fop/contrib/plan/build.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.xml	5 Mar 2002 10:58:45 -0000	1.1
  +++ build.xml	8 Mar 2002 10:12:30 -0000	1.2
  @@ -15,7 +15,7 @@
       <property name="name" value="plan"/>
       <property name="version" value="0.1-CVS"/>
       <filter  token="version" value="${version}"/>
  -    <property name="year" value="2001"/>
  +    <property name="year" value="2002"/>
   
       <echo message="------------------- ${Name} ${version} [${year}] ----------------"/>
   
  
  
  
  1.2       +7 -0      xml-fop/contrib/plan/docs/plan.fo
  
  Index: plan.fo
  ===================================================================
  RCS file: /home/cvs/xml-fop/contrib/plan/docs/plan.fo,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- plan.fo	5 Mar 2002 10:58:46 -0000	1.1
  +++ plan.fo	8 Mar 2002 10:12:30 -0000	1.2
  @@ -101,6 +101,13 @@
   
         </fo:block>
   
  +      <fo:block>
  +A plan as an external graphic.
  +      </fo:block>
  +
  +      <fo:block>
  +<fo:external-graphic src="june.xml"/>
  +      </fo:block>
       </fo:flow>
     </fo:page-sequence>
   </fo:root>
  
  
  
  1.2       +3 -6      xml-fop/contrib/plan/src/org/apache/fop/plan/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/contrib/plan/src/org/apache/fop/plan/Main.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Main.java	5 Mar 2002 10:58:46 -0000	1.1
  +++ Main.java	8 Mar 2002 10:12:30 -0000	1.2
  @@ -1,4 +1,4 @@
  -/* $Id: Main.java,v 1.1 2002/03/05 10:58:46 keiron Exp $
  +/* $Id: Main.java,v 1.2 2002/03/08 10:12:30 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -48,15 +48,12 @@
       public Document createSVGDocument(InputStream is) {
           Document doc = null;
   
  -        Element svgRoot = null;
  +        Element root = null;
           try {
  -            //        DOMImplementation impl = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
  -            //        String ns = GraphElementMapping.URI;
  -            //        doc = impl.createDocument(ns, "graph", null);
               doc = javax.xml.parsers.DocumentBuilderFactory.newInstance().
                     newDocumentBuilder().parse(is);
   
  -            svgRoot = doc.getDocumentElement();
  +            root = doc.getDocumentElement();
   
           } catch (Exception e) {
               e.printStackTrace();
  
  
  
  1.2       +13 -2     xml-fop/contrib/plan/src/org/apache/fop/plan/PlanElement.java
  
  Index: PlanElement.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/contrib/plan/src/org/apache/fop/plan/PlanElement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlanElement.java	5 Mar 2002 10:58:46 -0000	1.1
  +++ PlanElement.java	8 Mar 2002 10:12:30 -0000	1.2
  @@ -1,4 +1,4 @@
  -/* $Id: PlanElement.java,v 1.1 2002/03/05 10:58:46 keiron Exp $
  +/* $Id: PlanElement.java,v 1.2 2002/03/08 10:12:30 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -23,6 +23,7 @@
       Document svgDoc = null;
       float width;
       float height;
  +    boolean converted;
   
       public PlanElement(FONode parent) {
           super(parent);
  @@ -34,7 +35,9 @@
       }
   
       public void convertToSVG() {
  -        if(svgDoc == null && doc != null) {
  +        try {
  +        if(!converted) {
  +            converted = true;
               PlanRenderer pr = new PlanRenderer();
               pr.setFontInfo("Helvetica", 12);
               svgDoc = pr.createSVGDocument(doc);
  @@ -43,6 +46,11 @@
   
               doc = svgDoc;
           }
  +        } catch(Throwable t) {
  +            log.error("Could not convert Plan to SVG", t);
  +            width = 0;
  +            height = 0;
  +        }
   
       }
   
  @@ -52,6 +60,9 @@
       }
   
       public String getDocumentNamespace() {
  +        if(svgDoc == null) {
  +            return PlanElementMapping.URI;
  +        }
           return "http://www.w3.org/2000/svg";
       }
   
  
  
  
  1.2       +26 -1     xml-fop/contrib/plan/src/org/apache/fop/plan/PlanElementMapping.java
  
  Index: PlanElementMapping.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/contrib/plan/src/org/apache/fop/plan/PlanElementMapping.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlanElementMapping.java	5 Mar 2002 10:58:46 -0000	1.1
  +++ PlanElementMapping.java	8 Mar 2002 10:12:30 -0000	1.2
  @@ -1,4 +1,4 @@
  -/* $Id: PlanElementMapping.java,v 1.1 2002/03/05 10:58:46 keiron Exp $
  +/* $Id: PlanElementMapping.java,v 1.2 2002/03/08 10:12:30 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -7,6 +7,9 @@
   package org.apache.fop.plan;
   
   import org.apache.fop.fo.*;
  +import org.apache.fop.image.analyser.XMLReader;
  +import org.apache.fop.image.FopImage;
  +import org.w3c.dom.Document;
   
   import java.util.HashMap;
   
  @@ -21,6 +24,8 @@
               foObjs = new HashMap();
               foObjs.put("plan", new PE());
               foObjs.put(DEFAULT, new PlanMaker());
  +
  +            XMLReader.setConverter(URI, new PlanConverter());
           }
       }
   
  @@ -38,6 +43,26 @@
       static class PE extends ElementMapping.Maker {
           public FONode make(FONode parent) {
               return new PlanElement(parent);
  +        }
  +    }
  +
  +    static class PlanConverter implements XMLReader.Converter {
  +        public FopImage.ImageInfo convert(Document doc) {
  +            try {
  +            PlanRenderer pr = new PlanRenderer();
  +            pr.setFontInfo("Helvetica", 12);
  +            FopImage.ImageInfo info = new FopImage.ImageInfo();
  +            info.data = pr.createSVGDocument(doc);
  +            info.width = (int)pr.getWidth();
  +            info.height = (int)pr.getHeight();
  +            info.mimeType = "image/svg+xml";
  +            info.str = "http://www.w3.org/2000/svg";
  +
  +            return info;
  +            } catch(Throwable t) {
  +            }
  +            return null;
  +
           }
       }
   
  
  
  

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