Skip to content

Instantly share code, notes, and snippets.

@Nelrohd
Created May 27, 2015 14:46
Show Gist options
  • Save Nelrohd/24879332915cd67cb133 to your computer and use it in GitHub Desktop.
Save Nelrohd/24879332915cd67cb133 to your computer and use it in GitHub Desktop.
'createGraph': function() {
var /**yfiles.graph.IGraph*/graph = this.graphControl.graph;
var /**yfiles.graph.IGroupedGraph*/ groupedGraph = graph.getGroupedGraph();
// Create the pool node
var /**demo.bpmn.PoolNodeStyle*/ poolNodeStyle = new demo.bpmn.PoolNodeStyle();
var /**yfiles.graph.INode*/ poolNode = groupedGraph.createGroupNode();
graph.setNodeStyle(poolNode,poolNodeStyle);
var /**yfiles.graph.ITable*/ poolTable = getTable(poolNodeStyle, poolNode);
poolTable.columnDefaults.insets = new yfiles.geometry.InsetsD.createDefault();
// Define the table:
// - create two rows
var firstRow = poolTable.createRootRowWithSize(100);
var secondRow = poolTable.createRootRowWithSize(100);
// - and a single column
poolTable.createRootColumnWithSize(400);
graph.addLabelWithParameter(poolNode, demo.bpmn.PoolHeaderLabelModel.WEST, "Pool");
poolTable.addLabel(firstRow,"First Row");
poolTable.addLabel(secondRow,"Second Row");
// Apply the table size to the root node
graph.setBounds(poolNode, poolTable.layout.toRectD());
var firstRowBounds = firstRow.getAbsoluteBounds(poolNode);
var secondRowBounds = secondRow.getAbsoluteBounds(poolNode);
// Add some leaf nodes
// - make sure that the nodes are located within the correct lane (row)
// (nodes are mapped to rows based on their geometric position!)
var activityNode = groupedGraph.createNodeWithParentBoundsAndStyle(poolNode,new yfiles.geometry.RectD(firstRowBounds.centerX,firstRowBounds.centerY,80,50), new demo.bpmn.ActivityNodeStyle());
var eventNode = groupedGraph.createNodeWithParentBoundsAndStyle(poolNode,new yfiles.geometry.RectD(secondRowBounds.centerX,secondRowBounds.centerY,50,50), new demo.bpmn.Even
tNodeStyle());
var gatewayNode = groupedGraph.createNodeWithParentBoundsAndStyle(poolNode,new yfiles.geometry.RectD(secondRowBounds.centerX,secondRowBounds.centerY,50,50), new demo.bpmn.Ga
tewayNodeStyle());
graph.createEdge(eventNode,gatewayNode);
graph.createEdge(activityNode,gatewayNode);
// run the layout
this.onLayoutButtonClicked();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment