Package org.cytoscape.view.layout
Class LayoutPartition
java.lang.Object
org.cytoscape.view.layout.LayoutPartition
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
ConstructorDescriptionLayoutPartition(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 TypeMethodDescriptionprotected void
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
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 partitionReturn an iterator over all of the LayoutEdges in this partitionvoid
fixEdges()
Convenience routine to update the source and target for all of the edges in a partition.double
getArea()
Return the average location of the nodes in this partitiondouble
getDepth()
Return the total depth of all of the LayoutNodesReturn the list of LayoutEdges within this partition.double
Return the total height of all of the LayoutNodesdouble
getMaxX()
Return the maximum X location of all of the LayoutNodesdouble
getMaxY()
Return the maximum Y location of all of the LayoutNodesdouble
getMaxZ()
Return the maximum Z location of all of the LayoutNodesdouble
getMinX()
Return the minimum X location of all of the LayoutNodesdouble
getMinY()
Return the minimum Y location of all of the LayoutNodesdouble
getMinZ()
Return the minimum Z location of all of the LayoutNodesReturn the list of LayoutNodes within this partition.int
Return the partition number of this partitiondouble
getWidth()
Return the total width of all of the LayoutNodesint
Return the number of locked nodes within this partitionvoid
moveNodeToLocation(LayoutNode node)
Move the node to its current X and Y values.void
moveNodeToLocation3D(LayoutNode node)
Move the node to its current X, Y and Z values.int
Return the number of nodes in this partitionReturn an iterator over all of the LayoutNodes in this partitionvoid
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
setEdgeWeighter(EdgeWeighter edgeWeighter)
Set the EdgeWeighter to use for this partition.void
setPartitionNumber(int part)
Set the partition number of this partitionint
size()
Return the size of this partition, which is defined as the number of nodes that it contains.
-
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 usenodeSet
- the nodes to be considerededgeWeighter
- the weighter to use for edge weighting
-
-
Method Details
-
dontMove
protected void dontMove(boolean dm) -
setEdgeWeighter
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
Add a node to this partition.- Parameters:
nv
- the Viewof the node to add locked
- a boolean value to determine if this node is locked or not
-
addEdge
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
Add an edge to this partition assuming that the source and target nodes are known.- Parameters:
edge
- the Edge to add to the partitionv1
- the LayoutNode of the edge sourcev2
- 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
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
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
Return the list of LayoutNodes within this partition.- Returns:
- List of LayoutNodes
- See Also:
LayoutNode
-
getEdgeList
Return the list of LayoutEdges within this partition.- Returns:
- List of LayoutEdges
- See Also:
LayoutEdge
-
nodeIterator
Return an iterator over all of the LayoutNodes in this partition- Returns:
- Iterator over the list of LayoutNodes
- See Also:
LayoutNode
-
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
-
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
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 directionyoffset
- 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 directionyoffset
- 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()
-