- STYLE_VERTICAL_ALIGN:垂直方向のアライメント指定
- STYLE_ALIGN:水平方向のアライメント指定
- ALIGN_TOP:上寄せ
- ALIGN_BOTTOM:下寄せ
- ALIGN_LEFT:左寄せ
- ALIGN_RIGHT:右寄せ
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() sb = new SwingBuilder() def frm = sb.frame( title: "JGraphX - text position", visible: true, size: [150, 300], resizable: true, contentPane: new mxGraphComponent(graph), defaultCloseOperation: WindowConstants.EXIT_ON_CLOSE ){ parent = graph.getDefaultParent() graph.model.beginUpdate() try { def stylesheet = graph.getStylesheet() // カスタムスタイル def style1 = [ (mxConstants.STYLE_VERTICAL_ALIGN):mxConstants.ALIGN_TOP ] stylesheet.putCellStyle("style1", style1) def style2 = [ (mxConstants.STYLE_VERTICAL_ALIGN):mxConstants.ALIGN_BOTTOM ] stylesheet.putCellStyle("style2", style2) def style3 = [ (mxConstants.STYLE_ALIGN):mxConstants.ALIGN_LEFT ] stylesheet.putCellStyle("style3", style3) def style4 = [ (mxConstants.STYLE_ALIGN):mxConstants.ALIGN_RIGHT ] stylesheet.putCellStyle("style4", style4) def v1 = graph.insertVertex(parent, null, "処理1", 20, 20, 100, 30, "style1") def v2 = graph.insertVertex(parent, null, "処理2", 20, 90, 100, 30, "style2") def v3 = graph.insertVertex(parent, null, "処理3", 20, 160, 100, 30, "style3") def v4 = graph.insertVertex(parent, null, "処理4", 20, 230, 100, 30, "style4") graph.insertEdge(parent, null, "正常終了", v1, v2) graph.insertEdge(parent, null, "正常終了", v2, v3) graph.insertEdge(parent, null, "正常終了", v3, v4) } finally { graph.model.endUpdate() } }実行結果
関連情報
JGraphxのダウンロードページ
0 件のコメント:
コメントを投稿