1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
public class Graphe_Hello_World
{
MyFrame frame;
//Le constructeur
public Graphe_Hello_World(MyFrame f)
{
super();
mxGraph graph = new mxGraph();
frame = f;
//On récupère la racine du graphe
Object parent = graph.getDefaultParent();
//On commence la création des noeuds
graph.getModel().beginUpdate();
try
{
Object v1 = graph.insertVertex(parent, null, "Hello", 300, 40, 40, 40);
Object v3 = graph.insertVertex(parent, null, "World", 300, 90, 40, 40);
graph.insertEdge(parent, null, "Edge", v1, v3);
}
finally
{
graph.getModel().endUpdate();
}
mxGraphComponent graphComponent = new mxGraphComponent(graph);
frame.add_graph(graphComponent);
} |
Partager