cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-cocoon/webapp sitemap.xmap
Date Wed, 03 Jan 2001 13:49:01 GMT
dims        01/01/03 05:49:01

  Modified:    .        Tag: xml-cocoon2 build.xml
               src/org/apache/cocoon/serialization Tag: xml-cocoon2
                        FOPSerializer.java SVGSerializer.java
               webapp   Tag: xml-cocoon2 sitemap.xmap
  Added:       lib      Tag: xml-cocoon2 batik-all.jar fop-0_16_0.jar
  Removed:     lib      Tag: xml-cocoon2 fop-0_15_0.jar ss_css2.jar
                        svg-20001010.jar
  Log:
  Moving to FOP .16 and xml-batik. the latest CSIRO SVG Toolkit is not good
  enough for use with FOP .16.  Hence the move to xml-batik.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.6.2.51  +1 -1      xml-cocoon/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/build.xml,v
  retrieving revision 1.6.2.50
  retrieving revision 1.6.2.51
  diff -u -r1.6.2.50 -r1.6.2.51
  --- build.xml	2000/12/16 14:58:22	1.6.2.50
  +++ build.xml	2001/01/03 13:48:56	1.6.2.51
  @@ -164,7 +164,7 @@
       <available property="xt.present" classname="com.jclark.xsl.sax.XMLProcessorImpl">
         <classpath refid="classpath"/>
       </available>
  -    <available property="svg.present" classname="org.csiro.svg.dom.SVGDocumentImpl">
  +    <available property="svg.present" classname="org.apache.batik.transcoder.TranscoderFactory">
         <classpath refid="classpath"/>
       </available>
       <available property="rhino.present" classname="org.mozilla.javascript.tools.jsc.Main">
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +6016 -0   xml-cocoon/lib/Attic/batik-all.jar
  
  	<<Binary file>>
  
  
  1.1.2.1   +3424 -0   xml-cocoon/lib/Attic/fop-0_16_0.jar
  
  	<<Binary file>>
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.10  +2 -2      xml-cocoon/src/org/apache/cocoon/serialization/Attic/FOPSerializer.java
  
  Index: FOPSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/FOPSerializer.java,v
  retrieving revision 1.1.2.9
  retrieving revision 1.1.2.10
  diff -u -r1.1.2.9 -r1.1.2.10
  --- FOPSerializer.java	2000/12/08 20:40:09	1.1.2.9
  +++ FOPSerializer.java	2001/01/03 13:49:00	1.1.2.10
  @@ -29,7 +29,7 @@
    * @author <a href="mailto:giacomo.pati@pwr.ch">Giacomo Pati</a>
    *         (PWR Organisation &amp; Entwicklung)
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.9 $ $Date: 2000/12/08 20:40:09 $
  + * @version CVS $Revision: 1.1.2.10 $ $Date: 2001/01/03 13:49:00 $
    *
    */
   public class FOPSerializer extends AbstractSerializer implements MessageListener, Poolable
{
  @@ -57,7 +57,7 @@
           this.driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
           this.driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
           this.driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
  -        this.driver.setWriter(new PrintWriter(out));
  +        this.driver.setOutputStream(out);
           this.setContentHandler(this.driver.getContentHandler());
        }
   
  
  
  
  1.1.2.18  +50 -66    xml-cocoon/src/org/apache/cocoon/serialization/Attic/SVGSerializer.java
  
  Index: SVGSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/SVGSerializer.java,v
  retrieving revision 1.1.2.17
  retrieving revision 1.1.2.18
  diff -u -r1.1.2.17 -r1.1.2.18
  --- SVGSerializer.java	2000/12/08 20:40:11	1.1.2.17
  +++ SVGSerializer.java	2001/01/03 13:49:00	1.1.2.18
  @@ -11,7 +11,6 @@
   import org.apache.cocoon.*;
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.components.parser.Parser;
  -import org.apache.cocoon.components.image.ImageEncoder;
   import org.apache.cocoon.xml.*;
   import org.apache.cocoon.xml.dom.*;
   import org.apache.avalon.*;
  @@ -22,8 +21,17 @@
   import org.xml.sax.ext.*;
   import org.w3c.dom.*;
   import org.w3c.dom.svg.*;
  -import org.csiro.svg.dom.SVGDocumentImpl;
   
  +import org.apache.batik.refimpl.transcoder.*;
  +import org.apache.batik.transcoder.*;
  +
  +import org.apache.xml.serialize.SerializerFactory;
  +import org.apache.xml.serialize.Method;
  +import org.apache.xml.serialize.OutputFormat;
  +
  +import java.io.ByteArrayInputStream;
  +import java.io.ByteArrayOutputStream;
  +
   public class SVGSerializer extends DOMBuilder implements Composer, Serializer, Configurable
{
   
       /** The <code>ContentHandler</code> receiving SAX events. */
  @@ -36,16 +44,10 @@
       private Environment environment=null;
       /** The current <code>Parameters</code>. */
       private Configuration config=null;
  -    /** The source URI associated with the request or <b>null</b>. */
  -    private String source=null;
       /** The current <code>OutputStream</code>. */
       private OutputStream output=null;
  -    /** The current <code>ImageEncoder</code>. */
  -    private ImageEncoder encoder;
  -    /** Does the produced image have a transparent background? */
  -    private boolean transparent;
  -    /** The background colour of this image if not transparent */
  -    private Color backgroundColour = null;
  +    /** The current <code>mime-type</code>. */
  +    private String mimetype = null;
   
       /**
        * Set the <code>OutputStream</code> where the XML should be serialized.
  @@ -68,42 +70,9 @@
               log.error("Could not find component", e);
               throw new ConfigurationException("Could not find Parser", e);
           }
  -
  -        // What image encoder do I use?
  -        String enc = this.config.getChild("encoder").getValue();
  -
  -        try {
  -            log.debug("Selecting " + Roles.IMAGE_ENCODER + ": " + enc);
  -            ComponentSelector selector = (ComponentSelector) this.manager.lookup(Roles.IMAGE_ENCODER);
  -            this.encoder = (ImageEncoder) selector.select(enc);
  -        } catch (Exception e) {
  -            log.error("Could not select " + Roles.IMAGE_ENCODER, e);
  -            throw new ConfigurationException("The ImageEncoder '"
  -                + enc + "' cannot be found. Check your component configuration in the sitemap",
e);
  -        }
  -
  -        // Configure the encoder
  -        if (this.encoder instanceof Configurable) {
  -            ((Configurable)this.encoder).configure(conf);
  -        }
  -
  -        // Transparent or a solid colour background?
  -        this.transparent = this.config.getChild("transparent").getValueAsBoolean(false);
   
  -        if (!transparent) {
  -            String bg = this.config.getChild("background").getValue("#FFFFFF").trim();
  -
  -            if (bg.startsWith("#")) {
  -                bg = bg.substring(1);
  -            }
  -
  -            try {
  -                this.backgroundColour = new Color(Integer.parseInt(bg, 16));
  -            } catch (NumberFormatException e) {
  -                log.debug("Invalid color(SVGSerializer)", e);
  -                throw new ConfigurationException(bg + " is not a valid color.", e);
  -            }
  -        }
  +        mimetype = this.config.getAttribute("mime-type");
  +        log.debug("SVGSerializer mime-type:" + mimetype);
       }
   
       /**
  @@ -154,27 +123,42 @@
        */
       public void notify(Document doc) throws SAXException {
           try {
  -            SVGDocumentImpl svg = new SVGDocumentImpl(doc);
  -            SVGSVGElement root = svg.getRootElement();
  -            SVGLength width = root.getWidth().getBaseVal();
  -            SVGLength height = root.getHeight().getBaseVal();
  -            width.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX);
  -            height.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX);
  -            int w = (int) width.getValue();
  -            int h = (int) height.getValue();
  -            BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
  -            // Either leave this image transparent, or fill it with a solid colour
  -            Graphics2D gra = img.createGraphics();
  -            if (!transparent) {
  -                gra.setColor(backgroundColour);
  -                gra.fillRect(0, 0, w, h);
  -            }
  -            svg.draw(gra);
  -            encoder.encode(img, this.output);
  +            TranscoderFactory transcoderFactory =
  +	            ConcreteTranscoderFactory.getTranscoderFactoryImplementation();
  +            Transcoder transcoder = 
  +                transcoderFactory.createTranscoder(mimetype);
  +
  +            // TODO: FIXME(DIMS) : Remove hard-coded parser name.
  +            transcoder.addTranscodingHint(
  +                        TranscodingHints.KEY_XML_PARSER_CLASSNAME,
  +		                "org.apache.xerces.parsers.SAXParser");
  +
  +            // TODO: FIXME(DIMS) - batik is flaky in accepting DOM and don't 
  +            // support SAX yet. So we have to create a Byte Array as an input
  +            // stream for them.
  +            ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
  +            BufferedOutputStream ostream = new BufferedOutputStream(bytestream);
  +
  +            OutputFormat outformat = new OutputFormat();
  +            SerializerFactory serializerFactory = 
  +                        SerializerFactory.getSerializerFactory(Method.XML);
  +            org.apache.xml.serialize.Serializer serializer = 
  +                        serializerFactory.makeSerializer(outformat);
  +            serializer.setOutputByteStream(ostream);
  +            serializer.asDOMSerializer().serialize(doc);
  +
  +            // Use the Byte Array as the InputSource for the transcoder.
  +            InputSource inputSource = new InputSource(new ByteArrayInputStream
  +                                                        (bytestream.toByteArray()));
  +
  +            // TODO: FIXME(DIMS) - Why do they need a SystemId?
  +            inputSource.setSystemId("http://xml.apache.org");
  +            transcoder.transcodeToStream(inputSource,this.output);
  +
               this.output.flush();
  -        } catch (IOException ex) {
  -            log.warn("SVGSerializer: IOException writing image", ex);
  -            throw new SAXException("IOException writing image ", ex);
  +        } catch (Exception ex) {
  +            log.warn("SVGSerializer: Exception writing image", ex);
  +            throw new SAXException("Exception writing image ", ex);
           }
       }
   
  @@ -182,6 +166,6 @@
        * Return the MIME type.
        */
       public String getMimeType() {
  -        return encoder.getMimeType();
  +        return mimetype;
       }
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.30  +3 -4      xml-cocoon/webapp/Attic/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/webapp/Attic/sitemap.xmap,v
  retrieving revision 1.1.2.29
  retrieving revision 1.1.2.30
  diff -u -r1.1.2.29 -r1.1.2.30
  --- sitemap.xmap	2000/12/30 23:01:02	1.1.2.29
  +++ sitemap.xmap	2001/01/03 13:49:00	1.1.2.30
  @@ -43,10 +43,9 @@
       <doctype-system>http://www.w3.org/TR/2000/03/WD-SVG-20000303/</doctype-system>
      </map:serializer>
      <map:serializer name="svg2jpeg" mime-type="image/jpeg"     src="org.apache.cocoon.serialization.SVGSerializer">
  -    <encoder>jpegencoder</encoder>
  -    <transparent>false</transparent>
  -    <background>#FFFFFF</background>
      </map:serializer>
  +   <map:serializer name="svg2png" mime-type="image/png"     src="org.apache.cocoon.serialization.SVGSerializer">
  +   </map:serializer>
     </map:serializers>
   
     <map:selectors default="browser">
  @@ -207,7 +206,7 @@
   
      <map:match pattern="svg">
       <map:generate src="docs/samples/opac.svg"/>
  -    <map:serialize type="svg2jpeg"/>
  +    <map:serialize type="svg2png"/>
      </map:match>
   
      <map:match pattern="slides/slides">
  
  
  

Mime
View raw message