package atd; import java.util.HashSet; import model.Diagram; import model.MImage; public class ATDFactory { public static ATDNode createNew(ATDNode.NodeType nodeType, Diagram diagram){ HashSet id = new HashSet(); int i; switch(nodeType){ case ELEMENTARYACTORROLE: for(N shape: diagram.getShapes()){ if(shape instanceof ElementaryActorRole) id.add(shape.getId()); } i=0; while(id.contains(i)){ i++; } return new ElementaryActorRole(i); case COMPOSITEACTORROLE: for(N shape: diagram.getShapes()){ if(shape instanceof CompositeActorRole) id.add(shape.getId()); } i=0; while(id.contains(i)){ i++; } return new CompositeActorRole(i); case TRANSACTIONTYPE: for(N shape: diagram.getShapes()){ if(shape instanceof TransactionType) id.add(shape.getId()); } i=0; while(id.contains(i)){ i++; } return new TransactionType(i); } return null; } }