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 14:01:18 UTC

svn commit: r371909 - in /xmlgraphics/batik/branches/svg11: 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 05:01:04 2006
New Revision: 371909

URL: http://svn.apache.org/viewcvs?rev=371909&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/branches/svg11/samples/tests/spec12/text/flowTextAlign.svg
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGAElementBridge.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/flow/FlowRegions.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/swing/gvt/JGVTComponent.java

Modified: xmlgraphics/batik/branches/svg11/samples/tests/spec12/text/flowTextAlign.svg
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/samples/tests/spec12/text/flowTextAlign.svg?rev=371909&r1=371908&r2=371909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/samples/tests/spec12/text/flowTextAlign.svg (original)
+++ xmlgraphics/batik/branches/svg11/samples/tests/spec12/text/flowTextAlign.svg Tue Jan 24 05:01:04 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/branches/svg11/sources/org/apache/batik/bridge/SVGAElementBridge.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGAElementBridge.java?rev=371909&r1=371908&r2=371909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGAElementBridge.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/bridge/SVGAElementBridge.java Tue Jan 24 05:01:04 2006
@@ -22,6 +22,7 @@
 import org.apache.batik.dom.events.AbstractEvent;
 import org.apache.batik.dom.util.XLinkSupport;
 import org.apache.batik.gvt.GraphicsNode;
+
 import org.w3c.dom.Element;
 import org.w3c.dom.events.Event;
 import org.w3c.dom.events.EventListener;
@@ -37,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.
      */
@@ -72,20 +77,36 @@
 
         if (ctx.isInteractive()) {
             EventTarget target = (EventTarget)e;
-            EventListener l = new AnchorListener(ctx.getUserAgent());
-            target.addEventListener(SVG_EVENT_CLICK, l, false);
-            ctx.storeEventListener(target, SVG_EVENT_CLICK, l, false);
-
-            l = new CursorMouseOverListener(ctx.getUserAgent());
-            target.addEventListener(SVG_EVENT_MOUSEOVER, l, false);
-            ctx.storeEventListener(target, SVG_EVENT_MOUSEOVER, l, false);
-
-            l = new CursorMouseOutListener(ctx.getUserAgent());
-            target.addEventListener(SVG_EVENT_MOUSEOUT, l, false);
-            ctx.storeEventListener(target, SVG_EVENT_MOUSEOUT, l, false);
+            al = new AnchorListener(ctx.getUserAgent());
+            target.addEventListener(SVG_EVENT_CLICK, al, false);
+            ctx.storeEventListener(target, SVG_EVENT_CLICK, al, false);
+
+            bl = new CursorMouseOverListener(ctx.getUserAgent());
+            target.addEventListener(SVG_EVENT_MOUSEOVER, bl, false);
+            ctx.storeEventListener(target, SVG_EVENT_MOUSEOVER, bl, false);
+
+            cl = new CursorMouseOutListener(ctx.getUserAgent());
+            target.addEventListener(SVG_EVENT_MOUSEOUT, cl, false);
+            ctx.storeEventListener(target, SVG_EVENT_MOUSEOUT, cl, false);
         }
     }
 
+    public void dispose() {
+        EventTarget target = (EventTarget)e;
+        if (al != null) {
+            target.removeEventListener(SVG_EVENT_CLICK, al, false);
+            al = null;
+        }
+        if (bl != null) {
+            target.removeEventListener(SVG_EVENT_MOUSEOVER, bl, false);
+            bl = null;
+        }
+        if (cl != null) {
+            target.removeEventListener(SVG_EVENT_MOUSEOUT, cl, false);
+            cl = null;
+        }
+        super.dispose();
+    }
     /**
      * Returns true as the &lt;a> element is a container.
      */

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

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/swing/gvt/JGVTComponent.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/swing/gvt/JGVTComponent.java?rev=371909&r1=371908&r2=371909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/swing/gvt/JGVTComponent.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/swing/gvt/JGVTComponent.java Tue Jan 24 05:01:04 2006
@@ -588,7 +588,7 @@
 
     public void setRenderingTransform(AffineTransform at, 
                                       boolean performRedraw) {
-        renderingTransform = at;
+        renderingTransform = new AffineTransform(at);
         suspendInteractions = true;
         if (eventDispatcher != null) {
             try {
@@ -616,14 +616,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);
     }
 
     /**