Hello,
Has anyone tackled the situation where layout of child nodes takes too
long to do on the event thread in layoutChildren()?
I tried using a javax.swing.SwingWorker as follows
protected void layoutChildren()
{
// layout quickly now
layoutQuickly(childNode);
// delay long-running layout
new LayoutCorrectly(childNode).execute();
}
private static class LayoutCorrectly extends SwingWorker<Point2D, Object>
{
private PNode childNode;
private LayoutCorrectly(final PNode childNode)
{
this.childNode = childNode;
}
public Point2D doInBackground()
{
// calculate offset in background thread
// ...
return offset;
}
protected void done()
{
// set offset back in event thread
Point2D offset = get();
childNode.setOffset(offset.getX(), offset.getY());
}
When setOffset is called on the child node on the event thread in
SwingWorker.done(), it re-calls layoutChildren() on the parent,
leading to that soft infinite loop described in comments for
validateFullBounds() in PNode.java source.
I tried making childNode's bounds volatile without fully understanding
what that means to no effect.
michael
--
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
To unsubscribe, reply using "remove me" as the subject.