xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1416342 [1/2] - in /xmlgraphics/site/trunk/content/batik: dev/ tools/ using/ using/scripting/
Date Mon, 03 Dec 2012 03:49:12 GMT
Author: clay
Date: Mon Dec  3 03:49:09 2012
New Revision: 1416342

URL: http://svn.apache.org/viewvc?rev=1416342&view=rev
Log:
Updating (improving?) Markdown for Batik pages.

Modified:
    xmlgraphics/site/trunk/content/batik/dev/test.mdtext
    xmlgraphics/site/trunk/content/batik/tools/browser.mdtext
    xmlgraphics/site/trunk/content/batik/tools/font-converter.mdtext
    xmlgraphics/site/trunk/content/batik/tools/rasterizer.mdtext
    xmlgraphics/site/trunk/content/batik/using/architecture.mdtext
    xmlgraphics/site/trunk/content/batik/using/dom-api.mdtext
    xmlgraphics/site/trunk/content/batik/using/scripting/ecmascript.mdtext
    xmlgraphics/site/trunk/content/batik/using/scripting/java.mdtext
    xmlgraphics/site/trunk/content/batik/using/svg-generator.mdtext
    xmlgraphics/site/trunk/content/batik/using/swing.mdtext
    xmlgraphics/site/trunk/content/batik/using/transcoder.mdtext

Modified: xmlgraphics/site/trunk/content/batik/dev/test.mdtext
URL: http://svn.apache.org/viewvc/xmlgraphics/site/trunk/content/batik/dev/test.mdtext?rev=1416342&r1=1416341&r2=1416342&view=diff
==============================================================================
--- xmlgraphics/site/trunk/content/batik/dev/test.mdtext (original)
+++ xmlgraphics/site/trunk/content/batik/dev/test.mdtext Mon Dec  3 03:49:09 2012
@@ -250,18 +250,20 @@ Writing a new test involves either confi
 ### Adding a new test configuration <a id="Adding+a+new+test+configuration"></a>
 
 Imagine that you add a cool new test case to the `samples` directory, such as `linking-viewBox.svg` . In order to check for regressions on that file you can add the following entry:
-  <test id="anne.svg" class="org.apache.batik.test.svg.SVGRenderingAccuracyTest">
-    <arg class="java.net.URL" 
-        value="file:samples/tests/linkingViewBox.svg"/>
-    <arg class="java.net.URL" 
-         value="file:test-references/samples/tests/solaris/linkingViewBox.png"/>
-    <property name="VariationURL" 
-              class="java.net.URL" 
-              value="file:test-references/samples/tests/variation/linkingViewBox.png"/>
-    <property name="SaveVariation" 
-              class="java.io.File" 
-              value="test-references/samples/tests/variation-candidate/linkingViewBox.png"/>
-  </test>
+
+        <test id="anne.svg" class="org.apache.batik.test.svg.SVGRenderingAccuracyTest">
+                <arg class="java.net.URL" 
+                    value="file:samples/tests/linkingViewBox.svg"/>
+                <arg class="java.net.URL" 
+                     value="file:test-references/samples/tests/solaris/linkingViewBox.png"/>
+                <property name="VariationURL" 
+                          class="java.net.URL" 
+                          value="file:test-references/samples/tests/variation/linkingViewBox.png"/>
+                <property name="SaveVariation" 
+                          class="java.io.File" 
+                          value="test-references/samples/tests/variation-candidate/linkingViewBox.png"/>
+        </test>
+
 to the `test-resources/org/apache/batik/test/samplesRendering.xml` test suite description, the description of the regard test suite. If you have access to the build machine where the reference images are typically generated, you can check 0n the reference image in `test-references/samples/tests` . Otherwise (and this is OK), you can let the test fail the first time it is run on the build/test machine and that will be a reminder for whoever is responsible for that machine that a valid reference image should be checked in.
 
 ### Writing a new test <a id="Writing+a+new+test"></a>
@@ -269,18 +271,20 @@ to the `test-resources/org/apache/batik/
 Imagine you want to validate some aspect of your code, and let's take the bridge error handling as an example. You could create a new class in the `test-sources` directory, in `test-sources/org/apache/batik/bridge` in our example, and let's call it `ErrorHandlingTest` . To simplify the implementation of the `Test` interface, you can choose to derive from the `AbstractTest` class and generate a `DefaultTestReport` .
 
 While writing the `Test` you may want to use your own XML file with just your test, for example:
-  <testReportProcessor class="org.apache.batik.test.SimpleTestReportProcessor"/> 
 
-  <test class="org.apache.batik.bridge.ErrorHandlingTest">
-    <!-- Expected error code -->
-    <arg class="java.lang.String" value="expected.error.code"/>
-    <!-- Input SVG that this test manipulates to generate error conditions -->
-    <arg class="java.net.URL" value="file:test-resources/org/apache/batik/bridge/ErrorHandlingBase.svg"/>
-    <!-- Id of the element to test -->
-    <arg class="java.lang.String value="rectangle6"/>
-    <!-- Attribute to test -->
-    <arg class="java.lang.String value="x"/>
-    <!-- Value to test on the attribute -->
-    <arg class="java.lang.String value="abcd"/>
-  </test>
+        <testReportProcessor class="org.apache.batik.test.SimpleTestReportProcessor"/> 
+        
+        <test class="org.apache.batik.bridge.ErrorHandlingTest">
+            <!-- Expected error code -->
+            <arg class="java.lang.String" value="expected.error.code"/>
+            <!-- Input SVG that this test manipulates to generate error conditions -->
+            <arg class="java.net.URL" value="file:test-resources/org/apache/batik/bridge/ErrorHandlingBase.svg"/>
+            <!-- Id of the element to test -->
+            <arg class="java.lang.String value="rectangle6"/>
+            <!-- Attribute to test -->
+            <arg class="java.lang.String value="x"/>
+            <!-- Value to test on the attribute -->
+            <arg class="java.lang.String value="abcd"/>
+        </test>
+
 This is just an example and does not pretend to be the right way to go about implementing or specifying this specific type of test. Once done with tuning the test, one or multiple configurations for the test can be added to the relevant test suite’s XML description. In some cases, it will be interesting to create a separate test suite.

Modified: xmlgraphics/site/trunk/content/batik/tools/browser.mdtext
URL: http://svn.apache.org/viewvc/xmlgraphics/site/trunk/content/batik/tools/browser.mdtext?rev=1416342&r1=1416341&r2=1416342&view=diff
==============================================================================
--- xmlgraphics/site/trunk/content/batik/tools/browser.mdtext (original)
+++ xmlgraphics/site/trunk/content/batik/tools/browser.mdtext Mon Dec  3 03:49:09 2012
@@ -43,14 +43,14 @@ If you are using Mac OS X, and you have 
 
 ### Starting the browser for the source distribution <a id="starting-source"></a>
 
-If you downloaded the [source distribution](../install.html#distributions) of Batik, you should have a zip file called `batik-src-1.6.zip` (or similar) that expanded into a directory called `xml-batik` or<code>batik- *version* </code>. In that directory, you can find build scripts for the platform you are running on. For example, there is a `build.bat` script for users of the Windows platform and there is a `build.sh` script for UNIX users.
+If you downloaded the [source distribution](../install.html#distributions) of Batik, you should have a zip file called `batik-src-1.6.zip` (or similar) that expanded into a directory called `xml-batik` or <code>batik- *version*</code>. In that directory, you can find build scripts for the platform you are running on. For example, there is a `build.bat` script for users of the Windows platform and there is a `build.sh` script for UNIX users.
 
 To start the browser you should:
 
 
 - Make sure that your `JAVA_HOME` environment variable is set to your JDK installation directory
 
-- Open a command line window and change to the `xml-batik` or<code>batik- *version* </code>directory where the Batik distribution was expanded
+- Open a command line window and change to the `xml-batik` or <code>batik- *version*</code> directory where the Batik distribution was expanded
 
 - 
 For Windows, type the following at the command prompt:
@@ -73,6 +73,7 @@ Note that the number of files that can b
 The following image shows the result of starting the browser, from the binary or source distribution, with the `-font-size 10
             samples/batikFX.svg` options.
 <div class="figure"> ![Screenshot of Squiggle showing the batikFX.svg sample](images/svgviewerDefaultRegular.png "") </div>
+
 # Viewing SVG documents <a id="viewing"></a>
 
 The browser has several features to view and browse SVG documents:
@@ -92,14 +93,17 @@ The browser has several features to view
 
 In situations where you want to open SVG files locally on the machine where you are running Squiggle, you can use **File→Open File** menu item to open that file, or use the **Ctrl-F** key accelerator. Doing so brings up a file chooser that lets you select the file you want to view.
 <div class="figure"> ![Screenshot of Squiggle showing the 'File→Open' menu and file chooser](images/svgviewerFileOpen.png "") </div>
+
 ## Opening an SVG file from the web <a id="urlFile"></a>
 
 There are many situations where the SVG content you want to view is not local to the machine where Squiggle is running. In that case, you can use the **File→Open Location** menu item, or use the **Ctrl-A** key accelerator to open that page. Doing so brings up a dialog box where you can type in the URL for the file you want to view.
 <div class="figure"> ![Screenshot of Squiggle showing the 'File→Open Location' menu and window](images/svgviewerOpenPage.png "") </div>
+
 ## Using the location bar text field to view an SVG file <a id="locationBar"></a>
 
 When you know the URL of the document you want to view, you can enter it directly in the location bar text field at the top of Squiggle, the same way you can enter a URL in an HTML browser.
 <div class="figure"> ![Screenshot of Squiggle showing the location bar](images/svgviewerLocationBar.png "") </div>
+
 ## Browsing SVG files <a id="browsing"></a>
 
 As with HTML content, it is common to navigate back and forth between SVG files (remember that SVG files contain hyperlinks, just like HTML does) and, as described later in this document, it is possible to [zoom](#zoomInOut) into SVG documents, [pan](#panning) and [rotate](#rotating) .
@@ -134,17 +138,19 @@ When working on an SVG document, you may
 
 The **File→Print** menu item or **Ctrl-P** will print the currently displayed SVG document.
 
-The **File→Export As** menu item offers the option to export the currently displayed SVG document to various raster formats. Currently, the browser supports the<abbr title="Portable Network Graphics">PNG</abbr>,<abbr title="Joint Photographic Expert Group">JPEG</abbr>and<abbr title="Tagged Image File Format">TIFF</abbr>formats.
+The **File→Export As** menu item offers the option to export the currently displayed SVG document to various raster formats. Currently, the browser supports the <abbr title="Portable Network Graphics">PNG</abbr>, <abbr title="Joint Photographic Expert Group">JPEG</abbr> and <abbr title="Tagged Image File Format">TIFF</abbr> formats.
 
 ## Inspecting the SVG source <a id="inspecting"></a>
 
 The browser offers two ways to inspect the source of an SVG document: [viewing the plain source](#viewingSource) or [viewing the document tree](#viewingTree) . Both are explained below.
 
 ### Viewing the source <a id="viewingSource"></a>
+
 <div class="figure"> ![Screenshot of Squiggle showing the 'View→View Source' menu item and the source window](images/svgviewerViewSource.png "") </div>
 When the browser displays an SVG file, you can select the **View→View Source...** menu item or use the **Ctrl-U** keyboard accelerator to view the source code.
 
 ### Viewing the document tree <a id="viewingTree"></a>
+
 <div class="figure"> ![Screenshot of Squiggle showing the 'View→DOM Viewer...' menu item and the DOM viewer window](images/svgviewerViewTree.png "") </div>
 When the browser displays an SVG file, you can select the **View→DOM Viewer...** menu item or use the **Ctrl-D** keyboard accelerator to open a window that shows the SVG document in the form of a tree. The window lets you navigate the tree, select individual elements, such as a path elements, and view the attributes and CSS values that apply to these elements. While the View Source window shows the SVG source as it was when it was loaded, the DOM Viewer window reflects the current state of the document, including any modifications that have occurred due to script.
 
@@ -226,7 +232,8 @@ There are several methods to zoom in or 
 - If the mouse is over the document in the display area, you can press the **Ctrl key** then **click the left mouse button and drag** to select the area of interest in the document. This can only be used to zoom into a document.
 
 - If the mouse is over the document in the display area, you can press the **Shift key** then **click the right mouse button and drag** it. This is called the *real time* zoom and can be used both for zooming in and out.
-<div class="figure"> ![Screenshot of Squiggle showing the Zoom In and Zoom Out menu items and tool bar buttons](images/svgviewerZoomin.png "") </div><div class="figure"> ![Screenshot of Squiggle zooming to an area of interest](images/svgviewerAOI.png "") </div><anchor id="panning"></anchor>
+<div class="figure"> ![Screenshot of Squiggle showing the Zoom In and Zoom Out menu items and tool bar buttons](images/svgviewerZoomin.png "") </div><div class="figure"> ![Screenshot of Squiggle zooming to an area of interest](images/svgviewerAOI.png "") </div>
+
 ## Panning a document <a id="panning"></a>
 
 Some documents are too big to fit into the browser, especially when you [zoom](#zoomInOut) in with a large zoom factor. In these circumstances, it is useful to be able to move around the document and pan to view different parts of the documents. Again, there are multiple ways to do this:
@@ -236,6 +243,7 @@ Some documents are too big to fit into t
 
 - If you have the [thumbnail](#thumbnail) open, you can select the marker showing the current area of interest and move it to the desired location.
 <div class="figure"> ![Screenshot of Squiggle illustrating the panning gesture](images/svgviewerPan.png "") </div>
+
 ## Rotating a document <a id="rotating"></a>
 
 It is sometimes useful to be able to rotate a document (maps for example). You can do this in the Batik browser by first pressing the **Ctrl key** and then **clicking and dragging the right mouse button** to a new location. The browser will dynamically rotate the image as you move your cursor. When you are satisfied with that angle, you can release the mouse button and the document will be displayed with that new angle.

Modified: xmlgraphics/site/trunk/content/batik/tools/font-converter.mdtext
URL: http://svn.apache.org/viewvc/xmlgraphics/site/trunk/content/batik/tools/font-converter.mdtext?rev=1416342&r1=1416341&r2=1416342&view=diff
==============================================================================
--- xmlgraphics/site/trunk/content/batik/tools/font-converter.mdtext (original)
+++ xmlgraphics/site/trunk/content/batik/tools/font-converter.mdtext Mon Dec  3 03:49:09 2012
@@ -54,7 +54,8 @@ specifies that a sequence of SVG `text` 
 For example:
 java -jar batik-ttf2svg.jar /usr/home/myFont.ttf -l 48 -h 57 -id MySVGFont -o mySVGFont.svg -testcard
 will convert characters 48 to 57, i.e., `'0'` to `'9'` , in the `myFont.ttf` file into their SVG equivalent in the `mySVGFont.svg` file, appending a test card so that the font can be visualized.
-<anchor id="useCases"></anchor>
+
+
 # Use cases <a id="use-cases"></a>
 
 The TrueType Font converter application is helpful to be able to embed font definitions in SVG files. This will ensure that the SVG document will look exactly the same on all platform by not relying on system fonts.

Modified: xmlgraphics/site/trunk/content/batik/tools/rasterizer.mdtext
URL: http://svn.apache.org/viewvc/xmlgraphics/site/trunk/content/batik/tools/rasterizer.mdtext?rev=1416342&r1=1416341&r2=1416342&view=diff
==============================================================================
--- xmlgraphics/site/trunk/content/batik/tools/rasterizer.mdtext (original)
+++ xmlgraphics/site/trunk/content/batik/tools/rasterizer.mdtext Mon Dec  3 03:49:09 2012
@@ -3,7 +3,7 @@ Title: SVG Rasterizer
 #SVG Rasterizer
 
 
-This page describes the features of the SVG Rasterizer utility that comes with the Batik distribution. The SVG Rasterizer is a utility that can convert SVG files to a raster format. The tool can convert individual files or sets of files, making it easy to convert entire directories of SVG files. The provided formats are<abbr title="Joint Photography Expert Group">JPEG</abbr>,<abbr title="Portable Network Graphics">PNG</abbr>and<abbr title="Tagged Image File Format">TIFF</abbr>, however the design allows new formats to be added easily. In addition, the rasterizer can (despite its name) transcode to<abbr title="Portable Document Format">PDF</abbr>.
+This page describes the features of the SVG Rasterizer utility that comes with the Batik distribution. The SVG Rasterizer is a utility that can convert SVG files to a raster format. The tool can convert individual files or sets of files, making it easy to convert entire directories of SVG files. The provided formats are <abbr title="Joint Photography Expert Group">JPEG</abbr>, <abbr title="Portable Network Graphics">PNG</abbr> and <abbr title="Tagged Image File Format">TIFF</abbr>, however the design allows new formats to be added easily. In addition, the rasterizer can (despite its name) transcode to <abbr title="Portable Document Format">PDF</abbr>.
 
 ## Downloading the rasterizer <a id="downloading"></a>
 
@@ -144,14 +144,14 @@ will generate JPEG images for all the SV
 
 ### Using the source distribution <a id="usingSource"></a>
 
-If you downloaded the source distribution of Batik, you got a zip or tar file that expanded into a directory called `xml-batik` or<code>batik- *version* </code>. In that directory, you can find build scripts for the platform you are running on. For example, there is a `build.bat` script for users of the Windows platform and there is a `build.sh` script for UNIX users.
+If you downloaded the source distribution of Batik, you got a zip or tar file that expanded into a directory called `xml-batik` or <code>batik- *version*</code> . In that directory, you can find build scripts for the platform you are running on. For example, there is a `build.bat` script for users of the Windows platform and there is a `build.sh` script for UNIX users.
 
 To start the rasterizer you should:
 
 
 - Make sure that your `JAVA_HOME` environment variable is set to your JDK installation directory.
 
-- Open a command line window and go to the `xml-batik` or<code>batik- *version* </code>directory where the Batik distribution was expanded.
+- Open a command line window and go to the `xml-batik` or <code>batik- *version*</code> directory where the Batik distribution was expanded.
 
 - 
 For windows, type the following at the command prompt:
@@ -171,7 +171,7 @@ Refer to [“Using the binary distrib
 
 The Rasterizer task is an [Ant](http://ant.apache.org/) version of the rasterizer utility. It fulfills the same basic purpose as the utility but has a different syntax and a slightly different set of features.
 
-The task is able to produce four raster formats:<abbr title="Portable Network Graphics">PNG</abbr>,<abbr title="Joint Photographic Expert Group">JPEG</abbr>,<abbr title="Tagged Image File Format">TIFF</abbr>and<abbr title="Portable Document Format">PDF</abbr>.
+The task is able to produce four raster formats: <abbr title="Portable Network Graphics">PNG</abbr>, <abbr title="Joint Photographic Expert Group">JPEG</abbr>, <abbr title="Tagged Image File Format">TIFF</abbr> and <abbr title="Portable Document Format">PDF</abbr>.
 
 ### Using the rasterizer task <a id="initTask"></a>
 
@@ -180,8 +180,10 @@ The first thing to do is to compile rast
 After building, ensure that the generated `batik-rasterizer.jar` and the classes (or jar file) of the rasterizer task are in your `CLASSPATH` .
 
 Next you have to define the task in your Ant project. To do this, add the following line either after the `project` start tag or after the `target` start tag in the target you are using the rasterizer task:
-  <taskdef name="rasterize" 
+
+    <taskdef name="rasterize" 
            classname="org.apache.tools.ant.taskdefs.optional.RasterizerTask"/>
+
 Now you can use the rasterizer task in your project. See the [parameters section](#taskParameters) for an explanation of the available parameters or the [examples section](#taskExamples) to see few usage examples.
 
 ### Parameters of the Ant task <a id="taskParameters"></a>
@@ -212,21 +214,21 @@ You can use `fileset` elements to select
 ### Examples of using the rasterizer task <a id="taskExamples"></a>
 
 The following example is the complete Ant project that converts an SVG image (called `input.svg` ) to a PNG image (called `output.png` ):
-<?xml version="1.0"?>
 
-<project name="RasterizerExample" default="main" basedir=".">
-
-  <taskdef name="rasterize" 
+    <?xml version="1.0"?>
+    <project name="RasterizerExample" default="main" basedir=".">
+        <taskdef name="rasterize" 
            classname="org.apache.tools.ant.taskdefs.optional.RasterizerTask"/>
+        <target name="main">
+            <rasterize result="image/png" src="input.svg" dest="output.png"/>
+        </target>
+    </project>
 
-  <target name="main">
-    <rasterize result="image/png" src="input.svg" dest="output.png"/>
-  </target>
-</project>
 The next example is just one task in a project. It converts all files with a `.svg` suffix in the `images` directory and all files in the `images2` directory to TIFF images. The resulting image files are placed in the `results` directory.
-  <rasterize result="image/tiff" destdir="results">
-    <fileset dir="images">
-      <include name="**/*.svg"/>
-    </fileset>
-    <fileset dir="images2"/>
-  </rasterize>
\ No newline at end of file
+
+    <rasterize result="image/tiff" destdir="results">
+        <fileset dir="images">
+            <include name="**/*.svg"/>
+        </fileset>
+        <fileset dir="images2"/>
+    </rasterize>

Modified: xmlgraphics/site/trunk/content/batik/using/architecture.mdtext
URL: http://svn.apache.org/viewvc/xmlgraphics/site/trunk/content/batik/using/architecture.mdtext?rev=1416342&r1=1416341&r2=1416342&view=diff
==============================================================================
--- xmlgraphics/site/trunk/content/batik/using/architecture.mdtext (original)
+++ xmlgraphics/site/trunk/content/batik/using/architecture.mdtext Mon Dec  3 03:49:09 2012
@@ -32,11 +32,11 @@ Note that even though the application mo
 The Batik core modules are the heart of the Batik architecture. They can be used individually or in combination for various purposes, and the [application modules](#applicationComponents) offer some usage examples.
 
 
-- The [SVG generator](../using/svg-generator.html) is a module containing<code> [SVGGraphics2D](../javadoc/org/apache/batik/svggen/SVGGraphics2D.html) </code>class, that lets all Java applications or applets easily convert their graphics to the SVG format, as easily as they draw to a screen or a printer, by leveraging the Java 2D API’s extensible design.
+- The [SVG generator](../using/svg-generator.html) is a module containing <code> [SVGGraphics2D](../javadoc/org/apache/batik/svggen/SVGGraphics2D.html)</code> class, that lets all Java applications or applets easily convert their graphics to the SVG format, as easily as they draw to a screen or a printer, by leveraging the Java 2D API’s extensible design.
 
 -  [SVG DOM](../using/dom-api.html) an implementation of the SVG DOM API defined in the SVG recommendation. It lets the programmer manipulate SVG documents in a Java program.
 
-- The [Swing components](../using/swing.html) module includes, primarily, the<code> [JSVGCanvas](../javadoc/org/apache/batik/swing/JSVGCanvas.html) </code>class, a UI component that can display SVG content and let the user interact with that content (zoom, pan, rotate, select text, etc.).
+- The [Swing components](../using/swing.html) module includes, primarily, the <code> [JSVGCanvas](../javadoc/org/apache/batik/swing/JSVGCanvas.html)</code> class, a UI component that can display SVG content and let the user interact with that content (zoom, pan, rotate, select text, etc.).
 
 - The **Bridge** module is rarely used directly. It is responsible for creating and maintaining an appropriate object corresponding to an SVG element. The bridge converts an SVG document into the internal representation Batik uses for graphics (GVT, the Graphic Vector Toolkit).
 

Modified: xmlgraphics/site/trunk/content/batik/using/dom-api.mdtext
URL: http://svn.apache.org/viewvc/xmlgraphics/site/trunk/content/batik/using/dom-api.mdtext?rev=1416342&r1=1416341&r2=1416342&view=diff
==============================================================================
--- xmlgraphics/site/trunk/content/batik/using/dom-api.mdtext (original)
+++ xmlgraphics/site/trunk/content/batik/using/dom-api.mdtext Mon Dec  3 03:49:09 2012
@@ -61,9 +61,11 @@ rectangle.setAttributeNS(null, "fill", "
 // Attach the rectangle to the root 'svg' element.
 svgRoot.appendChild(rectangle);
 The example given constructs a document equivalent to parsing the following SVG file:
-<svg xmlns="http://www.w3.org/2000/svg" width="400" height="450">
-  <rect x="10" y="20" width="100" height="50" fill="red"/>
-</svg>
+
+    <svg xmlns="http://www.w3.org/2000/svg" width="400" height="450">
+        <rect x="10" y="20" width="100" height="50" fill="red"/>
+    </svg>
+
 # Creating a Document from an SVG file <a id="createdocfromsvgfile"></a>
 
 With Batik, you can also create an SVG DOM tree from a URI, an [InputStream](http://java.sun.com/j2se/1.5.0/docs/api/java/io/InputStream.html) , or a [Reader](http://java.sun.com/j2se/1.5.0/docs/api/java/io/Reader.html) , using the [SAXSVGDocumentFactory](../javadoc/org/apache/batik/dom/util/SAXDocumentFactory.html) . The following example illustrates how to create an SVG document from a URI using the `SAXSVGDocumentFactory` class.

Modified: xmlgraphics/site/trunk/content/batik/using/scripting/ecmascript.mdtext
URL: http://svn.apache.org/viewvc/xmlgraphics/site/trunk/content/batik/using/scripting/ecmascript.mdtext?rev=1416342&r1=1416341&r2=1416342&view=diff
==============================================================================
--- xmlgraphics/site/trunk/content/batik/using/scripting/ecmascript.mdtext (original)
+++ xmlgraphics/site/trunk/content/batik/using/scripting/ecmascript.mdtext Mon Dec  3 03:49:09 2012
@@ -12,20 +12,24 @@ As the ECMAScript language (the standard
 There are two places in an SVG file where you can put scripts.
 
 The first one is in the `script` element, where you can place any code, including function definitions, to be executed just before the document `SVGLoad` event is fired.
-<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
-  <script type="text/ecmascript">
-    // ECMAScript code to be executed 
-  </script>
 
-  <!-- Remainder of the document... -->
-</svg>
+    <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
+      <script type="text/ecmascript">
+        // ECMAScript code to be executed 
+      </script>
+    
+      <!-- Remainder of the document... -->
+    </svg>
+
 You can also attach script to respond to user or document events using attributes on SVG elements. As shown in the previous example, the scripting language must be set on the `script` element. However, for event handling the default language type `text/ecmascript` is assumed. If you want to change it you can use the `contentScriptType` attribute on the `svg` element.
 
 The event attribute can contain any script code to execute when the event reaches the element (as described by the [DOM event flow](http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-flow) ) in either the bubbling or at-target phases. The following example will change the `rect` to be filled in blue when it is clicked.
-<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
-  <rect x="0" y="0" width="10" height="10"
-        onclick="evt.target.setAttribute('fill', 'blue')"/>
-</svg>
+
+    <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
+      <rect x="0" y="0" width="10" height="10"
+            onclick="evt.target.setAttribute('fill', 'blue')"/>
+    </svg>
+
 Note that inside the event attribute script, there is a variable called `evt` that is a reference to the [Event](http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event) object that represents the event that is being handled.
 
 For more information on using scripting in SVG you can have a look at:
@@ -46,22 +50,24 @@ var frame = new JFrame("My test frame");
 Note how an ECMAScript string value is passed as the parameter to `JFrame` ’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 `java.lang.String` object to be passed to the constructor.
 
 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:
-<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
-  <circle cx="50" cy="50" r="50" fill="green" onclick="showFrame()"/>
-  <script type="text/ecmascript">
-    importPackage(Packages.javax.swing);
-
-    function showFrame() {
-      var frame = new JFrame("My test frame");
-      var label = new JLabel("Hello from Java objects created in ECMAScript!");
-      label.setHorizontalAlignment(SwingConstants.CENTER);
-      frame.getContentPane().add(label);
-      frame.setSize(400, 100);
-      frame.setVisible(true);
-      frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
-    }
-  </script>
-</svg>
+
+    <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
+      <circle cx="50" cy="50" r="50" fill="green" onclick="showFrame()"/>
+      <script type="text/ecmascript">
+        importPackage(Packages.javax.swing);
+    
+        function showFrame() {
+          var frame = new JFrame("My test frame");
+          var label = new JLabel("Hello from Java objects created in ECMAScript!");
+          label.setHorizontalAlignment(SwingConstants.CENTER);
+          frame.getContentPane().add(label);
+          frame.setSize(400, 100);
+          frame.setVisible(true);
+          frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+        }
+      </script>
+    </svg>
+
 For more information on scripting Java classes from ECMAScript code, see Rhino's [Scripting Java](http://www.mozilla.org/rhino/ScriptingJava.html) document.
 
 ## Customizing the Rhino interpreter <a id="customizingRhino"></a>
@@ -69,70 +75,76 @@ For more information on scripting Java c
 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 `print` 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.
 
 You should first subclass the default Batik ECMAScript interpreter to add the functionality to it as below.
-import org.apache.batik.script.rhino.RhinoInterpreter;
 
-import java.net.URL;
-
-import org.mozilla.javascript.Context;
-import org.mozilla.javascript.Function;
-import org.mozilla.javascript.Scriptable;
-import org.mozilla.javascript.ScriptableObject;
-import org.mozilla.javascript.PropertyException;
-
-public class ExtendedRhinoInterpreter extends RhinoInterpreter {
-
-    public ExtendedRhinoInterpreter(URL documentURL) {
-        super(documentURL);
-
-        // Array of functions to put in the global object.
-        final String[] names = { "print" }
-        try {
-            // Add the functions to the global object.
-            getGlobalObject().defineFunctionProperties
-                (names, ExtendedRhinoInterpreter.class,
-                 ScriptableObject.DONTENUM);
-        } catch (PropertyException e) {
-            throw new Error(e);
-        }
-    }
+    import org.apache.batik.script.rhino.RhinoInterpreter;
+    
+    import java.net.URL;
+    
+    import org.mozilla.javascript.Context;
+    import org.mozilla.javascript.Function;
+    import org.mozilla.javascript.Scriptable;
+    import org.mozilla.javascript.ScriptableObject;
+    import org.mozilla.javascript.PropertyException;
     
-    public static void print(Context cx, Scriptable thisObj,
-                             Object[] args, Function funObj) {
-        for (int i = 0; i < args.length; i++) {
-            if (i > 0) {
-                System.out.print(" ");
+    public class ExtendedRhinoInterpreter extends RhinoInterpreter {
+    
+        public ExtendedRhinoInterpreter(URL documentURL) {
+            super(documentURL);
+    
+            // Array of functions to put in the global object.
+            final String[] names = { "print" }
+            try {
+                // Add the functions to the global object.
+                getGlobalObject().defineFunctionProperties
+                    (names, ExtendedRhinoInterpreter.class,
+                     ScriptableObject.DONTENUM);
+            } catch (PropertyException e) {
+                throw new Error(e);
+            }
+        }
+        
+        public static void print(Context cx, Scriptable thisObj,
+                                 Object[] args, Function funObj) {
+            for (int i = 0; i < args.length; i++) {
+                if (i > 0) {
+                    System.out.print(" ");
+                }
+            
+                // Convert the ECMAScript value into a string form.
+                String s = Context.toString(args[i]);
+                System.out.print(s);
             }
-	    
-            // Convert the ECMAScript value into a string form.
-            String s = Context.toString(args[i]);
-            System.out.print(s);
+            System.out.println();
         }
-        System.out.println();
     }
-}
-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.
-import org.apache.batik.script.Interpreter;
-import org.apache.batik.script.rhino.RhinoInterpreterFactory;
 
-public class ExtendedRhinoInterpreterFactory extends RhinoInterpreterFactory {
+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.
 
-    public Interpreter createInterpreter(URL documentURL, boolean isSVG12) {
-        return new ExtendedRhinoInterpreter(documentURL);
+    import org.apache.batik.script.Interpreter;
+    import org.apache.batik.script.rhino.RhinoInterpreterFactory;
+    
+    public class ExtendedRhinoInterpreterFactory extends RhinoInterpreterFactory {
+    
+        public Interpreter createInterpreter(URL documentURL, boolean isSVG12) {
+            return new ExtendedRhinoInterpreter(documentURL);
+        }
     }
-}
+
 Then, you must build an [IntepreterPool](../../javadoc/org/apache/batik/script/InterpreterPool.html) that will use this factory, and then set the pool on the [BridgeContext](../../javadoc/org/apache/batik/bridge/BridgeContext.html) of your application.
-org.apache.batik.bridge.BridgeContext ctx = ...;
-org.apache.batik.script.InterpreterPool pool =
-    new org.apache.batik.script.InterpreterPool();
-InterpreterFactory f = new ExtendedRhinoInterpreterFactory();
-
-// Register the interpreter factory for all four MIME types that
-// Batik normally supports for ECMAScript.
-pool.putInterpreterFactory("text/ecmascript", f);
-pool.putInterpreterFactory("text/javascript", f);
-pool.putInterpreterFactory("application/ecmascript", f);
-pool.putInterpreterFactory("application/javascript", f);
-ctx.setIntepreterPool(pool);
+
+    org.apache.batik.bridge.BridgeContext ctx = ...;
+    org.apache.batik.script.InterpreterPool pool =
+        new org.apache.batik.script.InterpreterPool();
+    InterpreterFactory f = new ExtendedRhinoInterpreterFactory();
+    
+    // Register the interpreter factory for all four MIME types that
+    // Batik normally supports for ECMAScript.
+    pool.putInterpreterFactory("text/ecmascript", f);
+    pool.putInterpreterFactory("text/javascript", f);
+    pool.putInterpreterFactory("application/ecmascript", f);
+    pool.putInterpreterFactory("application/javascript", f);
+    ctx.setIntepreterPool(pool);
+
 For example if you are using the Batik SVG browser application you should be able to use the previous piece of code on a subclass of the [JSVGCanvas](../../javadoc/org/apache/batik/swing/JSVGCanvas.html) class in the `createBridgeContext()` method.
 
 For further information on working with Rhino, consult the [Rhino website](http://www.mozilla.org/rhino/) .

Modified: xmlgraphics/site/trunk/content/batik/using/scripting/java.mdtext
URL: http://svn.apache.org/viewvc/xmlgraphics/site/trunk/content/batik/using/scripting/java.mdtext?rev=1416342&r1=1416341&r2=1416342&view=diff
==============================================================================
--- xmlgraphics/site/trunk/content/batik/using/scripting/java.mdtext (original)
+++ xmlgraphics/site/trunk/content/batik/using/scripting/java.mdtext Mon Dec  3 03:49:09 2012
@@ -8,163 +8,174 @@ This page explains how to manipulate the
 ## How to manipulate a document in a JSVGCanvas <a id="Swing"></a>
 
 The follow code template demonstrates how to manipulate an SVG document displayed in a [JSVGCanvas](../../javadoc/org/apache/batik/swing/JSVGCanvas.html) directly from a Java program.
-You don’t have to worry about graphics updates; after each event listener invocation the canvas is updated if needed.import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
+You don’t have to worry about graphics updates; after each event listener invocation the canvas is updated if needed.
 
-import javax.swing.JFrame;
-
-import org.apache.batik.swing.JSVGCanvas;
-import org.apache.batik.swing.svg.SVGLoadEventDispatcherAdapter;
-import org.apache.batik.swing.svg.SVGLoadEventDispatcherEvent;
-import org.apache.batik.script.Window;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.events.Event;
-import org.w3c.dom.events.EventListener;
-import org.w3c.dom.events.EventTarget;
-
-public class SVGApplication {
-
-    public static void main(String[] args) {
-        new SVGApplication();
-    }
-
-    JFrame frame;
-    JSVGCanvas canvas;
-    Document document;
-    Window window;
-
-    public SVGApplication() {
-        frame = new JFrame();
-        canvas = new JSVGCanvas();
-        // Forces the canvas to always be dynamic even if the current
-        // document does not contain scripting or animation.
-        canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
-        canvas.addSVGLoadEventDispatcherListener
-            (new SVGLoadEventDispatcherAdapter() {
-                    public void svgLoadEventDispatchStarted
-                        (SVGLoadEventDispatcherEvent e) {
-                        // At this time the document is available...
-                        document = canvas.getSVGDocument();
-                        // ...and the window object too.
-                        window = canvas.getUpdateManager().
-                            getScriptingEnvironment().createWindow();
-                        // Registers the listeners on the document
-                        // just before the SVGLoad event is
-                        // dispatched.
-                        registerListeners();
-                        // It is time to pack the frame.
-                        frame.pack();
+    import java.awt.event.WindowAdapter;
+    import java.awt.event.WindowEvent;
+    
+    import javax.swing.JFrame;
+    
+    import org.apache.batik.swing.JSVGCanvas;
+    import org.apache.batik.swing.svg.SVGLoadEventDispatcherAdapter;
+    import org.apache.batik.swing.svg.SVGLoadEventDispatcherEvent;
+    import org.apache.batik.script.Window;
+    
+    import org.w3c.dom.Document;
+    import org.w3c.dom.Element;
+    import org.w3c.dom.events.Event;
+    import org.w3c.dom.events.EventListener;
+    import org.w3c.dom.events.EventTarget;
+    
+    public class SVGApplication {
+    
+        public static void main(String[] args) {
+            new SVGApplication();
+        }
+    
+        JFrame frame;
+        JSVGCanvas canvas;
+        Document document;
+        Window window;
+    
+        public SVGApplication() {
+            frame = new JFrame();
+            canvas = new JSVGCanvas();
+            // Forces the canvas to always be dynamic even if the current
+            // document does not contain scripting or animation.
+            canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
+            canvas.addSVGLoadEventDispatcherListener
+                (new SVGLoadEventDispatcherAdapter() {
+                        public void svgLoadEventDispatchStarted
+                            (SVGLoadEventDispatcherEvent e) {
+                            // At this time the document is available...
+                            document = canvas.getSVGDocument();
+                            // ...and the window object too.
+                            window = canvas.getUpdateManager().
+                                getScriptingEnvironment().createWindow();
+                            // Registers the listeners on the document
+                            // just before the SVGLoad event is
+                            // dispatched.
+                            registerListeners();
+                            // It is time to pack the frame.
+                            frame.pack();
+                        }
+                    });
+            
+            frame.addWindowListener(new WindowAdapter() {
+                    public void windowOpened(WindowEvent e) {
+                        // The canvas is ready to load the base document
+                        // now, from the AWT thread.
+                        canvas.setURI("doc.svg");
                     }
                 });
-        
-        frame.addWindowListener(new WindowAdapter() {
-                public void windowOpened(WindowEvent e) {
-                    // The canvas is ready to load the base document
-                    // now, from the AWT thread.
-                    canvas.setURI("doc.svg");
-                }
-            });
-
-        frame.getContentPane().add(canvas);
-        frame.setSize(800, 600);
-        frame.show();
-    }
-
-    public void registerListeners() {
-        // Gets an element from the loaded document.
-        Element elt = document.getElementById("elt-id");
-        EventTarget t = (EventTarget)elt;
-
-        // Adds a 'onload' listener
-        t.addEventListener("SVGLoad", new OnLoadAction(), false);
-
-        // Adds a 'onclick' listener
-        t.addEventListener("click", new OnClickAction(), false);
-    }
-
-    public class OnLoadAction implements EventListener {
-        public void handleEvent(Event evt) {
-            // Perform some actions here...
-            
-            // ...for example start an animation loop:
-            window.setInterval(new Animation(), 50);
-        }
-    }
-
-    public class OnClickAction implements EventListener {
-        public void handleEvent(Event evt) {
-            // Perform some actions here...
-
-            // ...for example schedule an action for later:
-            window.setTimeout(new DelayedTask(), 500);
-        }
-    }
-
-    public class Animation implements Runnable {
-        public void run() {
-            // Insert animation code here...
+    
+            frame.getContentPane().add(canvas);
+            frame.setSize(800, 600);
+            frame.show();
+        }
+    
+        public void registerListeners() {
+            // Gets an element from the loaded document.
+            Element elt = document.getElementById("elt-id");
+            EventTarget t = (EventTarget)elt;
+    
+            // Adds a 'onload' listener
+            t.addEventListener("SVGLoad", new OnLoadAction(), false);
+    
+            // Adds a 'onclick' listener
+            t.addEventListener("click", new OnClickAction(), false);
+        }
+    
+        public class OnLoadAction implements EventListener {
+            public void handleEvent(Event evt) {
+                // Perform some actions here...
+                
+                // ...for example start an animation loop:
+                window.setInterval(new Animation(), 50);
+            }
+        }
+    
+        public class OnClickAction implements EventListener {
+            public void handleEvent(Event evt) {
+                // Perform some actions here...
+    
+                // ...for example schedule an action for later:
+                window.setTimeout(new DelayedTask(), 500);
+            }
+        }
+    
+        public class Animation implements Runnable {
+            public void run() {
+                // Insert animation code here...
+            }
+        }
+    
+        public class DelayedTask implements Runnable {
+            public void run() {
+                // Perform some actions here...
+    
+                // ...for example displays an alert dialog:
+                window.alert("Delayed Action invoked!");
+            }
         }
     }
 
-    public class DelayedTask implements Runnable {
-        public void run() {
-            // Perform some actions here...
-
-            // ...for example displays an alert dialog:
-            window.alert("Delayed Action invoked!");
-        }
-    }
-}
-
 ## Writing thread-safe code <a id="Threads"></a>
 
 The DOM listeners registered on the SVG document are called from the canvas update thread. To avoid race conditions, do not manipulate the DOM tree from another thread.
 
 The way to switch from an external thread to the canvas update thread is to use the following code:
-// Returns immediately
-canvas.getUpdateManager().getUpdateRunnableQueue().
-    invokeLater(new Runnable() {
-        public void run() {
-            // Insert some actions on the DOM here
-        }
-    });
-or:
-// Waits until the Runnable is invoked
-canvas.getUpdateManager().getUpdateRunnableQueue().
-    invokeAndWait(new Runnable() {
-        public void run() {
-            // Insert some actions on the DOM here
-        }
-    });
+
+    // Returns immediately
+    canvas.getUpdateManager().getUpdateRunnableQueue().
+        invokeLater(new Runnable() {
+            public void run() {
+                // Insert some actions on the DOM here
+            }
+        });
+    or:
+    // Waits until the Runnable is invoked
+    canvas.getUpdateManager().getUpdateRunnableQueue().
+        invokeAndWait(new Runnable() {
+            public void run() {
+                // Insert some actions on the DOM here
+            }
+        });
+
 Like with event listeners, when a [Runnable](http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runnable.html) is invoked from the update thread, the graphics are updated.
 It is very dangerous to call `invokeAndWait` from the Swing event thread. This is the only thread that can be used to interact with Swing components. In some cases DOM calls may need to query the canvas for information (such as actual Swing component size, etc). If this happens you will get a thread deadlock. You should only make invokeAndWait calls from “third party” threads.
+
 # Using the SVG DOM <a id="SVGDOM"></a>
 
 Batik provides a fairly complete implementation of the SVG DOM. The SVG DOM provides all the functionality most applications require. In particular, the DOM implements DOM Events, including mutation and UI Events. As an example, DOM events allow you to get notified when the cursor moves over elements of interest:
-// Element of Interest.
-Element theElem = ...;
-((EventTarget) theElem).addEventListener("mouseover", mouseOverListener, true);
+
+    // Element of Interest.
+    Element theElem = ...;
+    ((EventTarget) theElem).addEventListener("mouseover", mouseOverListener, true);
+
 where `mouseOverListener` implements the [org.w3c.dom.events.EventListener](http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/events/EventListener.html) interface. This interface consists of the method:
-void handleEvent(Event evt);
+
+    void handleEvent(Event evt);
+
 This is called whenever the event occurs with the element it is registered on. It is worth reviewing the DOM Events specification as there are many useful features to this interface that are not immediately obvious.
 
 It is also worth looking at the DOM interfaces defined by the SVG specification as they provide a large number of useful methods, in particular those of [SVGLocatable](../../javadoc/org/w3c/dom/svg/SVGLocatable.html) :
-// Returns Bounding box of SVG Element.
-public SVGRect   getBBox (  );
-// Returns the transformation matrix to the screen.
-public SVGMatrix getScreenCTM (  );
-// Returns the transformation matrix to the given element.
-public SVGMatrix getTransformToElement ( SVGElement element )
-                throws SVGException;
-In particular, `getScreenCTM` is very useful for taking the `clientX` and `clientY` attributes of the DOM [UIEvent](http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/events/UIEvent.html) and mapping them to the coordinate system of an element in the SVG document:
-SVGMatrix mat  = elem.getScreenCTM();
-SVGMatrix imat = mat.inverse();
-SVGPoint  cPt  = document.getRootElement().createSVGPoint();
-cPt.setX(uiEvt.getClientX());
-cPt.setY(uiEvt.getClientY());
-cPt = cPt.matrixTransform(imat);
+
+    // Returns Bounding box of SVG Element.
+    public SVGRect   getBBox (  );
+    // Returns the transformation matrix to the screen.
+    public SVGMatrix getScreenCTM (  );
+    // Returns the transformation matrix to the given element.
+    public SVGMatrix getTransformToElement ( SVGElement element )
+                    throws SVGException;
+    In particular, `getScreenCTM` is very useful for taking the `clientX` and `clientY` attributes of the DOM [UIEvent](http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/events/UIEvent.html) and mapping them to the coordinate system of an element in the SVG document:
+    SVGMatrix mat  = elem.getScreenCTM();
+    SVGMatrix imat = mat.inverse();
+    SVGPoint  cPt  = document.getRootElement().createSVGPoint();
+    cPt.setX(uiEvt.getClientX());
+    cPt.setY(uiEvt.getClientY());
+    cPt = cPt.matrixTransform(imat);
+
 # Referencing Java code from a document <a id="javaInDocument"></a>
 
 Batik implements the Java bindings for SVG, and thus allows Java code to be referenced from `script` elements. This feature is available to any application of Batik that uses the bridge module (for example the Swing component and the transcoders).
@@ -172,7 +183,9 @@ Batik implements the Java bindings for S
 In order to use this extension, the `type` attribute of a `script` element must be set to `application/java-archive` . In addition, the `xlink:href` attribute must be the URI of a jar file that contains the code to run.
 
 The manifest of this jar file must contains an entry of the form:
-SVG-Handler-Class: classname
+
+    SVG-Handler-Class: classname
+
 where *classname* must be the name of a class that implements the [org.w3c.dom.svg.EventListenerInitializer](../../javadoc/org/w3c/dom/svg/EventListenerInitializer.html) interface. Just before the document `SVGLoad` event is fired, an instance of this class is created, and this instance has its `initializeEventListeners` method invoked. Note that there is no way to specify Java handlers in event attributes on SVG elements, so having the `initializeEventListeners` call `addEventListener` on a node is the only way to attach a Java listener from within the document.
 
 The class specified by `SVG-Handler-Class` can be contained directly in the jar file, but it is also possible for it to be contained in a jar file added to the classpath using the `Class-Path` entry of the manifest.

Modified: xmlgraphics/site/trunk/content/batik/using/svg-generator.mdtext
URL: http://svn.apache.org/viewvc/xmlgraphics/site/trunk/content/batik/using/svg-generator.mdtext?rev=1416342&r1=1416341&r2=1416342&view=diff
==============================================================================
--- xmlgraphics/site/trunk/content/batik/using/svg-generator.mdtext (original)
+++ xmlgraphics/site/trunk/content/batik/using/svg-generator.mdtext Mon Dec  3 03:49:09 2012
@@ -17,6 +17,7 @@ On the Java platform, all rendering goes
 - it does not require any modification of the graphics code to export to SVG, and
 
 - it offers the user the ability to use the DOM API to manipulate the generated document.
+
 <div class="figure"> ![Diagram illustrating how the SVGGraphics2D inherits from Graphics2D, and uses Document to generate a DOM tree](images/svggenHighLevelArchi.jpg "") </div>
 The above figure shows how the generator works with the DOM API. The W3C has defined an API for representing XML content with a Java object. That API allows programmers to manipulate, create, and/or modify XML content in memory. The DOM API contains interfaces such as [Document](http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/Document.html) , [Element](http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/Element.html) , and [Attr](http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/Attr.html) , which model the Java programming language equivalent of XML documents, elements and attributes.
 
@@ -29,55 +30,57 @@ The programmer, using this generator, ca
 From the figure in the previous section we can see that in order for an instance of `SVGGraphics2D` to build the SVG content (the DOM tree), an instance of a `Document` class is needed. The DOM tree is an in-memory representation of the SVG document, which can be further manipulated by the user using DOM API or be streamed out by a [Writer](http://java.sun.com/j2se/1.5.0/docs/api/java/io/Writer.html) object.
 
 The following example program demonstrates how to generate SVG content from Java graphics.
-import java.awt.Rectangle;
-import java.awt.Graphics2D;
-import java.awt.Color;
-import java.io.Writer;
-import java.io.OutputStreamWriter;
-import java.io.IOException;
-
-import org.apache.batik.svggen.SVGGraphics2D;
-import org.apache.batik.dom.GenericDOMImplementation;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.DOMImplementation;
-
-public class TestSVGGen {
-
-    public void paint(Graphics2D g2d) {
-        g2d.setPaint(Color.red);
-        g2d.fill(new Rectangle(10, 10, 100, 100));
-    }
-
-    public static void main(String[] args) throws IOException {
-
-        // Get a DOMImplementation.
-        DOMImplementation domImpl =
-            GenericDOMImplementation.getDOMImplementation();
-
-        // Create an instance of org.w3c.dom.Document.
-        String svgNS = "http://www.w3.org/2000/svg";
-        Document document = domImpl.createDocument(svgNS, "svg", null);
 
-        // Create an instance of the SVG Generator.
-        SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
-
-        // Ask the test to render into the SVG Graphics2D implementation.
-        TestSVGGen test = new TestSVGGen();
-        test.paint(svgGenerator);
+	import java.awt.Rectangle;
+	import java.awt.Graphics2D;
+	import java.awt.Color;
+	import java.io.Writer;
+	import java.io.OutputStreamWriter;
+	import java.io.IOException;
+	
+	import org.apache.batik.svggen.SVGGraphics2D;
+	import org.apache.batik.dom.GenericDOMImplementation;
+	
+	import org.w3c.dom.Document;
+	import org.w3c.dom.DOMImplementation;
+	
+	public class TestSVGGen {
+	
+		public void paint(Graphics2D g2d) {
+			g2d.setPaint(Color.red);
+			g2d.fill(new Rectangle(10, 10, 100, 100));
+		}
+	
+		public static void main(String[] args) throws IOException {
+	
+			// Get a DOMImplementation.
+			DOMImplementation domImpl =
+				GenericDOMImplementation.getDOMImplementation();
+	
+			// Create an instance of org.w3c.dom.Document.
+			String svgNS = "http://www.w3.org/2000/svg";
+			Document document = domImpl.createDocument(svgNS, "svg", null);
+	
+			// Create an instance of the SVG Generator.
+			SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
+	
+			// Ask the test to render into the SVG Graphics2D implementation.
+			TestSVGGen test = new TestSVGGen();
+			test.paint(svgGenerator);
+	
+			// Finally, stream out SVG to the standard output using
+			// UTF-8 encoding.
+			boolean useCSS = true; // we want to use CSS style attributes
+			Writer out = new OutputStreamWriter(System.out, "UTF-8");
+			svgGenerator.stream(out, useCSS);
+		}
+	}
 
-        // Finally, stream out SVG to the standard output using
-        // UTF-8 encoding.
-        boolean useCSS = true; // we want to use CSS style attributes
-        Writer out = new OutputStreamWriter(System.out, "UTF-8");
-        svgGenerator.stream(out, useCSS);
-    }
-}
 We can see that generating SVG content from our `TestSVGGen` instance is a three step process:
 
 
-1. 
-Create an instance of `org.w3c.dom.Document` that the generator will use to build its XML content, and create an SVG generator using the `Document` instance.
+1. Create an instance of `org.w3c.dom.Document` that the generator will use to build its XML content, and create an SVG generator using the `Document` instance.
+
         // Get a DOMImplementation.
         DOMImplementation domImpl =
             GenericDOMImplementation.getDOMImplementation();
@@ -89,14 +92,15 @@ Create an instance of `org.w3c.dom.Docum
         // Create an instance of the SVG Generator.
         SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
 
-1. 
-Invoke the rendering code on our SVG generator. In our example, we invoke `TestSVGGen` ‘s `paint` method:
+1. Invoke the rendering code on our SVG generator. In our example, we invoke `TestSVGGen` ‘s `paint` method:
+
         // Ask the test to render into the SVG Graphics2D implementation.
         TestSVGGen test = new TestSVGGen();
         test.paint(svgGenerator);
 
 1. 
 Stream out the SVG content. The SVG generator can stream its content into any `java.io.Writer` . In our example, we stream the content to the standard output stream:
+
         // Finally, stream out SVG to the standard output using
         // UTF-8 encoding.
         boolean useCSS = true; // we want to use CSS style attributes
@@ -114,242 +118,260 @@ Instead of creating the `SVGGraphics2D` 
 ### Have your own comment in the generated SVG file <a id="Have+your+own+comment+in+the+generated+SVG+file"></a>
 
 We begin with the simplest 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.
-DOMImplementation impl =
-    GenericDOMImplementation.getDOMImplementation();
-String svgNS = "http://www.w3.org/2000/svg";
-Document myFactory = impl.createDocument(svgNS, "svg", null);
-
-SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
-ctx.setComment("Generated by FooApplication with Batik SVG Generator");
-SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
+
+    DOMImplementation impl =
+        GenericDOMImplementation.getDOMImplementation();
+    String svgNS = "http://www.w3.org/2000/svg";
+    Document myFactory = impl.createDocument(svgNS, "svg", null);
+    
+    SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
+    ctx.setComment("Generated by FooApplication with Batik SVG Generator");
+    SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
+
 ## Use embedded SVG Fonts in the generated SVG file <a id="Use+embedded+SVG+Fonts+in+the+generated+SVG+file"></a>
 
 In order to have a self-contained SVG file that doesn't have to use system fonts to be displayed, you can embed the fonts you used for drawing strings in the SVG file through the SVG fonts facility.
-DOMImplementation impl =
-    GenericDOMImplementation.getDOMImplementation();
-String svgNS = "http://www.w3.org/2000/svg";
-Document myFactory = impl.createDocument(svgNS, "svg", null);
-
-SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
-ctx.setEmbeddedFontsOn(true);
-SVGGraphics2D g2d = new SVGGraphics2D(ctx, true);
+
+    DOMImplementation impl =
+        GenericDOMImplementation.getDOMImplementation();
+    String svgNS = "http://www.w3.org/2000/svg";
+    Document myFactory = impl.createDocument(svgNS, "svg", null);
+    
+    SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
+    ctx.setEmbeddedFontsOn(true);
+    SVGGraphics2D g2d = new SVGGraphics2D(ctx, true);
+
 ## Customizing the way images are stored <a id="Customizing+the+way+images+are+stored"></a>
 
 Every time you call one of the `drawImage` methods provided by the `Graphics2D` interface, a default representation of your image is created in a location and put in a default 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.
 
 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` .
-DOMImplementation impl =
-    GenericDOMImplementation.getDOMImplementation();
-String svgNS = "http://www.w3.org/2000/svg";
-Document myFactory = impl.createDocument(svgNS, "svg", null);
-
-SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
-GenericImageHandler ihandler = new ImageHandlerPNGEncoder("res/images", null);
-ctx.setImageHandler(ihandler);
-SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
+
+    DOMImplementation impl =
+        GenericDOMImplementation.getDOMImplementation();
+    String svgNS = "http://www.w3.org/2000/svg";
+    Document myFactory = impl.createDocument(svgNS, "svg", null);
+    
+    SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
+    GenericImageHandler ihandler = new ImageHandlerPNGEncoder("res/images", null);
+    ctx.setImageHandler(ihandler);
+    SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
+
 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 `drawImage` 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.
-DOMImplementation impl =
-    GenericDOMImplementation.getDOMImplementation();
-String svgNS = "http://www.w3.org/2000/svg";
-Document myFactory = impl.createDocument(svgNS, "svg", null);
-
-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);
+    DOMImplementation impl =
+        GenericDOMImplementation.getDOMImplementation();
+    String svgNS = "http://www.w3.org/2000/svg";
+    Document myFactory = impl.createDocument(svgNS, "svg", null);
+    
+    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);
+
 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 `SVGGraphics2D` 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.
-class MySVGGenerator {
 
-    // The image handler will write all images files to "res/images".
-    private static ImageHandler ihandler =
-        new CachedImageHandlerPNGEncoder("res/images", null);
+	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(svgNS, "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);
+		}
+	}
 
-    public void generateSVG(JPanel myCanvas, OutputStream outStream) {
-        DOMImplementation domImpl =
-            GenericDOMImplementation.getDOMImplementation();
-        Document myFactory = domImpl.createDocument(svgNS, "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);
-    }
-}
 ## Customizing the generated SVG style <a id="Customizing+the+generated+SVG+style"></a>
 
 Your needs in matter of styling may be different from the two provided options (XML presentation attributes or CSS inline stylesheets). For example, you may want to put the CSS properties in a SVG `style` element section and reference them through the class attribute. In this case you will need to define a new [StyleHandler](../javadoc/org/apache/batik/svggen/StyleHandler.html) as below.
-public class StyleSheetStyleHandler implements StyleHandler {
 
-    // The CDATA section that holds the CSS stylesheet.
-    private CDATASection styleSheet;
+	public class StyleSheetStyleHandler implements StyleHandler {
+	
+		// The CDATA section that holds the CSS stylesheet.
+		private CDATASection styleSheet;
+	
+		// Build the handler with a reference to the stylesheet section.
+		public StyleSheetStyleHandler(CDATASection styleSheet) {
+			this.styleSheet = styleSheet;
+		}
+	
+		public void setStyle(Element element, Map styleMap,
+							 SVGGeneratorContext generatorContext) {
+			Iterator iter = styleMap.keySet().iterator();
+	
+			// Create a new class in the style sheet.
+			String id = generatorContext.getIDGenerator().generateID("C");
+			styleSheet.appendData("."+ id +" {");
+	
+			// Append each key/value pair.
+			while (iter.hasNext()) {
+				String key = (String) iter.next();
+				String value = (String) styleMap.get(key);
+				styleSheet.appendData(key + ":" + value + ";");
+			}
+	
+			styleSheet.appendData("}\n");
+	
+			// Reference the stylesheet class on the element to be styled.
+			element.setAttributeNS(null, "class", id);
+		}
+	}
 
-    // Build the handler with a reference to the stylesheet section.
-    public StyleSheetStyleHandler(CDATASection styleSheet) {
-        this.styleSheet = styleSheet;
-    }
-
-    public void setStyle(Element element, Map styleMap,
-                         SVGGeneratorContext generatorContext) {
-        Iterator iter = styleMap.keySet().iterator();
-
-        // Create a new class in the style sheet.
-        String id = generatorContext.getIDGenerator().generateID("C");
-        styleSheet.appendData("."+ id +" {");
-
-        // Append each key/value pair.
-        while (iter.hasNext()) {
-            String key = (String) iter.next();
-            String value = (String) styleMap.get(key);
-            styleSheet.appendData(key + ":" + value + ";");
-        }
-
-        styleSheet.appendData("}\n");
-
-        // Reference the stylesheet class on the element to be styled.
-        element.setAttributeNS(null, "class", id);
-    }
-}
 Then you can create and use an `SVGGraphics2D` with a correctly configured `SVGGeneratorContext` .
 
-// Configure the SVGGraphics2D for a given Document myFactory.
-SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
-CDATASection styleSheet = myFactory.createCDATASection("");
-ctx.setStyleHandler(new StyleSheetStyleHandler(styleSheet));
-SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
-
-// Use the g2d to draw (e.g., component.paint(g2d)).
-
-// Add a stylesheet to the definition section.
-SVGSVGElement root = (SVGSVGElement) g2d.getRoot();
-Element defs = root.getElementById(SVGSyntax.ID_PREFIX_GENERIC_DEFS);
-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);
+	// Configure the SVGGraphics2D for a given Document myFactory.
+	SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
+	CDATASection styleSheet = myFactory.createCDATASection("");
+	ctx.setStyleHandler(new StyleSheetStyleHandler(styleSheet));
+	SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
+	
+	// Use the g2d to draw (e.g., component.paint(g2d)).
+	
+	// Add a stylesheet to the definition section.
+	SVGSVGElement root = (SVGSVGElement) g2d.getRoot();
+	Element defs = root.getElementById(SVGSyntax.ID_PREFIX_GENERIC_DEFS);
+	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);
+	
+	// Dump the root content to a given Writer myWriter.
+	g2d.stream(root, myWriter);
 
-// Dump the root content to a given Writer myWriter.
-g2d.stream(root, myWriter);
 ## Extending Paint object to SVG element translation <a id="Extending+Paint+object+to+SVG+element+translation"></a>
 
 The `SVGGraphics2D` 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 [Paint](http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Paint.html) interface. In this case, you will need to write an [ExtensionHandler](../javadoc/org/apache/batik/svggen/ExtensionHandler.html) that you will set on your `SVGGeneratorContext` .
 
 In the following example we define the first draft of an `ExtensionHandler` allowing to translate a Batik implementation of the `Paint` interface named [LinearGradientPaint](../javadoc/org/apache/batik/ext/awt/LinearGradientPaint.html) .
-class MyExtensionHandler extends DefaultExtensionHandler {
 
-    public SVGPaintDescriptor handlePaint(Paint paint,
-                                          SVGGeneratorContext generatorCtx) {
-        if (paint instanceof LinearGradientPaint) {
-            LinearGradientPaint gradient = (LinearGradientPaint) paint;
-
-            // Create a new SVG 'linearGradient' element to represent the
-            // LinearGradientPaint being used.
-            String id = generatorCtx.getIDGenerator().generateID("gradient");
-            Document doc = generatorCtx.getDOMFactory();
-            Element grad = doc.createElementNS
-                (SVGSyntax.SVG_NAMESPACE_URI,
-                 SVGSyntax.SVG_LINEAR_GRADIENT_TAG);
-
-            // Set the relevant attributes on the 'linearGradient' element.
-            grad.setAttributeNS(null, SVGSyntax.SVG_ID_ATTRIBUTE, id);
-            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 {
-            // Let the default mechanism do its job.
-            return null;
-        }
-    }
-}
+	class MyExtensionHandler extends DefaultExtensionHandler {
+	
+		public SVGPaintDescriptor handlePaint(Paint paint,
+											  SVGGeneratorContext generatorCtx) {
+			if (paint instanceof LinearGradientPaint) {
+				LinearGradientPaint gradient = (LinearGradientPaint) paint;
+	
+				// Create a new SVG 'linearGradient' element to represent the
+				// LinearGradientPaint being used.
+				String id = generatorCtx.getIDGenerator().generateID("gradient");
+				Document doc = generatorCtx.getDOMFactory();
+				Element grad = doc.createElementNS
+					(SVGSyntax.SVG_NAMESPACE_URI,
+					 SVGSyntax.SVG_LINEAR_GRADIENT_TAG);
+	
+				// Set the relevant attributes on the 'linearGradient' element.
+				grad.setAttributeNS(null, SVGSyntax.SVG_ID_ATTRIBUTE, id);
+				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 {
+				// Let the default mechanism do its job.
+				return null;
+			}
+		}
+	}
+
 You should then set it on the `SVGGeneratorContext` by using the `setExtensionHandler` method.
-SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
-ctx.setExtensionHandler(new MyExtensionHandler());
-SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
+
+	SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
+	ctx.setExtensionHandler(new MyExtensionHandler());
+	SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
+
 # How to view the generated SVG document <a id="view"></a>
 
 The following code example illustrates how to view the SVG content generated by an `SVGGraphics2D` object.
-import java.awt.*;
-import java.awt.geom.*;
-
-import javax.swing.*;
 
-import org.apache.batik.swing.*;
-import org.apache.batik.svggen.*;
-import org.apache.batik.dom.svg.SVGDOMImplementation;
-
-import org.w3c.dom.*;
-import org.w3c.dom.svg.*;
-
-public class ViewGeneratedSVGDemo {
-
-    public static void main(String[] args) {
-        // Create an SVG document.
-        DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
-        String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
-        SVGDocument doc = (SVGDocument) impl.createDocument(svgNS, "svg", null);
-
-        // Create a converter for this document.
-        SVGGraphics2D g = new SVGGraphics2D(doc);
-
-        // Do some drawing.
-        Shape circle = new Ellipse2D.Double(0, 0, 50, 50);
-        g.setPaint(Color.red);
-        g.fill(circle);
-        g.translate(60, 0);
-        g.setPaint(Color.green);
-        g.fill(circle);
-        g.translate(60, 0);
-        g.setPaint(Color.blue);
-        g.fill(circle);
-        g.setSVGCanvasSize(new Dimension(180, 50));
-
-        // Populate the document root with the generated SVG content.
-        Element root = doc.getDocumentElement();
-        g.getRoot(root);
-
-        // Display the document.
-        JSVGCanvas canvas = new JSVGCanvas();
-        JFrame f = new JFrame();
-        f.getContentPane().add(canvas);
-        canvas.setSVGDocument(doc);
-        f.pack();
-        f.setVisible(true);
-    }
-}
\ No newline at end of file
+	import java.awt.*;
+	import java.awt.geom.*;
+	
+	import javax.swing.*;
+	
+	import org.apache.batik.swing.*;
+	import org.apache.batik.svggen.*;
+	import org.apache.batik.dom.svg.SVGDOMImplementation;
+	
+	import org.w3c.dom.*;
+	import org.w3c.dom.svg.*;
+	
+	public class ViewGeneratedSVGDemo {
+	
+		public static void main(String[] args) {
+			// Create an SVG document.
+			DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
+			String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
+			SVGDocument doc = (SVGDocument) impl.createDocument(svgNS, "svg", null);
+	
+			// Create a converter for this document.
+			SVGGraphics2D g = new SVGGraphics2D(doc);
+	
+			// Do some drawing.
+			Shape circle = new Ellipse2D.Double(0, 0, 50, 50);
+			g.setPaint(Color.red);
+			g.fill(circle);
+			g.translate(60, 0);
+			g.setPaint(Color.green);
+			g.fill(circle);
+			g.translate(60, 0);
+			g.setPaint(Color.blue);
+			g.fill(circle);
+			g.setSVGCanvasSize(new Dimension(180, 50));
+	
+			// Populate the document root with the generated SVG content.
+			Element root = doc.getDocumentElement();
+			g.getRoot(root);
+	
+			// Display the document.
+			JSVGCanvas canvas = new JSVGCanvas();
+			JFrame f = new JFrame();
+			f.getContentPane().add(canvas);
+			canvas.setSVGDocument(doc);
+			f.pack();
+			f.setVisible(true);
+		}
+	}



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


Mime
View raw message