Class LayoutPartition

java.lang.Object
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.

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>
  • Constructor Summary

    Constructors
    Constructor
    Description
    LayoutPartition(int nodeCount, int edgeCount)
    LayoutPartition: use this constructor to create an empty LayoutPartition.
    LayoutPartition(CyNetworkView networkView, Collection<View<CyNode>> nodeSet, EdgeWeighter edgeWeighter)
    LayoutPartition: use this constructor to create a LayoutPartition that includes the entire network.
  • Method Summary

    Modifier and Type
    Method
    Description
    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
    Calculate and set the edge weights.
    protected void
    dontMove(boolean dm)
     
    int
    Return the number of edges in this partition
    Return an iterator over all of the LayoutEdges in this partition
    void
    Convenience routine to update the source and target for all of the edges in a partition.
    double
     
    Return the average location of the nodes in this partition
    double
    Return the total depth of all of the LayoutNodes
    Return the list of LayoutEdges within this partition.
    double
    Return the total height of all of the LayoutNodes
    double
    Return the maximum X location of all of the LayoutNodes
    double
    Return the maximum Y location of all of the LayoutNodes
    double
    Return the maximum Z location of all of the LayoutNodes
    double
    Return the minimum X location of all of the LayoutNodes
    double
    Return the minimum Y location of all of the LayoutNodes
    double
    Return the minimum Z location of all of the LayoutNodes
    Return the list of LayoutNodes within this partition.
    int
    Return the partition number of this partition
    double
    Return the total width of all of the LayoutNodes
    int
    Return the number of locked nodes within this partition
    void
    Move the node to its current X and Y values.
    void
    Move the node to its current X, Y and Z values.
    int
    Return the number of nodes in this partition
    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
    offset(double xoffset, double yoffset, double zoffset)
    Offset all of the nodes in the partition by a fixed amount.
    void
    Randomize the graph locations (ignoring Z values).
    void
    randomizeLocations(boolean is3D)
    Randomize the graph locations.
    void
    Reset all of the data maintained for the LayoutNodes contained within this partition, including the min, max and average x and y values.
    void
    Set the EdgeWeighter to use for this partition.
    void
    Set the partition number of this partition
    int
    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 Details

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

    • dontMove

      protected void dontMove(boolean dm)
    • 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(boolean is3D)
      Randomize the graph locations.
      Parameters:
      is3D - ignores Z values if false
    • randomizeLocations

      public void randomizeLocations()
      Randomize the graph locations (ignoring Z values).
    • 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. Note, updates the Z min and max to 0.
      Parameters:
      node - the LayoutNode to move
    • moveNodeToLocation3D

      public void moveNodeToLocation3D(LayoutNode node)
      Move the node to its current X, Y and Z values. This is a wrapper to LayoutNode's moveToLocation3D, 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:
    • getEdgeList

      public List<LayoutEdge> getEdgeList()
      Return the list of LayoutEdges within this partition.
      Returns:
      List of LayoutEdges
      See Also:
    • 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:
    • 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:
    • 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
    • getMaxZ

      public double getMaxZ()
      Return the maximum Z location of all of the LayoutNodes
      Returns:
      maximum Z 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
    • getMinZ

      public double getMinZ()
      Return the minimum Z location of all of the LayoutNodes
      Returns:
      minimum Z 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
    • getDepth

      public double getDepth()
      Return the total depth of all of the LayoutNodes
      Returns:
      total depth 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
    • offset

      public void offset(double xoffset, double yoffset, double zoffset)
      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.
    • getArea

      public double getArea()