* on the container to sort the result.
* @return The set of selected objects.
*/
protected HashSet _getSelectionSet() {
GraphController controller = _getGraphController();
GraphModel graphModel = controller.getGraphModel();
SelectionModel model = controller.getSelectionModel();
Object[] selection = model.getSelectionAsArray();
// A set, because some objects may represent the same
// ptolemy object.
HashSet namedObjSet = new HashSet();
HashSet nodeSet = new HashSet();
// First get all the nodes.
for (int i = 0; i < selection.length; i++) {
if (selection[i] instanceof Figure) {
Object userObject = ((Figure) selection[i]).getUserObject();
if (graphModel.isNode(userObject)) {
nodeSet.add(userObject);
NamedObj actual = (NamedObj) graphModel
.getSemanticObject(userObject);
namedObjSet.add(actual);
}
}
}
for (int i = 0; i < selection.length; i++) {
if (selection[i] instanceof Figure) {
Object userObject = ((Figure) selection[i]).getUserObject();
if (graphModel.isEdge(userObject)) {
// Check to see if the head and tail are both being
// copied. Only if so, do we actually take the edge.
Object head = graphModel.getHead(userObject);
Object tail = graphModel.getTail(userObject);
boolean headOK = nodeSet.contains(head);
boolean tailOK = nodeSet.contains(tail);
Iterator objects = nodeSet.iterator();
while (!(headOK && tailOK) && objects.hasNext()) {
Object object = objects.next();
if (!headOK
&& GraphUtilities.isContainedNode(head, object,
graphModel)) {
headOK = true;
}
if (!tailOK
&& GraphUtilities.isContainedNode(tail, object,
graphModel)) {
tailOK = true;
}
}
if (headOK && tailOK) {
// Add the relation.
NamedObj actual = (NamedObj) graphModel
.getSemanticObject(userObject);
namedObjSet.add(actual);
}
}
}