*/
private void handleSelectionOnMouseClicked(EditorMouseEvent e) {
double mx = e.getX(), my = e.getY();
// this is a pretty ugly cast, it is needed in order to use the getLabel()
// method which is not a base DiagramElement method
DiagramElement previousSelected = currentSelection.getElement();
DiagramElement element = editor.getDiagram().getChildAt(mx, my);
if (element instanceof UmlDiagramElement && previousSelected == element) {
Label label = element.getLabelAt(mx, my);
if (label != null) {
editor.editLabel(label);
} else if (e.getClickCount() >= 2) {
editor.editProperties(element);
}
} else if (editor.getDiagram().getLabelAt(mx, my) != null) {
// Edit the diagram name
editor.editLabel(editor.getDiagram().getLabelAt(mx, my));
} else {
if (element == NullElement.getInstance()) {
element = editor.getDiagram();
}
currentSelection = element.getSelection(editor);
}
editor.redraw();
notifyListeners();
}