X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scenegraph%2Fsrc%2Forg%2Fsimantics%2Fscenegraph%2Futils%2FNodeUtil.java;h=5dac6fd2a59b68bc380fddbdbdda71efc5fd74f5;hb=452670c58399d8054872655841ebb6e66d9c6b6e;hp=615899a59eef25676ff17b0cbdcb69ca0d62d1b8;hpb=c26409b1caf2f1e560d37c5befd11b442399c3fe;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/NodeUtil.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/NodeUtil.java index 615899a59..5dac6fd2a 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/NodeUtil.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/NodeUtil.java @@ -54,6 +54,8 @@ import org.simantics.scl.runtime.function.Function1; import org.simantics.scl.runtime.function.FunctionImpl1; import org.simantics.utils.datastructures.Pair; import org.simantics.utils.threads.IThreadWorkQueue; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Utilities for debugging/printing the contents of a scenegraph. @@ -62,6 +64,7 @@ import org.simantics.utils.threads.IThreadWorkQueue; */ public final class NodeUtil { + private static final Logger LOGGER = LoggerFactory.getLogger(NodeUtil.class); /** * @param */ @@ -97,6 +100,18 @@ public final class NodeUtil { } } + public static INode getPossibleNearestParentOfType(INode node, Class clazz) { + ParentNode parent = null; + while (true) { + parent = node.getParent(); + if (parent == null) + return null; + node = parent; + if (clazz.isInstance(node)) + return node; + } + } + public static INode getRootNode(INode node) { ParentNode parent = null; while (true) { @@ -595,7 +610,7 @@ public final class NodeUtil { } else { if(pc.length > 0) { - System.err.println("Method " + setter.getName() + " expects " + pc[0].getCanonicalName() + " (got " + value.getClass().getCanonicalName() + ")."); + LOGGER.warn("Method " + setter.getName() + " expects " + pc[0].getCanonicalName() + " (got " + value.getClass().getCanonicalName() + ")."); } } @@ -924,7 +939,7 @@ public final class NodeUtil { // Find node transform.. AffineTransform transform = getGlobalToLocalTransform(node, null); if (transform == null) { - System.err.println("WARNING: Non-invertible transform for node: " + node); + LOGGER.warn("WARNING: Non-invertible transform for node: " + node); return event; } MouseEvent me = (MouseEvent)event; @@ -963,7 +978,7 @@ public final class NodeUtil { if(DEBUG_BOUNDS) { for(int i=0;i " + bl); + LOGGER.warn("+getLocalBoundsImpl " + next + " => " + bl); } if(bl != null) { @@ -977,7 +992,7 @@ public final class NodeUtil { if(DEBUG_BOUNDS) { for(int i=0;i " + bounds); + LOGGER.warn("=getLocalBoundsImpl " + node + " => " + bounds); } return bounds; @@ -986,7 +1001,7 @@ public final class NodeUtil { if(result != null) { if(DEBUG_BOUNDS) { for(int i=0;i " + result); + LOGGER.warn("=getLocalBoundsImpl " + node + " => " + result); } return result; }