}
@SuppressWarnings("unchecked")
private DirectedGraph mapDiagramToGraph(final SapphireDiagramEditor diagramEditor)
{
DiagramModel diagramModel = diagramEditor.getDiagramModel();
Map<DiagramNodeModel, Node> shapeToNode = new HashMap<DiagramNodeModel, Node>();
DirectedGraph dg = new DirectedGraph();
dg.setDirection(getGraphDirection());
EdgeList edgeList = new EdgeList();
NodeList nodeList = new NodeList();
List<DiagramNodeModel> children = diagramModel.getNodes();
for (DiagramNodeModel child : children)
{
Node node = new Node();
Rectangle bounds = child.getShapePresentation().getFigure().getBounds();//child.getNodeBounds();
node.x = bounds.x;
node.y = bounds.y;
node.width = bounds.width;
node.height = bounds.height;
node.data = child;
shapeToNode.put(child, node);
nodeList.add(node);
}
List<DiagramConnectionModel> connections = diagramModel.getConnections();
for (DiagramConnectionModel connection : connections)
{
DiagramNodeModel sourceNode = connection.getSourceNode();
DiagramNodeModel targetNode = connection.getTargetNode();
if (sourceNode != targetNode)