I am trying to use the layout algorithm in GVF for my own graph. I only need to layout algoritm to calculate the co-ordinates of each node in the graph and I will display them myself.
So I subclass the layout algorithm in GVF and over load the getSize() method so that it can take into the account of different node sizes in my graph, instead of create a NodeSize() with defaultSize.
And I check the ReingoldTilford algorithm in GVF, it does call getWidth() and getHeight() to account to different node size during layout.
But after I did this, there are still overlap in the graph hort. and the y-coordinate never get adjust (it always return 1.0, 2.0, 3.0, but the height is 69, 35, 30).
Could you please tell me what did I miss?
public class MyReingoldTilford extends ReingoldTilford {
public NodeSize getSize(Node node, Graph graph) {
NodeSize nodeSize = (NodeSize)sizeMap.get(node, graph);
if (nodeSize == null) {
if (node instanceof MyLayoutNode) {
MyLayoutNode myNode = (MyLayoutNode) node;
nodeSize = new NodeSize(myNode.getSize().width, myNode.getSize().height);
} else {
nodeSize = new NodeSize(getDefaultNodeSize(), getDefaultNodeSize());
}
sizeMap.put(node, graph, nodeSize);
}
return nodeSize;
}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is what I do to build the graph:
1. I create a source node and a target node (target Node of the src node). and Mynode is just a child class of the node
2. I add targetNode as the successor of the srcNode
3. I create an edge for the connection between sourceNode and targetNode.
4. I add both nodes to the graph.
Do I miss something? I see there are over-lapping in the graph.
// Inside a loop
MyNode srcNode = new MyNode();
MyNode targetNode = new MyNode();
srcNode.addSuccessor(targetNode, graph);
royere.cwi.structure.Edge edge = new royere.cwi.structure.Edge(srcNode, targetNode);
edge.setProperty(Keys.ISDIRECTED, Boolean.TRUE);
srcNode.addOutgoingEdge(edge, graph);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to use the layout algorithm in GVF for my own graph. I only need to layout algoritm to calculate the co-ordinates of each node in the graph and I will display them myself.
So I subclass the layout algorithm in GVF and over load the getSize() method so that it can take into the account of different node sizes in my graph, instead of create a NodeSize() with defaultSize.
And I check the ReingoldTilford algorithm in GVF, it does call getWidth() and getHeight() to account to different node size during layout.
But after I did this, there are still overlap in the graph hort. and the y-coordinate never get adjust (it always return 1.0, 2.0, 3.0, but the height is 69, 35, 30).
Could you please tell me what did I miss?
public class MyReingoldTilford extends ReingoldTilford {
public NodeSize getSize(Node node, Graph graph) {
NodeSize nodeSize = (NodeSize)sizeMap.get(node, graph);
if (nodeSize == null) {
if (node instanceof MyLayoutNode) {
MyLayoutNode myNode = (MyLayoutNode) node;
nodeSize = new NodeSize(myNode.getSize().width, myNode.getSize().height);
} else {
nodeSize = new NodeSize(getDefaultNodeSize(), getDefaultNodeSize());
}
sizeMap.put(node, graph, nodeSize);
}
return nodeSize;
}
}
Here is what I do to build the graph:
1. I create a source node and a target node (target Node of the src node). and Mynode is just a child class of the node
2. I add targetNode as the successor of the srcNode
3. I create an edge for the connection between sourceNode and targetNode.
4. I add both nodes to the graph.
Do I miss something? I see there are over-lapping in the graph.
// Inside a loop
MyNode srcNode = new MyNode();
MyNode targetNode = new MyNode();
srcNode.addSuccessor(targetNode, graph);
royere.cwi.structure.Edge edge = new royere.cwi.structure.Edge(srcNode, targetNode);
edge.setProperty(Keys.ISDIRECTED, Boolean.TRUE);
srcNode.addOutgoingEdge(edge, graph);