Class SimulationTreeNode


  • public class SimulationTreeNode
    extends Object
    A SimulationTreeNode is a data container used to build the simulation tree which is shown in the entity sidebar to allow the user to see and easily select entities in the simulation.
    Version:
    1.0
    Author:
    Tobias Wältken
    • Constructor Detail

      • SimulationTreeNode

        public SimulationTreeNode​(String elementId,
                                  String displayText,
                                  String textureId)
        Default constructor for leaf nodes
        Parameters:
        elementId - A non visible id used to better identify the slected entity.
        displayText - The name of the entity which is displayed to the user.
        textureId - The id of the texture which is rendered infront of the display text.
      • SimulationTreeNode

        public SimulationTreeNode​(String elementId,
                                  String displayText,
                                  String textureId,
                                  boolean isLeaf)
        This constructor can be used to create non leaf nodes as well as leaf nodes.
        Parameters:
        elementId - A non visible id used to better identify the slected entity.
        displayText - The name of the entity which is displayed to the user.
        textureId - The id of the texture which is rendered infront of the display text.
        isLeaf - This indicates if node is a leaf node or not.
    • Method Detail

      • getElementId

        public String getElementId()
        Getter for the element id the non visible string to better identify the selected entity.
        Returns:
        Returns a String
      • getDisplayText

        public String getDisplayText()
        Getter for the display text which is the name of the entity which is displayed to the user.
        Returns:
        Returns a String
      • getTextureId

        public String getTextureId()
        Getter for the texture id the identifier of the texture which is rendered infront of the display text.
        Returns:
        Returns a String
      • isLeaf

        public boolean isLeaf()
        This checks if node is a leaf node.
        Returns:
        Returns true if noe is a leaf node
      • hasChildren

        public boolean hasChildren()
        Function to check if the node has children.
        Returns:
        Returns false if it has no childen.
      • appendChild

        public boolean appendChild​(SimulationTreeNode node)
        Appends a child node to this node
        Parameters:
        node - The node to append
        Returns:
        Returns true if action was successfull
      • removeChild

        public boolean removeChild​(SimulationTreeNode node)
        Removes a child node from this node
        Parameters:
        node - The node to remove
        Returns:
        Returns true if the given node was a child node
      • forEachChild

        public void forEachChild​(Consumer<SimulationTreeNode> lamda)
        Runs a function for each added child node with the child node as a parameter
        Parameters:
        lamda - The function to run on every child node
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object