if (PERF) {
long endTime = System.nanoTime();
- LOGGER.info("[picked " + result.size() + " elements @ " + request.pickArea + "] total pick time : " + ((endTime - startTime)*1e-6));
+ LOGGER.info("[picked {} elements @ {}] total pick time {} ms", result.size(), request.pickArea, ((endTime - startTime)*1e-6));
}
if (!result.isEmpty()) {
*/
@SuppressWarnings("unchecked")
public Collection<T> getNodes() {
- return (Collection<T>) children.values();
+ return children.isEmpty() ? Collections.emptyList() : (Collection<T>) children.values();
}
public int getNodeCount() {
package org.simantics.scenegraph.g2d;
import java.awt.Component;
+import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.util.Map;
}
};
+ /**
+ * The current Graphics2D AffineTransform for all nodes under the special
+ * spatialRoot : RTreeNode.
+ *
+ * This can be used to optimize the creation and of new AffineTransforms by
+ * not having to use Graphics2D.getTransform to retrieve the current
+ * transformation which always creates new instances.
+ */
+ public static final Key KEY_TRANSFORM_UNDER_SPATIAL_ROOT = new Key(2006) {
+ @Override
+ public boolean isCompatibleValue(Object val) {
+ return val instanceof AffineTransform || val == null;
+ }
+ };
+
}
\ No newline at end of file
import org.simantics.scenegraph.INode;
import org.simantics.scenegraph.g2d.G2DParentNode;
+import org.simantics.scenegraph.g2d.G2DRenderingHints;
import org.simantics.scenegraph.g2d.IG2DNode;
import org.simantics.scenegraph.g2d.events.Event;
import org.simantics.scenegraph.g2d.events.EventTypes;
g.transform(transform);
}
+ g.setRenderingHint(G2DRenderingHints.KEY_TRANSFORM_UNDER_SPATIAL_ROOT, g.getTransform());
+
try {
// Get transformed clip bounds
Shape clipShape = g.getClip();
// drawTree(g, tree.rtree);
} finally {
+ g.setRenderingHint(G2DRenderingHints.KEY_TRANSFORM_UNDER_SPATIAL_ROOT, null);
if (ot != null)
g.setTransform(ot);
}