rendered paste bodypackage atd;
import java.util.HashSet;
import model.Diagram;
import model.MImage;
public class ATDFactory {
public static <N extends ATDNode, I extends MImage> ATDNode createNew(ATDNode.NodeType nodeType, Diagram<N, I> diagram){
HashSet<Integer> id = new HashSet<Integer>();
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;
}
}