package org.simantics.district.network.ui.nodes; import java.awt.Graphics2D; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import org.simantics.scenegraph.g2d.G2DNode; import org.simantics.utils.datastructures.Pair; public class DeferredRenderingNode extends G2DNode { private static final long serialVersionUID = 1L; List> queue = new LinkedList<>(); @Override public void render(Graphics2D g2d) { AffineTransform currentTransform = g2d.getTransform(); ListIterator> listIterator = queue.listIterator(); while (listIterator.hasNext()) { Pair node = listIterator.next(); listIterator.remove(); g2d.setTransform(node.first); node.second.renderDeferred(g2d); } g2d.setTransform(currentTransform); } @Override public Rectangle2D getBoundsInLocal() { return null; } public void deferNode(AffineTransform transform, DeferredNode node) { queue.add(new Pair<>(transform, node)); } }