You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by vh...@apache.org on 2001/11/05 15:57:25 UTC

cvs commit: xml-batik/xdocs index.xml svggen.xml

vhardy      01/11/05 06:57:24

  Modified:    xdocs    index.xml svggen.xml
  Log:
  + Use new splash image on front page
  + Updated SVGGraphics2D doc with Paul's contrib documentation.
  
  Revision  Changes    Path
  1.31      +2 -2      xml-batik/xdocs/index.xml
  
  Index: index.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/xdocs/index.xml,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- index.xml	2001/10/19 12:33:58	1.30
  +++ index.xml	2001/11/05 14:57:24	1.31
  @@ -11,7 +11,7 @@
   
   <!-- ========================================================================= -->
   <!-- author vincent.hardy@eng.sun.com                                          -->
  -<!-- version $Id: index.xml,v 1.30 2001/10/19 12:33:58 vhardy Exp $ -->
  +<!-- version $Id: index.xml,v 1.31 2001/11/05 14:57:24 vhardy Exp $ -->
   <!-- ========================================================================= -->
   <document>
       <header>
  @@ -26,7 +26,7 @@
   
       <body>
           <s1 title="Batik Overview">
  -        <figure src="images/1_0beta2splash.png" alt="Batik release 1.0" />
  +        <figure src="images/splash.png" alt="Batik release 1.1 is coming" />
   
           <p>
           Batik is a Java(tm) technology based toolkit for applications that want 
  
  
  
  1.10      +76 -3     xml-batik/xdocs/svggen.xml
  
  Index: svggen.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/xdocs/svggen.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- svggen.xml	2001/10/26 11:45:40	1.9
  +++ svggen.xml	2001/11/05 14:57:24	1.10
  @@ -12,7 +12,7 @@
   <!-- ========================================================================= -->
   <!-- author spei@cs.uiowa.edu                                                  -->
   <!-- author cjolif@ilog.fr                                                     -->
  -<!-- version $Id: svggen.xml,v 1.9 2001/10/26 11:45:40 cjolif Exp $          -->      
  +<!-- version $Id: svggen.xml,v 1.10 2001/11/05 14:57:24 vhardy Exp $          -->      
   <!-- ========================================================================= -->
   <document>
       <header>
  @@ -21,7 +21,8 @@
           <authors>
               <person name="Sheng Pei" email="spei@cs.uiowa.edu"/>
               <person name="Vincent Hardy" email="vincent.hardy@eng.sun.com"/>
  -	    <person name="Christophe Jolif" email="cjolif@ilog.fr"/>
  +	        <person name="Christophe Jolif" email="cjolif@ilog.fr"/>
  +            <person name="Paul Evenblij" email="paul_evenblij@compuware.com"/>
           </authors>
       </header>
   
  @@ -217,6 +218,78 @@
   
     </s2>
   
  +  <s2 title="Customizing the way images are stored">
  +  <p>
  +        Every time you call one of the <code>drawImage</code> methods provided by the <code>Graphics2D</code> class,
  +        a standard representation of your image is created in a location which can be reached from the generated SVG
  +        file. For instance, a base64 encoding is created and embedded in the SVG file by default. Alternatively, you
  +        can choose to have your images written to separate files in a predefined directory, in one of the two raster
  +        formats required by the SVG specification, JPEG or PNG.
  +  </p>
  +  <p>
  +        You can change the default behavior by explicitly providing the image handler to be used by the SVG generator.
  +        Once again, you use the SVGGeneratorContext for this. In the example below, all images are converted to PNG
  +        format and written to directory "res/images".
  +  </p>
  +  <source>
  +
  +SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
  +ImageHandler ihandler = new ImageHandlerPNGEncoder("res/images", null);
  +ctx.setImageHandler(ihandler);
  +SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
  +  </source>
  +  <p>
  +        Using the default image handlers results in a new copy of the image data being written to the SVG file or an
  +        external file, for every single <code>drawImage</code> call. If you use the same images over and over again,
  +        then this may result in an SVG file containing a lot of redundant data. At the price of a slight performance
  +        penalty during initial generation of the SVG DOM tree, you can choose to have your image data reused. For this
  +        you use a specialized image handler, as shown below.
  +  </p>
  +  <source>
  +
  +SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
  +
  +// Reuse our embedded base64-encoded image data
  +GenericImageHandler ihandler = new CachedImageHandlerBase64Encoder();
  +ctx.setGenericImageHandler(ihandler);
  +
  +SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
  +  </source>
  +  <p>
  +        With the caching image handlers, it is even possible to reuse the same copy of your image data across
  +        several different SVG documents. Just keep a reference to the image handler, and pass it to the
  +        <code>CachedImageSVGGraphics2D</code> instance used for generating the SVG DOM tree. The following
  +        simplified example shows how different SVG trees might be created by separate SVG generators,
  +        efficiently storing any common images just once.
  +  </p>
  +  <source>
  +  
  +class MySVGGenerator {
  +    // the image handler will write all images files to "res/images"
  +    private static ImageHandler ihandler =
  +        new CachedImageHandlerPNGEncoder("res/images", null);
  +    
  +    public void generateSVG(JPanel myCanvas, OutputStream outStream) {
  +        DOMImplementation domImpl =
  +            GenericDOMImplementation.getDOMImplementation();
  +        Document myFactory = domImpl.createDocument(null, "svg", null);
  +        SVGGeneratorContext ctx =
  +            SVGGeneratorContext.createDefault(myFactory);
  +        ctx.setGenericImageHandler(ihandler);
  +            
  +        SVGGraphics2D svgGenerator =
  +            new SVGGraphics2D(ctx, false);
  +
  +        // create the SVG DOM tree
  +        myCanvas.paintComponent(svgGenerator);
  +        
  +        Writer out = new OutputStreamWriter(outStream, "UTF-8");
  +        svgGenerator.stream(out, true);
  +    }
  +}  </source>
  +
  +  </s2>
  +
     <s2 title="Customizing the generated SVG style">
     <p>
              Your needs in matter of styling may be different from the two provided options (XML attributes or CSS inline properties). For example you may want to put the CSS properties in a stylesheet SVG element section and reference them through the class attribute. In this case you will need to define a new <code>StyleHandler</code> as below.
  @@ -343,4 +416,4 @@
     </s2>
     </s1>
       </body>
  -</document>
  \ No newline at end of file
  +</document>
  
  
  

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