/** * Find the Figs in the given layer that should be the source and destination and attach these to * either end of the FigEdge * * @param layer the layer to look for the FigNodes * @param newEdge The edge to attach */ protected final void setPorts(Layer layer, FigEdge newEdge) { Object modelElement = newEdge.getOwner(); if (newEdge.getSourcePortFig() == null) { Object source; if (modelElement instanceof CommentEdge) { source = ((CommentEdge) modelElement).getSource(); } else { source = Model.getUmlHelper().getSource(modelElement); } FigNode sourceNode = getNodePresentationFor(layer, source); assert (sourceNode != null) : "No FigNode found for " + source; setSourcePort(newEdge, sourceNode); } if (newEdge.getDestPortFig() == null) { Object dest; if (modelElement instanceof CommentEdge) { dest = ((CommentEdge) modelElement).getDestination(); } else { dest = Model.getUmlHelper().getDestination(newEdge.getOwner()); } setDestPort(newEdge, getNodePresentationFor(layer, dest)); } if (newEdge.getSourcePortFig() == null || newEdge.getDestPortFig() == null) { throw new IllegalStateException( "Edge of type " + newEdge.getClass().getName() + " created with no source or destination port"); } }
private void buildTree(Fig f, DefaultMutableTreeNode tn) { if (f instanceof FigGroup) { FigGroup fg = (FigGroup) f; for (int i = 0; i < fg.getFigCount(); ++i) { addNode(tn, fg.getFigAt(i)); } } else if (f instanceof FigEdge) { FigEdge fe = (FigEdge) f; Fig lineFig = fe.getFig(); addNode(tn, lineFig); addNode(tn, fe.getSourceFigNode()); addNode(tn, fe.getSourcePortFig()); addNode(tn, fe.getDestFigNode()); addNode(tn, fe.getDestPortFig()); for (Fig pathFig : (Vector<Fig>) fe.getPathItemFigs()) { addNode(tn, pathFig); } } }
protected void addEdge(Layer lay, FigEdge newEdge, Object edge) { if (newEdge == null) { throw new IllegalArgumentException( "Don't know how to create FigEdge for model type " + edge.getClass().getName()); } setPorts(lay, newEdge); assert newEdge != null : "There has been no FigEdge created"; // newEdge.setDiElement( // GraphChangeAdapter.getInstance().createElement(gm, edge)); assert newEdge != null : "There has been no FigEdge created"; assert (newEdge.getDestFigNode() != null) : "The FigEdge has no dest node"; assert (newEdge.getDestPortFig() != null) : "The FigEdge has no dest port"; assert (newEdge.getSourceFigNode() != null) : "The FigEdge has no source node"; assert (newEdge.getSourcePortFig() != null) : "The FigEdge has no source port"; lay.add(newEdge); }