xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r840735 [2/19] - in /websites/staging/xmlgraphics/trunk/content: ./ batik/ batik/dev/ batik/tools/ batik/using/ batik/using/scripting/ commons/ fop/ fop/0.95/ fop/1.0/ fop/1.1/ fop/trunk/
Date Tue, 04 Dec 2012 15:59:44 GMT
Modified: websites/staging/xmlgraphics/trunk/content/batik/using/dom-api.html
==============================================================================
--- websites/staging/xmlgraphics/trunk/content/batik/using/dom-api.html (original)
+++ websites/staging/xmlgraphics/trunk/content/batik/using/dom-api.html Tue Dec  4 15:59:34 2012
@@ -168,73 +168,96 @@ $(document).ready(function () {
       	<!-- <div id="breadcrumb"><a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/batik/">Batik</a>&nbsp;&raquo&nbsp;<a href="/batik/using/">Using</a></div> -->
       	<div class="section-content"><h1 id="svg-dom-api">SVG DOM API</h1>
 <p>The <a href="http://www.w3.org/dom/">Document Object Model</a> (DOM) is an API for XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated. This page shows how to create an SVG document using the DOM API.</p>
-<h2 id="getting-started-wzxhzdk1wzxhzdk2">Getting started <a id="gettingStarted"></a></h2>
+<h2 id="getting-started-wzxhzdk5wzxhzdk6">Getting started <a id="gettingStarted"></a></h2>
 <p>The DOM API defines an interface called <a href="http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/DOMImplementation.html">DOMImplementation</a> , which represents the bootstrap of any DOM implementation. The role of this class is to bootstrap a particular implementation of the DOM by providing a method to create a <a href="http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/Document.html">Document</a> . Then, the concrete <code>Document</code> represents an XML document and also acts like a factory for the various DOM objects such as <a href="http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/Element.html">Element</a> , <a href="http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/Attr.html">Attr</a> and <a href="http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/Text.html">Text</a> .</p>
-<p>How to get an instance of the <code>DOMImplementation</code> interface depends on the DOM implementation you are using. In Batik, the DOM implementation is located in the package <code>org.apache.batik.dom.svg</code> and the class is named <a href="http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/dom/svg/SVGDOMImplementation.html">SVGDOMImplementation</a> . The following example shows how to get a concrete <code>DOMImplementation</code> object.
-import org.w3c.dom.DOMImplementation;
-import org.apache.batik.dom.svg.SVGDOMImplementation;</p>
-<p>DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
-Once you have an instance of a <code>DOMImplementation</code> , you are not relying on Batik-specific code any more and ready to use the DOM API.</p>
-<h2 id="creating-a-document-wzxhzdk3wzxhzdk4">Creating a Document <a id="creating"></a></h2>
-<p>Using the <code>DOMImplementation</code> , you are now able to create a <code>Document</code> . The following example illustrates how to create an SVG document. Note that the Batik’s DOM implementation can be used to represent either an SVG document fragment or any kind of XML document. Note that by choosing the namespace URI and the local name of the root element of SVG, we are creating an SVG document.
-import org.apache.batik.dom.svg.SVGDOMImplementation;
-import org.w3c.dom.Document;</p>
-<p>// We are using a constant available on the SVGDOMImplementation,
-// but we could have used "http://www.w3.org/2000/svg".
-String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
-DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
-Document doc = impl.createDocument(svgNS, "svg", null);
-As we have created an SVG <code>Document</code> , we can cast this document to an <a href="../javadoc/org/w3c/dom/svg/SVGDocument.html">SVGDocument</a> (defined in the <code>org.w3c.dom.svg</code> package) if needed.</p>
-<h2 id="building-an-svg-document-wzxhzdk5wzxhzdk6">Building an SVG Document <a id="buildsvgdoc"></a></h2>
+<p>How to get an instance of the <code>DOMImplementation</code> interface depends on the DOM implementation you are using. In Batik, the DOM implementation is located in the package <code>org.apache.batik.dom.svg</code> and the class is named <a href="http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/dom/svg/SVGDOMImplementation.html">SVGDOMImplementation</a> . The following example shows how to get a concrete <code>DOMImplementation</code> object.</p>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">org.w3c.dom.DOMImplementation</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.batik.dom.svg.SVGDOMImplementation</span><span class="o">;</span>
+
+<span class="n">DOMImplementation</span> <span class="n">impl</span> <span class="o">=</span> <span class="n">SVGDOMImplementation</span><span class="o">.</span><span class="na">getDOMImplementation</span><span class="o">();</span>
+</pre></div>
+
+
+<p>Once you have an instance of a <code>DOMImplementation</code> , you are not relying on Batik-specific code any more and ready to use the DOM API.</p>
+<h2 id="creating-a-document-wzxhzdk7wzxhzdk8">Creating a Document <a id="creating"></a></h2>
+<p>Using the <code>DOMImplementation</code> , you are now able to create a <code>Document</code> . The following example illustrates how to create an SVG document. Note that the Batik’s DOM implementation can be used to represent either an SVG document fragment or any kind of XML document. Note that by choosing the namespace URI and the local name of the root element of SVG, we are creating an SVG document.</p>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">org.apache.batik.dom.svg.SVGDOMImplementation</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.w3c.dom.Document</span><span class="o">;</span>
+
+<span class="c1">// We are using a constant available on the SVGDOMImplementation,</span>
+<span class="c1">// but we could have used &quot;http://www.w3.org/2000/svg&quot;.</span>
+<span class="n">String</span> <span class="n">svgNS</span> <span class="o">=</span> <span class="n">SVGDOMImplementation</span><span class="o">.</span><span class="na">SVG_NAMESPACE_URI</span><span class="o">;</span>
+<span class="n">DOMImplementation</span> <span class="n">impl</span> <span class="o">=</span> <span class="n">SVGDOMImplementation</span><span class="o">.</span><span class="na">getDOMImplementation</span><span class="o">();</span>
+<span class="n">Document</span> <span class="n">doc</span> <span class="o">=</span> <span class="n">impl</span><span class="o">.</span><span class="na">createDocument</span><span class="o">(</span><span class="n">svgNS</span><span class="o">,</span> <span class="s">&quot;svg&quot;</span><span class="o">,</span> <span class="kc">null</span><span class="o">);</span>
+</pre></div>
+
+
+<p>As we have created an SVG <code>Document</code> , we can cast this document to an <a href="../javadoc/org/w3c/dom/svg/SVGDocument.html">SVGDocument</a> (defined in the <code>org.w3c.dom.svg</code> package) if needed.</p>
+<h2 id="building-an-svg-document-wzxhzdk9wzxhzdk10">Building an SVG Document <a id="buildsvgdoc"></a></h2>
 <p>Finally, using the <code>Document</code> object, we are now able to construct SVG content. Note that the document created before supports both generic XML and SVG. Though the DOM implementation of Batik is an SVG DOM implementation, the SVG-specific methods that rely on the document having been rendered (particularly geometry related methods, such as <a href="../javadoc/org/w3c/dom/svg/SVGLocatable.html#getBBox()">SVGLocatable.getBBox</a> ) cannot be used at this point.</p>
 <p>The document can be built using DOM Level 2 Core methods. The following example shows how to create a red rectangle located at (10, 20), with a size of (100, 50) placed in a (400, 450) SVG canvas:</p>
-<p>import org.apache.batik.dom.svg.SVGDOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;</p>
-<p>DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
-String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
-Document doc = impl.createDocument(svgNS, "svg", null);</p>
-<p>// Get the root element (the 'svg' element).
-Element svgRoot = doc.getDocumentElement();</p>
-<p>// Set the width and height attributes on the root 'svg' element.
-svgRoot.setAttributeNS(null, "width", "400");
-svgRoot.setAttributeNS(null, "height", "450");</p>
-<p>// Create the rectangle.
-Element rectangle = doc.createElementNS(svgNS, "rect");
-rectangle.setAttributeNS(null, "x", "10");
-rectangle.setAttributeNS(null, "y", "20");
-rectangle.setAttributeNS(null, "width", "100");
-rectangle.setAttributeNS(null, "height", "50");
-rectangle.setAttributeNS(null, "fill", "red");</p>
-<p>// Attach the rectangle to the root 'svg' element.
-svgRoot.appendChild(rectangle);
-The example given constructs a document equivalent to parsing the following SVG file:</p>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">org.apache.batik.dom.svg.SVGDOMImplementation</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.w3c.dom.Document</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.w3c.dom.Element</span><span class="o">;</span>
+
+<span class="n">DOMImplementation</span> <span class="n">impl</span> <span class="o">=</span> <span class="n">SVGDOMImplementation</span><span class="o">.</span><span class="na">getDOMImplementation</span><span class="o">();</span>
+<span class="n">String</span> <span class="n">svgNS</span> <span class="o">=</span> <span class="n">SVGDOMImplementation</span><span class="o">.</span><span class="na">SVG_NAMESPACE_URI</span><span class="o">;</span>
+<span class="n">Document</span> <span class="n">doc</span> <span class="o">=</span> <span class="n">impl</span><span class="o">.</span><span class="na">createDocument</span><span class="o">(</span><span class="n">svgNS</span><span class="o">,</span> <span class="s">&quot;svg&quot;</span><span class="o">,</span> <span class="kc">null</span><span class="o">);</span>
+
+<span class="c1">// Get the root element (the &#39;svg&#39; element).</span>
+<span class="n">Element</span> <span class="n">svgRoot</span> <span class="o">=</span> <span class="n">doc</span><span class="o">.</span><span class="na">getDocumentElement</span><span class="o">();</span>
+
+<span class="c1">// Set the width and height attributes on the root &#39;svg&#39; element.</span>
+<span class="n">svgRoot</span><span class="o">.</span><span class="na">setAttributeNS</span><span class="o">(</span><span class="kc">null</span><span class="o">,</span> <span class="s">&quot;width&quot;</span><span class="o">,</span> <span class="s">&quot;400&quot;</span><span class="o">);</span>
+<span class="n">svgRoot</span><span class="o">.</span><span class="na">setAttributeNS</span><span class="o">(</span><span class="kc">null</span><span class="o">,</span> <span class="s">&quot;height&quot;</span><span class="o">,</span> <span class="s">&quot;450&quot;</span><span class="o">);</span>
+
+<span class="c1">// Create the rectangle.</span>
+<span class="n">Element</span> <span class="n">rectangle</span> <span class="o">=</span> <span class="n">doc</span><span class="o">.</span><span class="na">createElementNS</span><span class="o">(</span><span class="n">svgNS</span><span class="o">,</span> <span class="s">&quot;rect&quot;</span><span class="o">);</span>
+<span class="n">rectangle</span><span class="o">.</span><span class="na">setAttributeNS</span><span class="o">(</span><span class="kc">null</span><span class="o">,</span> <span class="s">&quot;x&quot;</span><span class="o">,</span> <span class="s">&quot;10&quot;</span><span class="o">);</span>
+<span class="n">rectangle</span><span class="o">.</span><span class="na">setAttributeNS</span><span class="o">(</span><span class="kc">null</span><span class="o">,</span> <span class="s">&quot;y&quot;</span><span class="o">,</span> <span class="s">&quot;20&quot;</span><span class="o">);</span>
+<span class="n">rectangle</span><span class="o">.</span><span class="na">setAttributeNS</span><span class="o">(</span><span class="kc">null</span><span class="o">,</span> <span class="s">&quot;width&quot;</span><span class="o">,</span> <span class="s">&quot;100&quot;</span><span class="o">);</span>
+<span class="n">rectangle</span><span class="o">.</span><span class="na">setAttributeNS</span><span class="o">(</span><span class="kc">null</span><span class="o">,</span> <span class="s">&quot;height&quot;</span><span class="o">,</span> <span class="s">&quot;50&quot;</span><span class="o">);</span>
+<span class="n">rectangle</span><span class="o">.</span><span class="na">setAttributeNS</span><span class="o">(</span><span class="kc">null</span><span class="o">,</span> <span class="s">&quot;fill&quot;</span><span class="o">,</span> <span class="s">&quot;red&quot;</span><span class="o">);</span>
+
+<span class="c1">// Attach the rectangle to the root &#39;svg&#39; element.</span>
+<span class="n">svgRoot</span><span class="o">.</span><span class="na">appendChild</span><span class="o">(</span><span class="n">rectangle</span><span class="o">);</span>
+</pre></div>
+
+
+<p>The example given constructs a document equivalent to parsing the following SVG file:</p>
 <div class="codehilite"><pre><span class="nt">&lt;svg</span> <span class="na">xmlns=</span><span class="s">&quot;http://www.w3.org/2000/svg&quot;</span> <span class="na">width=</span><span class="s">&quot;400&quot;</span> <span class="na">height=</span><span class="s">&quot;450&quot;</span><span class="nt">&gt;</span>
     <span class="nt">&lt;rect</span> <span class="na">x=</span><span class="s">&quot;10&quot;</span> <span class="na">y=</span><span class="s">&quot;20&quot;</span> <span class="na">width=</span><span class="s">&quot;100&quot;</span> <span class="na">height=</span><span class="s">&quot;50&quot;</span> <span class="na">fill=</span><span class="s">&quot;red&quot;</span><span class="nt">/&gt;</span>
 <span class="nt">&lt;/svg&gt;</span>
 </pre></div>
 
 
-<h1 id="creating-a-document-from-an-svg-file-wzxhzdk7wzxhzdk8">Creating a Document from an SVG file <a id="createdocfromsvgfile"></a></h1>
-<p>With Batik, you can also create an SVG DOM tree from a URI, an <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/InputStream.html">InputStream</a> , or a <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/Reader.html">Reader</a> , using the <a href="../javadoc/org/apache/batik/dom/util/SAXDocumentFactory.html">SAXSVGDocumentFactory</a> . The following example illustrates how to create an SVG document from a URI using the <code>SAXSVGDocumentFactory</code> class.
-import java.io.IOException;</p>
-<p>import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
-import org.apache.batik.util.XMLResourceDescriptor;</p>
-<p>import org.w3c.dom.Document;</p>
-<p>try {
-    String parser = XMLResourceDescriptor.getXMLParserClassName();
-    SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
-    String uri = "http://www.example.org/diagram.svg";
-    Document doc = f.createDocument(uri);
-} catch (IOException ex) {
-    // ...
-}</p>
+<h1 id="creating-a-document-from-an-svg-file-wzxhzdk11wzxhzdk12">Creating a Document from an SVG file <a id="createdocfromsvgfile"></a></h1>
+<p>With Batik, you can also create an SVG DOM tree from a URI, an <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/InputStream.html">InputStream</a> , or a <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/Reader.html">Reader</a> , using the <a href="../javadoc/org/apache/batik/dom/util/SAXDocumentFactory.html">SAXSVGDocumentFactory</a> . The following example illustrates how to create an SVG document from a URI using the <code>SAXSVGDocumentFactory</code> class.</p>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">java.io.IOException</span><span class="o">;</span>
+
+<span class="kn">import</span> <span class="nn">org.apache.batik.dom.svg.SAXSVGDocumentFactory</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.batik.util.XMLResourceDescriptor</span><span class="o">;</span>
+
+<span class="kn">import</span> <span class="nn">org.w3c.dom.Document</span><span class="o">;</span>
+
+<span class="k">try</span> <span class="o">{</span>
+    <span class="n">String</span> <span class="n">parser</span> <span class="o">=</span> <span class="n">XMLResourceDescriptor</span><span class="o">.</span><span class="na">getXMLParserClassName</span><span class="o">();</span>
+    <span class="n">SAXSVGDocumentFactory</span> <span class="n">f</span> <span class="o">=</span> <span class="k">new</span> <span class="n">SAXSVGDocumentFactory</span><span class="o">(</span><span class="n">parser</span><span class="o">);</span>
+    <span class="n">String</span> <span class="n">uri</span> <span class="o">=</span> <span class="s">&quot;http://www.example.org/diagram.svg&quot;</span><span class="o">;</span>
+    <span class="n">Document</span> <span class="n">doc</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="na">createDocument</span><span class="o">(</span><span class="n">uri</span><span class="o">);</span>
+<span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">IOException</span> <span class="n">ex</span><span class="o">)</span> <span class="o">{</span>
+    <span class="c1">// ...</span>
+<span class="o">}</span>
+</pre></div>
+
+
 <p>As we have created an SVG <code>Document</code> , we can cast this document to an <code>SVGDocument</code> (defined in the <code>org.w3c.dom.svg</code> package) if needed.</p>
-<h2 id="rendering-an-svg-document-wzxhzdk9wzxhzdk10">Rendering an SVG Document <a id="rendering"></a></h2>
+<h2 id="rendering-an-svg-document-wzxhzdk13wzxhzdk14">Rendering an SVG Document <a id="rendering"></a></h2>
 <p>Batik provides several ways to use an SVG DOM tree. Two modules can be immediately used to render your SVG document.</p>
+<p>JSVGCanvas
+:
+The <a href="../javadoc/org/apache/batik/swing/JSVGCanvas.html">JSVGCanvas</a> is a Swing component that can display SVG document. A SVG document can be specified using a URI or an SVG DOM tree (using the <a href="../javadoc/org/apache/batik/swing/JSVGCanvas.html#setSVGDocument(Document)">setSVGDocument</a> method). For futher information about the <code>JSVGCanvas</code> , see the <a href="../using/swing.html">Swing components module documentation</a> .</p>
 <dl>
-<dt>JSVGCanvas</dt>
-<dd>The <a href="../javadoc/org/apache/batik/swing/JSVGCanvas.html">JSVGCanvas</a> is a Swing component that can display SVG document. A SVG document can be specified using a URI or an SVG DOM tree (using the <a href="../javadoc/org/apache/batik/swing/JSVGCanvas.html#setSVGDocument(Document)">setSVGDocument</a> method). For futher information about the <code>JSVGCanvas</code> , see the <a href="../using/swing.html">Swing components module documentation</a> .</dd>
 <dt>ImageTranscoder</dt>
 <dd>The <a href="../javadoc/org/apache/batik/transcoder/image/ImageTranscoder.html">ImageTranscoder</a> is a transcoder that can take a URI, an <code>InputStream</code> or an SVG DOM tree and produces a raster image (such JPEG, PNG or TIFF). By creating a <a href="../javadoc/org/apache/batik/transcoder/TranscoderInput.html">TranscoderInput</a> object with the SVG DOM tree, you will be able to transform your SVG content to a raster image. For futher information, see the <a href="../using/transcoder.html">transcoder module documentation</a> .</dd>
 </dl></div>

Modified: websites/staging/xmlgraphics/trunk/content/batik/using/parsers.html
==============================================================================
--- websites/staging/xmlgraphics/trunk/content/batik/using/parsers.html (original)
+++ websites/staging/xmlgraphics/trunk/content/batik/using/parsers.html Tue Dec  4 15:59:34 2012
@@ -172,75 +172,88 @@ $(document).ready(function () {
 <p>In the parser module, each microsyntax is supported by a pair of classes: a parser and a handler. The parser is a class that implements the <a href="../javadoc/org/apache/batik/parser/Parser.html">Parser</a> interface, which has methods to parse values from a <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/Reader.html">Reader</a> or a <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html">String</a> . The handler is an interface specific to the microsyntax that will have its methods called whenever the corresponding element in the input is parsed. For those handler interfaces that have more than one method, adapter classes are provided (named <code>Default</code> *).</p>
 <p>Parsers can also have an error handler associated with them, whose single method <code>error</code> will be called when there is a problem parsing the input. If an error handler is not associated with a parser, a <a href="../javadoc/org/apache/batik/parser/ParseException.html">ParseException</a> will be thrown if an error occurs.</p>
 <p>The microsyntaxes supported by the parser module are:</p>
-<dl>
-<dt>Angles</dt>
-<dd>Implemented by <a href="../javadoc/org/apache/batik/parser/AngleParser.html">AngleParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/AngleHandler.html">AngleHandler</a> . This parser is used for parsing angles formed by a floating point number followed by <code>deg</code> , <code>grad</code> or <code>rad</code> . It is not currently used by the rest of the Batik codebase.</dd>
-<dt>Clock values</dt>
-<dd>Implemented by <a href="../javadoc/org/apache/batik/parser/ClockParser.html">ClockParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/ClockHandler.html">ClockHandler</a> . This parser is used for parsing SMIL <a href="http://www.w3.org/TR/smil-animation/#Timing-ClockValueSyntax">clock values</a> .</dd>
-<dt>Fragment identifiers</dt>
-<dd>Implemented by <a href="../javadoc/org/apache/batik/parser/FragmentIdentifierParser.html">FragmentIdentifierParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/FragmentIdentifierHandler.html">FragmentIdentifierHandler</a> . This parser is used for parsing the various formats of <a href="http://www.w3.org/TR/SVG11/linking.html#SVGFragmentIdentifiers">fragment identifier</a> that SVG allows.</dd>
-<dt>Lengths</dt>
-<dd>Implemented by <a href="../javadoc/org/apache/batik/parser/LengthParser.html">LengthParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/LengthHandler.html">LengthHandler</a> . This parser is used for parsing SVG length values.</dd>
-<dt>Length lists</dt>
-<dd>Implemented by <a href="../javadoc/org/apache/batik/parser/LengthListParser.html">LengthListParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/LengthListHandler.html">LengthListHandler</a> . This parser is used for parsing lists of comma or space separated SVG lengths.</dd>
-<dt>Numbers</dt>
-<dd>Implemented by <a href="../javadoc/org/apache/batik/parser/NumberListParser.html">NumberListParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/NumberListHandler.html">NumberListHandler</a> . This parser is used for parsing SVG number values.</dd>
-<dt>Number lists</dt>
-<dd>Implemented by <a href="../javadoc/org/apache/batik/parser/NumberListParser.html">NumberListParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/NumberListHandler.html">NumberListHandler</a> . This parser is used for parsing lists of comma or space separated SVG numbers.</dd>
-<dt>Path data</dt>
-<dd>Implemented by <a href="../javadoc/org/apache/batik/parser/PathParser.html">PathParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/PathHandler.html">PathHandler</a> . This parser is used for parsing SVG path data, as found in <code>path</code> element <code>d</code> attributes.</dd>
-<dt>Points</dt>
-<dd>Implemented by <a href="../javadoc/org/apache/batik/parser/PointsParser.html">PointsParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/PointsHandler.html">PointsHandler</a> . This parser is used for parsing point lists, as found in <code>polygon</code> element <code>points</code> attributes.</dd>
-<dt>Preserve aspect ratio values</dt>
-<dd>Implemented by <a href="../javadoc/org/apache/batik/parser/PreserveAspectRatioParser.html">PreserveAspectRatioParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/PreserveAspectRatioHandler.html">PreserveAspectRatioHandler</a> . This parser is used for parsing the values found in the <code>preserveAspectRatio</code> attribute of <code>svg</code> elements.</dd>
-<dt>Transform lists</dt>
-<dd>Implemented by <a href="../javadoc/org/apache/batik/parser/TransformListParser.html">TransformListParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/TransformListHandler.html">TransformListHandler</a> . This parser is used for parsing transform lists, as found in the <code>transform</code> attribute of any transformable element.</dd>
-</dl>
+<p>Angles
+:
+Implemented by <a href="../javadoc/org/apache/batik/parser/AngleParser.html">AngleParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/AngleHandler.html">AngleHandler</a> . This parser is used for parsing angles formed by a floating point number followed by <code>deg</code> , <code>grad</code> or <code>rad</code> . It is not currently used by the rest of the Batik codebase.</p>
+<p>Clock values
+:
+Implemented by <a href="../javadoc/org/apache/batik/parser/ClockParser.html">ClockParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/ClockHandler.html">ClockHandler</a> . This parser is used for parsing SMIL <a href="http://www.w3.org/TR/smil-animation/#Timing-ClockValueSyntax">clock values</a> .</p>
+<p>Fragment identifiers
+:
+Implemented by <a href="../javadoc/org/apache/batik/parser/FragmentIdentifierParser.html">FragmentIdentifierParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/FragmentIdentifierHandler.html">FragmentIdentifierHandler</a> . This parser is used for parsing the various formats of <a href="http://www.w3.org/TR/SVG11/linking.html#SVGFragmentIdentifiers">fragment identifier</a> that SVG allows.</p>
+<p>Lengths
+:
+Implemented by <a href="../javadoc/org/apache/batik/parser/LengthParser.html">LengthParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/LengthHandler.html">LengthHandler</a> . This parser is used for parsing SVG length values.</p>
+<p>Length lists
+:
+Implemented by <a href="../javadoc/org/apache/batik/parser/LengthListParser.html">LengthListParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/LengthListHandler.html">LengthListHandler</a> . This parser is used for parsing lists of comma or space separated SVG lengths.</p>
+<p>Numbers
+:
+Implemented by <a href="../javadoc/org/apache/batik/parser/NumberListParser.html">NumberListParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/NumberListHandler.html">NumberListHandler</a> . This parser is used for parsing SVG number values.</p>
+<p>Number lists
+:
+Implemented by <a href="../javadoc/org/apache/batik/parser/NumberListParser.html">NumberListParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/NumberListHandler.html">NumberListHandler</a> . This parser is used for parsing lists of comma or space separated SVG numbers.</p>
+<p>Path data
+:
+Implemented by <a href="../javadoc/org/apache/batik/parser/PathParser.html">PathParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/PathHandler.html">PathHandler</a> . This parser is used for parsing SVG path data, as found in <code>path</code> element <code>d</code> attributes.</p>
+<p>Points
+:
+Implemented by <a href="../javadoc/org/apache/batik/parser/PointsParser.html">PointsParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/PointsHandler.html">PointsHandler</a> . This parser is used for parsing point lists, as found in <code>polygon</code> element <code>points</code> attributes.</p>
+<p>Preserve aspect ratio values
+:
+Implemented by <a href="../javadoc/org/apache/batik/parser/PreserveAspectRatioParser.html">PreserveAspectRatioParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/PreserveAspectRatioHandler.html">PreserveAspectRatioHandler</a> . This parser is used for parsing the values found in the <code>preserveAspectRatio</code> attribute of <code>svg</code> elements.</p>
+<p>Transform lists
+:
+Implemented by <a href="../javadoc/org/apache/batik/parser/TransformListParser.html">TransformListParser</a> , handled with <a href="../javadoc/org/apache/batik/parser/TransformListHandler.html">TransformListHandler</a> . This parser is used for parsing transform lists, as found in the <code>transform</code> attribute of any transformable element.</p>
 <p>Some microsyntaxes also have a corresponding producer class, which is an implementation of the handler interface that generates an object while parsing.</p>
 <h2 id="examples-wzxhzdk4wzxhzdk5">Examples <a id="examples"></a></h2>
-<p>The following example code demonstrates how to use the parser classes to parse a list of points:
-import java.awt.geom.Point2D;
-import java.util.LinkedList;
-import java.util.List;</p>
-<p>import org.apache.batik.parser.DefaultPointsHandler;
-import org.apache.batik.parser.ParseException;
-import org.apache.batik.parser.PointsHandler;
-import org.apache.batik.parser.PointsParser;</p>
-<p>public class PointsParserExample {</p>
-<div class="codehilite"><pre><span class="n">public</span> <span class="n">List</span> <span class="n">extractPoints</span><span class="p">(</span><span class="n">String</span> <span class="n">s</span><span class="p">)</span> <span class="n">throws</span> <span class="n">ParseException</span> <span class="p">{</span>
-    <span class="n">final</span> <span class="n">LinkedList</span> <span class="n">points</span> <span class="o">=</span> <span class="k">new</span> <span class="n">LinkedList</span><span class="p">();</span>
-    <span class="n">PointsParser</span> <span class="n">pp</span> <span class="o">=</span> <span class="k">new</span> <span class="n">PointsParser</span><span class="p">();</span>
-    <span class="n">PointsHandler</span> <span class="n">ph</span> <span class="o">=</span> <span class="k">new</span> <span class="n">DefaultPointsHandler</span><span class="p">()</span> <span class="p">{</span>
-        <span class="n">public</span> <span class="n">void</span> <span class="n">point</span><span class="p">(</span><span class="n">float</span> <span class="n">x</span><span class="p">,</span> <span class="n">float</span> <span class="n">y</span><span class="p">)</span> <span class="n">throws</span> <span class="n">ParseException</span> <span class="p">{</span>
-            <span class="n">Point2D</span> <span class="n">p</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Point2D</span><span class="o">.</span><span class="n">Float</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">);</span>
-            <span class="n">points</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">p</span><span class="p">);</span>
-        <span class="p">}</span>
-    <span class="p">};</span>
-    <span class="n">pp</span><span class="o">.</span><span class="n">setPointsHandler</span><span class="p">(</span><span class="n">ph</span><span class="p">);</span>
-    <span class="n">pp</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">s</span><span class="p">);</span>
-    <span class="k">return</span> <span class="n">points</span><span class="p">;</span>
-<span class="p">}</span>
+<p>The following example code demonstrates how to use the parser classes to parse a list of points:</p>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">java.awt.geom.Point2D</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">java.util.LinkedList</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span>
+
+<span class="kn">import</span> <span class="nn">org.apache.batik.parser.DefaultPointsHandler</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.batik.parser.ParseException</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.batik.parser.PointsHandler</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.batik.parser.PointsParser</span><span class="o">;</span>
+
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">PointsParserExample</span> <span class="o">{</span>
+
+    <span class="kd">public</span> <span class="n">List</span> <span class="nf">extractPoints</span><span class="o">(</span><span class="n">String</span> <span class="n">s</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">ParseException</span> <span class="o">{</span>
+        <span class="kd">final</span> <span class="n">LinkedList</span> <span class="n">points</span> <span class="o">=</span> <span class="k">new</span> <span class="n">LinkedList</span><span class="o">();</span>
+        <span class="n">PointsParser</span> <span class="n">pp</span> <span class="o">=</span> <span class="k">new</span> <span class="n">PointsParser</span><span class="o">();</span>
+        <span class="n">PointsHandler</span> <span class="n">ph</span> <span class="o">=</span> <span class="k">new</span> <span class="n">DefaultPointsHandler</span><span class="o">()</span> <span class="o">{</span>
+            <span class="kd">public</span> <span class="kt">void</span> <span class="nf">point</span><span class="o">(</span><span class="kt">float</span> <span class="n">x</span><span class="o">,</span> <span class="kt">float</span> <span class="n">y</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">ParseException</span> <span class="o">{</span>
+                <span class="n">Point2D</span> <span class="n">p</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Point2D</span><span class="o">.</span><span class="na">Float</span><span class="o">(</span><span class="n">x</span><span class="o">,</span> <span class="n">y</span><span class="o">);</span>
+                <span class="n">points</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">p</span><span class="o">);</span>
+            <span class="o">}</span>
+        <span class="o">};</span>
+        <span class="n">pp</span><span class="o">.</span><span class="na">setPointsHandler</span><span class="o">(</span><span class="n">ph</span><span class="o">);</span>
+        <span class="n">pp</span><span class="o">.</span><span class="na">parse</span><span class="o">(</span><span class="n">s</span><span class="o">);</span>
+        <span class="k">return</span> <span class="n">points</span><span class="o">;</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
 
 
-<p>}
-This example uses the <a href="../javadoc/org/apache/batik/parser/AWTTransformProducer.html">AWTTransformProducer</a> class to generate an <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/awt/geom/AffineTransform.html">AffineTransform</a> object from an SVG transform list:
-import java.awt.geom.AffineTransform;</p>
-<p>import org.apache.batik.parser.AWTTransformProducer;
-import org.apache.batik.parser.ParseException;
-import org.apache.batik.parser.TransformListParser;</p>
-<p>public class TransformParserExample {</p>
-<div class="codehilite"><pre><span class="n">public</span> <span class="n">AffineTransform</span> <span class="n">parseTransformList</span><span class="p">(</span><span class="n">String</span> <span class="n">s</span><span class="p">)</span> <span class="n">throws</span> <span class="n">ParseException</span> <span class="p">{</span>
-    <span class="n">TransformListParser</span> <span class="n">p</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TransformListParser</span><span class="p">();</span>
-    <span class="n">AWTTransformProducer</span> <span class="n">tp</span> <span class="o">=</span> <span class="k">new</span> <span class="n">AWTTransformProducer</span><span class="p">();</span>
-    <span class="n">p</span><span class="o">.</span><span class="n">setTransformListHandler</span><span class="p">(</span><span class="n">tp</span><span class="p">);</span>
-    <span class="n">p</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">s</span><span class="p">);</span>
-    <span class="k">return</span> <span class="n">tp</span><span class="o">.</span><span class="n">getAffineTransform</span><span class="p">();</span>
-<span class="p">}</span>
-</pre></div>
-
+<p>This example uses the <a href="../javadoc/org/apache/batik/parser/AWTTransformProducer.html">AWTTransformProducer</a> class to generate an <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/awt/geom/AffineTransform.html">AffineTransform</a> object from an SVG transform list:</p>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">java.awt.geom.AffineTransform</span><span class="o">;</span>
 
-<p>}</p></div>
+<span class="kn">import</span> <span class="nn">org.apache.batik.parser.AWTTransformProducer</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.batik.parser.ParseException</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.batik.parser.TransformListParser</span><span class="o">;</span>
+
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">TransformParserExample</span> <span class="o">{</span>
+
+    <span class="kd">public</span> <span class="n">AffineTransform</span> <span class="nf">parseTransformList</span><span class="o">(</span><span class="n">String</span> <span class="n">s</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">ParseException</span> <span class="o">{</span>
+        <span class="n">TransformListParser</span> <span class="n">p</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TransformListParser</span><span class="o">();</span>
+        <span class="n">AWTTransformProducer</span> <span class="n">tp</span> <span class="o">=</span> <span class="k">new</span> <span class="n">AWTTransformProducer</span><span class="o">();</span>
+        <span class="n">p</span><span class="o">.</span><span class="na">setTransformListHandler</span><span class="o">(</span><span class="n">tp</span><span class="o">);</span>
+        <span class="n">p</span><span class="o">.</span><span class="na">parse</span><span class="o">(</span><span class="n">s</span><span class="o">);</span>
+        <span class="k">return</span> <span class="n">tp</span><span class="o">.</span><span class="na">getAffineTransform</span><span class="o">();</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div></div>
       </div>
       
       <div class="clear"></div>

Modified: websites/staging/xmlgraphics/trunk/content/batik/using/scripting/ecmascript.html
==============================================================================
--- websites/staging/xmlgraphics/trunk/content/batik/using/scripting/ecmascript.html (original)
+++ websites/staging/xmlgraphics/trunk/content/batik/using/scripting/ecmascript.html Tue Dec  4 15:59:34 2012
@@ -174,7 +174,7 @@ $(document).ready(function () {
 <p>The first one is in the <code>script</code> element, where you can place any code, including function definitions, to be executed just before the document <code>SVGLoad</code> event is fired.</p>
 <div class="codehilite"><pre><span class="nt">&lt;svg</span> <span class="na">xmlns=</span><span class="s">&quot;http://www.w3.org/2000/svg&quot;</span> <span class="na">width=</span><span class="s">&quot;100&quot;</span> <span class="na">height=</span><span class="s">&quot;100&quot;</span><span class="nt">&gt;</span>
   <span class="nt">&lt;script</span> <span class="na">type=</span><span class="s">&quot;text/ecmascript&quot;</span><span class="nt">&gt;</span>
-    // ECMAScript code to be executed 
+    // ECMAScript code to be executed
   <span class="nt">&lt;/script&gt;</span>
 
   <span class="c">&lt;!-- Remainder of the document... --&gt;</span>
@@ -203,11 +203,11 @@ $(document).ready(function () {
 </ul>
 <h2 id="using-rhino-features-wzxhzdk8wzxhzdk9">Using Rhino features <a id="rhinoFeatures"></a></h2>
 <p>Rhino has a number of features beyond those supported by standard ECMAScript interpreters, and these can be used with Batik. One useful feature is that ECMAScript code can use Java classes and objects, and not just the standard ECMAScript primitive types and host objects exposed by Batik.</p>
-<p>To create an instance of a Java class from ECMAScript, you first need to import the package in which it resides. This is done using the <code>importPackage</code> global function that Rhino provides. For example, to import the <code>javax.swing.JFrame</code> class, you use:
-importPackage(Packages.javax.swing);
-This then exposes a global property for each class in the <code>javax.swing</code> package that you can use to create a new object of this class, similar to a <code>import javax.swing.*;</code> statement in Java. We can use the exposed <code>JFrame</code> property to create a new instance of this class:
-var frame = new JFrame("My test frame");
-Note how an ECMAScript string value is passed as the parameter to <code>JFrame</code> ’s constructor. Rhino will attempt to convert ECMAScript values into appropriate Java primitive types or objects to make underlying constructor or method calls. In this instance, the ECMAScript string value is converted into a <code>java.lang.String</code> object to be passed to the constructor.</p>
+<p>To create an instance of a Java class from ECMAScript, you first need to import the package in which it resides. This is done using the <code>importPackage</code> global function that Rhino provides. For example, to import the <code>javax.swing.JFrame</code> class, you use:</p>
+<p>importPackage(Packages.javax.swing);</p>
+<p>This then exposes a global property for each class in the <code>javax.swing</code> package that you can use to create a new object of this class, similar to a <code>import javax.swing.*;</code> statement in Java. We can use the exposed <code>JFrame</code> property to create a new instance of this class:</p>
+<p>var frame = new JFrame("My test frame");</p>
+<p>Note how an ECMAScript string value is passed as the parameter to <code>JFrame</code> ’s constructor. Rhino will attempt to convert ECMAScript values into appropriate Java primitive types or objects to make underlying constructor or method calls. In this instance, the ECMAScript string value is converted into a <code>java.lang.String</code> object to be passed to the constructor.</p>
 <p>Now that we have a reference to this Java object, we can call any method on it as we usually would from Java code. The following complete example demonstrates this, where clicking the green circle will pop up a frame:</p>
 <div class="codehilite"><pre><span class="nt">&lt;svg</span> <span class="na">xmlns=</span><span class="s">&quot;http://www.w3.org/2000/svg&quot;</span> <span class="na">width=</span><span class="s">&quot;100&quot;</span> <span class="na">height=</span><span class="s">&quot;100&quot;</span><span class="nt">&gt;</span>
   <span class="nt">&lt;circle</span> <span class="na">cx=</span><span class="s">&quot;50&quot;</span> <span class="na">cy=</span><span class="s">&quot;50&quot;</span> <span class="na">r=</span><span class="s">&quot;50&quot;</span> <span class="na">fill=</span><span class="s">&quot;green&quot;</span> <span class="na">onclick=</span><span class="s">&quot;showFrame()&quot;</span><span class="nt">/&gt;</span>
@@ -232,76 +232,76 @@ Note how an ECMAScript string value is p
 <h2 id="customizing-the-rhino-interpreter-wzxhzdk10wzxhzdk11">Customizing the Rhino interpreter <a id="customizingRhino"></a></h2>
 <p>A useful example of customization of the Rhino interpreter comes from the fact that the ECMAScript specification doesn’t provide any predefined I/O facilities to interact with the console. However, it is very common for ECMAScript compatible languages to provide a function named <code>print</code> to output messages to the console. We will describe here an example of cutomization of the Batik Rhino interpreter to add such functionality to it.</p>
 <p>You should first subclass the default Batik ECMAScript interpreter to add the functionality to it as below.</p>
-<div class="codehilite"><pre><span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">batik</span><span class="o">.</span><span class="n">script</span><span class="o">.</span><span class="n">rhino</span><span class="o">.</span><span class="n">RhinoInterpreter</span><span class="p">;</span>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">org.apache.batik.script.rhino.RhinoInterpreter</span><span class="o">;</span>
 
-<span class="nb">import</span> <span class="n">java</span><span class="o">.</span><span class="n">net</span><span class="o">.</span><span class="n">URL</span><span class="p">;</span>
+<span class="kn">import</span> <span class="nn">java.net.URL</span><span class="o">;</span>
 
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">mozilla</span><span class="o">.</span><span class="n">javascript</span><span class="o">.</span><span class="n">Context</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">mozilla</span><span class="o">.</span><span class="n">javascript</span><span class="o">.</span><span class="n">Function</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">mozilla</span><span class="o">.</span><span class="n">javascript</span><span class="o">.</span><span class="n">Scriptable</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">mozilla</span><span class="o">.</span><span class="n">javascript</span><span class="o">.</span><span class="n">ScriptableObject</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">mozilla</span><span class="o">.</span><span class="n">javascript</span><span class="o">.</span><span class="n">PropertyException</span><span class="p">;</span>
-
-<span class="n">public</span> <span class="n">class</span> <span class="n">ExtendedRhinoInterpreter</span> <span class="n">extends</span> <span class="n">RhinoInterpreter</span> <span class="p">{</span>
-
-    <span class="n">public</span> <span class="n">ExtendedRhinoInterpreter</span><span class="p">(</span><span class="n">URL</span> <span class="n">documentURL</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">super</span><span class="p">(</span><span class="n">documentURL</span><span class="p">);</span>
-
-        <span class="sr">//</span> <span class="n">Array</span> <span class="n">of</span> <span class="n">functions</span> <span class="n">to</span> <span class="n">put</span> <span class="n">in</span> <span class="n">the</span> <span class="n">global</span> <span class="n">object</span><span class="o">.</span>
-        <span class="n">final</span> <span class="n">String</span><span class="o">[]</span> <span class="n">names</span> <span class="o">=</span> <span class="p">{</span> <span class="s">&quot;print&quot;</span> <span class="p">}</span>
-        <span class="n">try</span> <span class="p">{</span>
-            <span class="sr">//</span> <span class="n">Add</span> <span class="n">the</span> <span class="n">functions</span> <span class="n">to</span> <span class="n">the</span> <span class="n">global</span> <span class="n">object</span><span class="o">.</span>
-            <span class="n">getGlobalObject</span><span class="p">()</span><span class="o">.</span><span class="n">defineFunctionProperties</span>
-                <span class="p">(</span><span class="n">names</span><span class="p">,</span> <span class="n">ExtendedRhinoInterpreter</span><span class="o">.</span><span class="n">class</span><span class="p">,</span>
-                 <span class="n">ScriptableObject</span><span class="o">.</span><span class="n">DONTENUM</span><span class="p">);</span>
-        <span class="p">}</span> <span class="n">catch</span> <span class="p">(</span><span class="n">PropertyException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
-            <span class="n">throw</span> <span class="k">new</span> <span class="n">Error</span><span class="p">(</span><span class="n">e</span><span class="p">);</span>
-        <span class="p">}</span>
-    <span class="p">}</span>
-
-    <span class="n">public</span> <span class="n">static</span> <span class="n">void</span> <span class="k">print</span><span class="p">(</span><span class="n">Context</span> <span class="n">cx</span><span class="p">,</span> <span class="n">Scriptable</span> <span class="n">thisObj</span><span class="p">,</span>
-                             <span class="n">Object</span><span class="o">[]</span> <span class="n">args</span><span class="p">,</span> <span class="n">Function</span> <span class="n">funObj</span><span class="p">)</span> <span class="p">{</span>
-        <span class="k">for</span> <span class="p">(</span><span class="nb">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">args</span><span class="o">.</span><span class="nb">length</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
-            <span class="k">if</span> <span class="p">(</span><span class="n">i</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
-                <span class="n">System</span><span class="o">.</span><span class="n">out</span><span class="o">.</span><span class="k">print</span><span class="p">(</span><span class="s">&quot; &quot;</span><span class="p">);</span>
-            <span class="p">}</span>
-
-            <span class="sr">//</span> <span class="n">Convert</span> <span class="n">the</span> <span class="n">ECMAScript</span> <span class="n">value</span> <span class="n">into</span> <span class="n">a</span> <span class="n">string</span> <span class="n">form</span><span class="o">.</span>
-            <span class="n">String</span> <span class="n">s</span> <span class="o">=</span> <span class="n">Context</span><span class="o">.</span><span class="n">toString</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="n">i</span><span class="p">]);</span>
-            <span class="n">System</span><span class="o">.</span><span class="n">out</span><span class="o">.</span><span class="k">print</span><span class="p">(</span><span class="n">s</span><span class="p">);</span>
-        <span class="p">}</span>
-        <span class="n">System</span><span class="o">.</span><span class="n">out</span><span class="o">.</span><span class="n">println</span><span class="p">();</span>
-    <span class="p">}</span>
-<span class="p">}</span>
+<span class="kn">import</span> <span class="nn">org.mozilla.javascript.Context</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.mozilla.javascript.Function</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.mozilla.javascript.Scriptable</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.mozilla.javascript.ScriptableObject</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.mozilla.javascript.PropertyException</span><span class="o">;</span>
+
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">ExtendedRhinoInterpreter</span> <span class="kd">extends</span> <span class="n">RhinoInterpreter</span> <span class="o">{</span>
+
+    <span class="kd">public</span> <span class="nf">ExtendedRhinoInterpreter</span><span class="o">(</span><span class="n">URL</span> <span class="n">documentURL</span><span class="o">)</span> <span class="o">{</span>
+        <span class="kd">super</span><span class="o">(</span><span class="n">documentURL</span><span class="o">);</span>
+
+        <span class="c1">// Array of functions to put in the global object.</span>
+        <span class="kd">final</span> <span class="n">String</span><span class="o">[]</span> <span class="n">names</span> <span class="o">=</span> <span class="o">{</span> <span class="s">&quot;print&quot;</span> <span class="o">}</span>
+        <span class="k">try</span> <span class="o">{</span>
+            <span class="c1">// Add the functions to the global object.</span>
+            <span class="n">getGlobalObject</span><span class="o">().</span><span class="na">defineFunctionProperties</span>
+                <span class="o">(</span><span class="n">names</span><span class="o">,</span> <span class="n">ExtendedRhinoInterpreter</span><span class="o">.</span><span class="na">class</span><span class="o">,</span>
+                 <span class="n">ScriptableObject</span><span class="o">.</span><span class="na">DONTENUM</span><span class="o">);</span>
+        <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">PropertyException</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span>
+            <span class="k">throw</span> <span class="k">new</span> <span class="nf">Error</span><span class="o">(</span><span class="n">e</span><span class="o">);</span>
+        <span class="o">}</span>
+    <span class="o">}</span>
+
+    <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">print</span><span class="o">(</span><span class="n">Context</span> <span class="n">cx</span><span class="o">,</span> <span class="n">Scriptable</span> <span class="n">thisObj</span><span class="o">,</span>
+                             <span class="n">Object</span><span class="o">[]</span> <span class="n">args</span><span class="o">,</span> <span class="n">Function</span> <span class="n">funObj</span><span class="o">)</span> <span class="o">{</span>
+        <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">args</span><span class="o">.</span><span class="na">length</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
+            <span class="k">if</span> <span class="o">(</span><span class="n">i</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="o">)</span> <span class="o">{</span>
+                <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">print</span><span class="o">(</span><span class="s">&quot; &quot;</span><span class="o">);</span>
+            <span class="o">}</span>
+
+            <span class="c1">// Convert the ECMAScript value into a string form.</span>
+            <span class="n">String</span> <span class="n">s</span> <span class="o">=</span> <span class="n">Context</span><span class="o">.</span><span class="na">toString</span><span class="o">(</span><span class="n">args</span><span class="o">[</span><span class="n">i</span><span class="o">]);</span>
+            <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">print</span><span class="o">(</span><span class="n">s</span><span class="o">);</span>
+        <span class="o">}</span>
+        <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">();</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
 
 
 <p>Now, you need to tell to Batik to use this interpreter instead of the default one. For that, you must first define a factory to create instances of your interpreter.</p>
-<div class="codehilite"><pre><span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">batik</span><span class="o">.</span><span class="n">script</span><span class="o">.</span><span class="n">Interpreter</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">batik</span><span class="o">.</span><span class="n">script</span><span class="o">.</span><span class="n">rhino</span><span class="o">.</span><span class="n">RhinoInterpreterFactory</span><span class="p">;</span>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">org.apache.batik.script.Interpreter</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.batik.script.rhino.RhinoInterpreterFactory</span><span class="o">;</span>
 
-<span class="n">public</span> <span class="n">class</span> <span class="n">ExtendedRhinoInterpreterFactory</span> <span class="n">extends</span> <span class="n">RhinoInterpreterFactory</span> <span class="p">{</span>
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">ExtendedRhinoInterpreterFactory</span> <span class="kd">extends</span> <span class="n">RhinoInterpreterFactory</span> <span class="o">{</span>
 
-    <span class="n">public</span> <span class="n">Interpreter</span> <span class="n">createInterpreter</span><span class="p">(</span><span class="n">URL</span> <span class="n">documentURL</span><span class="p">,</span> <span class="n">boolean</span> <span class="n">isSVG12</span><span class="p">)</span> <span class="p">{</span>
-        <span class="k">return</span> <span class="k">new</span> <span class="n">ExtendedRhinoInterpreter</span><span class="p">(</span><span class="n">documentURL</span><span class="p">);</span>
-    <span class="p">}</span>
-<span class="p">}</span>
+    <span class="kd">public</span> <span class="n">Interpreter</span> <span class="nf">createInterpreter</span><span class="o">(</span><span class="n">URL</span> <span class="n">documentURL</span><span class="o">,</span> <span class="kt">boolean</span> <span class="n">isSVG12</span><span class="o">)</span> <span class="o">{</span>
+        <span class="k">return</span> <span class="k">new</span> <span class="nf">ExtendedRhinoInterpreter</span><span class="o">(</span><span class="n">documentURL</span><span class="o">);</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
 
 
 <p>Then, you must build an <a href="../../javadoc/org/apache/batik/script/InterpreterPool.html">IntepreterPool</a> that will use this factory, and then set the pool on the <a href="../../javadoc/org/apache/batik/bridge/BridgeContext.html">BridgeContext</a> of your application.</p>
-<div class="codehilite"><pre><span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">batik</span><span class="o">.</span><span class="n">bridge</span><span class="o">.</span><span class="n">BridgeContext</span> <span class="n">ctx</span> <span class="o">=</span> <span class="o">...</span><span class="p">;</span>
-<span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">batik</span><span class="o">.</span><span class="n">script</span><span class="o">.</span><span class="n">InterpreterPool</span> <span class="n">pool</span> <span class="o">=</span>
-    <span class="k">new</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">batik</span><span class="o">.</span><span class="n">script</span><span class="o">.</span><span class="n">InterpreterPool</span><span class="p">();</span>
-<span class="n">InterpreterFactory</span> <span class="n">f</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ExtendedRhinoInterpreterFactory</span><span class="p">();</span>
-
-<span class="sr">//</span> <span class="n">Register</span> <span class="n">the</span> <span class="n">interpreter</span> <span class="n">factory</span> <span class="k">for</span> <span class="n">all</span> <span class="n">four</span> <span class="n">MIME</span> <span class="n">types</span> <span class="n">that</span>
-<span class="sr">//</span> <span class="n">Batik</span> <span class="n">normally</span> <span class="n">supports</span> <span class="k">for</span> <span class="n">ECMAScript</span><span class="o">.</span>
-<span class="n">pool</span><span class="o">.</span><span class="n">putInterpreterFactory</span><span class="p">(</span><span class="s">&quot;text/ecmascript&quot;</span><span class="p">,</span> <span class="n">f</span><span class="p">);</span>
-<span class="n">pool</span><span class="o">.</span><span class="n">putInterpreterFactory</span><span class="p">(</span><span class="s">&quot;text/javascript&quot;</span><span class="p">,</span> <span class="n">f</span><span class="p">);</span>
-<span class="n">pool</span><span class="o">.</span><span class="n">putInterpreterFactory</span><span class="p">(</span><span class="s">&quot;application/ecmascript&quot;</span><span class="p">,</span> <span class="n">f</span><span class="p">);</span>
-<span class="n">pool</span><span class="o">.</span><span class="n">putInterpreterFactory</span><span class="p">(</span><span class="s">&quot;application/javascript&quot;</span><span class="p">,</span> <span class="n">f</span><span class="p">);</span>
-<span class="n">ctx</span><span class="o">.</span><span class="n">setIntepreterPool</span><span class="p">(</span><span class="n">pool</span><span class="p">);</span>
+<div class="codehilite"><pre><span class="n">org</span><span class="o">.</span><span class="na">apache</span><span class="o">.</span><span class="na">batik</span><span class="o">.</span><span class="na">bridge</span><span class="o">.</span><span class="na">BridgeContext</span> <span class="n">ctx</span> <span class="o">=</span> <span class="o">...;</span>
+<span class="n">org</span><span class="o">.</span><span class="na">apache</span><span class="o">.</span><span class="na">batik</span><span class="o">.</span><span class="na">script</span><span class="o">.</span><span class="na">InterpreterPool</span> <span class="n">pool</span> <span class="o">=</span>
+    <span class="k">new</span> <span class="n">org</span><span class="o">.</span><span class="na">apache</span><span class="o">.</span><span class="na">batik</span><span class="o">.</span><span class="na">script</span><span class="o">.</span><span class="na">InterpreterPool</span><span class="o">();</span>
+<span class="n">InterpreterFactory</span> <span class="n">f</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ExtendedRhinoInterpreterFactory</span><span class="o">();</span>
+
+<span class="c1">// Register the interpreter factory for all four MIME types that</span>
+<span class="c1">// Batik normally supports for ECMAScript.</span>
+<span class="n">pool</span><span class="o">.</span><span class="na">putInterpreterFactory</span><span class="o">(</span><span class="s">&quot;text/ecmascript&quot;</span><span class="o">,</span> <span class="n">f</span><span class="o">);</span>
+<span class="n">pool</span><span class="o">.</span><span class="na">putInterpreterFactory</span><span class="o">(</span><span class="s">&quot;text/javascript&quot;</span><span class="o">,</span> <span class="n">f</span><span class="o">);</span>
+<span class="n">pool</span><span class="o">.</span><span class="na">putInterpreterFactory</span><span class="o">(</span><span class="s">&quot;application/ecmascript&quot;</span><span class="o">,</span> <span class="n">f</span><span class="o">);</span>
+<span class="n">pool</span><span class="o">.</span><span class="na">putInterpreterFactory</span><span class="o">(</span><span class="s">&quot;application/javascript&quot;</span><span class="o">,</span> <span class="n">f</span><span class="o">);</span>
+<span class="n">ctx</span><span class="o">.</span><span class="na">setIntepreterPool</span><span class="o">(</span><span class="n">pool</span><span class="o">);</span>
 </pre></div>
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Mime
View raw message