Vector<Line> lines = new Vector<Line>();
if (graph.getChildren().size() > 0) {
Stack<ModelGraph> graphs = new Stack<ModelGraph>();
graphs.add(graph);
while (!graphs.empty()) {
ModelGraph curGraph = graphs.pop();
if (curGraph.getModel().isParentType()) {
if (curGraph.getChildren().size() == 0)
curGraph.addChild(new ModelGraph(createDummyNode()));
List<Line> relaventLines = getRelaventLines(lines, curGraph
.getModel().getId());
for (Line relaventLine : relaventLines) {
int index = lines.indexOf(relaventLine);
if (curGraph.getModel().getExecutionType().toLowerCase()
.equals("sequential")) {
lines.remove(index);
if (curGraph.getChildren().size() > 0) {
if (relaventLine.getFromModel().equals(curGraph.getModel()))
lines.add(new Line(curGraph.getChildren()
.get(curGraph.getChildren().size() - 1).getModel(),
relaventLine.getToModel()));
else
lines.add(new Line(relaventLine.getFromModel(), curGraph
.getChildren().get(0).getModel()));
}
} else if (curGraph.getModel().getExecutionType().toLowerCase()
.equals("parallel")) {
lines.remove(index);
if (relaventLine.getFromModel().equals(curGraph.getModel()))
for (ModelGraph child : curGraph.getChildren())
lines.add(new Line(child.getModel(), relaventLine
.getToModel()));
else
for (ModelGraph child : curGraph.getChildren())
lines.add(new Line(relaventLine.getFromModel(), child
.getModel()));
}
}
if (curGraph.getModel().getExecutionType().toLowerCase()
.equals("sequential")) {
for (int i = 0; i < curGraph.getChildren().size(); i++) {
if (i == curGraph.getChildren().size() - 1)
lines.add(new Line(curGraph.getChildren().get(i).getModel(),
null));
else
lines.add(new Line(curGraph.getChildren().get(i).getModel(),
curGraph.getChildren().get(i + 1).getModel()));
}
} else if (curGraph.getModel().getExecutionType().toLowerCase()
.equals("parallel")) {
for (int i = 0; i < curGraph.getChildren().size(); i++)
lines
.add(new Line(curGraph.getChildren().get(i).getModel(), null));
}
graphs.addAll(curGraph.getChildren());
}
}
} else {
lines.add(new Line(graph.getModel(), null));
}