Cytoscape 3.0.1 API

org.cytoscape.view.layout
Class LayoutNode

java.lang.Object
  extended by org.cytoscape.view.layout.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.


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
LayoutNode(View<CyNode> nodeView, int index, CyRow row)
          The main constructor for a LayoutNode.
 
Method Summary
 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 decrementDisp(double x, double y)
          Decrement the displacement recorded for this node by (x,y).
 double distance(double uX, double uY)
          Return the Euclidean distance between this node and a location
 double distance(LayoutNode otherNode)
          Return the Euclidean distance between this node and another node
 int getDegree()
          Return the node's degree (i.e.
 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.
 void increment(double x, double y)
          Increment the location of this node by (x,y).
 void incrementDisp(double x, double y)
          Increment the displacement recorded for this node by (x,y).
 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.
 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 displacement of this LayoutNode.
 void setLocation(double x, double y)
          Set the 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.
 String toString()
          Return a string representation of the node
 void unLock()
          Register this node as being "unlocked".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 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

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

setDisp

public void setDisp(double x,
                    double y)
Set the 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

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

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

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

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

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

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

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

distance

public double distance(LayoutNode otherNode)
Return the Euclidean distance between this node and another node

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 between this node and a location

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)

moveToLocation

public void moveToLocation()
Move the node to its current x,y 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

compareTo

public int compareTo(LayoutNode nodeView)
Specified by:
compareTo in interface Comparable<LayoutNode>

Cytoscape 3.0.1 API

Copyright 2011 Cytoscape Consortium. All rights reserved.