Of course, as Umit says, there are other FREE Frameworks that have figured it out, like Lienzo, that take care of it all for you, http://www.emitrom.com/lienzo
Or, you can do it yourself, if your REALLY into that sort of thing
On Thursday, December 20, 2012 8:29:40 AM UTC-5, RyanZA wrote:
-- On Thursday, December 20, 2012 8:29:40 AM UTC-5, RyanZA wrote:
First option is definitely best, but you need to expand it slightly:
Use a bounding box around every shape, so you can do an O(1) check if the click is inside the bounding box (click.x < box.left, click.x > box.right, etc)
If the click is inside the bounding box, then you can run normal edge detect O(number of lines per poly) -- (drop a line to the axis, count number of line intersections - check stackoverflow or similar for code)
If you have Z index on your shapes, then start from the biggest Z index and take the first match.
If you are drawing in a list, then start from the bottom of the list and work upwards and take the first match.
On Thursday, December 20, 2012 1:14:43 PM UTC+2, membersound wrote:I'm creating some kind of drawings/flowchart/UML-diagram like tool with GWT Canvas (Java).
For hit-detection of my drawings I could imagine 3 different strategies, but I do not know which would work best for my goal.
- Just keep track of all Shape coordinates and iterate all objects on mouseclick
- draw all objects on a ghost-canvas on mouseclick, and use isPointInPath() after every object drawing
- using a ghost-canvas and draw each object with its own color (like #000001, #000002), and keep reference of them in a Map<Color, Shape>. Then just detecting the mouseclick on the ghost-canvas and get the object belonging to the pixelcolor under mouse
What would you prefer, and why?
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/NInrojT5PVkJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment