xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Balderscape <psolo...@iinet.net.au>
Subject Mouse Detection / GVT Node Reference
Date Mon, 04 Aug 2008 01:41:03 GMT


I am new to this list and trying to get up to speed on batik. I am currently
attempting to develop CAD like software and would appreciate some guidance /

Currently I start with a fresh DOM, and set up a dynamic bridge to a GVT.
Then I allow the user to add elements to the dom with the mouse like
dragging a rectangle onto the screen. I paint the rectangle whilst the user
is drawing then when the mouse is released I add it to the DOM like so:

  Document doc = model.getDocument();

  // Create the rectangle.
  Element elem = doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
  elem.setAttributeNS(null, "x", DoubleFormat.format(x));
  elem .setAttributeNS(null, "y", DoubleFormat.format(y));
  elem.setAttributeNS(null, "width", DoubleFormat.format(w));
  elem.setAttributeNS(null, "height", DoubleFormat.format(h));
  elem.setAttributeNS(null, "style", "fill:none;stroke:#000000;");

This works, and when I repaint the GVT the rectangle is there. Now I am
trying to detect mouseover and allow modification like select, drag, rotate,
delete etc....

I have 2 key questions at this stage:

1. Is there any way to detect mouse over with some tolerance, i.e. I have
mouse over code that will detect if the mouse is on the rectangle above,
however this rectangle has a 1 px line width, and it is very hard to keep
the mouse on the rectangle. Ideally I would like to detect is the mouse is
within 3px of the rectangle and trigger an event then. The code that I am
currently using is:

  GraphicsNode gn = model.getGVTRoot().nodeHitAt(p);

2. Is there any way to maintain a link between a DOM Element or GVT Node and
a custom object? What I am trying to do is have my own object representing
the rectangle that allows for a properties panel where when the Element is
selected the user can see height, width etc and modify these properties. Is
there a better way to do this?

Thanks in advance for your assistance.
View this message in context: http://www.nabble.com/Mouse-Detection---GVT-Node-Reference-tp18804429p18804429.html
Sent from the Batik - Users mailing list archive at Nabble.com.

To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

View raw message