You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2005/07/12 04:06:00 UTC

svn commit: r215909 [9/13] - in /xmlgraphics/batik/branches/svg12: ./ contrib/charts/xml/ contrib/charts/xsl/ contrib/fonts/gladiator/svg/ contrib/jsvg/ contrib/tiledTranscoder/ resources/org/apache/batik/apps/svgbrowser/resources/ resources/org/apache...

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGArc.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGArc.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGArc.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGArc.java Mon Jul 11 19:05:44 2005
@@ -18,6 +18,7 @@
 package org.apache.batik.svggen;
 
 import java.awt.geom.Arc2D;
+import java.awt.geom.Ellipse2D;
 import java.awt.geom.Line2D;
 import java.awt.geom.Point2D;
 
@@ -32,12 +33,18 @@
  * @version $Id$
  */
 public class SVGArc extends SVGGraphicObjectConverter {
+
     /**
      * Line converter used for degenerate cases
      */
     private SVGLine svgLine;
 
     /**
+     * Ellipse converter for 360 degree arcs.
+     */
+    private SVGEllipse svgEllipse;
+
+    /**
      * @param generatorContext used to build Elements
      */
     public SVGArc(SVGGeneratorContext generatorContext) {
@@ -48,23 +55,36 @@
      * @param arc the Arc2D object to be converted
      */
     public Element toSVG(Arc2D arc) {
-        if ((arc.getWidth() == 0) ||  (arc.getHeight() == 0)) {
+        double ext    = arc.getAngleExtent();
+        double width  = arc.getWidth();
+        double height = arc.getHeight();
+
+        if (width == 0 || height == 0) {
             Line2D line = new Line2D.Double
                 (arc.getX(), arc.getY(), 
-                 arc.getX() + arc.getWidth(), 
-                 arc.getY() + arc.getHeight());
-            if (svgLine == null)
+                 arc.getX() + width, 
+                 arc.getY() + height);
+            if (svgLine == null) {
                 svgLine = new SVGLine(generatorContext);
+            }
             return svgLine.toSVG(line);
         }
 
+        if (ext >= 360 || ext <= -360) {
+            Ellipse2D ellipse = new Ellipse2D.Double
+                (arc.getX(), arc.getY(), width, height);
+            if (svgEllipse == null) {
+                svgEllipse = new SVGEllipse(generatorContext);
+            }
+            return svgEllipse.toSVG(ellipse);
+        }
+
         Element svgPath = generatorContext.domFactory.createElementNS
             (SVG_NAMESPACE_URI, SVG_PATH_TAG);
         StringBuffer d = new StringBuffer("");
 
         Point2D startPt = arc.getStartPoint();
         Point2D endPt   = arc.getEndPoint();
-        double  ext     = arc.getAngleExtent();
         int     type    = arc.getArcType();
 
         d.append(PATH_MOVE);
@@ -74,17 +94,25 @@
         d.append(SPACE);
 
         d.append(PATH_ARC);
-        d.append(doubleString(arc.getWidth()/2));
+        d.append(doubleString(width / 2));
         d.append(SPACE);
-        d.append(doubleString(arc.getHeight()/2));
+        d.append(doubleString(height / 2));
         d.append(SPACE);
         d.append("0");  // no rotation with J2D arc.
         d.append(SPACE);
-        if (ext > 180)  d.append("1");  // use large arc.
-        else            d.append("0");  // use small arc.
-        d.append(SPACE);
-        if (ext > 0)    d.append("0");  // sweep ccw
-        else            d.append("1");  // sweep cw
+        if (ext > 0) { 
+            // CCW sweep case, ext > 0
+            if (ext > 180)  d.append("1");  // use large arc.
+            else            d.append("0");  // use small arc.
+            d.append(SPACE);
+            d.append("0");  // sweep ccw
+        } else {
+            // CW sweep case, ext < 0
+            if (ext < -180)  d.append("1");  // use large arc.
+            else             d.append("0");  // use small arc.
+            d.append(SPACE);
+            d.append("1");  // sweep cw
+        }
 
         d.append(SPACE);
         d.append(doubleString(endPt.getX()));
@@ -94,8 +122,8 @@
         if (type == Arc2D.CHORD) {
             d.append(PATH_CLOSE);
         } else if (type == Arc2D.PIE) {
-            double cx = arc.getX()+arc.getWidth()/2;
-            double cy = arc.getY()+arc.getHeight()/2;
+            double cx = arc.getX() + width / 2;
+            double cy = arc.getY() + height / 2;
             d.append(PATH_LINE_TO);
             d.append(SPACE);
             d.append(doubleString(cx));

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGAttributeMap.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGAttributeMap.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGAttributeMap.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGAttributeMap.java Mon Jul 11 19:05:44 2005
@@ -34,7 +34,7 @@
     private static Map attrMap = new HashMap();
 
     /**
-     * @param name SVG name of the requested attribute
+     * @param attrName SVG name of the requested attribute
      * @return attribute with requested name
      */
     public static SVGAttribute get(String attrName) {

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGClipDescriptor.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGClipDescriptor.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGClipDescriptor.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGClipDescriptor.java Mon Jul 11 19:05:44 2005
@@ -37,8 +37,9 @@
     private Element clipPathDef;
 
     /**
+     * Creates a new SVGClipDescriptor.
+     * @param clipPathValue the clip path value
      * @param clipPathDef definition of a clip path
-     * @param attribute value referencing clipPathDef
      */
     public SVGClipDescriptor(String clipPathValue, Element clipPathDef){
         if (clipPathValue == null)

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGComposite.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGComposite.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGComposite.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGComposite.java Mon Jul 11 19:05:44 2005
@@ -26,14 +26,16 @@
 
 /**
  * Utility class that converts a Composite object into
- * a set of SVG properties and definitions. Here is
- * how Composites are mapped to SVG:
- * + AlphaComposite.SRC_OVER with extra alpha is mapped
- *   to the opacity attribute
- * + AlphaComposite's other rules are translated into
- *   predefined filter effects.
- * + Custom Composite implementations are handled by the
- *   extension mechanism.
+ * a set of SVG properties and definitions.
+ * <p>Here is how Composites are mapped to SVG:</p>
+ * <ul>
+ *   <li>AlphaComposite.SRC_OVER with extra alpha is mapped
+ *     to the opacity attribute</li>
+ *   <li>AlphaComposite's other rules are translated into
+ *     predefined filter effects.</li>
+ *   <li>Custom Composite implementations are handled by the
+ *     extension mechanism.</li>
+ * </ul>
  *
  * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
  * @version $Id$
@@ -56,10 +58,8 @@
     private SVGGeneratorContext generatorContext;
 
     /**
-     * @param domFactory used by the converter to create Element and other
-     *        needed DOM objects
-     * @param extensionHandler can be invoked to handle unknown Composite
-     *        implementations.
+     * @param generatorContext The generator context used for handling
+     *        custom and alpha composites
      */
     public SVGComposite(SVGGeneratorContext generatorContext) {
         this.svgAlphaComposite =  new SVGAlphaComposite(generatorContext);

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGConvolveOp.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGConvolveOp.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGConvolveOp.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGConvolveOp.java Mon Jul 11 19:05:44 2005
@@ -45,7 +45,7 @@
      * Converts a Java 2D API BufferedImageOp into
      * a set of attribute/value pairs and related definitions
      *
-     * @param op BufferedImageOp filter to be converted
+     * @param filter BufferedImageOp filter to be converted
      * @param filterRect Rectangle, in device space, that defines the area
      *        to which filtering applies. May be null, meaning that the
      *        area is undefined.

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGFilterConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGFilterConverter.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGFilterConverter.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGFilterConverter.java Mon Jul 11 19:05:44 2005
@@ -34,7 +34,7 @@
      * Converts a Java 2D API BufferedImageOp into
      * a set of attribute/value pairs and related definitions
      *
-     * @param op BufferedImageOp filter to be converted
+     * @param filter BufferedImageOp filter to be converted
      * @param filterRect Rectangle, in device space, that defines the area
      *        to which filtering applies. May be null, meaning that the
      *        area is undefined.

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGGeneratorContext.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGGeneratorContext.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGGeneratorContext.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGGeneratorContext.java Mon Jul 11 19:05:44 2005
@@ -39,7 +39,7 @@
  * You can subclass it to change the defaults.
  *
  * @see org.apache.batik.svggen.SVGGraphics2D#SVGGraphics2D(SVGGeneratorContext,boolean)
- * @author <a href="mailto:cjolif@ilog.fr>Christophe Jolif</a>
+ * @author <a href="mailto:cjolif@ilog.fr">Christophe Jolif</a>
  * @version $Id$
  */
 public class SVGGeneratorContext implements ErrorConstants {

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGGraphics2D.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGGraphics2D.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGGraphics2D.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGGraphics2D.java Mon Jul 11 19:05:44 2005
@@ -103,7 +103,7 @@
      * the DOMTreeManager to process attributes based on the
      * GraphicContext state and create groups when needed.
      */
-    private DOMTreeManager domTreeManager;
+    protected DOMTreeManager domTreeManager;
 
     /**
      * The DOMGroupManager manages additions to the current group
@@ -115,28 +115,28 @@
      * originating from the same SVGGraphics2D through various
      * createGraphics calls share the same DOMTreeManager.
      */
-    private DOMGroupManager domGroupManager;
+    protected DOMGroupManager domGroupManager;
 
     /**
      * Contains some information for SVG generation.
      */
-    private SVGGeneratorContext generatorCtx;
+    protected SVGGeneratorContext generatorCtx;
 
     /**
      * Used to convert Java 2D API Shape objects to equivalent SVG
      * elements
      */
-    private SVGShape shapeConverter;
+    protected SVGShape shapeConverter;
 
     /**
      * SVG Canvas size
      */
-    private Dimension svgCanvasSize;
+    protected Dimension svgCanvasSize;
 
     /**
      * Used to create proper font metrics
      */
-    private Graphics2D fmg;
+    protected Graphics2D fmg;
 
     {
         BufferedImage bi
@@ -153,7 +153,10 @@
     }
 
     /**
-     * @param SVG Canvas size. May be null (equivalent to 100%, 100%)
+     * Set the Canvas size, this is used to set the width and
+     * height attributes on the outermost 'svg' element.
+     * @param svgCanvasSize SVG Canvas size. May be null (equivalent
+     * to 100%, 100%)
      */
     public final void setSVGCanvasSize(Dimension svgCanvasSize) {
         this.svgCanvasSize = new Dimension(svgCanvasSize);
@@ -167,12 +170,29 @@
     }
 
     /**
+     * @return the SVGShape used by this SVGGraphics2D instance to
+     *         turn Java2D shapes into SVG Shape objects.
+     */ 
+    public final SVGShape getShapeConverter() {
+        return shapeConverter;
+    }
+
+    /**
      * @return the DOMTreeManager used by this SVGGraphics2D instance
      */
     public final DOMTreeManager getDOMTreeManager(){
         return domTreeManager;
     }
 
+    /** 
+     * Set a DOM Tree manager for the SVGGraphics2D.
+     * @param treeMgr the new DOM Tree manager this SVGGraphics2D should use
+     */
+     protected final void setDOMTreeManager(DOMTreeManager treeMgr) {
+        this.domTreeManager = treeMgr;
+        generatorCtx.genericImageHandler.setDOMTreeManager(domTreeManager);
+    }
+
      /**
      * @return the DOMGroupManager used by this SVGGraphics2D instance
      */
@@ -180,6 +200,14 @@
         return domGroupManager;
     }
 
+    /** 
+     * Set a new DOM Group manager for this SVGGraphics2D.
+     * @param groupMgr the new DOM Group manager this SVGGraphics2D should use
+     */
+     protected final void setDOMGroupManager(DOMGroupManager groupMgr) {
+	this.domGroupManager = groupMgr;
+    }
+
     /**
      * @return the Document used as a DOM object factory by this
      *         SVGGraphics2D instance
@@ -210,7 +238,8 @@
     }
 
     /**
-     * @param new extension handler this SVGGraphics2D should use
+     * @param extensionHandler new extension handler this SVGGraphics2D
+     *        should use
      */
     public final void setExtensionHandler(ExtensionHandler extensionHandler) {
         generatorCtx.setExtensionHandler(extensionHandler);
@@ -227,7 +256,7 @@
 
     /**
      * @param domFactory Factory which will produce Elements for the DOM tree
-     *                    this Graphics2D generates.
+     *                   this Graphics2D generates.
      * @param imageHandler defines how images are referenced in the
      *                     generated SVG fragment
      * @param extensionHandler defines how Java 2D API extensions map
@@ -268,7 +297,8 @@
     }
 
     /**
-     * @param generatorContext the <code>SVGGeneratorContext</code> instance
+     * Creates a new SVGGraphics2D object.
+     * @param generatorCtx the <code>SVGGeneratorContext</code> instance
      * that will provide all useful information to the generator.
      * @param textAsShapes if true, all text is turned into SVG shapes in the
      *        convertion. No SVG text is output.
@@ -289,7 +319,7 @@
     /**
      * Sets an non null <code>SVGGeneratorContext</code>.
      */
-    private void setGeneratorContext(SVGGeneratorContext generatorCtx) {
+    protected void setGeneratorContext(SVGGeneratorContext generatorCtx) {
         this.generatorCtx = generatorCtx;
 
         this.gc = new GraphicContext(new AffineTransform());
@@ -331,7 +361,7 @@
     }
 
     /**
-     * This private constructor is used in create
+     * This constructor is used in create()
      *
      * @see #create
      */
@@ -515,8 +545,8 @@
      *
      * @param svgRoot an SVG element underwhich the content should 
      *        be appended.
-     * @returns the svg root node of the SVG document associated with 
-     *          this object.
+     * @return the svg root node of the SVG document associated with 
+     *         this object.
      */
     public Element getRoot(Element svgRoot) {
         svgRoot = domTreeManager.getRoot(svgRoot);
@@ -846,9 +876,10 @@
      * </pre>
      * @param op the filter to be applied to the image before rendering
      * @param img the <code>BufferedImage</code> to be rendered
-     * @param x,&nbsp;y the location in user space where the upper left
-     * corner of the
-     * image is rendered
+     * @param x the x coordinate in user space where the upper left
+     *          corner of the image is rendered
+     * @param y the y coordinate in user space where the upper left
+     *          corner of the image is rendered
      * @see #transform
      * @see #setTransform
      * @see #setComposite
@@ -966,7 +997,7 @@
      * that no rendering is done if the specified transform is
      * noninvertible.
      * @param img the image to be rendered
-     * @param xform the transformation from image space into user space
+     * @param trans2 the transformation from image space into user space
      * @see #transform
      * @see #setTransform
      * @see #setComposite
@@ -1036,7 +1067,7 @@
      * <code>Transform</code>, and <code>Composite</code> attributes. Note
      * that no rendering is done if the specified transform is
      * noninvertible.
-     *<p>
+     * <p>
      * Rendering hints set on the <code>Graphics2D</code> object might
      * be used in rendering the <code>RenderableImage</code>.
      * If explicit control is required over specific hints recognized by a
@@ -1044,9 +1075,9 @@
      * are used is required, then a <code>RenderedImage</code> should be
      * obtained directly from the <code>RenderableImage</code>
      * and rendered using
-     *{@link #drawRenderedImage(RenderedImage, AffineTransform)}.
+     * {@link #drawRenderedImage(RenderedImage, AffineTransform)}.
      * @param img the image to be rendered
-     * @param xform the transformation from image space into user space
+     * @param trans2 the transformation from image space into user space
      * @see #transform
      * @see #setTransform
      * @see #setComposite
@@ -1120,8 +1151,10 @@
      * left, in which case the coordinate supplied is the location of the
      * leftmost character on the baseline.
      * @param s the <code>String</code> to be rendered
-     * @param x,&nbsp;y the coordinates where the <code>String</code>
-     * should be rendered
+     * @param x the x coordinate where the <code>String</code>
+     *          should be rendered
+     * @param y the y coordinate where the <code>String</code>
+     *          should be rendered
      * @see #setPaint
      * @see java.awt.Graphics#setColor
      * @see java.awt.Graphics#setFont
@@ -1205,8 +1238,8 @@
      * longer text but shapes), but it is graphically accurate.
      *
      * @param iterator the iterator whose text is to be rendered
-     * @param x,&nbsp;y the coordinates where the iterator's text is to be
-     * rendered
+     * @param x the x coordinate where the iterator's text is to be rendered
+     * @param y the y coordinate where the iterator's text is to be rendered
      * @see #setPaint
      * @see java.awt.Graphics#setColor
      * @see #setTransform

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGLookupOp.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGLookupOp.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGLookupOp.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGLookupOp.java Mon Jul 11 19:05:44 2005
@@ -84,7 +84,7 @@
      * Converts a Java 2D API BufferedImageOp into
      * a set of attribute/value pairs and related definitions
      *
-     * @param op BufferedImageOp filter to be converted
+     * @param filter BufferedImageOp filter to be converted
      * @param filterRect Rectangle, in device space, that defines the area
      *        to which filtering applies. May be null, meaning that the
      *        area is undefined.

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGRescaleOp.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGRescaleOp.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGRescaleOp.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SVGRescaleOp.java Mon Jul 11 19:05:44 2005
@@ -49,7 +49,7 @@
      * Converts a Java 2D API BufferedImageOp into
      * a set of attribute/value pairs and related definitions
      *
-     * @param op BufferedImageOp filter to be converted
+     * @param filter BufferedImageOp filter to be converted
      * @param filterRect Rectangle, in device space, that defines the area
      *        to which filtering applies. May be null, meaning that the
      *        area is undefined.

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SwingSVGPrettyPrint.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SwingSVGPrettyPrint.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SwingSVGPrettyPrint.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/SwingSVGPrettyPrint.java Mon Jul 11 19:05:44 2005
@@ -14,7 +14,8 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 
- */package org.apache.batik.svggen;
+ */
+package org.apache.batik.svggen;
 
 import java.awt.Component;
 import java.awt.Rectangle;
@@ -32,20 +33,22 @@
 import javax.swing.plaf.ComponentUI;
 
 import org.w3c.dom.Element;
+
 /**
  * This class offers a way to create an SVG document with grouping
  * that reflects the Swing composite structure (container/components).
  *
- * @author             Vincent Hardy
- * @version            1.1, May 2nd, 2000. Added
+ * @author Vincent Hardy
+ * @version $Id$
  */
 public abstract class SwingSVGPrettyPrint implements SVGSyntax {
-        /**
-         * @param cmp Swing component to be converted to SVG
-         * @param svgGen SVGraphics2D to use to paint Swing components
-         * @return an SVG fragment containing an SVG equivalent of the Swing
-         *         component tree.
-         */
+
+    /**
+     * @param cmp Swing component to be converted to SVG
+     * @param svgGen SVGraphics2D to use to paint Swing components
+     * @return an SVG fragment containing an SVG equivalent of the Swing
+     *         component tree.
+     */
     public static void print(JComponent cmp, SVGGraphics2D svgGen) {
         if ((cmp instanceof JComboBox) || (cmp instanceof JScrollBar)) {
             // This is a work around unresolved issue with JComboBox
@@ -85,8 +88,6 @@
     /**
      * @param cmp Swing component to be converted to SVG
      * @param svgGen SVGraphics2D to use to paint Swing components
-     * @return an SVG fragment containing an SVG equivalent of the Swing
-     *         component tree.
      */
     private static void printHack(JComponent cmp, SVGGraphics2D svgGen) {
         // Spawn a new Graphics2D for this component

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/font/SVGFont.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/font/SVGFont.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/font/SVGFont.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/font/SVGFont.java Mon Jul 11 19:05:44 2005
@@ -259,7 +259,8 @@
     }
 
     /**
-     * Returns a <font>...</font> block, defining the specified font.
+     * Returns a &lt;font&gt;&#x2e;&#x2e;&#x2e;&lt;/font&gt; block,
+     * defining the specified font.
      *
      * @param font The TrueType font to be converted to SVG
      * @param id An XML id attribute for the font element
@@ -504,7 +505,8 @@
                 arabInitGlyphIndex,
                 defaultHorizAdvanceX,
                 // " arabic-form=\"initial\"",
-                SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + SVG_INITIAL_VALUE + XML_CHAR_QUOT,
+                (XML_SPACE + SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + 
+                 SVG_INITIAL_VALUE + XML_CHAR_QUOT),
                 code));
             // sb.append("\r\n");
             sb.append(EOL);
@@ -517,8 +519,9 @@
                 font.getGlyph(arabMediGlyphIndex),
                 arabMediGlyphIndex,
                 defaultHorizAdvanceX,
-                SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + SVG_MEDIAL_VALUE + XML_CHAR_QUOT,
                 // " arabic-form=\"medial\"",
+                (XML_SPACE + SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + 
+                 SVG_MEDIAL_VALUE + XML_CHAR_QUOT),
                 code));
             // sb.append("\r\n");
             sb.append(EOL);
@@ -531,8 +534,9 @@
                 font.getGlyph(arabTermGlyphIndex),
                 arabTermGlyphIndex,
                 defaultHorizAdvanceX,
-                SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + SVG_TERMINAL_VALUE + XML_CHAR_QUOT,
                 // " arabic-form=\"terminal\"",
+                (XML_SPACE + SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + 
+                 SVG_TERMINAL_VALUE + XML_CHAR_QUOT),
                 code));
             // sb.append("\r\n");
             sb.append(EOL);
@@ -545,8 +549,9 @@
                 glyph,
                 glyphIndex,
                 defaultHorizAdvanceX,
-                SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + SVG_ISOLATED_VALUE + XML_CHAR_QUOT,
                 // " arabic-form=\"isolated\"",
+                (XML_SPACE + SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + 
+                 SVG_ISOLATED_VALUE + XML_CHAR_QUOT),
                 code));
         } else {
             sb.append(getGlyphAsSVG(

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/font/table/Coverage.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/font/table/Coverage.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/font/table/Coverage.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/font/table/Coverage.java Mon Jul 11 19:05:44 2005
@@ -31,7 +31,7 @@
 
     /**
      * @param glyphId The ID of the glyph to find.
-     * @returns The index of the glyph within the coverage, or -1 if the glyph
+     * @return The index of the glyph within the coverage, or -1 if the glyph
      * can't be found.
      */
     public abstract int findGlyph(int glyphId);

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/JSVGCanvas.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/JSVGCanvas.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/JSVGCanvas.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/JSVGCanvas.java Mon Jul 11 19:05:44 2005
@@ -28,7 +28,10 @@
 import java.awt.geom.AffineTransform;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
 
 import javax.swing.AbstractAction;
 import javax.swing.ActionMap;
@@ -52,6 +55,7 @@
 import org.apache.batik.util.SVGConstants;
 import org.apache.batik.util.XMLConstants;
 import org.apache.batik.util.gui.JErrorPane;
+
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.events.Event;
@@ -173,21 +177,41 @@
      * Keeps track of the last known mouse position over the canvas.
      * This is used for displaying tooltips at the right location.
      */
-    protected LocationListener locationListener = null;
+    protected LocationListener locationListener = new LocationListener();
+
+    /**
+     * Mapping of elements to listeners so they can be removed,
+     * if the tooltip is removed.
+     */
+    protected Map toolTipMap = null;
+    protected EventListener toolTipListener = new ToolTipModifier();
+    protected EventTarget   lastTarget = null;;
+    /**
+     * The time of the last tool tip event.
+     */
+    protected long lastToolTipEventTimeStamp;
+
+    /**
+     * The target for which the last tool tip event was fired.
+     */
+    protected EventTarget lastToolTipEventTarget;
+
+
 
     /**
      * Creates a new JSVGCanvas.
      */
     public JSVGCanvas() {
         this(null, true, true);
+        addMouseMotionListener(locationListener);
     }
 
     /**
      * Creates a new JSVGCanvas.
      *
      * @param ua a SVGUserAgent instance or null.
-     * @param eventEnabled Whether the GVT tree should be reactive to mouse and
-     * key events.
+     * @param eventsEnabled Whether the GVT tree should be reactive to mouse
+     *                      and key events.
      * @param selectableText Whether the text should be selectable.
      */
     public JSVGCanvas(SVGUserAgent ua,
@@ -217,6 +241,7 @@
 
             installKeyboardActions();
         }
+        addMouseMotionListener(locationListener);
     }
 
     /**
@@ -520,6 +545,35 @@
 
     }
 
+    protected void installSVGDocument(SVGDocument doc) {
+        if (svgDocument != null) {
+            EventTarget root;
+            root = (EventTarget)svgDocument.getRootElement();
+            root.removeEventListener(SVGConstants.SVG_EVENT_MOUSEOVER,
+                                     toolTipListener, false);
+            root.removeEventListener(SVGConstants.SVG_EVENT_MOUSEOUT,
+                                     toolTipListener, false);
+            lastTarget = null;
+        }
+
+        if (toolTipMap != null) {
+            toolTipMap.clear();
+        }
+
+        if (doc != null) {
+            EventTarget root;
+            root = (EventTarget)doc.getRootElement();
+            // On mouseover, it sets the tooltip to the given value
+            root.addEventListener(SVGConstants.SVG_EVENT_MOUSEOVER,
+                                  toolTipListener, false);
+            // On mouseout, it removes the tooltip
+            root.addEventListener(SVGConstants.SVG_EVENT_MOUSEOUT,
+                                  toolTipListener, false);
+        }
+
+        super.installSVGDocument(doc);
+    }
+
     // ----------------------------------------------------------------------
     // Actions
     // ----------------------------------------------------------------------
@@ -733,7 +787,7 @@
 
     /**
      * The <tt>CanvasUserAgent</tt> only adds tooltips to the behavior of the
-     * default <tt>BridgeUserAgent</tt>.<br /> A tooltip will be displayed
+     * default <tt>BridgeUserAgent</tt>. A tooltip will be displayed
      * wheneven the mouse lingers over an element which has a &lt;title&gt; or a
      * &lt;desc&gt; child element.
      */
@@ -749,16 +803,6 @@
             = "JSVGCanvas.CanvasUserAgent.ToolTip.titleAndDesc";
 
         /**
-         * The time of the last tool tip event.
-         */
-        protected long lastToolTipEventTimeStamp;
-
-        /**
-         * The target for which the last tool tip event was fired.
-         */
-        protected EventTarget lastToolTipEventTarget;
-
-        /**
          * The handleElement method builds a tool tip from the
          * content of a &lt;title&gt; element, a &lt;desc&gt;
          * element or both. <br/>
@@ -787,65 +831,103 @@
 
             // Don't handle tool tips for the root SVG element.
             if (elt.getParentNode() == 
-                    elt.getOwnerDocument().getDocumentElement()) {
+                elt.getOwnerDocument().getDocumentElement()) {
                 return;
             }
 
+            Element parent;
+            // When node is removed data is old parent node
+            // since we can't get it otherwise.
+            if (data instanceof Element) parent = (Element)data;
+            else                         parent = (Element)elt.getParentNode();
+
+            Element descPeer = null;
+            Element titlePeer = null;
             if (elt.getLocalName().equals(SVGConstants.SVG_TITLE_TAG)) {
-                // If there is a <desc> peer, do nothing as the tooltip will
-                // be handled when handleElement is invoked for the <desc>
-                // peer.
-                if (hasPeerWithTag
-                    (elt,
-                     SVGConstants.SVG_NAMESPACE_URI,
-                     SVGConstants.SVG_DESC_TAG)){
-                    return;
-                }
-                
-                elt.normalize();
-                if (elt.getFirstChild() == null) {
-                    return;
-                }
-                String toolTip = elt.getFirstChild().getNodeValue();
-                if (toolTip == null || toolTip.length() == 0) {
-                    return;
+                if (data == Boolean.TRUE) 
+                    titlePeer = elt;
+                descPeer = getPeerWithTag(parent,
+                                           SVGConstants.SVG_NAMESPACE_URI,
+                                           SVGConstants.SVG_DESC_TAG);
+            } else if (elt.getLocalName().equals(SVGConstants.SVG_DESC_TAG)) {
+                if (data == Boolean.TRUE) 
+                    descPeer = elt;
+                titlePeer = getPeerWithTag(parent,
+                                           SVGConstants.SVG_NAMESPACE_URI,
+                                           SVGConstants.SVG_TITLE_TAG);
+            }
+
+            String titleTip = null;
+            if (titlePeer != null) {
+                titlePeer.normalize();
+                if (titlePeer.getFirstChild() != null)
+                    titleTip = titlePeer.getFirstChild().getNodeValue();
+            }
+
+            String descTip = null;
+            if (descPeer != null) {
+                descPeer.normalize();
+                if (descPeer.getFirstChild() != null)
+                    descTip = descPeer.getFirstChild().getNodeValue();
+            }
+
+            final String toolTip;
+            if ((titleTip != null) && (titleTip.length() != 0)) {
+                if ((descTip != null) && (descTip.length() != 0)) {
+                    toolTip = Messages.formatMessage
+                        (TOOLTIP_TITLE_AND_TEXT,
+                         new Object[] { toFormattedHTML(titleTip),
+                                        toFormattedHTML(descTip)});
+                } else {
+                    toolTip = Messages.formatMessage
+                        (TOOLTIP_TITLE_ONLY,
+                         new Object[]{toFormattedHTML(titleTip)});
                 }
-                toolTip = Messages.formatMessage
-                    (TOOLTIP_TITLE_ONLY,
-                     new Object[]{toFormattedHTML(toolTip)});
-                
-                setToolTip((Element)(elt.getParentNode()), toolTip);
-            } else if (elt.getLocalName().equals
-                       (SVGConstants.SVG_DESC_TAG)) {
-                //  If there is a <title> peer, prepend its content to the
-                // content of the <desc> element.
-                elt.normalize();
-                if (elt.getFirstChild() == null) {
-                    return;
+            } else {
+                if ((descTip != null) && (descTip.length() != 0)) {
+                    toolTip = Messages.formatMessage
+                        (TOOLTIP_DESC_ONLY,
+                         new Object[]{toFormattedHTML(descTip)});
+                } else {
+                    toolTip = null;
                 }
-                String toolTip = elt.getFirstChild().getNodeValue();
-                if (toolTip == null || toolTip.length() == 0) {
-                    return;
+            }
+
+            if (toolTip == null) {
+                removeToolTip(parent);
+                return;
+            }
+
+            if (lastTarget != parent) {
+                setToolTip(parent, toolTip);
+            } else {
+                // Already has focus check if it already has tip text.
+                Object o = null;
+                if (toolTipMap != null) {
+                    o = toolTipMap.get(parent);
+                    toolTipMap.put(parent, toolTip);
                 }
-                
-                Element titlePeer =
-                    getPeerWithTag(elt,
-                                   SVGConstants.SVG_NAMESPACE_URI,
-                                   SVGConstants.SVG_TITLE_TAG);
-                if (titlePeer != null) {
-                    titlePeer.normalize();
-                    toolTip = Messages.formatMessage(TOOLTIP_TITLE_AND_TEXT,
-                                                     new Object[] {
-                                                         toFormattedHTML(titlePeer.getFirstChild().getNodeValue()),
-                                                         toFormattedHTML(toolTip)});
+
+                if (o != null) {
+                    // Update components tooltip text now.
+                    EventQueue.invokeLater(new Runnable() {
+                            public void run() {
+                                setToolTipText(toolTip);
+                                MouseEvent e = new MouseEvent
+                                    (JSVGCanvas.this,
+                                     MouseEvent.MOUSE_MOVED,
+                                     System.currentTimeMillis(),
+                                     0,
+                                     locationListener.getLastX(),
+                                     locationListener.getLastY(),
+                                     0,
+                                     false);
+                                ToolTipManager.sharedInstance().mouseMoved(e);
+                            }
+                        });
                 } else {
-                    toolTip =
-                        Messages.formatMessage
-                        (TOOLTIP_DESC_ONLY,
-                         new Object[]{toFormattedHTML(toolTip)});
+                    EventQueue.invokeLater(new ToolTipRunnable(toolTip));
                 }
-                
-                setToolTip((Element)(elt.getParentNode()), toolTip);
             }
         }
 
@@ -880,11 +962,11 @@
          * Checks if there is a peer element of a given type.  This returns the
          * first occurence of the given type or null if none is found.
          */
-        public Element getPeerWithTag(Element elt,
+        public Element getPeerWithTag(Element parent,
                                       String nameSpaceURI,
                                       String localName) {
 
-            Element p = (Element)elt.getParentNode();
+            Element p = (Element)parent;
             if (p == null) {
                 return null;
             }
@@ -918,22 +1000,21 @@
          * Sets the tool tip on the input element.
          */
         public void setToolTip(Element elt, String toolTip){
-            EventTarget target = (EventTarget)elt;
-            elt.normalize();
+            if (toolTipMap == null) {
+                toolTipMap = new WeakHashMap();
+            }
+
+            toolTipMap.put(elt, toolTip);
 
-            // On mouseover, set the tooltip to the title value
-            target.addEventListener(SVGConstants.SVG_EVENT_MOUSEOVER,
-                                    new ToolTipModifier(toolTip, this),
-                                    false);
-
-            // On mouseout, remove the tooltip
-            target.addEventListener(SVGConstants.SVG_EVENT_MOUSEOUT,
-                                    new ToolTipModifier(null, this),
-                                    false);
-
-            if (locationListener == null) {
-                locationListener = new LocationListener();
-                addMouseMotionListener(locationListener);
+            if (elt == lastTarget)
+                EventQueue.invokeLater(new ToolTipRunnable(toolTip));
+        }
+
+        public void removeToolTip(Element elt) {
+            if (toolTipMap != null)
+                toolTipMap.remove(elt);
+            if (lastTarget == elt) { // clear ToolTip.
+                EventQueue.invokeLater(new ToolTipRunnable(null));
             }
         }
 
@@ -967,23 +1048,6 @@
                 dialog.setVisible(true); // Safe to be called from any thread
             }
         }
-
-        /**
-         * Sets the time and element of the last tool tip event handled.
-         */
-        public void setLastToolTipEvent(long t, EventTarget et) {
-            lastToolTipEventTimeStamp = t;
-            lastToolTipEventTarget = et;
-        }
-
-        /**
-         * Checks if the specified event time and element are the same
-         * as the last tool tip event.
-         */
-        public boolean matchLastToolTipEvent(long t, EventTarget et) {
-            return lastToolTipEventTimeStamp == t
-                && lastToolTipEventTarget == et;
-        }
     }
 
     // ----------------------------------------------------------------------
@@ -991,6 +1055,23 @@
     // ----------------------------------------------------------------------
 
     /**
+     * Sets the time and element of the last tool tip event handled.
+     */
+    public void setLastToolTipEvent(long t, EventTarget et) {
+        lastToolTipEventTimeStamp = t;
+        lastToolTipEventTarget = et;
+    }
+
+    /**
+     * Checks if the specified event time and element are the same
+     * as the last tool tip event.
+     */
+    public boolean matchLastToolTipEvent(long t, EventTarget et) {
+        return lastToolTipEventTimeStamp == t
+            && lastToolTipEventTarget == et;
+    }
+
+    /**
      * Helper class. Simply keeps track of the last known mouse
      * position over the canvas.
      */
@@ -998,6 +1079,10 @@
 
         protected int lastX, lastY;
 
+        public LocationListener () { 
+            lastX = 0; lastY = 0; 
+        }
+
         public void mouseMoved(MouseEvent evt) {
             lastX = evt.getX();
             lastY = evt.getY();
@@ -1013,65 +1098,99 @@
     }
 
     /**
-     * Sets a specific tooltip on the JSVGCanvas when a given event occurs. This
-     * listener is used in the handleElement method to set, remove or modify the
-     * JSVGCanvas tooltip on mouseover and on mouseout.<br/>
+     * Sets a specific tooltip on the JSVGCanvas when a given event occurs. 
+     * This listener is used in the handleElement method to set, remove or 
+     * modify the JSVGCanvas tooltip on mouseover and on mouseout.<br/>
      *
      * Because we are on a single <tt>JComponent</tt> we trigger an artificial
-     * <tt>MouseEvent</tt> when the toolTip is set to a non-null value, so as to
-     * make sure it will show after the <tt>ToolTipManager</tt>'s default delay.
+     * <tt>MouseEvent</tt> when the toolTip is set to a non-null value, so as 
+     * to make sure it will show after the <tt>ToolTipManager</tt>'s default 
+     * delay.
      */
     protected class ToolTipModifier implements EventListener {
         /**
-         * Value of the toolTip
-         */
-        protected String toolTip;
-
-        /**
          * The CanvasUserAgent used to track the last tool tip event.
          */
         protected CanvasUserAgent canvasUserAgent;
 
         /**
-         * @param toolTip value to which the JSVGCanvas should be
-         *        set when the event occurs.
-         * @param cua the CanvasUserAgent which will be used to track
-         *        the last tool tip event.
+         * Creates a new ToolTipModifier object.
          */
-        public ToolTipModifier(String toolTip, CanvasUserAgent cua) {
-            this.toolTip = toolTip;
-            canvasUserAgent = cua;
+        public ToolTipModifier() {
         }
 
         public void handleEvent(Event evt){
             // Don't set the tool tip if another ToolTipModifier
             // has already handled this event (as it will have been
             // a higher priority tool tip).
-            if (canvasUserAgent.matchLastToolTipEvent(evt.getTimeStamp(),
-                                                     evt.getTarget())) {
+            if (matchLastToolTipEvent(evt.getTimeStamp(), evt.getTarget())) {
                 return;
             }
-            canvasUserAgent.setLastToolTipEvent(evt.getTimeStamp(), 
-                                                evt.getTarget());
+            setLastToolTipEvent(evt.getTimeStamp(), evt.getTarget());
+            EventTarget prevLastTarget = lastTarget;
+            if (SVGConstants.SVG_EVENT_MOUSEOVER.equals(evt.getType())) {
+                lastTarget = evt.getTarget();
+            } else if (SVGConstants.SVG_EVENT_MOUSEOUT.equals(evt.getType())) {
+                // related target is one it is entering or null.
+                org.w3c.dom.events.MouseEvent mouseEvt;
+                mouseEvt = ((org.w3c.dom.events.MouseEvent)evt);
+                lastTarget = mouseEvt.getRelatedTarget(); 
+            }
 
-            EventQueue.invokeLater(new Runnable() {
-                    public void run() {
-                        setToolTipText(toolTip);
-
-                        if (toolTip != null) {
-                            MouseEvent e = new MouseEvent
-                                (JSVGCanvas.this,
-                                 MouseEvent.MOUSE_ENTERED,
-                                 System.currentTimeMillis(),
-                                 0,
-                                 locationListener.getLastX(),
-                                 locationListener.getLastY(),
-                                 0,
-                                 false);
-                            ToolTipManager.sharedInstance().mouseEntered(e);
-                        }
-                    }
-                });
+            if (toolTipMap != null) {
+                Object o = toolTipMap.get(lastTarget);
+                final String theToolTip;
+                if (o == null) theToolTip = null;
+                else           theToolTip = (String)o;
+                if (prevLastTarget != lastTarget)
+                    EventQueue.invokeLater(new ToolTipRunnable(theToolTip));
+            }
+        }
+    }
+
+    protected class ToolTipRunnable implements Runnable {
+        String theToolTip;
+        public ToolTipRunnable(String toolTip) {
+            this.theToolTip = toolTip;
+        }
+
+        public void run() {
+            setToolTipText(theToolTip);
+
+            MouseEvent e;
+            if (theToolTip != null) {
+                e = new MouseEvent
+                    (JSVGCanvas.this,
+                     MouseEvent.MOUSE_ENTERED,
+                     System.currentTimeMillis(),
+                     0,
+                     locationListener.getLastX(),
+                     locationListener.getLastY(),
+                     0,
+                     false);
+                ToolTipManager.sharedInstance().mouseEntered(e);
+                e = new MouseEvent
+                    (JSVGCanvas.this,
+                     MouseEvent.MOUSE_MOVED,
+                     System.currentTimeMillis(),
+                     0,
+                     locationListener.getLastX(),
+                     locationListener.getLastY(),
+                     0,
+                     false);
+                ToolTipManager.sharedInstance().mouseMoved(e);
+            } else {
+                e = new MouseEvent
+                    (JSVGCanvas.this,
+                     MouseEvent.MOUSE_MOVED,
+                     System.currentTimeMillis(),
+                     0,
+                     locationListener.getLastX(),
+                     locationListener.getLastY(),
+                     0,
+                     false);
+                ToolTipManager.sharedInstance().mouseMoved(e);
+            }
         }
     }
 }

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/JSVGScrollPane.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/JSVGScrollPane.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/JSVGScrollPane.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/JSVGScrollPane.java Mon Jul 11 19:05:44 2005
@@ -51,6 +51,7 @@
 import org.apache.batik.swing.gvt.JGVTComponentListener;
 import org.apache.batik.swing.svg.SVGDocumentLoaderAdapter;
 import org.apache.batik.swing.svg.SVGDocumentLoaderEvent;
+import org.apache.batik.swing.svg.SVGDocumentLoaderListener;
 import org.apache.batik.swing.svg.GVTTreeBuilderListener;
 import org.apache.batik.swing.svg.GVTTreeBuilderEvent;
 
@@ -132,11 +133,10 @@
         add(horizontalPanel, BorderLayout.SOUTH);
 		
         // inform of ZOOM events (to print sizes, such as in a status bar)
-        canvas.addSVGDocumentLoaderListener
-            (new SVGScrollDocumentLoaderListener());
+        canvas.addSVGDocumentLoaderListener(createLoadListener());
 		
         // canvas listeners
-        ScrollListener xlistener = new ScrollListener();
+        ScrollListener xlistener = createScrollListener();
         this.addComponentListener(xlistener);
         canvas.addJGVTComponentListener(xlistener);
         canvas.addGVTTreeBuilderListener(xlistener);
@@ -146,12 +146,27 @@
 
     /**
      * Scrollbar listener factory method so subclasses can
-     * use a subclass of SBListener if needed.
+     * override the default SBListener behaviour.
      */
     protected SBListener createScrollBarListener(boolean isVertical) {
         return new SBListener(isVertical);
     }
 
+    /**
+     * Factory method so subclasses can override the default listener behaviour
+     */
+    protected ScrollListener createScrollListener() {
+        return new ScrollListener();
+    }
+	
+
+    /**
+     * Factory method so subclasses can override the default load listener.
+     */
+    protected SVGDocumentLoaderListener createLoadListener() {
+        return new SVGScrollDocumentLoaderListener();
+    }
+	
     public JSVGCanvas getCanvas() {
         return canvas;
     }
@@ -320,8 +335,7 @@
         }// stateChanged()
     }// inner class SBListener
 	
-	
-	
+
     /** Handle scroll, zoom, and resize events */
     protected class ScrollListener extends ComponentAdapter 
         implements JGVTComponentListener, GVTTreeBuilderListener, 
@@ -343,14 +357,17 @@
         }// componentResized()
 		
 		
-        public void gvtBuildPrepare  (GVTTreeBuilderEvent e) { 
+        public void gvtBuildStarted  (GVTTreeBuilderEvent e) { 
             isReady = false;
+            // Start by assuming we won't need them.
+            vertical       .setVisible(false);
+            horizontalPanel.setVisible(false);
+            cornerBox      .setVisible(false);
         }
         public void gvtBuildCompleted(GVTTreeBuilderEvent e)
         {
             isReady = true;
             viewBox = null;   // new document forget old viewBox if any.
-            resizeScrollBars();
         }// gvtRenderingCompleted()
 		
         public void updateCompleted(UpdateManagerEvent e) { 
@@ -372,7 +389,6 @@
 
         public void gvtBuildCancelled(GVTTreeBuilderEvent e) { }
         public void gvtBuildFailed   (GVTTreeBuilderEvent e) { }
-        public void gvtBuildStarted  (GVTTreeBuilderEvent e) { }
 
         public void managerStarted  (UpdateManagerEvent e) { }
         public void managerSuspended(UpdateManagerEvent e) { }

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java Mon Jul 11 19:05:44 2005
@@ -25,7 +25,10 @@
 import java.awt.Graphics2D;
 import java.awt.Rectangle;
 import java.awt.RenderingHints;
+import java.awt.Toolkit;
 import java.awt.Shape;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.StringSelection;
 import java.awt.event.ComponentAdapter;
 import java.awt.event.ComponentEvent;
 import java.awt.event.InputEvent;
@@ -37,6 +40,7 @@
 import java.awt.geom.AffineTransform;
 import java.awt.geom.NoninvertibleTransformException;
 import java.awt.image.BufferedImage;
+import java.text.CharacterIterator;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -46,6 +50,8 @@
 
 import org.apache.batik.gvt.GraphicsNode;
 import org.apache.batik.gvt.event.AWTEventDispatcher;
+import org.apache.batik.gvt.event.SelectionAdapter;
+import org.apache.batik.gvt.event.SelectionEvent;
 import org.apache.batik.gvt.renderer.ConcreteImageRendererFactory;
 import org.apache.batik.gvt.renderer.ImageRenderer;
 import org.apache.batik.gvt.renderer.ImageRendererFactory;
@@ -178,6 +184,14 @@
     protected boolean selectableText;
 
     /**
+     * Whether the JGVTComponent should adhere to 'Unix' text
+     * selection semantics where as soon as text is selected it
+     * is copied to the clipboard.  If users want Mac/Windows
+     * behaviour they need to handle selections them selves.
+     */
+    protected boolean useUnixTextSelection = true;
+
+    /**
      * Whether to suspend interactions.
      */
     protected boolean suspendInteractions;
@@ -196,7 +210,7 @@
 
     /**
      * Creates a new abstract JGVTComponent.
-     * @param eventEnabled Whether the GVT tree should be reactive
+     * @param eventsEnabled Whether the GVT tree should be reactive
      *        to mouse and key events.
      * @param selectableText Whether the text should be selectable.
      *        if eventEnabled is false, this flag is ignored.
@@ -233,15 +247,42 @@
         addMouseMotionListener(listener);
     }
 
+    /**
+     * Turn off all 'interactor' objects (pan, zoom, etc) if
+     * 'b' is true, turn them on if 'b' is false.
+     */
     public void setDisableInteractions(boolean b) {
         disableInteractions = b;
     }
 
+    /**
+     * Returns true if all 'interactor' objects 
+     * (pan, zoom, etc) are disabled.
+     */
     public boolean getDisableInteractions() {
         return disableInteractions;
     }
 
     /**
+     * If 'b' is true text selections will copied to
+     * the clipboard immediately.  If 'b' is false
+     * then nothing will be done when selections are
+     * made (the application is responsable for copying
+     * the selection in response to user actions).
+     */
+    public void setUseUnixTextSelection(boolean b) {
+        useUnixTextSelection = b;
+    }
+
+    /**
+     * Returns true if the canvas will copy selections
+     * to the clipboard when they are completed.
+     */
+    public void getUseUnixTextSelection(boolean b) {
+        useUnixTextSelection = b;
+    }
+
+    /**
      * Returns the interactor list.
      */
     public List getInteractors() {
@@ -331,6 +372,8 @@
             if (selectableText) {
                 textSelectionManager =
                     new TextSelectionManager(this, eventDispatcher);
+                textSelectionManager.addSelectionListener
+                    (new UnixTextSelectionListener());
             }
         }
     }
@@ -340,6 +383,15 @@
     ////////////////////////////////////////////////////////////////////////
 
     /**
+     * Returns the current Text selection manager for the Component.
+     * Users can register with this to be notifed of changes in
+     * the text selection.
+     */
+    public TextSelectionManager getTextSelectionManager() {
+        return textSelectionManager;
+    }
+
+    /**
      * Sets the color of the selection overlay to the specified color.
      *
      * @param color the new color of the selection overlay
@@ -1157,4 +1209,52 @@
             }
         }
     }
+
+    protected class UnixTextSelectionListener 
+        extends SelectionAdapter {
+        
+        public void selectionDone(SelectionEvent evt) {
+            if (!useUnixTextSelection) return;
+
+            Object o = evt.getSelection();
+            if (!(o instanceof CharacterIterator))
+                return;
+            CharacterIterator iter = (CharacterIterator) o;
+
+            // first see if we can access the clipboard
+            SecurityManager securityManager;
+            securityManager = System.getSecurityManager();
+            if (securityManager != null) {
+                try {
+                    securityManager.checkSystemClipboardAccess();
+                } catch (SecurityException e) {
+                    return; // Can't access clipboard.
+                }
+            }
+
+            int sz = iter.getEndIndex()-iter.getBeginIndex();
+            if (sz == 0) return;
+
+            char[] cbuff = new char[sz];
+            cbuff[0] = iter.first();
+            for (int i=1; i<cbuff.length;++i) {
+                cbuff[i] = iter.next();
+            }
+            final String strSel = new String(cbuff);
+            // HACK: getSystemClipboard sometimes deadlocks on
+            // linux when called from the AWT Thread. The Thread
+            // creation prevents that.
+            new Thread() {
+                public void run() {
+                    Clipboard cb;
+                    cb = Toolkit.getDefaultToolkit().getSystemClipboard();
+                    StringSelection sel;
+                    sel = new StringSelection(strSel);
+                    cb.setContents(sel, sel);
+                }
+            }.start();
+        }
+    }
+
+
 }

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/gvt/GVTTreeRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/gvt/GVTTreeRenderer.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/gvt/GVTTreeRenderer.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/gvt/GVTTreeRenderer.java Mon Jul 11 19:05:44 2005
@@ -79,7 +79,8 @@
      * @param usr2dev The user to device transform.
      * @param dbuffer Whether the double buffering should be enabled.
      * @param aoi The area of interest in the renderer space units.
-     * @param width&nbsp;height The offscreen buffer size.
+     * @param width The offscreen buffer width.
+     * @param height The offscreen buffer height.
      */
     public GVTTreeRenderer(ImageRenderer r, AffineTransform usr2dev,
                            boolean dbuffer,

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/gvt/TextSelectionManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/gvt/TextSelectionManager.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/gvt/TextSelectionManager.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/gvt/TextSelectionManager.java Mon Jul 11 19:05:44 2005
@@ -100,6 +100,11 @@
     protected boolean xorMode = false;
 
     /**
+     * The current selection or null if there is none.
+     */
+    Object selection = null;
+
+    /**
      * Creates a new TextSelectionManager.
      */
     public TextSelectionManager(AbstractJGVTComponent comp,
@@ -190,6 +195,13 @@
     }
 
     /**
+     * Returns the current text selection or null if there is none.
+     */
+    public Object getSelection() {
+        return selection;
+    }
+
+    /**
      * Sets the selected text
      */
     public void setSelection(Mark start, Mark end) {
@@ -222,9 +234,7 @@
         }
 
         public void mouseReleased(GraphicsNodeMouseEvent evt) {
-            if (evt.getSource() instanceof Selectable) {
-                textSelector.mouseReleased(evt);
-            }
+            textSelector.mouseReleased(evt);
         }
 
         public void mouseEntered(GraphicsNodeMouseEvent evt) {
@@ -252,11 +262,7 @@
             }
         }
 
-        public void mouseMoved(GraphicsNodeMouseEvent evt) {
-            if (evt.getSource() instanceof Selectable) {
-                textSelector.mouseMoved(evt);
-            }
-        }
+        public void mouseMoved(GraphicsNodeMouseEvent evt) { }
     }
 
     /**
@@ -265,6 +271,7 @@
     protected class TextSelectionListener implements SelectionListener {
         public void selectionDone(SelectionEvent e) {
             selectionChanged(e);
+            selection = e.getSelection();
         }
         public void selectionCleared(SelectionEvent e) {
             selectionStarted(e);
@@ -275,6 +282,7 @@
                 selectionHighlight = null;
                 component.repaint(r);
             }
+            selection = null;
         }
         public void selectionChanged(SelectionEvent e) {
             Rectangle r = null;

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java Mon Jul 11 19:05:44 2005
@@ -207,16 +207,29 @@
 
     /**
      * Means that all document must be considered as dynamic.
+     *
+     * Indicates that all DOM listeners should be registered. This supports
+     * 'interactivity' (anchors and cursors), as well as DOM modifications
+     * listeners to update the GVT rendering tree.
      */
     public final static int ALWAYS_DYNAMIC = 1; 
 
     /**
      * Means that all document must be considered as static.
+     *
+     * Indicates that no DOM listeners should be registered.
+     * In this case the generated GVT tree should be totally
+     * independent of the DOM tree (in practice text holds
+     * references to the source text elements for font resolution).
      */
     public final static int ALWAYS_STATIC = 2;
 
     /**
      * Means that all document must be considered as interactive.
+     *
+     * Indicates that DOM listeners should be registered to support,
+     * 'interactivity' this includes anchors and cursors, but does not
+     * include support for DOM modifications.
      */
     public final static int ALWAYS_INTERACTIVE = 3;
 
@@ -345,7 +358,7 @@
     /**
      * Creates a new AbstractJSVGComponent.
      * @param ua a SVGUserAgent instance or null.
-     * @param eventEnabled Whether the GVT tree should be reactive
+     * @param eventsEnabled Whether the GVT tree should be reactive
      *        to mouse and key events.
      * @param selectableText Whether the text should be selectable.
      */
@@ -698,7 +711,7 @@
     /**
      * Starts a tree builder.
      */
-    private void startGVTTreeBuilder() {
+    protected void startGVTTreeBuilder() {
         gvtTreeBuilder = nextGVTTreeBuilder;
         nextGVTTreeBuilder = null;
         gvtTreeBuilder.start();
@@ -753,7 +766,7 @@
             (fragmentIdentifier, elt);
         CanvasGraphicsNode cgn = getCanvasGraphicsNode(gn);
         cgn.setViewingTransform(at);
-        viewingTransform = at;
+        viewingTransform = null;
         initialTransform = new AffineTransform();
         setRenderingTransform(initialTransform, false);
         jsvgComponentListener.updateMatrix(initialTransform);
@@ -823,6 +836,19 @@
         return (CanvasGraphicsNode)gn;
     }
 
+    public AffineTransform getViewingTransform() {
+        AffineTransform vt;
+        synchronized (this) {
+            vt = viewingTransform;
+            if (vt == null) {
+                CanvasGraphicsNode cgn = getCanvasGraphicsNode();
+                if (cgn != null)
+                    vt = cgn.getViewingTransform();
+            }
+        }
+        return vt;
+    }
+
     /**
      * Returns the transform from viewBox coords to screen coords
      */
@@ -830,8 +856,9 @@
         AffineTransform at = getRenderingTransform();
         if (at == null) at = new AffineTransform();
         else            at = new AffineTransform(at);
-        if (viewingTransform != null) {
-            at.concatenate(viewingTransform);
+        AffineTransform vt = getViewingTransform();
+        if (vt != null) {
+            at.concatenate(vt);
         }
         return at;
     }
@@ -880,7 +907,7 @@
             if (d.height < 1) d.height = 1;
             final AffineTransform at = calculateViewingTransform
                 (fragmentIdentifier, elt);
-            AffineTransform vt = viewingTransform;
+            AffineTransform vt = getViewingTransform();
             if (at.equals(vt)) {
                 // No new transform
                 // Only repaint if size really changed.
@@ -927,12 +954,18 @@
                     (AffineTransform.getTranslateInstance(dx, dy));
                 setRenderingTransform(rendAT, false);
             }
-            viewingTransform = at;
+            synchronized (this) {
+                viewingTransform = at;
+            }
             Runnable r = new Runnable() {
                     AffineTransform myAT = at;
                     CanvasGraphicsNode myCGN = getCanvasGraphicsNode();
                     public void run() {
-                        myCGN.setViewingTransform(myAT);
+                        synchronized (AbstractJSVGComponent.this) {
+                            myCGN.setViewingTransform(myAT);
+                            if (viewingTransform == myAT) 
+                                viewingTransform = null;
+                        }
                     }
                 };
             UpdateManager um = getUpdateManager();
@@ -1204,7 +1237,7 @@
 
             final boolean dispatchZoom    = (currScale != prevScale);
             final boolean dispatchScroll  = ((currTransX != prevTransX) ||
-                                             (currTransX != prevTransX));
+                                             (currTransY != prevTransY));
             if (isDynamicDocument &&
                 (updateManager != null) && updateManager.isRunning()) {
                 updateManager.getUpdateRunnableQueue().invokeLater
@@ -2442,7 +2475,7 @@
         }
         
         /**
-         * Informs the user agent that the text selection should changed.
+         * Informs the user agent that the text selection should be changed.
          * @param start The Mark for the start of the selection.
          * @param end   The Mark for the end of the selection.
          */
@@ -2459,9 +2492,7 @@
         }
 
         /**
-         * Informs the user agent that the text selection should changed.
-         * @param start The Mark for the start of the selection.
-         * @param end   The Mark for the end of the selection.
+         * Informs the user agent that the text should be deselected.
          */
         public void deselectAll() {
             if (EventQueue.isDispatchThread()) {
@@ -2692,11 +2723,11 @@
          * 
          * @param scriptType type of script, as found in the 
          *        type attribute of the &lt;script&gt; element.
-         * @param scriptURL url for the script, as defined in
+         * @param scriptPURL url for the script, as defined in
          *        the script's xlink:href attribute. If that
          *        attribute was empty, then this parameter should
          *        be null
-         * @param docURL url for the document into which the 
+         * @param docPURL url for the document into which the 
          *        script was found.
          */
         public ScriptSecurity getScriptSecurity(String scriptType,
@@ -2733,11 +2764,11 @@
          *
          * @param scriptType type of script, as found in the 
          *        type attribute of the &lt;script&gt; element.
-         * @param scriptURL url for the script, as defined in
+         * @param scriptPURL url for the script, as defined in
          *        the script's xlink:href attribute. If that
          *        attribute was empty, then this parameter should
          *        be null
-         * @param docURL url for the document into which the 
+         * @param docPURL url for the document into which the 
          *        script was found.
          */
         public void checkLoadScript(String scriptType,
@@ -2775,11 +2806,11 @@
          * Returns the security settings for the given resource
          * url and document url
          * 
-         * @param resourceURL url for the resource, as defined in
+         * @param resourcePURL url for the resource, as defined in
          *        the resource's xlink:href attribute. If that
          *        attribute was empty, then this parameter should
          *        be null
-         * @param docURL url for the document into which the 
+         * @param docPURL url for the document into which the 
          *        resource was found.
          */
         public ExternalResourceSecurity 
@@ -2812,12 +2843,12 @@
          * on the ExternalResourceSecurity strategy returned by 
          * getExternalResourceSecurity.
          *
-         * @param scriptURL url for the script, as defined in
-         *        the script's xlink:href attribute. If that
+         * @param resourceURL url for the resource, as defined in
+         *        the resource's xlink:href attribute. If that
          *        attribute was empty, then this parameter should
          *        be null
          * @param docURL url for the document into which the 
-         *        script was found.
+         *        resource was found.
          */
         public void 
             checkLoadExternalResource(ParsedURL resourceURL,
@@ -3374,12 +3405,12 @@
          * on the ExternalResourceSecurity strategy returned by 
          * getExternalResourceSecurity.
          *
-         * @param scriptURL url for the script, as defined in
-         *        the script's xlink:href attribute. If that
+         * @param resourceURL url for the resource, as defined in
+         *        the resource's xlink:href attribute. If that
          *        attribute was empty, then this parameter should
          *        be null
          * @param docURL url for the document into which the 
-         *        script was found.
+         *        resource was found.
          */
         public void 
             checkLoadExternalResource(ParsedURL resourceURL,

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGFileFilter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGFileFilter.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGFileFilter.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGFileFilter.java Mon Jul 11 19:05:44 2005
@@ -25,7 +25,7 @@
  * This implementation of FileFilter will allows SVG files
  * with extention '.svg' or '.svgz'.
  *
- * @author <a href="mailto:vincent.hardy@eng.sun.com>Vincent Hardy</a>
+ * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
  * @author <a href="mailto:cjolif@ilog.fr">Christophe Jolif</a>
  * @version $Id$
  */

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUpdateOverlay.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUpdateOverlay.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUpdateOverlay.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUpdateOverlay.java Mon Jul 11 19:05:44 2005
@@ -32,7 +32,7 @@
  *
  * Complete Class Desc
  *
- * @author <a href="mailto:deweese@apache.org>deweese</a>
+ * @author <a href="mailto:deweese@apache.org">deweese</a>
  * @version $Id$
  */
 public class SVGUpdateOverlay implements Overlay {

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUserAgent.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUserAgent.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUserAgent.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUserAgent.java Mon Jul 11 19:05:44 2005
@@ -217,12 +217,12 @@
      * on the ExternalResourceSecurity strategy returned by 
      * getExternalResourceSecurity.
      *
-     * @param scriptURL url for the script, as defined in
-     *        the script's xlink:href attribute. If that
+     * @param resourceURL url for the script, as defined in
+     *        the resource's xlink:href attribute. If that
      *        attribute was empty, then this parameter should
      *        be null
      * @param docURL url for the document into which the 
-     *        script was found.
+     *        resource was found.
      */
     void checkLoadExternalResource(ParsedURL resourceURL,
                                    ParsedURL docURL) throws SecurityException;

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUserAgentAdapter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUserAgentAdapter.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUserAgentAdapter.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUserAgentAdapter.java Mon Jul 11 19:05:44 2005
@@ -45,7 +45,7 @@
  * most of the alert,prompt,etc methods are totally useless.
  * In a GUI environment you probably want to use SVGUserAgentGUIAdapter.
  *
- * @author <a href="mailto:deweese@apache.org>deweese</a>
+ * @author <a href="mailto:deweese@apache.org">deweese</a>
  * @version $Id$
  */
 public class SVGUserAgentAdapter implements SVGUserAgent {
@@ -332,12 +332,12 @@
      * on the ExternalResourceSecurity strategy returned by 
      * getExternalResourceSecurity.
      *
-     * @param scriptURL url for the script, as defined in
-     *        the script's xlink:href attribute. If that
+     * @param resourceURL url for the resource, as defined in
+     *        the resource's xlink:href attribute. If that
      *        attribute was empty, then this parameter should
      *        be null
      * @param docURL url for the document into which the 
-     *        script was found.
+     *        resource was found.
      */
     public void 
         checkLoadExternalResource(ParsedURL resourceURL,

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUserAgentGUIAdapter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUserAgentGUIAdapter.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUserAgentGUIAdapter.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/swing/svg/SVGUserAgentGUIAdapter.java Mon Jul 11 19:05:44 2005
@@ -29,7 +29,7 @@
  * Methods users may want to implement:
  *    displayMessage
  *
- * @author <a href="mailto:deweese@apache.org>deweese</a>
+ * @author <a href="mailto:deweese@apache.org">deweese</a>
  * @version $Id$
  */
 public class SVGUserAgentGUIAdapter extends SVGUserAgentAdapter{

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/SVGAbstractTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/SVGAbstractTranscoder.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/SVGAbstractTranscoder.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/SVGAbstractTranscoder.java Mon Jul 11 19:05:44 2005
@@ -242,16 +242,18 @@
         } else {
             String ref = new ParsedURL(uri).getRef();
 
-            try {
-                Px = ViewBox.getViewTransform(ref, root, width, height);
-            } catch (BridgeException ex) {
-                throw new TranscoderException(ex);
-            }
+            String viewBox = root.getAttributeNS
+                (null, SVGConstants.SVG_VIEW_BOX_ATTRIBUTE);
 
-            if (Px.isIdentity() && 
-                (width != docWidth || height != docHeight)) {
-                // The document has no viewBox, we need to resize it by hand.
-                // we want to keep the document size ratio
+            if ((ref != null) && (ref.length() != 0)) {
+                Px = ViewBox.getViewTransform(ref, root, width, height);
+            } else if ((viewBox != null) && (viewBox.length() != 0)) {
+                String aspectRatio = root.getAttributeNS
+                    (null, SVGConstants.SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE);
+                Px = ViewBox.getPreserveAspectRatioTransform
+                    (root, viewBox, aspectRatio, width, height);
+            } else {
+                // no viewBox has been specified, create a scale transform
                 float xscale, yscale;
                 xscale = width/docWidth;
                 yscale = height/docHeight;

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/TranscodingHints.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/TranscodingHints.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/TranscodingHints.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/TranscodingHints.java Mon Jul 11 19:05:44 2005
@@ -120,7 +120,7 @@
      * Copies all of the mappings from the specified <tt>Map</tt>
      * to this <tt>TranscodingHints</tt>.
      *
-     * @param t mappings to be stored in this <tt>TranscodingHints</tt>.
+     * @param m mappings to be stored in this <tt>TranscodingHints</tt>.
      * @exception ClassCastException key is not of type
      * <tt>TranscodingHints.Key</tt>
      */

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/ImageTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/ImageTranscoder.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/ImageTranscoder.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/ImageTranscoder.java Mon Jul 11 19:05:44 2005
@@ -143,7 +143,7 @@
      * Writes the specified image to the specified output.
      * @param img the image to write
      * @param output the output where to store the image
-     * @param TranscoderException if an error occured while storing the image
+     * @throws TranscoderException if an error occured while storing the image
      */
     public abstract void writeImage(BufferedImage img, TranscoderOutput output)
         throws TranscoderException;

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/JPEGTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/JPEGTranscoder.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/JPEGTranscoder.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/JPEGTranscoder.java Mon Jul 11 19:05:44 2005
@@ -59,7 +59,7 @@
      * Writes the specified image to the specified output.
      * @param img the image to write
      * @param output the output where to store the image
-     * @param TranscoderException if an error occured while storing the image
+     * @throws TranscoderException if an error occured while storing the image
      */
     public void writeImage(BufferedImage img, TranscoderOutput output)
             throws TranscoderException {

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/PNGTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/PNGTranscoder.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/PNGTranscoder.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/PNGTranscoder.java Mon Jul 11 19:05:44 2005
@@ -61,7 +61,7 @@
      * Writes the specified image to the specified output.
      * @param img the image to write
      * @param output the output where to store the image
-     * @param TranscoderException if an error occured while storing the image
+     * @throws TranscoderException if an error occured while storing the image
      */
     public void writeImage(BufferedImage img, TranscoderOutput output)
             throws TranscoderException {

Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/TIFFTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/TIFFTranscoder.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/TIFFTranscoder.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/transcoder/image/TIFFTranscoder.java Mon Jul 11 19:05:44 2005
@@ -68,7 +68,7 @@
      * Writes the specified image to the specified output.
      * @param img the image to write
      * @param output the output where to store the image
-     * @param TranscoderException if an error occured while storing the image
+     * @throws TranscoderException if an error occured while storing the image
      */
     public void writeImage(BufferedImage img, TranscoderOutput output)
             throws TranscoderException {