Class TLcdModelTreeNodeUtil

java.lang.Object
com.luciad.model.TLcdModelTreeNodeUtil

public class TLcdModelTreeNodeUtil extends Object

Class with utility methods to work with ILcdModelTreeNodes. The methods in this class are all thread-safe.

Since:
9.0
  • Method Details

    • getModels

      public static List<ILcdModel> getModels(ILcdModelTreeNode aNode)

      Returns a list containing all the models underneath the node aNode, including aNode, by using a depth first search over trhe tree with root node aNode.

      Parameters:
      aNode - the start node for the search. Must not be null
      Returns:
      a list containing over all the underlying models, including the node aNode
    • getModels

      public static List<ILcdModel> getModels(ILcdModelTreeNode aNode, boolean aIncludeNode)

      Returns a list containing all the models underneath the node aNode by using a depth first search over the tree starting at node aNode.

      Parameters:
      aNode - the start node for the search. Must not be null
      aIncludeNode - true if the given aNode should be part of the returned list
      Returns:
      a list containing all the underlying models
    • getModelCount

      public static int getModelCount(ILcdModel aModel)

      Returns the total number of models and model nodes in the tree with root node aModel, including aModel.

      Parameters:
      aModel - the root node of the tree
      Returns:
      the total number of models and model nodes in the tree with root node aModel
    • getPathToParent

      public static List<ILcdModelTreeNode> getPathToParent(ILcdModelTreeNode aFrom, ILcdModel aTo)
      Returns a list containing all the ILcdModelTreeNodes to go from aFrom to the parent of aTo. The list starts with aFrom and ends with the parent node.
      Parameters:
      aFrom - the starting node of the path. Must be different from aTo.
      aTo - the node for which the path to its parent must be found. Must be different from aFrom.
      Returns:
      a list containing all the ILcdModelTreeNodes to go from aFrom to the parent of aTo, or null when aTo is not a part of the tree with root node aTo
    • getPath

      public static List<ILcdModel> getPath(ILcdModelTreeNode aFrom, ILcdModel aTo)
      Returns a list containing all the ILcdModels to go from aFrom to the model aTo. The list starts with aFrom and ends with aTo.
      Parameters:
      aFrom - the starting node of the path
      aTo - the end node of the path
      Returns:
      a list containing all the ILcdModel to go from aFrom to the layer aTo, or null when aTo is not a part of the tree with root node aTo.
    • getParent

      public static ILcdModelTreeNode getParent(ILcdModel aModel, ILcdModelTreeNode aRootNode)

      Finds the parent node of aModel in the tree with root node aRootNode.

      Parameters:
      aModel - the model for which the parent is searched
      aRootNode - the root node of the tree to be searched
      Returns:
      the parent node for aModel, or null when no parent can be found
    • containsModelInTree

      public static boolean containsModelInTree(ILcdModel aModel, ILcdModel aRootNode)

      Returns true when the model aModel is an element of the tree with root node aRootNode

      Parameters:
      aModel - the model
      aRootNode - the root node of the tree
      Returns:
      true when the model aModel is an element of the tree with root node aRootNode, false otherwise
    • containsModel

      public static boolean containsModel(ILcdModel aModel, ILcdModelTreeNode aNode)

      Returns true when aModel is a child of the node aNode.

      Parameters:
      aModel - the model
      aNode - the node
      Returns:
      true when aModel is a child of the node aNode, false in all other cases
    • getFirstCommonAncestor

      public static ILcdModelTreeNode getFirstCommonAncestor(ILcdModel aFirstModel, ILcdModelTreeNode aFirstRootNode, ILcdModel aSecondModel, ILcdModelTreeNode aSecondRootNode)
      Returns the first ancestor that two ILcdModels have in common. When no common ancestor is found, this method will return null. This is only possible when the two models are not part of the same tree. Otherwise the root node will be the common ancestor
      Parameters:
      aFirstModel - the first model
      aFirstRootNode - the root node of the tree containing the first node
      aSecondModel - the second model
      aSecondRootNode - the root node of the tree containing the second node
      Returns:
      the first common ancestor of aFirstModel and aSecondModel, or null when the two models do not belong to the same tree
    • isEmptyModel

      public static boolean isEmptyModel(ILcdModel aModel)

      Returns true when the model is an ILcdModelTreeNode and when ILcdModelTreeNode#isEmpty() returns true. Returns false in all other cases.

      Parameters:
      aModel - the model to be checked
      Returns:
      true when the model is an ILcdModelTreeNode and when ILcdModelTreeNode#isEmpty() returns true