Hi Thomas,
> So I am a little confused about this. First your example shows this
> being done in 'Main' which is not the Swing (AWT Event) thread. There
> would not be a problem with the above code using invokeAndWait. Do you
> call the above 'Main' from a Swing/AWT event handler? If you are calling
> this from Swing/AWT, you should be able to move the call to Main
> to another thread.
I tried to give one example program. but by mistake i called update method
in main. It is suppossed to be called from “valueChanged” and “stateChanged”
methods.
> Also the above code doesn't make lots of sense to me.
> Is the code performing an 'animation'? (change a bunch
> of things, redraw, setup the next set of things, redraw, etc).
yes. My application can have ablity to move all the selected "ExBox" objects
in SVGCanvas.
> Also you say '// Changing the SVG Elements attributes'
> however you can't modify the SVG elements outside of the
> UpdateManager thread. So if you are modifying the DOM
> you need to move those modifications into the update runnable.
Class ExBox {
SetColor(){…};
getColor(){…};
setName(){…};
getName(){…};
setX(){…};
getX(){…};
setY(){…};
getY(){…};
.
.
.
}
Actually my application is having “ExBox” objects which is created using
external data. Sometimes “ExBox” objects may be in thousands. So after
created the “ExBox” objects my application draws all the objects in
SVGCanvas. While drawing, it will create one Image Element, one Text Element
and one Rectangle Element for each “ExBox” object. Element are named using
“ExBox” object name.
To update the “ExBox” objects in Canvas, After changed the “ExBox”
attributes’ values, it will call the update() method to update the new
changes in SVG Canvas. So whenever changes happening in “ExBox” objects’
attribute values, it calls update() method to update the SVG Document.
Public void update() {
try {
UpdateManager um = getUpdateManager();
um.getUpdateRunnableQueue().invokeLater(new Runnable() {
public void run() {
render(redraw);
}
});
} catch (Exception ex) {}
}
synchronized void render(boolean redraw) {
.
.
.
for(int I = 0; I<exBoxes.length;I++) {
ExBox exBox = exBoxes[i];
Element nodeGrp = document.getElementById(exBox.getName());
If(nodeGrp == null) {
// It will create new Exbox object in SVG Canvas based on its
attributes
.
.
.
} else {
//// It will update Exbox object in SVG Canvas based on its
attributes
.
.
.
}
}
}
> Synchronize can mean many things. I think you mean that you
> don't want the main thread to continue until the runnable in the
> UpdateManager has completed.
Yes. It may be “valueChanged” or “stateChanged”, once it is completed the
update method then only it should execute the next statement.
If I use third thread with invokeAndWait, it is running without getting
struck. But it is not waiting to finish update()/render() to finish
executing. So it is giving some problems in updating the objects in SVG
Canvas.
Please let me know, if you want somemore information.
Thanks,
Sudhakar
--
View this message in context:
http://www.nabble.com/Problem-in-invokeAndWait-tf2124331.html#a5961196
Sent from the Batik - Users forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]