Class LayoutNode

  • All Implemented Interfaces:
    Comparable<LayoutNode>

    public final class LayoutNode
    extends Object
    implements Comparable<LayoutNode>
    The LayoutNode class. This class is used as a container for information about the nodes in a layout. In particular, it provides a convenient handle to information about position, the node itself, the node view. Many of the methods of this class are wrappers for Node or View methods, and these are often wrapped by LayoutPartition methods.

    Module: layout-api

    To use this in your app, include the following dependency in your POM:

    <dependency>
        <groupId>org.cytoscape</groupId>
        <artifactId>layout-api</artifactId>
    </dependency>

    Cytoscape Backwards Compatibility (Final Class): This class is final and therefore can't be extended by users. This means that we may add methods for minor version updates. Methods will only be removed for major version updates.
    • Constructor Summary

      Constructors 
      Constructor Description
      LayoutNode​(View<CyNode> nodeView, int index, CyRow row)
      The main constructor for a LayoutNode.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addNeighbor​(LayoutNode v)
      Convenience function to keep track of neighbors of this node.
      int compareTo​(LayoutNode nodeView)  
      void decrement​(double x, double y)
      Decrement the location of this node by (x,y).
      void decrement​(double x, double y, double z)
      Decrement the location of this node by (x,y,z).
      void decrementDisp​(double x, double y)
      Decrement the displacement recorded for this node by (x,y).
      void decrementDisp​(double x, double y, double z)
      Decrement the displacement recorded for this node by (x,y,z).
      double distance​(double uX, double uY)
      Return the Euclidean distance (in 2D) between this node and a location.
      double distance​(LayoutNode otherNode)
      Return the Euclidean distance (in 2D) between this node and another node.
      double distance3D​(double uX, double uY, double uZ)
      Return the Euclidean distance (in 3D) between this node and a location.
      double distance3D​(LayoutNode otherNode)
      Return the Euclidean distance (in 3D) between this node and another node.
      int getDegree()
      Return the node's degree (i.e.
      double getDepth()
      Return the height of this node
      double getHeight()
      Return the height of this node
      String getIdentifier()
      Return the node's identifier.
      int getIndex()
      Returns the index of this LayoutNode.
      List<LayoutNode> getNeighbors()
      Convenience function to return the list of neighbors (connected nodes) of this node.
      CyNode getNode()
      Accessor function to return the Node associated with this LayoutNode.
      View<CyNode> getNodeView()
      Accessor function to return the View associated with this LayoutNode.
      CyRow getRow()
      Accessor function to return the CyRow associated with this LayoutNode.
      double getWidth()
      Return the width of this node
      double getX()
      Return the current X value for this LayoutNode.
      double getXDisp()
      Return the current X displacement value for this LayoutNode.
      double getY()
      Return the current Y value for this LayoutNode.
      double getYDisp()
      Return the current Y displacement value for this LayoutNode.
      double getZ()
      Return the current Z value for this LayoutNode.
      double getZDisp()
      Return the current Z displacement value for this LayoutNode.
      void increment​(double x, double y)
      Increment the location of this node by (x,y).
      void increment​(double x, double y, double z)
      Increment the location of this node by (x,y,z).
      void incrementDisp​(double x, double y)
      Increment the displacement recorded for this node by (x,y).
      void incrementDisp​(double x, double y, double z)
      Increment the displacement recorded for this node by (x,y,z).
      boolean isLocked()
      Returns "true" if this node is locked, false otherwise.
      void lock()
      Register this node as being "locked".
      void moveToLocation()
      Move the node to its current x,y coordinate (ignores the value of the z coordinate).
      void moveToLocation3D()
      Move the node to its current x,y,z coordinate.
      String printDisp()
      Return a string representation of the node's displacement
      String printLocation()
      Return a string representation of the node's location
      void setDisp​(double x, double y)
      Set the 2D displacement of this LayoutNode.
      void setDisp​(double x, double y, double z)
      Set the 3D displacement of this LayoutNode.
      void setLocation​(double x, double y)
      Set the 2D location of this LayoutNode.
      void setLocation​(double x, double y, double z)
      Set the 3D location of this LayoutNode.
      void setX​(double x)
      Set the X location of this LayoutNode.
      void setY​(double y)
      Set the Y location of this LayoutNode.
      void setZ​(double z)
      Set the Z location of this LayoutNode.
      String toString()
      Return a string representation of the node
      void unLock()
      Register this node as being "unlocked".
    • Constructor Detail

      • LayoutNode

        public LayoutNode​(View<CyNode> nodeView,
                          int index,
                          CyRow row)
        The main constructor for a LayoutNode.
        Parameters:
        nodeView - The View of this node
        index - The index (usually in a node array) of this node
    • Method Detail

      • getNode

        public CyNode getNode()
        Accessor function to return the Node associated with this LayoutNode.
        Returns:
        Node that is associated with this LayoutNode
      • getRow

        public CyRow getRow()
        Accessor function to return the CyRow associated with this LayoutNode.
        Returns:
        CyRow that is associated with this LayoutNode
      • getNodeView

        public View<CyNode> getNodeView()
        Accessor function to return the View associated with this LayoutNode.
        Returns:
        View that is associated with this LayoutNode
      • setLocation

        public void setLocation​(double x,
                                double y)
        Set the 2D location of this LayoutNode. Note that this only sets the location -- it does not actually move the node to that location. Users should call moveToLocation to actually accomplish the move.
        Parameters:
        x - Double representing the new X coordinate of this node
        y - Double representing the new Y coordinate of this node
      • setLocation

        public void setLocation​(double x,
                                double y,
                                double z)
        Set the 3D location of this LayoutNode. Note that this only sets the location -- it does not actually move the node to that location. Users should call moveToLocation to actually accomplish the move.
        Parameters:
        x - Double representing the new X coordinate of this node
        y - Double representing the new Y coordinate of this node
        z - Double representing the new Z coordinate of this node
      • setX

        public void setX​(double x)
        Set the X location of this LayoutNode. Note that this only sets the location -- it does not actually move the node to that location. Users should call moveToLocation to actually accomplish the move.
        Parameters:
        x - Double representing the new X coordinate of this node
      • setY

        public void setY​(double y)
        Set the Y location of this LayoutNode. Note that this only sets the location -- it does not actually move the node to that location. Users should call moveToLocation to actually accomplish the move.
        Parameters:
        y - Double representing the new Y coordinate of this node
      • setZ

        public void setZ​(double z)
        Set the Z location of this LayoutNode. Note that this only sets the location -- it does not actually move the node to that location. Users should call moveToLocation to actually accomplish the move.
        Parameters:
        z - Double representing the new Z coordinate of this node
      • setDisp

        public void setDisp​(double x,
                            double y)
        Set the 2D displacement of this LayoutNode. The displacement is a little different than the location in that it records an offset from the current location. This is useful for algorithms such as Kamada Kawai and Fructerman Rheingold, which update positions iteratively.
        Parameters:
        x - Double representing the amount to offset in the x direction
        y - Double representing the amount to offset in the y direction
      • setDisp

        public void setDisp​(double x,
                            double y,
                            double z)
        Set the 3D displacement of this LayoutNode. The displacement is a little different than the location in that it records an offset from the current location. This is useful for algorithms such as Kamada Kawai and Fructerman Rheingold, which update positions iteratively.
        Parameters:
        x - Double representing the amount to offset in the x direction
        y - Double representing the amount to offset in the y direction
        z - Double representing the amount to offset in the y direction
      • addNeighbor

        public void addNeighbor​(LayoutNode v)
        Convenience function to keep track of neighbors of this node. This can be used to improve the performance of algorithms that try to determine the edge partners of nodes.
        Parameters:
        v - LayoutNode that is a neighbor of this LayoutNode
      • getNeighbors

        public List<LayoutNode> getNeighbors()
        Convenience function to return the list of neighbors (connected nodes) of this node.
        Returns:
        List of all of the neighbors (nodes with shared edges) of this node.
      • getIndex

        public int getIndex()
        Returns the index of this LayoutNode. This is not the same as the rootGraphIndex of the node. Its primarily used by LayoutPartition to keep track of the offset in the node array that holds this LayoutNode.
        Returns:
        The index of this node
        See Also:
        LayoutPartition
      • lock

        public void lock()
        Register this node as being "locked". Locked nodes are exempt from being moved during layout. Usually, these are the unselected nodes when a selected-only layout is being executed.
      • unLock

        public void unLock()
        Register this node as being "unlocked". Locked nodes are exempt from being moved during layout. Usually, these are the unselected nodes when a selected-only layout is being executed. The "unlocked" state is the default.
      • isLocked

        public boolean isLocked()
        Returns "true" if this node is locked, false otherwise.
        Returns:
        true if locked, false if unlocked.
      • incrementDisp

        public void incrementDisp​(double x,
                                  double y)
        Increment the displacement recorded for this node by (x,y).
        Parameters:
        x - the additional amount to displace in the x direction
        y - the additional amount to displace in the y direction
      • incrementDisp

        public void incrementDisp​(double x,
                                  double y,
                                  double z)
        Increment the displacement recorded for this node by (x,y,z).
        Parameters:
        x - the additional amount to displace in the x direction
        y - the additional amount to displace in the y direction
        z - the additional amount to displace in the z direction
      • increment

        public void increment​(double x,
                              double y)
        Increment the location of this node by (x,y). Note that location values are merely recorded until moveToLocation is called.
        Parameters:
        x - the amount to move in the x direction
        y - the amount to move in the y direction
      • increment

        public void increment​(double x,
                              double y,
                              double z)
        Increment the location of this node by (x,y,z). Note that location values are merely recorded until moveToLocation is called.
        Parameters:
        x - the amount to move in the x direction
        y - the amount to move in the y direction
        z - the amount to move in the z direction
      • decrementDisp

        public void decrementDisp​(double x,
                                  double y)
        Decrement the displacement recorded for this node by (x,y).
        Parameters:
        x - the additional amount to displace in the -x direction
        y - the additional amount to displace in the -y direction
      • decrementDisp

        public void decrementDisp​(double x,
                                  double y,
                                  double z)
        Decrement the displacement recorded for this node by (x,y,z).
        Parameters:
        x - the additional amount to displace in the -x direction
        y - the additional amount to displace in the -y direction
        z - the additional amount to displace in the -z direction
      • decrement

        public void decrement​(double x,
                              double y)
        Decrement the location of this node by (x,y). Note that location values are merely recorded until moveToLocation is called.
        Parameters:
        x - the amount to move in the -x direction
        y - the amount to move in the -y direction
      • decrement

        public void decrement​(double x,
                              double y,
                              double z)
        Decrement the location of this node by (x,y,z). Note that location values are merely recorded until moveToLocation is called.
        Parameters:
        x - the amount to move in the -x direction
        y - the amount to move in the -y direction
        z - the amount to move in the -z direction
      • getX

        public double getX()
        Return the current X value for this LayoutNode.
        Returns:
        current X value
      • getY

        public double getY()
        Return the current Y value for this LayoutNode.
        Returns:
        current Y value
      • getZ

        public double getZ()
        Return the current Z value for this LayoutNode.
        Returns:
        current Z value
      • getXDisp

        public double getXDisp()
        Return the current X displacement value for this LayoutNode.
        Returns:
        current X displacement value
      • getYDisp

        public double getYDisp()
        Return the current Y displacement value for this LayoutNode.
        Returns:
        current Y displacement value
      • getZDisp

        public double getZDisp()
        Return the current Z displacement value for this LayoutNode.
        Returns:
        current Z displacement value
      • getWidth

        public double getWidth()
        Return the width of this node
        Returns:
        width of this node
      • getHeight

        public double getHeight()
        Return the height of this node
        Returns:
        height of this node
      • getDepth

        public double getDepth()
        Return the height of this node
        Returns:
        height of this node
      • distance

        public double distance​(LayoutNode otherNode)
        Return the Euclidean distance (in 2D) between this node and another node. This method only considers the X and Y coordinates of the nodes.
        Parameters:
        otherNode - the node to measure the distance to
        Returns:
        the Euclidean distance from this node to otherNode
      • distance3D

        public double distance3D​(LayoutNode otherNode)
        Return the Euclidean distance (in 3D) between this node and another node. This method considers the X, Y and Z coordinates of the nodes.
        Parameters:
        otherNode - the node to measure the distance to
        Returns:
        the Euclidean distance from this node to otherNode
      • distance

        public double distance​(double uX,
                               double uY)
        Return the Euclidean distance (in 2D) between this node and a location. This method only considers the X and Y coordinates of the nodes.
        Parameters:
        uX - the X location to measure the distance to
        uY - the Y location to measure the distance to
        Returns:
        the Euclidean distance from this node to (uX,uY)
      • distance3D

        public double distance3D​(double uX,
                                 double uY,
                                 double uZ)
        Return the Euclidean distance (in 3D) between this node and a location. This method considers the X, Y and Z coordinates of the nodes.
        Parameters:
        uX - the X location to measure the distance to
        uY - the Y location to measure the distance to
        uZ - the Z location to measure the distance to
        Returns:
        the Euclidean distance from this node to (uX,uY,uZ)
      • moveToLocation

        public void moveToLocation()
        Move the node to its current x,y coordinate (ignores the value of the z coordinate).
      • moveToLocation3D

        public void moveToLocation3D()
        Move the node to its current x,y,z coordinate.
      • getIdentifier

        public String getIdentifier()
        Return the node's identifier.
        Returns:
        String containing the node's identifier
      • getDegree

        public int getDegree()
        Return the node's degree (i.e. number of nodes it's connected to).
        Returns:
        Degree of this node
      • toString

        public String toString()
        Return a string representation of the node
        Overrides:
        toString in class Object
        Returns:
        String containing the node's identifier and location
      • printDisp

        public String printDisp()
        Return a string representation of the node's displacement
        Returns:
        String containing the node's X,Y displacement
      • printLocation

        public String printLocation()
        Return a string representation of the node's location
        Returns:
        String containing the node's X,Y location