if (selectionNode != null)
selectionNode.getRoot()
.removeTreeGraphicsNodeChangeListener(this);
dispatchSelectionEvent(
new SelectionEvent(null,
SelectionEvent.SELECTION_CLEARED,
null));
copyToClipboard(null);
selectionNode = null;
} else if (isSelectStartGesture(evt)) {
if (selectionNode != source) {
if (selectionNode != null)
selectionNode.getRoot()
.removeTreeGraphicsNodeChangeListener(this);
if (source != null)
source.getRoot()
.addTreeGraphicsNodeChangeListener(this);
}
selectionNode = source;
((Selectable) source).selectAt(p.getX(), p.getY());
dispatchSelectionEvent(
new SelectionEvent(null,
SelectionEvent.SELECTION_STARTED,
null));
} else if (isSelectEndGesture(evt)) {
if (selectionNode != source) {
if (selectionNode != null)
selectionNode.getRoot()
.removeTreeGraphicsNodeChangeListener(this);
if (source != null)
source.getRoot()
.addTreeGraphicsNodeChangeListener(this);
}
selectionNode = source;
((Selectable) source).selectTo(p.getX(), p.getY());
Object oldSelection = getSelection();
Shape newShape =
((Selectable) source).getHighlightShape();
dispatchSelectionEvent(
new SelectionEvent(oldSelection,
SelectionEvent.SELECTION_DONE,
newShape));
copyToClipboard(oldSelection);
} else
if (isSelectContinueGesture(evt)) {
if (selectionNode == source) {
boolean result = ((Selectable) source).selectTo(p.getX(),
p.getY());
if (result) {
Shape newShape =
((Selectable) source).getHighlightShape();
dispatchSelectionEvent(
new SelectionEvent(null,
SelectionEvent.SELECTION_CHANGED,
newShape));
}
}
} else if (isSelectAllGesture(evt)) {
if (selectionNode != source) {
if (selectionNode != null)
selectionNode.getRoot()
.removeTreeGraphicsNodeChangeListener(this);
if (source != null)
source.getRoot()
.addTreeGraphicsNodeChangeListener(this);
}
selectionNode = source;
((Selectable) source).selectAll(p.getX(), p.getY());
Object oldSelection = getSelection();
Shape newShape =
((Selectable) source).getHighlightShape();
dispatchSelectionEvent(
new SelectionEvent(oldSelection,
SelectionEvent.SELECTION_DONE,
newShape));
copyToClipboard(oldSelection);
}
}