// File: ActionCreateConstEdge.java // Classes: ActionCreateConstEdge // Author: Kedar Patankar package edu.neu.ccs.demeter.tools.apstudio.graphedit; import edu.neu.ccs.demeter.Ident; import java.awt.Point; public class ActionCreateConstEdge extends Action { private UEdge _edge; private UVertex _s,_d; private Point _midPoint; public ActionCreateConstEdge(Editor editor,UEdge n,UVertex s,UVertex d,Point midPoint) { super(editor); _edge=n; _s=s;_d=d; _midPoint=midPoint; } public String name() { return "Create Construction Edge"; } public void doIt() { String edgeName = _d.get_vertexname().get_name().toString(); edgeName = edgeName.toLowerCase(); // unique(with respect to a perticular source and destination pair) edge name found here if(((UConstOrAltVertex)_s).checkThisOut(edgeName)) // so first edge will have destination name in lowercase { int count =0; for(boolean found = true;found;) // All later edges have destination name followed by edge number { count++; String trialName = edgeName + "_"+count; found = ((UConstOrAltVertex)_s).checkThisOut(trialName); } edgeName = edgeName + "_"+count; } _edge.set_eid(_editor.curDocument().nextId()); ((UConstEdge)_edge).set_edgename(new UEdgeName(new Ident(edgeName))); ((UConstEdge)_edge).set_card(new Cardinality(new Lower(new Integer(1)),null)); _edge.connect(_s,_d); String card = new String("1"); ArcPerspective ap; if(_midPoint==null) ap= new ArcPerspective(_edge,edgeName,card,_editor.curDocument()); else ap=new ArcPerspective(_edge,edgeName,card,_editor.curDocument(),_midPoint); _editor.showEdgePropertySheet(ap); _editor.curDocument().add(ap); showDefaultMessage(); _editor.curDocument().damaged(ap); _editor.curDocument().selectItem(ap); _editor.menuForsingleSelection(); } public void undoIt() { } public void showDefaultMessage(){_editor.setDefaultMessage();} } /* end class ActionCreateConstEdge */