deweese 2002/11/14 11:44:49 Modified: sources/org/apache/batik/bridge BridgeContext.java BridgeEventSupport.java CursorManager.java sources/org/apache/batik/swing/svg JSVGComponent.java Log: 1) getRelatedTarget fixed for mouseout event. 2) Modified the new Custom Cursor code so the cursor doesn't 'flicker' as much. Revision Changes Path 1.55 +12 -3 xml-batik/sources/org/apache/batik/bridge/BridgeContext.java Index: BridgeContext.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/BridgeContext.java,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- BridgeContext.java 14 Nov 2002 14:57:12 -0000 1.54 +++ BridgeContext.java 14 Nov 2002 19:44:49 -0000 1.55 @@ -52,6 +52,7 @@ import org.w3c.dom.events.EventListener; import org.w3c.dom.events.EventTarget; import org.w3c.dom.events.MutationEvent; +import org.w3c.dom.events.MouseEvent; import org.w3c.dom.svg.SVGDocument; import org.apache.batik.gvt.filter.GraphicsNodeRableFactory; @@ -951,7 +952,16 @@ */ protected class DOMMouseOutEventListener implements EventListener { public void handleEvent(Event evt) { - userAgent.setSVGCursor(CursorManager.DEFAULT_CURSOR); + MouseEvent me = (MouseEvent)evt; + Element newTarget = (Element)me.getRelatedTarget(); + Cursor cursor = CursorManager.DEFAULT_CURSOR; + if (newTarget != null) + cursor = CSSUtilities.convertCursor + (newTarget, BridgeContext.this); + if (cursor == null) + cursor = CursorManager.DEFAULT_CURSOR; + + userAgent.setSVGCursor(cursor); } } @@ -969,7 +979,6 @@ */ public void handleEvent(Event evt) { Element target = (Element)evt.getTarget(); - String tag = target.getNodeName(); Cursor cursor = CSSUtilities.convertCursor(target, BridgeContext.this); if (cursor != null) { 1.45 +8 -6 xml-batik/sources/org/apache/batik/bridge/BridgeEventSupport.java Index: BridgeEventSupport.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/BridgeEventSupport.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- BridgeEventSupport.java 8 Oct 2002 15:43:10 -0000 1.44 +++ BridgeEventSupport.java 14 Nov 2002 19:44:49 -0000 1.45 @@ -214,7 +214,8 @@ public void mouseExited(GraphicsNodeMouseEvent evt) { Point clientXY = getClientMouseLocation(evt.getPoint2D()); - GraphicsNode node = evt.getGraphicsNode(); + // Get the 'new' node for the DOM event. + GraphicsNode node = evt.getRelatedNode(); Element targetElement = getEventTarget(node, clientXY); if (lastTargetElement != null) { dispatchMouseEvent("mouseout", @@ -234,10 +235,11 @@ Point clientXY = getClientMouseLocation(evt.getPoint2D()); GraphicsNode node = evt.getGraphicsNode(); Element targetElement = getEventTarget(node, clientXY); - if (lastTargetElement != targetElement) { - if (lastTargetElement != null) { + Element holdLTE = lastTargetElement; + if (holdLTE != targetElement) { + if (holdLTE != null) { dispatchMouseEvent("mouseout", - lastTargetElement, // target + holdLTE, // target targetElement, // relatedTarget clientXY, evt, @@ -246,7 +248,7 @@ if (targetElement != null) { dispatchMouseEvent("mouseover", targetElement, // target - lastTargetElement, // relatedTarget + holdLTE, // relatedTarget clientXY, evt, true); 1.4 +6 -8 xml-batik/sources/org/apache/batik/bridge/CursorManager.java Index: CursorManager.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/CursorManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- CursorManager.java 14 Nov 2002 16:35:18 -0000 1.3 +++ CursorManager.java 14 Nov 2002 19:44:49 -0000 1.4 @@ -26,6 +26,7 @@ import java.util.Hashtable; import java.lang.ref.SoftReference; +import org.apache.batik.ext.awt.image.GraphicsUtil; import org.apache.batik.ext.awt.image.spi.ImageTagRegistry; import org.apache.batik.ext.awt.image.renderable.Filter; @@ -218,7 +219,7 @@ (int)Math.round(rh), null); - if (bi instanceof Image) { + if (img instanceof Image) { bi = (Image)img; } else { bi = renderedImageToImage(img); @@ -237,8 +238,8 @@ RenderedImage ri = f.createScaledRendering(preferredSize.width, preferredSize.height, null); - Graphics2D g = tbi.createGraphics(); - g.drawRenderedImage(ri, new AffineTransform()); + Graphics2D g = GraphicsUtil.createGraphics(tbi); + GraphicsUtil.drawImage(g, ri); g.dispose(); bi = tbi; } @@ -274,10 +275,7 @@ WritableRaster wr = Raster.createWritableRaster(sm, new Point(x,y)); ri.copyData(wr); - return new BufferedImage(ri.getColorModel(), - wr, - cm.isAlphaPremultiplied(), - null); + return new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null); } /** 1.61 +3 -2 xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java Index: JSVGComponent.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- JSVGComponent.java 13 Nov 2002 20:20:51 -0000 1.60 +++ JSVGComponent.java 14 Nov 2002 19:44:49 -0000 1.61 @@ -2536,7 +2536,8 @@ * @param cursor the new cursor */ public void setSVGCursor(Cursor cursor) { - JSVGComponent.this.setCursor(cursor); + if (cursor != JSVGComponent.this.getCursor()) + JSVGComponent.this.setCursor(cursor); } /**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]