I use the Eclipse bpmn2 plugin :
To modelize my workflow:
How can we create workflows programaticaly, in something that looks like this:
public void CreateFlow() {
StartEvent StartEvent1;
EndEvent EndEvent1;
Task Task1;
StartEvent1.linkTo (Task1);
Task1.linkTo(EndEvent1);
}
You can use Fluent API [1][2] to programatically create process definition. I am not sure if you can set X-Y coordinates of respective nodes, so can't confirm that importing *.BPMN file generated with this API into a BPMN designer will render properly - but it will be definitely executable.
[2] https://docs.jboss.org/jbpm/release/7.33.0.Final/jbpm-docs/html_single/#_process_fluent_api