サンプルコード
import java.awt.* import javax.swing.* import groovy.swing.* import com.mxgraph.swing.* import com.mxgraph.view.* import com.mxgraph.util.mxConstants def graph = new mxGraph() def mxgc = new mxGraphComponent(graph) sb = new SwingBuilder() def frm = sb.frame( title: "JGraphX - deleting selected cells", visible: true, size: [400, 150], resizable: true, show:true, contentPane: mxgc, defaultCloseOperation: WindowConstants.EXIT_ON_CLOSE ){ menuBar(){ menu(text:"Test", mnemonic: "T"){ menuItem(text:"Delete selected cells", mnemonic: "S", actionPerformed:{ def sm = graph.getSelectionModel() graph.removeCells(sm.getCells(), false /*=include edges*/) }) } } parent = graph.getDefaultParent() graph.model.beginUpdate() try { def v1 = graph.insertVertex(parent, null, "処理1", 20, 20, 50, 30, "style1") def v2 = graph.insertVertex(parent, null, "処理2", 170, 20, 50, 30, "style2") def v3 = graph.insertVertex(parent, null, "処理3", 320, 20, 50, 30, "style3") graph.insertEdge(parent, null, "正常終了", v1, v2) graph.insertEdge(parent, null, "正常終了", v2, v3) } finally { graph.model.endUpdate() } }実行結果
関連情報
JGraphxのダウンロードページ
0 件のコメント:
コメントを投稿