tkormann 2002/06/12 05:02:51
Modified: sources/org/apache/batik/bridge BridgeEventSupport.java
sources/org/apache/batik/gvt/event AWTEventDispatcher.java
GraphicsNodeMouseEvent.java
Log:
fix bug. mouse screen location is now correct.
Revision Changes Path
1.40 +2 -2
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.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- BridgeEventSupport.java 12 Jun 2002 08:20:34 -0000 1.39
+++ BridgeEventSupport.java 12 Jun 2002 12:02:51 -0000 1.40
@@ -293,7 +293,7 @@
}
*/
short button = getButton(evt);
- Point screenXY = getScreenMouseLocation(clientXY);
+ Point screenXY = evt.getScreenPoint();
// create the coresponding DOM MouseEvent
DocumentEvent d = (DocumentEvent)targetElement.getOwnerDocument();
MouseEvent mouseEvt = (MouseEvent)d.createEvent("MouseEvents");
1.8 +12 -4
xml-batik/sources/org/apache/batik/gvt/event/AWTEventDispatcher.java
Index: AWTEventDispatcher.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/gvt/event/AWTEventDispatcher.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AWTEventDispatcher.java 12 Jun 2002 08:20:34 -0000 1.7
+++ AWTEventDispatcher.java 12 Jun 2002 12:02:51 -0000 1.8
@@ -8,6 +8,7 @@
package org.apache.batik.gvt.event;
+import java.awt.Point;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
@@ -337,7 +338,6 @@
protected void dispatchMouseEvent(MouseEvent evt) {
GraphicsNodeMouseEvent gvtevt;
Point2D p = new Point2D.Float(evt.getX(), evt.getY());
-
if (baseTransform != null) {
p = baseTransform.transform(p, null);
}
@@ -354,6 +354,7 @@
// If the receiving node has changed, send a notification
// check if we enter a new node
+ Point screenPos = evt.getComponent().getLocationOnScreen();
if (lastHit != node) {
// post an MOUSE_EXITED
if (lastHit != null) {
@@ -364,6 +365,8 @@
evt.getModifiers(),
(float)p.getX(),
(float)p.getY(),
+ screenPos.x,
+ screenPos.y,
evt.getClickCount(),
node);
processMouseEvent(gvtevt);
@@ -379,8 +382,9 @@
getModifiers(),
(float)p.getX(),
(float)p.getY(),
- evt.
- getClickCount(),
+ screenPos.x,
+ screenPos.y,
+ evt.getClickCount(),
lastHit);
processMouseEvent(gvtevt);
// node.processMouseEvent(gvtevt);
@@ -394,6 +398,8 @@
evt.getModifiers(),
(float)p.getX(),
(float)p.getY(),
+ screenPos.x,
+ screenPos.y,
evt.getClickCount(),
relatedNode);
@@ -409,6 +415,8 @@
evt.getModifiers(),
(float)p.getX(),
(float)p.getY(),
+ screenPos.x,
+ screenPos.y,
evt.getClickCount(),
relatedNode);
1.6 +37 -2
xml-batik/sources/org/apache/batik/gvt/event/GraphicsNodeMouseEvent.java
Index: GraphicsNodeMouseEvent.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/gvt/event/GraphicsNodeMouseEvent.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- GraphicsNodeMouseEvent.java 21 Feb 2001 16:49:54 -0000 1.5
+++ GraphicsNodeMouseEvent.java 12 Jun 2002 12:02:51 -0000 1.6
@@ -8,6 +8,7 @@
package org.apache.batik.gvt.event;
+import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.awt.geom.AffineTransform;
@@ -82,6 +83,10 @@
*/
float y;
+ int screenX;
+
+ int screenY;
+
/**
* Indicates the number of quick consecutive clicks of a mouse button.
*/
@@ -101,17 +106,22 @@
* @param when the time the event occurred
* @param modifiers the modifier keys down while event occurred
* @param x, y the mouse coordinates
+ * @param screenX, screenY the mouse coordinates relative to the screen
* @param clickCount the number of clicks
* @param relatedNode the related node
* @see #getRelatedNode
*/
public GraphicsNodeMouseEvent(GraphicsNode source, int id,
long when, int modifiers,
- float x, float y, int clickCount,
+ float x, float y,
+ int screenX, int screenY,
+ int clickCount,
GraphicsNode relatedNode) {
super(source, id, when, modifiers);
this.x = x;
this.y = y;
+ this.screenX = screenX;
+ this.screenY = screenY;
this.clickCount = clickCount;
this.relatedNode = relatedNode;
}
@@ -144,6 +154,31 @@
*/
public float getY() {
return y;
+ }
+
+ /**
+ * Returns the horizontal x position of the event relative to the
+ * screen.
+ * @return x a float indicating horizontal position relative to the screen
+ */
+ public int getScreenX() {
+ return screenX;
+ }
+
+ /**
+ * Returns the vertical y position of the event relative to the screen.
+ * @return y a float indicating vertical position relative to the screen
+ */
+ public int getScreenY() {
+ return screenY;
+ }
+
+ /**
+ * Returns the (x, y) position of the event relative to the screen.
+ * @return a Point object containing the x and y coordinates
+ */
+ public Point getScreenPoint() {
+ return new Point(screenX, screenY);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]