java - jgraphx Layout algorithms explanations -


in order understand better how layout algorithms works in jgraphx, i've developed little example display issue.

1) in first example create node 2 nodes connected, apply layout algorithm, works expected, because i'm using parent of nodes , edges default parent

defaultparent

```

package it.test.graphdisplay;  import javax.swing.jframe; import javax.swing.swingconstants; import javax.swing.swingutilities;  import com.mxgraph.layout.hierarchical.mxhierarchicallayout; import com.mxgraph.swing.mxgraphcomponent; import com.mxgraph.view.mxgraph;  public class graphdisplaytest {      public static void main(string[] args) {     swingutilities.invokelater(new runnable() {          public void run() {         jframe frame = new jframe();         frame.setbounds(0, 0, 400, 300);          mxgraph graph = buildgraph();         mxgraphcomponent graphcomponent = new mxgraphcomponent(graph);          frame.getcontentpane().add(graphcomponent);         frame.setvisible(true);         }          private mxgraph buildgraph() {         mxgraph graph = new mxgraph();         object parent = graph.getdefaultparent();          graph.getmodel().beginupdate();         try {             object v1 = graph.insertvertex(parent, "v1", "v1", 20, 20,                 80, 30);             object v2 = graph.insertvertex(parent, "v2", "v2", 240,                 150, 80, 30);             graph.insertedge(parent, "e1", "e1", v1, v2);             object v3 = graph.insertvertex(parent, "v3", "v3", 240,                 200, 80, 30);             graph.insertedge(parent, "e2", "e2", v1, v3);              // apply layout graph             mxhierarchicallayout layout = new mxhierarchicallayout(                 graph);             layout.setorientation(swingconstants.west);             layout.execute(parent);          } {             graph.getmodel().endupdate();         }         return graph;         }     });      }  } 

2) in second example i'm using parent of second , third node first 1 , apply layout. result following

package it.test.graphdisplay;  import javax.swing.jframe; import javax.swing.swingconstants; import javax.swing.swingutilities;  import com.mxgraph.layout.hierarchical.mxhierarchicallayout; import com.mxgraph.swing.mxgraphcomponent; import com.mxgraph.view.mxgraph;  public class graphdisplaytest {      public static void main(string[] args) {     swingutilities.invokelater(new runnable() {          public void run() {         jframe frame = new jframe();         frame.setbounds(0, 0, 400, 300);          mxgraph graph = buildgraph();         mxgraphcomponent graphcomponent = new mxgraphcomponent(graph);          frame.getcontentpane().add(graphcomponent);         frame.setvisible(true);         }          private mxgraph buildgraph() {         mxgraph graph = new mxgraph();         object parent = graph.getdefaultparent();          graph.getmodel().beginupdate();         try {             object v1 = graph.insertvertex(parent, "v1", "v1", 20, 20,                 80, 30);             object v2 = graph.insertvertex(v1, "v2", "v2", 240, 150,                 80, 30);             graph.insertedge(v1, "e1", "e1", v1, v2);             object v3 = graph.insertvertex(v1, "v3", "v3", 240, 200,                 80, 30);             graph.insertedge(parent, "e2", "e2", v1, v3);              // apply layout graph             mxhierarchicallayout layout = new mxhierarchicallayout(                 graph);             layout.setorientation(swingconstants.west);             layout.execute(parent);          } {             graph.getmodel().endupdate();         }         return graph;         }     });      }  } 

second

there reason of behaviour ? i'm not able find explanation in documentation.

thank you!

p.s: opened issue here: https://github.com/jgraph/jgraphx/issues/50 no clues far


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -