|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gumbo.visualize.data.layout.GraphNodeOrdering
Similar to a graph node ranking (see GraphNodeRanking), but the nodes in each rank are ordered.
The nodes in an ordering constitute a set, with no nulls or duplicates. As such, each rank in an ordering is also a set. Placing a node in an ordering does not affect the topology of its graph, and a given node can be placed in more than one ordering (with the exception that GraphLayoutNode.setRanking() only allows a single ranking).
An ordering is loosely coupled to its host ranking. As such, changes to the host ranking are not reflected in the ordering. Instead, changes to the ordering and its ranking, such as adding or removing nodes, should be made to the ordering, which will relay the changes to its host ranking.
Constructor Summary | |
GraphNodeOrdering(GraphNodeOrdering ordering)
Creates an instance whose ranks are copied from the specified ordering. |
|
GraphNodeOrdering(GraphNodeRanking ranking)
Creates an instance whose ranks are defined by the specified host ranking. |
Method Summary | |
void |
addNode(int rankI,
GraphLayoutNode node)
Adds a node to a rank in this ordering and its host ranking; and, calls GraphNodeRanking.initNodes() on the host ranking. |
void |
addNodes(int rankI,
java.util.Collection nodes)
Adds a group of nodes to a rank in this ordering and its host ranking. |
static boolean |
centerNodes(int dim,
java.util.Collection nodes,
java.util.Set hits,
double centerPos,
double same,
java.util.List rank)
Tries to compress and center a group of target nodes in a rank along a given dimension, even if the target nodes are discontiguous (mixed with hit nodes and non-target nodes). |
static double |
compressRank(int dim,
int nodeI,
int hitI,
double delta,
double same,
java.util.List rank)
Deprecated. Replaced by moveNode(), which uses nodes instead of indices. |
boolean |
containsNode(GraphLayoutNode node)
Returns true if this ordering contains the specified node. |
int |
crossAfterCount(int rankI)
Returns the number of link crossings between the target rank and the rank after it (rankI+1) based on their current orderings. |
int |
crossCount()
Returns the number of link crossings in this ordering. |
protected static int |
findFirstHit(boolean doRight,
int nodeI,
java.util.Set hits,
java.util.List rank)
Finds the next hit node in a rank in a given direction. |
boolean |
getGraphChanged()
Gets the graph changed flag of this ordering since the last resetGraphChanged(). |
int |
getNodeCount()
Gets the number of nodes in this ordering. |
java.util.Set |
getNodes()
Returns an immutable view of the nodes in this ordering. |
int |
getRankCount()
Gets the number of ranks in this ordering. |
int |
getRankIndex(GraphLayoutNode node)
Gets the rank index of a node in this ordering. |
GraphNodeRanking |
getRanking()
Gets the ranking associated with this ordering. |
java.util.List |
getRankList(GraphLayoutNode node)
Gets an immutable view of the rank containing a given node in this ranking, as a list. |
java.util.List |
getRankList(int rankI)
Gets an immutable view of a rank in this ordering, as a list. |
java.util.Set |
getRankSet(GraphLayoutNode node)
Gets an immutable view of the rank containing a given node in this ranking, as a set. |
java.util.Set |
getRankSet(int rankI)
Gets an immutable view of a rank in this ordering, as a set. |
void |
gridAlignRanks(int dim,
double origin)
Grid aligns the positions of the nodes in each rank. |
void |
indexCenterRank(int rankI,
boolean useBefore,
double speed,
double noise)
Computes and sets the index barycenters of the nodes in the target rank based on the node indices of the fixed reference rank. |
java.util.List |
indexList(int rankI,
java.util.Collection nodes,
java.util.List retVal)
Returns a list with the nodes in a node group ordered according to their index in their target rank. |
static double |
moveNode(int dim,
GraphLayoutNode node,
java.util.Collection hits,
double delta,
double same,
java.util.List rank)
Tries to move a target node in a rank along a given dimension. |
void |
removeNode(GraphLayoutNode node)
Removes a node from this ordering and its host ranking; and, calls GraphNodeRanking.initNodes() on the host ranking. |
void |
removeNodes(java.util.Collection nodes)
Removes a group of nodes from this ordering and its host ranking. |
void |
resetGraphChanged()
Resets the graph changed flag of this ordering to false. |
void |
setGraphChanged()
Explicitely sets the graph changed flag of this ordering to true. |
void |
setRankList(int rankI,
java.util.List rank)
Sets a rank list in this ordering, replacing the previous ordering. |
void |
setRankLists(GraphNodeOrdering ordering)
Sets the ranks lists in this ordering from those in the specified ordering. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GraphNodeOrdering(GraphNodeRanking ranking)
ranking
- The host ranking. Never null.public GraphNodeOrdering(GraphNodeOrdering ordering)
ordering
- The target ordering. Never null.Method Detail |
public GraphNodeRanking getRanking()
public void resetGraphChanged()
public void setGraphChanged()
public boolean getGraphChanged()
public void indexCenterRank(int rankI, boolean useBefore, double speed, double noise)
rankI
- Target rank index (0:size-1 depending on doBefore).
Throws an exception if out of bounds.useBefore
- If true, the before rank (rankI-1) is used as
the fixed reference rank; otherwise, the after rank (rankI+1) is used.speed
- Speed factor (>=0, <=1) applied to barycenter
movement relative to old to new position delta. If zero, the
new barycenter is ignored. If one, the old barycenter is ignored.noise
- Noise magnitude (>=0) applied to the barycenter
movement delta. Ignored if zero.
java.lang.IllegalStateException
- Target's friend node not found
in fixed rank.public int crossAfterCount(int rankI)
rankI
- Target rank index (0:size-2). Throws an exception
if out of bounds.
public int crossCount()
public java.util.Set getNodes()
public java.util.Set getRankSet(int rankI)
rankI
- Rank index. Throws an exception if out of bounds.
public void setRankList(int rankI, java.util.List rank)
rankI
- Rank index. Throws an exception if out of bounds.rank
- Value of the node rank (GraphLayoutNode). Possibly
empty. Never null.
java.lang.IllegalArgumentException
- New and old rank nodes are different.public void setRankLists(GraphNodeOrdering ordering)
ordering
- The ordering with the new rank lists. Never null.
java.lang.IllegalArgumentException
- Ordering has a different ranking.public java.util.List getRankList(int rankI)
rankI
- Rank index. Throws an exception if out of bounds.
public java.util.Set getRankSet(GraphLayoutNode node)
node
- Reference to the node. Ignored if null or missing.
public java.util.List getRankList(GraphLayoutNode node)
node
- Reference to the node. Ignored if null or missing.
public int getRankIndex(GraphLayoutNode node)
node
- Reference to the node. Ignored if null or missing.
public int getRankCount()
public int getNodeCount()
public boolean containsNode(GraphLayoutNode node)
node
- Reference to the node. Returns false if null.
public void addNode(int rankI, GraphLayoutNode node)
rankI
- Rank index. Throws an exception if out of bounds.node
- Reference to the node. Ignored if null.
java.lang.IllegalArgumentException
- Node is already in this ordering.public void removeNode(GraphLayoutNode node)
node
- Reference to the node. Ignored if null.
java.lang.IllegalArgumentException
- Node is not in this ordering.public void addNodes(int rankI, java.util.Collection nodes)
rankI
- Rank index. Throws an exception if out of bounds.nodes
- Value of the nodes (GraphLayoutNode). Ignored if null.
Throws an exception if a node is already in this ranking.public void removeNodes(java.util.Collection nodes)
nodes
- Value of the nodes (GraphLayoutNode). Ignored if null.
Ignores missing nodes.public java.util.List indexList(int rankI, java.util.Collection nodes, java.util.List retVal)
rankI
- Rank index. Throws an exception if out of bounds.nodes
- AbstractGroup of nodes (GraphLayoutNode) from the target rank.
Never null. Throws an exception if not in the target rank.retVal
- Return value object. Ordered list (GraphLayoutNode).
Never null.
public void gridAlignRanks(int dim, double origin)
dim
- The affected layout position dimension (1:2).origin
- The position of the minimum extent of the most negative
node.public static double compressRank(int dim, int nodeI, int hitI, double delta, double same, java.util.List rank)
dim
- The affected layout position dimension (1:2).nodeI
- The target node index (0:size-1) in rankI to be moved.hitI
- The immovable node index in rankI (0:size-1). <0 if none.
If no hit node then the shift will always be complete (no remainder).delta
- The desired change in target node position. The sign
indicates the shift direction (>0 to right, <0 to left, 0 do nothing).same
- The tolerance for testing equality (>=0). Zero if <0.rank
- The target rank (GraphLayoutNode). Never null.
public static boolean centerNodes(int dim, java.util.Collection nodes, java.util.Set hits, double centerPos, double same, java.util.List rank)
The algorithm is not very efficient, and disturbs non-target nodes more than it needs to.
dim
- The affected layout position dimension (1:2).nodes
- The target nodes (GraphLayoutNode) to be moved.
Must be a set. Throws an exception if not in the rank or is a hit.
Never null.hits
- Immovable hit nodes. Null or empty if none.
If no hit nodes the shift will always be complete (no remainder).
Hits missing from the rank are ignored.centerPos
- The desired center position of the target nodes.same
- The tolerance for testing equality (>=0). Zero if <0.rank
- The target rank (GraphLayoutNode). Never null.
protected static int findFirstHit(boolean doRight, int nodeI, java.util.Set hits, java.util.List rank)
doRight
- If true, searches to the right; otherwise, to the left.nodeI
- Index of the starting node in the rank. Throws an
exception if not in the rank.hits
- Rank hit nodes. Never null.
public static double moveNode(int dim, GraphLayoutNode node, java.util.Collection hits, double delta, double same, java.util.List rank)
dim
- The affected layout position dimension (1:2).node
- The target node to be moved. Throws an exception if
not in the rank. If the target node is in hits, nothing happens.
Never null.hits
- Immovable hit nodes. Null or empty if none.
If no hit nodes the shift will always be complete (no remainder).
Hits missing from the rank are ignored.delta
- The desired change in target node position. The sign
indicates the shift direction (>0 to right, <0 to left, 0 do nothing).same
- The tolerance for testing equality (>=0). Zero if <0.rank
- The target rank (GraphLayoutNode). Never null.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |