xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Ávila <asan...@nextech.com.br>
Subject Re: Synchronizing JSVGCanvas - Again
Date Wed, 12 Apr 2006 13:48:01 GMT
Hi Thomas,


> > I have two JSVGCanvas, one on top of the other. The bottom JSVGCanvas is
> used
> > for displaying an SVG document. The upper is used as an overlay for
> drawing.
> > They are both transparent.
>
>    Why is the upper one a JSVGCanvas? Just so you can get events or
> something?

Yes. The idea is to get the events in the upper canvas and propagate them to
the bottom canvas. In fact this is related to that previous thread I wrote
about synchronization. They both could be holding SVG documents.

> > Is there a better form of synchronizing the overlay? I'd like to reach
> the
> > same effect as the SelectionOverlay in TextSelectionManager.
>
>   Well the JSVGCanvas is happy to have multiple Overlays active, so you
> could
> easily make your shape drawing function a real Canvas Overlay.  Then You
> will
> more or less automatically pick up the rendering/painting transform
> changes.
> The signature of Overlay is just the one method 'void paint(Graphics g)'.
> As your overlay changes you will need to 'trigger' repaints of the canvas
> but
> it shouldn't be significantly different from what you already need to do.
>
>   All you need to do to register your overlay is:
>         canvas.getOverlays().add(myOverlay);

It seems a very good idea. I couldn't find much on using overlays in the
list, so maybe you can point me some further directions.

I implemented the DrawOverlay class as an inner class of my SVG canvas and
added it to the canvas as you showed.:

private class DrawOverlay implements Overlay {

  public void paint(Graphics g) {
   Graphics2D g2d = (Graphics2D)g;
   drawTool.drawShapes(g2d);    // Redraw all shapes
   repaint();    // Calls repaint on owner SVGCanvas
}

So here's my question: when is the overlay paint() method called? My first
guess was that it would be called every time the canvas repaint() (or
paint()?) was called, but I see this is not the case.


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


Mime
View raw message