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 de...@apache.org on 2006/01/24 15:17:25 UTC

svn commit: r371920 - in /xmlgraphics/batik/trunk: samples/tests/spec12/text/ sources/org/apache/batik/bridge/ sources/org/apache/batik/gvt/flow/ sources/org/apache/batik/swing/gvt/

Author: deweese
Date: Tue Jan 24 06:17:17 2006
New Revision: 371920

URL: http://svn.apache.org/viewcvs?rev=371920&view=rev
Log:
1) Ensure that Anchor listener is removed when it's anchor is
   no longer displayed.
2) Fixed NPE in FlowText when a line has no valid ranges for
   placing text (too much interfearing geometry on line).
3) JSVG/GVTComponent now clones AffineTransforms before
   returning them.

Modified:
    xmlgraphics/batik/trunk/samples/tests/spec12/text/flowTextAlign.svg
    xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGAElementBridge.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/flow/FlowRegions.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java

Modified: xmlgraphics/batik/trunk/samples/tests/spec12/text/flowTextAlign.svg
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/samples/tests/spec12/text/flowTextAlign.svg?rev=371920&r1=371919&r2=371920&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/samples/tests/spec12/text/flowTextAlign.svg (original)
+++ xmlgraphics/batik/trunk/samples/tests/spec12/text/flowTextAlign.svg Tue Jan 24 06:17:17 2006
@@ -43,8 +43,7 @@
       	    <rect x="312.5" y="0" width="125" height="36"/>
 	 </g>
 
-      	 <flowText xmlns="http://xml.apache.org/batik/ext"
-      	           font-size="24" xml:space="preserve">
+      	 <flowRoot font-size="24" xml:space="preserve">
       	    <flowRegion vertical-align="top">
       	            <rect x="12.5"  y="0" width="125" height="36" visibility="hidden"/>
       	    </flowRegion>
@@ -62,7 +61,7 @@
                <flowRegionBreak justification="middle"
 		      >Try bottom</flowRegionBreak>
 	    </flowDiv>
-      	 </flowText>
+      	 </flowRoot>
       </g>
 
       <g font-family="serif" transform="translate(0,120)" >
@@ -75,8 +74,7 @@
       	    <rect x="312.5" y="40" width="125" height="36"/>
 	 </g>
 
-      	 <flowText xmlns="http://xml.apache.org/batik/ext"
-      	           font-size="24" xml:space="preserve">
+      	 <flowRoot font-size="24" xml:space="preserve">
       	    <flowRegion vertical-align="top">
       	            <rect x="12.5"  y="0"  width="125" height="36" visibility="hidden"/>
       	            <rect x="12.5"  y="40" width="125" height="36" visibility="hidden"/>
@@ -97,7 +95,7 @@
                <flowRegionBreak justification="middle"
 		      >Bottom two lines</flowRegionBreak>
 	    </flowDiv>
-      	 </flowText>
+      	 </flowRoot>
       </g>
 
       <g font-family="serif" transform="translate(0,220)" >
@@ -107,8 +105,7 @@
       	    <rect x="312.5" y="0"  width="125" height="72"/>
 	 </g>
 
-      	 <flowText xmlns="http://xml.apache.org/batik/ext"
-      	           font-size="24" xml:space="preserve">
+      	 <flowRoot font-size="24" xml:space="preserve">
       	    <flowRegion vertical-align="top">
       	            <rect x="12.5"  y="0"  width="125" height="72" visibility="hidden"/>
       	    </flowRegion>
@@ -126,7 +123,7 @@
                <flowRegionBreak justification="middle"
 		      >Bottom two lines</flowRegionBreak>
 	    </flowDiv>
-      	 </flowText>
+      	 </flowRoot>
       </g>
 
       <g font-family="serif" transform="translate(0,320)" >
@@ -136,8 +133,7 @@
       	    <rect x="312.5" y="0"  width="125" height="72"/>
 	 </g>
 
-      	 <flowText xmlns="http://xml.apache.org/batik/ext"
-      	           font-size="24" xml:space="preserve">
+      	 <flowRoot font-size="24" xml:space="preserve">
       	    <flowRegion vertical-align="top">
       	            <rect x="12.5"  y="0"  width="125" height="72" visibility="hidden"/>
       	    </flowRegion>
@@ -161,12 +157,12 @@
                <flowRegionBreak justification="middle"
 		      >two lines</flowRegionBreak>
 	    </flowDiv>
-      	 </flowText>
+      	 </flowRoot>
       </g>
    </g>
 
     <!-- ============================================================= -->
     <!-- Batik sample mark                                             -->
     <!-- ============================================================= -->
-    <use xlink:href="../batikLogo.svg#Batik_Tag_Box" />
+    <use xlink:href="../../../batikLogo.svg#Batik_Tag_Box" />
 </svg>

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGAElementBridge.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGAElementBridge.java?rev=371920&r1=371919&r2=371920&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGAElementBridge.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGAElementBridge.java Tue Jan 24 06:17:17 2006
@@ -38,6 +38,10 @@
  */
 public class SVGAElementBridge extends SVGGElementBridge {
 
+    protected AnchorListener          al;
+    protected CursorMouseOverListener bl;
+    protected CursorMouseOutListener  cl;
+
     /**
      * Constructs a new bridge for the &lt;a> element.
      */
@@ -73,32 +77,56 @@
 
         if (ctx.isInteractive()) {
             NodeEventTarget target = (NodeEventTarget)e;
-            EventListener l = new AnchorListener(ctx.getUserAgent());
+            al = new AnchorListener(ctx.getUserAgent());
             target.addEventListenerNS
                 (XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_CLICK,
-                 l, false, null);
+                 al, false, null);
             ctx.storeEventListenerNS
-                (target, XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_CLICK,
-                 l, false);
+                (target, 
+                 XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_CLICK,
+                 al, false);
 
-            l = new CursorMouseOverListener(ctx.getUserAgent());
+            bl = new CursorMouseOverListener(ctx.getUserAgent());
             target.addEventListenerNS
                 (XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEOVER,
-                 l, false, null);
+                 bl, false, null);
             ctx.storeEventListenerNS
-                (target, XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEOVER,
-                 l, false);
-
-            l = new CursorMouseOutListener(ctx.getUserAgent());
+                (target, 
+                 XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEOVER,
+                 bl, false);
+            cl = new CursorMouseOutListener(ctx.getUserAgent());
             target.addEventListenerNS
                 (XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEOUT,
-                 l, false, null);
+                 cl, false, null);
             ctx.storeEventListenerNS
-                (target, XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEOUT,
-                 l, false);
+                (target, 
+                 XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEOUT,
+                 cl, false);
         }
     }
 
+    public void dispose() {
+        NodeEventTarget target = (NodeEventTarget)e;
+        if (al != null) {
+            target.removeEventListenerNS
+                (XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_CLICK, 
+                 al, false);
+            al = null;
+        }
+        if (bl != null) {
+            target.removeEventListenerNS
+                (XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEOVER, 
+                 bl, false);
+            bl = null;
+        }
+        if (cl != null) {
+            target.removeEventListenerNS
+                (XMLConstants.XML_EVENTS_NAMESPACE_URI, SVG_EVENT_MOUSEOUT, 
+                 cl, false);
+            cl = null;
+        }
+        super.dispose();
+    }
     /**
      * Returns true as the &lt;a> element is a container.
      */

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/flow/FlowRegions.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/flow/FlowRegions.java?rev=371920&r1=371919&r2=371920&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/flow/FlowRegions.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/flow/FlowRegions.java Tue Jan 24 06:17:17 2006
@@ -81,6 +81,7 @@
     }
 
     public int getNumRangeOnLine() {
+        if (validRanges == null) return 0;
         return validRanges.size();
     }
     public void resetRange() {

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java?rev=371920&r1=371919&r2=371920&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java Tue Jan 24 06:17:17 2006
@@ -592,7 +592,7 @@
 
     public void setRenderingTransform(AffineTransform at, 
                                       boolean performRedraw) {
-        renderingTransform = at;
+        renderingTransform = new AffineTransform(at);
         suspendInteractions = true;
         if (eventDispatcher != null) {
             try {
@@ -620,14 +620,14 @@
      * Returns the initial transform.
      */
     public AffineTransform getInitialTransform() {
-        return initialTransform;
+        return new AffineTransform(initialTransform);
     }
 
     /**
      * Returns the current rendering transform.
      */
     public AffineTransform getRenderingTransform() {
-        return renderingTransform;
+        return new AffineTransform(renderingTransform);
     }
 
     /**