/** * Create an edge of the given type and connect it to the given nodes. * * @param graphModel the graph model in which to create the connection element * @param edgeType the UML object type of the connection * @param sourceFig the FigNode for the source element * @param destFig the FigNode for the destination element * @return The FigEdge representing the newly created model element */ @Override protected FigEdge buildConnection( MutableGraphModel graphModel, Object edgeType, Fig sourceFig, Fig destFig) { try { Object associationEnd = Model.getUmlFactory() .buildConnection( edgeType, sourceFig.getOwner(), null, destFig.getOwner(), null, null, null); final FigNode sourceFigNode = convertToFigNode(sourceFig); final FigNode destFigNode = convertToFigNode(destFig); graphModel.addEdge(associationEnd); setNewEdge(associationEnd); // Calling connect() will add the edge to the GraphModel and // any LayerPersectives on that GraphModel will get a // edgeAdded event and will add an appropriate FigEdge // (determined by the GraphEdgeRenderer). if (getNewEdge() != null) { sourceFigNode.damage(); destFigNode.damage(); Layer lay = editor.getLayerManager().getActiveLayer(); FigEdge fe = (FigEdge) lay.presentationFor(getNewEdge()); _newItem.setLineColor(Color.black); fe.setFig(_newItem); fe.setSourcePortFig(sourceFigNode); fe.setSourceFigNode(sourceFigNode); fe.setDestPortFig(destFigNode); fe.setDestFigNode(destFigNode); return fe; } else { return null; } } catch (IllegalModelElementConnectionException e) { // We have already confirmed the connection is valid return null; } }