rossb       01/03/10 07:48:42

  Modified:    webapp   Tag: xml-cocoon2 sitemap.xmap
               .        Tag: xml-cocoon2 changes.xml
               src/org/apache/cocoon/serialization Tag: xml-cocoon2
                        SVGSerializer.java
  Log:
  Updated the SVG Serializer to use the new TranscoderFactory, so that
  the user does not have to explicity set the transcoder, just the MIME
  type. Thus, removed the transcoder lines from the sitemap.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.47  +0 -2      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.46
  retrieving revision 1.1.2.47
  diff -u -r1.1.2.46 -r1.1.2.47
  --- sitemap.xmap      2001/03/08 15:24:42     1.1.2.46
  +++ sitemap.xmap      2001/03/10 15:48:41     1.1.2.47
  @@ -45,13 +45,11 @@
       
<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">
  -    <parameter name="transcoder" 
value="org.apache.batik.transcoder.image.JPEGTranscoder"/>
       <!-- example parameter - background colour is bright green
       <parameter name="background_color" type="color" value="#00FF00"/>
       -->
      </map:serializer>
      <map:serializer name="svg2png" mime-type="image/png"       
src="org.apache.cocoon.serialization.SVGSerializer">
  -    <parameter name="transcoder" 
value="org.apache.batik.transcoder.image.PNGTranscoder"/>
      </map:serializer>
     </map:serializers>
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.9.2.26  +7 -3      xml-cocoon/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/changes.xml,v
  retrieving revision 1.9.2.25
  retrieving revision 1.9.2.26
  diff -u -r1.9.2.25 -r1.9.2.26
  --- changes.xml       2001/03/03 16:08:38     1.9.2.25
  +++ changes.xml       2001/03/10 15:48:41     1.9.2.26
  @@ -4,7 +4,7 @@
   
   <!--
     History of Cocoon changes
  -  $Id: changes.xml,v 1.9.2.25 2001/03/03 16:08:38 prussell Exp $
  +  $Id: changes.xml,v 1.9.2.26 2001/03/10 15:48:41 rossb Exp $
   -->
   
   <changes title="History of Changes">
  @@ -12,7 +12,7 @@
    <devs>
     <!-- in strict alphabetical order -->
     <person name="Donald Ball" email="[EMAIL PROTECTED]" id="DB"/>
  -  <person name="Ross Burton" email="[EMAIL PROTECTED]" id="RB"/>
  +  <person name="Ross Burton" email="[EMAIL PROTECTED]" id="RB"/>
     <person name="Pierpaolo Fumagalli" email="[EMAIL PROTECTED]" id="PF"/>
     <person name="Berin Loritsch" email="[EMAIL PROTECTED]" id="BL"/>
     <person name="Stefano Mazzocchi" email="[EMAIL PROTECTED]" id="SM"/>
  @@ -23,6 +23,10 @@
    </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="RB" type="update">
  +    Added a TranscoderFactory for Batik, and updated the SVG Serializer to 
use
  +    it.
  +  </action>
     <action dev="PR" type="add">
       Added support for SAXConnectors. This is the first stage in the
       implementation of content aggregation. SAXConnectors could also
  @@ -54,7 +58,7 @@
     <action dev="BL" type="update">
       Put meat on the Action Framework for the ManageEmployees form.
     </action>
  -  <action dev="RB" type="add"> 
  +  <action dev="RB" type="update"> 
      SVG serializer now uses Batik.
     </action>
     <action dev="BL" type="add">
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.28  +17 -13    
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.27
  retrieving revision 1.1.2.28
  diff -u -r1.1.2.27 -r1.1.2.28
  --- SVGSerializer.java        2001/02/23 15:25:07     1.1.2.27
  +++ SVGSerializer.java        2001/03/10 15:48:42     1.1.2.28
  @@ -11,6 +11,8 @@
   import org.apache.cocoon.*;
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.components.parser.Parser;
  +import org.apache.cocoon.components.transcoder.TranscoderFactory;
  +import org.apache.cocoon.components.transcoder.ExtendableTranscoderFactory;
   import org.apache.cocoon.xml.*;
   import org.apache.cocoon.xml.dom.*;
   import org.apache.avalon.*;
  @@ -30,7 +32,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Ross Burton</a>
  - * @version CVS $Revision: 1.1.2.27 $ $Date: 2001/02/23 15:25:07 $
  + * @version CVS $Revision: 1.1.2.28 $ $Date: 2001/03/10 15:48:42 $
    */
   public class SVGSerializer extends SVGBuilder implements Composer, 
Serializer, Configurable, Poolable {
   
  @@ -50,6 +52,8 @@
       private String mimetype = null;
       /** The current <code>Transcoder</code>.  */
       Transcoder transcoder = null;
  +    /** The Transcoder Factory to use */
  +    TranscoderFactory factory = 
ExtendableTranscoderFactory.getTranscoderFactoryImplementation();
   
       /**
        * Set the <code>OutputStream</code> where the XML should be serialized.
  @@ -64,32 +68,32 @@
       public void configure(Configuration conf) throws ConfigurationException {
           this.mimetype = conf.getAttribute("mime-type");
           log.debug("SVGSerializer mime-type:" + mimetype);
  -        // TODO: take the mime type and create a transcoder from it
  -        // allow the parameter "transcoder" to override it however
  -        String transcoderName = null; // TODO: whatever the factory will say 
it is
   
  +        // Using the Transcoder Factory, get the default transcoder
  +        // for this MIME type.
  +        this.transcoder = factory.createTranscoder(mimetype);
           // Iterate through the parameters, looking for a transcoder reference
           for (Iterator i = conf.getChildren("parameter"); i.hasNext(); ) {
               Configuration paramConf = (Configuration)i.next();
               String name = paramConf.getAttribute("name");
               if ("transcoder".equals(name)) {
  -                transcoderName = paramConf.getAttribute("value");
  +                String transcoderName = paramConf.getAttribute("value");
  +                try {
  +                    this.transcoder = 
(Transcoder)ClassUtils.newInstance(transcoderName);
  +                } catch (Exception ex) {
  +                    log.error("Cannot load  class " + transcoderName, ex);
  +                    throw new ConfigurationException("Cannot load class " + 
transcoderName, ex);
  +                }
               }
           }
  -        // Now try creating this transcoder
  -        if ( transcoderName == null ) {
  +        // Do we have a transcoder yet?
  +        if (this.transcoder == null ) {
               throw new ConfigurationException(
                   "Could not autodetect transcoder for SVGSerializer and "
                   + "no transcoder was specified in the sitemap configuration."
               );
           }
           
  -        try {
  -            this.transcoder = 
(Transcoder)ClassUtils.newInstance(transcoderName);
  -        } catch (Exception ex) {
  -            log.error("Cannot load  class " + transcoderName, ex);
  -            throw new ConfigurationException("Cannot load class " + 
transcoderName, ex);
  -        }
           // Now run through the other parameters, using them as hints
           // to the transcoder
           for (Iterator i = conf.getChildren("parameter"); i.hasNext(); ) {
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to