public static void printStructure(Spatial s) {
   if (s.getParent() != null) {
     logger.debug(
         s.getParent().getName() + "." + s.getName() + " (" + s.getClass().getName() + ")");
   } else {
     logger.debug("Printing Structure of " + s.getName());
   }
   if (s instanceof Node) {
     if (((Node) s).getChildren() != null) {
       for (Spatial child : ((Node) s).getChildren()) {
         printStructure(child);
       }
     }
   }
 }
示例#2
0
 /**
  * Retrieve the spatial with given reference class.
  *
  * @param root The root <code>Node</code> to stop check at.
  * @param spatial The <code>Spatial</code> to check.
  * @param reference The <code>Class</code> reference of the expected object.
  * @return The <code>Spatial</code> that is of the given reference <code>Class</code>.
  */
 private Spatial validateClass(Node root, Spatial spatial, Class<? extends Spatial> reference) {
   if (spatial.getClass().equals(reference)) {
     return spatial;
   } else {
     while (spatial.getParent() != null) {
       spatial = spatial.getParent();
       if (spatial == root) {
         return null; // TODO Should throw an exception here saying reached parent.
       } else if (spatial.getClass().equals(reference)) {
         return spatial;
       }
     }
     // TODO Should throw an exception here saying that cannot find the referencing class.
   }
   return null;
 }