Cytoscape 3.0.1 API

org.cytoscape.view.layout
Class LayoutPartition

java.lang.Object
  extended by org.cytoscape.view.layout.LayoutPartition

public final class LayoutPartition
extends Object

The LayoutPartition class contains all of the information about a single graph partition, where a partition is defined as all nodes in a graph that connect only to each other. This class also provides static methods that are used to partition an existing graph.

Author:
Scooter Morris

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
LayoutPartition(CyNetworkView networkView, Collection<View<CyNode>> nodeSet, EdgeWeighter edgeWeighter)
          LayoutPartition: use this constructor to create a LayoutPartition that includes the entire network.
LayoutPartition(int nodeCount, int edgeCount)
          LayoutPartition: use this constructor to create an empty LayoutPartition.
 
Method Summary
protected  void addEdge(CyEdge edge, CyRow row)
          Add an edge to this partition assuming that the source and target nodes are not yet known.
protected  void addEdge(CyEdge edge, LayoutNode v1, LayoutNode v2, CyRow row)
          Add an edge to this partition assuming that the source and target nodes are known.
protected  void addNode(CyNetwork network, View<CyNode> nv, boolean locked)
          Add a node to this partition.
 void calculateEdgeWeights()
          Calculate and set the edge weights.
 int edgeCount()
          Return the number of edges in this partition
 Iterator<LayoutEdge> edgeIterator()
          Return an iterator over all of the LayoutEdges in this partition
 void fixEdges()
          Convenience routine to update the source and target for all of the edges in a partition.
 LayoutPoint getAverageLocation()
          Return the average location of the nodes in this partition
 List<LayoutEdge> getEdgeList()
          Return the list of LayoutEdges within this partition.
 double getHeight()
          Return the total height of all of the LayoutNodes
 double getMaxX()
          Return the maximum X location of all of the LayoutNodes
 double getMaxY()
          Return the maximum Y location of all of the LayoutNodes
 double getMinX()
          Return the minimum X location of all of the LayoutNodes
 double getMinY()
          Return the minimum Y location of all of the LayoutNodes
 List<LayoutNode> getNodeList()
          Return the list of LayoutNodes within this partition.
 int getPartitionNumber()
          Return the partition number of this partition
 double getWidth()
          Return the total width of all of the LayoutNodes
 int lockedNodeCount()
          Return the number of locked nodes within this partition
 void moveNodeToLocation(LayoutNode node)
          Move the node to its current X and Y values.
 int nodeCount()
          Return the number of nodes in this partition
 Iterator<LayoutNode> nodeIterator()
          Return an iterator over all of the LayoutNodes in this partition
 void offset(double xoffset, double yoffset)
          Offset all of the nodes in the partition by a fixed amount.
 void randomizeLocations()
          Randomize the graph locations.
 void resetNodes()
          Reset all of the data maintained for the LayoutNodes contained within this partition, including the min, max and average x and y values.
 void setEdgeWeighter(EdgeWeighter edgeWeighter)
          Set the EdgeWeighter to use for this partition.
 void setPartitionNumber(int part)
          Set the partition number of this partition
 int size()
          Return the size of this partition, which is defined as the number of nodes that it contains.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LayoutPartition

public LayoutPartition(int nodeCount,
                       int edgeCount)
LayoutPartition: use this constructor to create an empty LayoutPartition.

Parameters:
nodeCount - The number of nodes in the new partition.
edgeCount - The number of edges in the new partition.

LayoutPartition

public LayoutPartition(CyNetworkView networkView,
                       Collection<View<CyNode>> nodeSet,
                       EdgeWeighter edgeWeighter)
LayoutPartition: use this constructor to create a LayoutPartition that includes the entire network.

Parameters:
networkView - the CyNetworkView to use
nodeSet - the nodes to be considered
edgeWeighter - the weighter to use for edge weighting
Method Detail

setEdgeWeighter

public void setEdgeWeighter(EdgeWeighter edgeWeighter)
Set the EdgeWeighter to use for this partition. The EdgeWeighter should be shared by all partitions in the same graph to avoid contrary scaling problems.

Parameters:
edgeWeighter - the weighter to use for edge weighting

addNode

protected void addNode(CyNetwork network,
                       View<CyNode> nv,
                       boolean locked)
Add a node to this partition.

Parameters:
nv - the View of the node to add
locked - a boolean value to determine if this node is locked or not

addEdge

protected void addEdge(CyEdge edge,
                       CyRow row)
Add an edge to this partition assuming that the source and target nodes are not yet known.

Parameters:
edge - the Edge to add to the partition

addEdge

protected void addEdge(CyEdge edge,
                       LayoutNode v1,
                       LayoutNode v2,
                       CyRow row)
Add an edge to this partition assuming that the source and target nodes are known.

Parameters:
edge - the Edge to add to the partition
v1 - the LayoutNode of the edge source
v2 - the LayoutNode of the edge target

randomizeLocations

public void randomizeLocations()
Randomize the graph locations.


moveNodeToLocation

public void moveNodeToLocation(LayoutNode node)
Move the node to its current X and Y values. This is a wrapper to LayoutNode's moveToLocation, but has the property of updating the current min and max values for this partition.

Parameters:
node - the LayoutNode to move

fixEdges

public void fixEdges()
Convenience routine to update the source and target for all of the edges in a partition. This is useful when the algorithm used makes it difficult to record source and target until it has completed.


calculateEdgeWeights

public void calculateEdgeWeights()
Calculate and set the edge weights. Note that this will delete edges from the calculation (not the graph) when certain conditions are met.


size

public int size()
Return the size of this partition, which is defined as the number of nodes that it contains.

Returns:
partition size

getNodeList

public List<LayoutNode> getNodeList()
Return the list of LayoutNodes within this partition.

Returns:
List of LayoutNodes
See Also:
LayoutNode

getEdgeList

public List<LayoutEdge> getEdgeList()
Return the list of LayoutEdges within this partition.

Returns:
List of LayoutEdges
See Also:
LayoutEdge

nodeIterator

public Iterator<LayoutNode> nodeIterator()
Return an iterator over all of the LayoutNodes in this partition

Returns:
Iterator over the list of LayoutNodes
See Also:
LayoutNode

edgeIterator

public Iterator<LayoutEdge> edgeIterator()
Return an iterator over all of the LayoutEdges in this partition

Returns:
Iterator over the list of LayoutEdges
See Also:
LayoutEdge

nodeCount

public int nodeCount()
Return the number of nodes in this partition

Returns:
number of nodes in the partition

edgeCount

public int edgeCount()
Return the number of edges in this partition

Returns:
number of edges in the partition

getMaxX

public double getMaxX()
Return the maximum X location of all of the LayoutNodes

Returns:
maximum X location

getMaxY

public double getMaxY()
Return the maximum Y location of all of the LayoutNodes

Returns:
maximum Y location

getMinX

public double getMinX()
Return the minimum X location of all of the LayoutNodes

Returns:
minimum X location

getMinY

public double getMinY()
Return the minimum Y location of all of the LayoutNodes

Returns:
minimum Y location

getWidth

public double getWidth()
Return the total width of all of the LayoutNodes

Returns:
total width of all of the LayoutNodes

getHeight

public double getHeight()
Return the total height of all of the LayoutNodes

Returns:
total height of all of the LayoutNodes

getPartitionNumber

public int getPartitionNumber()
Return the partition number of this partition

Returns:
partition number

setPartitionNumber

public void setPartitionNumber(int part)
Set the partition number of this partition

Parameters:
part - partition number

lockedNodeCount

public int lockedNodeCount()
Return the number of locked nodes within this partition

Returns:
number of locked nodes in partition

getAverageLocation

public LayoutPoint getAverageLocation()
Return the average location of the nodes in this partition

Returns:
average location of the nodes as a Dimension

offset

public void offset(double xoffset,
                   double yoffset)
Offset all of the nodes in the partition by a fixed amount. This is used by algorithms of offset each partition after laying it out.

Parameters:
xoffset - the amount to offset in the X direction
yoffset - the amount to offset in the Y direction

resetNodes

public void resetNodes()
Reset all of the data maintained for the LayoutNodes contained within this partition, including the min, max and average x and y values.


Cytoscape 3.0.1 API

Copyright 2011 Cytoscape Consortium. All rights reserved.