Thomas DeWeese wrote:
Interactors are intended to be used for modal interaction. If you aren't interested in being modal you can use normal AWT event stuff.
Sorry to be obtuse, but what exactly do you mean by "modal interaction"? Here's what we are doing currently:
We allow the user to draw simple lines using the mouse. From MousePressed, through MouseDragged, and until MouseReleased we implement this as AWT Graphics2D drawing (for speed.) Once we see MouseReleased, we take all the collected mouse movements and turn these into SVG <line> elements which are then added to the DOM. In addition to this, we would also like to allow the user to click on embedded URLs in the document, and then launch an external browser in response to this. We found that if we ignore "right button" mouse clicks in our drawing code this allows the event to get passed onto our LinkActivationListener. So the user needs to click the right button to click URLs. This works for us, but I am curious how one would "share" events among many Interactors if there were ever such a need.
2) When my LinkActivationListener launches an external browser in response to a URL click, why afterwards does the JSVGComponent.getUpdateManager() always return null? I am setting my document state to ALWAYS_DYNAMIC in the constructor, and it seems to work fine until I launch the external browser.
I'm guessing some of the normal link handling code is still being called (you can hyperlink between SVG documents in the Canvas) and this code is, as it's first step, shutting down the UpdateManager, your code must head off the replacement of the document however. This may represent a bug in the canvas or your code.
Well the external browser launch is pretty simple (I use JNLP's BasicService.showDocument()). It returns quickly and successfully. However after that point getUpdateManager() forever returns null. Maybe I need to launch the external browser in a specific thread?
3) Is there any advantage to implementing Interactor vs Overlay for creating a "drawing tool" on top of JSVGComponent? It seems that you must implement Interactor in order to see the events, and that Overlay is merely a matter of painting (which you can easily do without implementing that interface- just grab the component's Graphics2D and paint away.) I notice that some of the batik examples implement both (e.g. AbstractZoomInteractor, which extends InteractorAdaptor, but also implements Overlay via an enclosed class.)
I would not recomend grabbing the component's Graphics2D and
painting. This will likely lead to poor behaviour if the area of
document drawn on is updated due to events, etc.
Maybe I didn't describe very well what I was doing. This is just transient drawing in response to mouse drags. Once the mouse is released the AWT drawing done previously is no longer needed as I convert the generated line segments into SVG <line> elements, which are then added to the DOM. It's really not that different from what's being done in AbstractZoomInteractor- when MouseEvents come in the overlay's paint() method is called directly on the component's Graphics2D.
If you use the overlay interface your code will be called when ever the area it covers is repainted due to update events. Try this select some 'animated' text (I like to select the 'batik rules' in samples/extensions/gears.svg).
Since the drawing is transient, no persistent updates are needed.
Thanks again for your wisdom!
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]