I found a solution to make this work with your information
I want to underline that the valuable/quick support/advice of this mail list I
would have dropped the batik solution. And it certainly would have been a big
mistake!
So,
I add a rendering listener
addGVTTreeRendererListener(new GVTTreeRendererAdapter() {
public void gvtRenderingCompleted(GVTTreeRendererEvent arg0) {
SvgRepaintEngine.getInstance().renderingComplete();
}
});
And my SvgRepaintEngine does this:
public void push(final UpdateTask todo) {
<...wait canvas initialized (by GVTTreeBuildComplete)...>
if (useUpdateQueue) {
canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new Runnable() {
public void run() {
todo.doit(canvas.getSVGDocument()); //modifies the
document
}
});
} else {
todo.doit(canvas.getSVGDocument()); //directly modifies the
document
}
<...calls the remote clients...>
}
public void renderingComplete() {
useUpdateQueue = true;
}
It seems to work. Like you said, I will merge the UpdateTasks to make bundles
and modify coherent parts in 1 runnable
De : [email protected] [mailto:[email protected]]
Envoyé : mardi 12 janvier 2010 12:24
À : [email protected]
Cc : [email protected]
Objet : Re: appending a child element in a document
Hi Dao,
dao <[email protected]> wrote on 01/11/2010 05:45:08 PM:
> I put my batik canvas in a panel, that I put in a frame.
> I have 2 modes. the frame is visible or not (because it is a server
> which can display locally or remotely. In this last case, I don't
> want to draw the frame)
>
> at the beginning of the process (ie after the treebuild complete) I
> want to append a child to a node of the document.
>
> If I have a local frame (setVisible(true)), I do this and it works
> fine: the element
> getMaskLayer().appendChild(mask);
> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> Runnable() {
> public void run() {
> mask.setAttribute("style", "display:none");
> }
> });;
>
> but when I put if I run the program with frame.setVisible(false),
> and I dump the document, I do not have the style attribute set.
>
> So, why the setVisible influences the behavior?
Because the UpdateManager is only started after the first rendering
of the SVG document completes. If the canvas isn't visible there isn't
a first rendering.
> FYI
> Then, I decided to do this:
> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> Runnable() {
> public void run() {
> getMaskLayer().appendChild(mask);
> mask.setAttribute("style", "display:none");
> }
> });;
>
> In this case, the element is not appended. I dump the document doing
> this several seconds after the call is performed
Right because the UpdateManager isn't started until after the
document is rendered for the first time. The question is what
should you do? The answer is I don't know, I think it's exactly
right that a non-visible SVG Canvas doesn't do anything.
This mail has originated outside your organization, either from an external
partner or the Global Internet.
Keep this in mind if you answer this message.
The information in this e-mail is confidential. The contents may not be
disclosed or used by anyone other than the addressee. Access to this e-mail by
anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and
delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of
this e-mail as it has been sent over public networks. If you have any concerns
over the content of this message or its Accuracy or Integrity, please contact
Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus
scanning software but you should take whatever measures you deem to be
appropriate to ensure that this message and any attachments are virus free.