}
@SuppressWarnings("unchecked")
protected DirectedGraph createDirectedGraph(Map<Long, Node> mapping) {
DirectedGraph graph = new DirectedGraph();
WorkflowProcess process = (WorkflowProcess) ((ProcessWrapper) ((GenericModelEditor) editor).getModel()).getProcess();
for (org.kie.api.definition.process.Node processNode: process.getNodes()) {
Node node = new Node();
Integer width = (Integer) processNode.getMetaData().get("width");
Integer height = (Integer) processNode.getMetaData().get("height");
if (width == null || width <= 0) {
width = 80;
}
if (height == null || height <= 0) {
height = 40;
}
node.setSize(new Dimension(width, height));
graph.nodes.add(node);
mapping.put(processNode.getId(), node);
}
for (org.kie.api.definition.process.Node processNode: process.getNodes()) {
for (List<Connection> connections: processNode.getIncomingConnections().values()) {
for (Connection connection: connections) {
Node source = mapping.get(connection.getFrom().getId());
Node target = mapping.get(connection.getTo().getId());
graph.edges.add(new Edge(source, target));