You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Harm Cuppens <ha...@iosint.be> on 2003/03/06 09:57:41 UTC

repainting the cavas on command

Hello all,

I have the following problem. I'm creating a little SVG editor and I have a
seperate toolbar for the drawing tools etc.
In my application I can create a grid (a group with line elements) that has
to be embedded inside the svg document.
The user has the abillity to toggle this grid on and off (which simply sets
the visible attribute of the gridgroup).
Now my problem, whenever I press the toggle button to turn on my grid (or
off), the canvas won't immediately update the changes made to the DOM. It
does nothing untill I move my mouse pointer over the canvas, then the
repainting kicks in (immediately). I've tried calling repaint,
immediateRepaint on the JSVGCanvas but that didn't help. I've also tried the
repaint method on the UpdateManager class, but this caused an exception.

I'm pretty new to Java, so I'm not sure if this because the painting
mechanics of Java (that the component must have focus for repaint to work),
or if this is something related to batik itself.
Or am I calling the wrong methods to repaint the canvas ?

Any input appreciated.
Thanks,

Harm


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


Re: repainting the cavas on command

Posted by Siarhei Biarozkin <sb...@zandar.com>.
Hi,
We had a similar problem, you need to call setDocumentState(ALWAYS_DYNAMIC).
Be aware though, that if you editor runs in a secure environment, then the
above call will cause a security exception be thrown (in our case it
translates to "unknown ecmascript element" or smth like that), so you'll
need then to sign your application as well. Additionally, your svg document
manipulation should be done on an update/event thread (to prevent
synchronization issues), we do it with SwingUtilities.invokeLater, perhaps,
there's a better way to do it in Batik ?

By the way, right now we'll need a grid (where a grid cell
vertical/horizontal size can be dynamically updated by a user) drawn in SVG
as well. With a native Java drawing, we use a 2x2 black rect to draw a grid
point, with a 1280/1024 view area it takes 64 * 51 rects with a grid cell
x&y equals to 20.
How do you draw the grid in SVG ?

Cheers
Siarhei Biarozkin
----- Original Message -----
From: "Harm Cuppens" <ha...@iosint.be>
To: "Batik Users (E-mail)" <ba...@xml.apache.org>
Sent: Thursday, March 06, 2003 8:57 AM
Subject: repainting the cavas on command


> Hello all,
>
> I have the following problem. I'm creating a little SVG editor and I have
a
> seperate toolbar for the drawing tools etc.
> In my application I can create a grid (a group with line elements) that
has
> to be embedded inside the svg document.
> The user has the abillity to toggle this grid on and off (which simply
sets
> the visible attribute of the gridgroup).
> Now my problem, whenever I press the toggle button to turn on my grid (or
> off), the canvas won't immediately update the changes made to the DOM. It
> does nothing untill I move my mouse pointer over the canvas, then the
> repainting kicks in (immediately). I've tried calling repaint,
> immediateRepaint on the JSVGCanvas but that didn't help. I've also tried
the
> repaint method on the UpdateManager class, but this caused an exception.
>
> I'm pretty new to Java, so I'm not sure if this because the painting
> mechanics of Java (that the component must have focus for repaint to
work),
> or if this is something related to batik itself.
> Or am I calling the wrong methods to repaint the canvas ?
>
> Any input appreciated.
> Thanks,
>
> Harm
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>
>


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