xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: Synchronizing JSVGCanvas - Again
Date Wed, 12 Apr 2006 09:45:19 GMT
Hi André,

André Ávila <asantos@nextech.com.br> wrote on 04/11/2006 05:28:01 PM:

> 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?

> Since the overlay canvas just has a bunch of Shapes all I have to do is 
> apply the same transform to its graphics context to make the Shapes 
> move or zoom with the SVG canvas. Below is the paint() method of the 
> overlay canvas.

> public void paint(Graphics g) {

> However, the final result does not look good: it always looks like the 
overlay
> canvas is a few milliseconds behind

> 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);


---------------------------------------------------------------------
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