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 cj...@apache.org on 2001/05/03 11:55:46 UTC

cvs commit: xml-batik/xdocs mail-lists.xml scriptIntro.xml svggen.xml

cjolif      01/05/03 02:55:46

  Modified:    xdocs    mail-lists.xml scriptIntro.xml svggen.xml
  Log:
  improve doc
  
  Revision  Changes    Path
  1.2       +68 -68    xml-batik/xdocs/mail-lists.xml
  
  Index: mail-lists.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/xdocs/mail-lists.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- mail-lists.xml	2001/02/05 10:15:51	1.1
  +++ mail-lists.xml	2001/05/03 09:55:45	1.2
  @@ -1,68 +1,68 @@
  -<?xml version="1.0"?>
  -
  -<!DOCTYPE document SYSTEM "./dtd/document-v10.dtd">
  -
  -<!-- ========================================================================= -->
  -<!-- Copyright (C) The Apache Software Foundation. All rights reserved.        -->
  -<!--                                                                           -->
  -<!-- This software is published under the terms of the Apache Software License -->
  -<!-- version 1.1, a copy of which has been included with this distribution in  -->
  -<!-- the LICENSE file.                                                         -->
  -<!-- ========================================================================= -->
  -
  -<!-- ========================================================================= -->
  -<!-- author cjolif@ilog.fr                                                     -->
  -<!-- version $Id: mail-lists.xml,v 1.1 2001/02/05 10:15:51 cjolif Exp $      -->
  -<!-- ========================================================================= -->
  -
  -<document>
  - <header>
  -  <title>Mailing Lists</title>
  -  <authors>
  -   <person name="Christophe Jolif" email="cjolif@ilog.fr"/>
  -  </authors>
  - </header>
  -
  - <body>
  -  <s1 title="Important Notice">
  -
  -   <p><strong>IMPORTANT:</strong> Before posting a question or problem to any
  -    mailing list, please first look at the following resources in this order:</p>
  -   <ol>
  -    <li><link href="faqs.html">Batik FAQs</link></li>
  -    <li><link href="http://www-sop.inria.fr/koala/batik/">Batik temporary mailing lists archives hosted by Koala</link></li>
  -   </ol>
  -  </s1>
  -
  -  <s1 title="Batik Users">
  -   <p><link href="mailto:batik-users-subscribe@xml.apache.org">Subscribe</link>
  -      <link href="mailto:batik-users-unsubscribe@xml.apache.org">Unsubscribe</link>
  -   </p>
  -
  -   <p>The general Batik list, for problems using Batik, bug reports... 
  -   This is not an appropriate list for general SVG questions.</p>
  -
  -   <p><strong>IMPORTANT:</strong> If you are posting about a problem you are having
  -    (as most people do), it will aid in finding a speedy resolution if you provide
  -    full configuration details</p>
  -  </s1>
  -
  -  <s1 title="Batik Dev">
  -   <p><link href="mailto:batik-dev-subscribe@xml.apache.org">Subscribe</link>
  -      <link href="mailto:batik-dev-unsubscribe@xml.apache.org">Unsubscribe</link>
  -   </p>
  -
  -   <p>This list is for developers <strong>working on</strong> or wanting to work on
  -    Batik itself (not developers merely working <strong>with</strong> Batik),
  -    for code patches to Batik to be posted,...
  -    </p>
  -  </s1>
  -  <s1 title="Related Mailing Lists">
  -   <ul>
  -    <li><link href="http://groups.yahoo.com/group/svg-developers">SVG Developers Mailing List</link> - Where you will find most of the developers working with/on SVG.</li>
  -    <li><link href="http://www.w3.org/Mail/Lists.html">W3C Public SVG Mailing List (www-svg)</link> - The official W3C mailing list for discussions on SVG specification.</li>
  -   </ul>
  -  </s1>
  - </body>
  -</document>
  -
  +<?xml version="1.0"?>
  +
  +<!DOCTYPE document SYSTEM "./dtd/document-v10.dtd">
  +
  +<!-- ========================================================================= -->
  +<!-- Copyright (C) The Apache Software Foundation. All rights reserved.        -->
  +<!--                                                                           -->
  +<!-- This software is published under the terms of the Apache Software License -->
  +<!-- version 1.1, a copy of which has been included with this distribution in  -->
  +<!-- the LICENSE file.                                                         -->
  +<!-- ========================================================================= -->
  +
  +<!-- ========================================================================= -->
  +<!-- author cjolif@ilog.fr                                                     -->
  +<!-- version $Id: mail-lists.xml,v 1.2 2001/05/03 09:55:45 cjolif Exp $      -->
  +<!-- ========================================================================= -->
  +
  +<document>
  + <header>
  +  <title>Mailing Lists</title>
  +  <authors>
  +   <person name="Christophe Jolif" email="cjolif@ilog.fr"/>
  +  </authors>
  + </header>
  +
  + <body>
  +  <s1 title="Important Notice">
  +
  +   <p><strong>IMPORTANT:</strong> Before posting a question or problem to any
  +    mailing list, please first look at the following resources in this order:</p>
  +   <ol>
  +    <li><link href="faqs.html">Batik FAQs</link></li>
  +    <li><link href="http://www-sop.inria.fr/koala/batik/">Batik temporary mailing lists archives hosted by Koala</link></li>
  +   </ol>
  +  </s1>
  +
  +  <s1 title="Batik Users">
  +   <p><link href="mailto:batik-users-subscribe@xml.apache.org">Subscribe</link>
  +      <link href="mailto:batik-users-unsubscribe@xml.apache.org">Unsubscribe</link>
  +   </p>
  +
  +   <p>The general Batik list, for problems using Batik, bug reports... 
  +   This is not an appropriate list for general SVG questions.</p>
  +
  +   <p><strong>IMPORTANT:</strong> If you are posting about a problem you are having
  +    (as most people do), it will aid in finding a speedy resolution if you provide
  +    full configuration details</p>
  +  </s1>
  +
  +  <s1 title="Batik Dev">
  +   <p><link href="mailto:batik-dev-subscribe@xml.apache.org">Subscribe</link>
  +      <link href="mailto:batik-dev-unsubscribe@xml.apache.org">Unsubscribe</link>
  +   </p>
  +
  +   <p>This list is for developers <strong>working on</strong> or wanting to work on
  +    Batik itself (not developers merely working <strong>with</strong> Batik),
  +    for code patches to Batik to be posted,...
  +    </p>
  +  </s1>
  +  <s1 title="Related Mailing Lists">
  +   <ul>
  +    <li><link href="http://groups.yahoo.com/group/svg-developers">SVG Developers Mailing List</link> - Where you will find most of the developers working with/on SVG.</li>
  +    <li><link href="http://www.w3.org/Mail/Lists.html">W3C Public SVG Mailing List (www-svg)</link> - The official W3C mailing list for discussions on SVG specification.</li>
  +   </ul>
  +  </s1>
  + </body>
  +</document>
  +
  
  
  
  1.2       +12 -7     xml-batik/xdocs/scriptIntro.xml
  
  Index: scriptIntro.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/xdocs/scriptIntro.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- scriptIntro.xml	2001/04/17 15:43:07	1.1
  +++ scriptIntro.xml	2001/05/03 09:55:45	1.2
  @@ -11,7 +11,7 @@
   
   <!-- ========================================================================= -->
   <!-- author cjolif@ilog.fr                                                     -->
  -<!-- version $Id: scriptIntro.xml,v 1.1 2001/04/17 15:43:07 cjolif Exp $   -->      
  +<!-- version $Id: scriptIntro.xml,v 1.2 2001/05/03 09:55:45 cjolif Exp $   -->      
   <!-- ========================================================================= -->
   <document>
       <header>
  @@ -180,8 +180,10 @@
           super(); // build RhinoInterpreter
           final String[] names = { "print" }
           try {
  -            getGlobalObject().defineFunctionProperties(names, ExtendedRhinoIntepreter.class,
  -                                                       ScriptableObject.DONTENUM);
  +            getGlobalObject().
  +	            defineFunctionProperties(names, 
  +	                          ExtendedRhinoIntepreter.class,
  +                                  ScriptableObject.DONTENUM);
           } catch (PropertyException e) {
               throw new Error(e.getMessage());
           }
  @@ -193,7 +195,8 @@
               if (i &gt; 0)
                   System.out.print(" ");
   	    
  -            // Convert the arbitrary JavaScript value into a string form.
  +            // Convert the arbitrary JavaScript value into 
  +            // a string form.
               String s = Context.toString(args[i]);
   	    
               System.out.print(s);
  @@ -202,12 +205,13 @@
       }
   }</source>
              <p>
  -	   Now, you should tell to Batik to use this interpreter instead of the default.
  +	   Now, you should tell to Batik to use this interpreter instead of the default one.
   	   For that, you should first define a factory to create instances of your interpreter.
   	   </p>
   	   <source>
   
  -public class ExtendedRhinoInterpreterFactory implements InterpreterFactory {
  +public class ExtendedRhinoInterpreterFactory 
  +  implements InterpreterFactory {
       public Interpreter createInterpreter() {
           return new ExtendedRhinoInterpreter();
       }
  @@ -221,7 +225,8 @@
   org.apache.batik.bridge BridgeContext ctx = ...;
   org.apache.batik.script.InterpreterPool pool =
       new org.apache.batik.scriptInterpreterPool();
  -pool.putInterpreterFactory("text/ecmascript", new ExtendedRhinoInterpreterFactory());
  +pool.putInterpreterFactory("text/ecmascript", 
  +                           new ExtendedRhinoInterpreterFactory());
   ctx.setIntepreterPool(pool);</source>
              <p>
   	   For example if you are using the Batik SVGBrowser application you should be able to use
  
  
  
  1.6       +97 -22    xml-batik/xdocs/svggen.xml
  
  Index: svggen.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/xdocs/svggen.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- svggen.xml	2001/04/18 15:27:59	1.5
  +++ svggen.xml	2001/05/03 09:55:45	1.6
  @@ -12,7 +12,7 @@
   <!-- ========================================================================= -->
   <!-- author spei@cs.uiowa.edu                                                  -->
   <!-- author cjolif@ilog.fr                                                     -->
  -<!-- version $Id: svggen.xml,v 1.5 2001/04/18 15:27:59 cjolif Exp $          -->      
  +<!-- version $Id: svggen.xml,v 1.6 2001/05/03 09:55:45 cjolif Exp $          -->      
   <!-- ========================================================================= -->
   <document>
       <header>
  @@ -187,25 +187,30 @@
     <anchor id="custom" />
     <s1 title="SVG Generator Customization">
     <p>
  -  In the previous section, we have seen that the SVG generation process can be customized to output
  -  SVG style as XML attributes or CSS inline properties. In this section we will talk about more 
  -  advanced customization possibilities.
  -  </p>
  -  <p>
  -  Instead of creating the <code>SVGGraphics2D</code> just by using the <code>Document</code> that will
  -  be used as a factory for creating the SVG elements, we can use the constructor that use an
  -  <code>SVGGeneratorContext</code> instance. By providing your own <code>SVGGeneratorContext</code>
  -  instance, you will be able to do advanced customization.
  -  </p>
  -  <!-- several examples : styling, 2 (to be done), 3 (to be done) -->
  -  <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.
  +   In the previous section, we have just seen that the SVG generation process can be customized to output SVG style as XML attributes or CSS inline properties. In this section we will talk about some examples of more advanced customizations.
     </p>
  +  <p>
  +         Instead of creating the <code>SVGGraphics2D</code> just by using the <code>Document</code> that will be used as a factory for creating the SVG elements, we can use the constructor that use an <code>SVGGeneratorContext</code> instance. By providing your own <code>SVGGeneratorContext</code> instance, you will be able to do advanced customization. You will find below three examples of possible customizations.
  +  </p>
  +  <s2 title="Have your own comment in the generated SVG file">
  +  <p>
  +  We begin with the simpliest possible example. If you integrate the Batik SVG generator in your own Java application, you may want to specialize the comment generated in the XML code. You can proceed as below.
  +  </p>
     <source>
   
  +SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
  +ctx.setComment("Generated by FooApplication with Batik SVG Generator");
  +SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
  +  </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.
  +  </p>
  +  <source>
  +
   public class StyleSheetStyleHandler {
       private CDATASection styleSheet;
       // Build the handler with a reference to the StyleSheet section
  @@ -225,17 +230,19 @@
               styleSheet.appendData(key+":"+value+";");
           }
           styleSheet.appendData("}\n");
  -	// reference the class id of the style sheet on the element to be styled
  +	// reference the class id of the style sheet on the element to 
  +	// be styled
           element.setAttribute("class", id);
       }
   }</source>
  -  <p>Then you can create and use an <code>SVGGraphics2D</code> with a correctly configured 
  -  <code>SVGGeneratorContext</code>.
  +  <p>
  +           Then you can create and use an <code>SVGGraphics2D</code> with a correctly configured 
  +	   <code>SVGGeneratorContext</code>.
     </p>
     <source>
   
   // configure the SVGGraphics2D for a given Document myFactory
  -SVGGeneratorContext ctx = new SVGGeneratorContext(myFactory);
  +SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
   CDATASection styleSheet = myFactory.createCDATASection("");
   ctx.setStyleHandler(new StyleSheetStyleHandler(styleSheet));
   SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
  @@ -245,7 +252,8 @@
   // add a style sheet to the definition section
   Element root = g2d.getRoot();
   Element defs = root.getElementById(SVGSyntax.ID_PREFIX_GENERIC_DEFS);
  -Element style = myFactory.createElementNS(SVGSyntax.SVG_NAMESPACE_URI, SVGSyntax.SVG_STYLE_TAG);
  +Element style = myFactory.createElementNS(SVGSyntax.SVG_NAMESPACE_URI, 
  +                                          SVGSyntax.SVG_STYLE_TAG);
   style.setAttributeNS(null, SVGSyntax.SVG_TYPE_ATTRIBUTE, "text/css");
   style.appendChild(styleSheet);
   defs.appendChild(style);
  @@ -254,6 +262,73 @@
   g2d.stream(root, myWriter);
   
     </source>
  +  </s2>
  +  <s2 title="Extending Paint object to SVG element translation">
  +  <p>
  +          The <code>SVGGraphics2D</code> is able to generate SVG elements for generic Java 2D objects, but you sometimes have your own classes such as implementations of the Java 2D <code>java.awt.Paint</code> interface. In this case, you will need to write an <code>ExtensionHandler</code> that you will set on your <code>SVGGeneratorContext</code>.
  +  </p>
  +  <p>
  +          In the following example we define the first draft of an <code>ExtensionHandler</code> allowing to translate a Batik implementation of the <code>java.awt.Paint</code> interface named <code>org.apache.batik.ext.awt.LinearGradientPaint</code>. 
  +  </p>
  +  <source>
  +  class SubExtensionHandler extends DefaultExtensionHandler 
  +  {
  +    public SVGPaintDescriptor handlePaint(Paint paint,
  +                                          SVGGeneratorContext generatorCtx) 
  +    {
  +      if (paint instanceof LinearGradientPaint) {
  +          LinearGradientPaint gradient = (LinearGradientPaint)paint;
  +	  String id = generatorCtx.getIDGenerator().generateID("gradient");
  +          Element grad = generatorCtx.getDOMFactory().
  +               createElementNS(SVGSyntax.SVG_NAMESPACE_URI, 
  +                               SVGSyntax.SVG_LINEAR_GRADIENT_TAG);
  +          grad.setAttributeNS(null, SVGSyntax.SVG_ID_ATTRIBUTE, ref);
  +          grad.setAttributeNS(null, 
  +	                      SVGSyntax.SVG_GRADIENT_UNITS_ATTRIBUTE, 
  +	                      SVGSyntax.SVG_USER_SPACE_ON_USE_VALUE);
  +          Point2D pt = gradient.getStartPoint();
  +          grad.setAttributeNS(null, "x1", pt.getX());
  +          grad.setAttributeNS(null, "y1", pt.getY());
  +          pt = gradient.getEndPoint();
  +          grad.setAttributeNS(null, "x2", pt.getX());
  +          grad.setAttributeNS(null, "y2", pt.getY());
  +          switch (gradient.getCycleMethod()) {
  +           case MultipleGradientPaint.REFLECT:
  +	     grad.setAttributeNS(null, 
  +	                         SVGSyntax.SVG_SPREAD_METHOD_ATTRIBUTE,
  +	                         SVGSyntax.SVG_REFLECT_VALUE);
  +	   break;
  +           case MultipleGradientPaint.REPEAT:
  +	     grad.setAttributeNS(null, 
  +	                         SVGSyntax.SVG_SPREAD_METHOD_ATTRIBUTE,
  +	                         SVGSyntax.SVG_REPEAT_VALUE);
  +	   break;
  +	   // pad is the default...
  +          }
  +
  +	  // here we should write the transform of the gradient
  +	  // in the transform attribute.
  +
  +	  // here we should write the stops of the gradients as 
  +	  // children elements.
  +
  +	  return new SVGPaintDescriptor("url(#"+ref+")", 
  +	                                SVGSyntax.SVG_OPAQUE_VALUE, grad);
  +      } else
  +        return null; // let the default mechanism do its job
  +    }
  +  }
  +
  +  </source>
  +  <p>
  +You should then set it on the <code>SVGGeneratorContext</code> by using the <code>setExtensionHandler</code> method.
  +  </p>
  +  <source>
  +
  +SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
  +ctx.setExtensionHandler(new SubExtensionHandler());
  +SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);</source>
  +  </s2>
     </s1>
       </body>
   </document>
  
  
  

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