サンプルコード
import java.awt.* import javax.swing.* import groovy.swing.* import com.mxgraph.swing.* import com.mxgraph.view.* import com.mxgraph.util.mxConstants import com.mxgraph.layout.* def graph = new mxGraph() def mxgc = new mxGraphComponent(graph) sb = new SwingBuilder() def frm = sb.frame( title: "JGraphX - circle layout", visible: true, size: [300, 300], resizable: true, contentPane: mxgc, defaultCloseOperation: WindowConstants.EXIT_ON_CLOSE ){ parent = graph.getDefaultParent() graph.model.beginUpdate() try { def v1 = graph.insertVertex(parent, null, "処理1", 0, 0, 50, 30) def v2 = graph.insertVertex(parent, null, "処理2", 0, 0, 50, 30) def v3 = graph.insertVertex(parent, null, "処理3", 0, 0, 50, 30) def v4 = graph.insertVertex(parent, null, "処理4", 0, 0, 50, 30) def v5 = graph.insertVertex(parent, null, "処理5", 0, 0, 50, 30) def v6 = graph.insertVertex(parent, null, "処理6", 0, 0, 50, 30) graph.insertEdge(parent, null, "呼出", v1, v2) graph.insertEdge(parent, null, "呼出", v1, v3) graph.insertEdge(parent, null, "呼出", v1, v4) graph.insertEdge(parent, null, "呼出", v1, v5) graph.insertEdge(parent, null, "呼出", v1, v6) def lm = new mxLayoutManager(graph) def cl = new mxCircleLayout(graph) cl.setRadius(50) lm.executeLayout(cl, graph.getDefaultParent()) } finally { graph.model.endUpdate() } }実行結果
関連情報
JGraphxのダウンロードページ
0 件のコメント:
コメントを投稿