use of au.gov.asd.tac.constellation.graph.interaction.plugins.select.BoxSelectionPlugin in project constellation by constellation-app.
the class DefaultInteractionEventHandler method performBoxSelection.
/**
* Performs a selection based on a given start and end point.
*
* If the start and end point are equal, a point selection is performed
* based on the hit tester.
*
* If the start and end point differ, a box selection is performed with the
* two points representing diagonally opposite corners of the box.
*
* In the latter case, the 2d box is actually converted to a 3d frustrum in
* order to make the correct selection on the 3 dimensional graph.
*
* @param selectTo the point where selection ends
* @param selectFrom the point where selection begins.
* @param appendSelection whether or not the selection will be appended to
* the current selection
* @param toggleSelection whether or not the selection will toggle the
* current selection. Note that if appendSelection is true, this parameter
* has no effect.
*/
private void performBoxSelection(final GraphReadMethods rg, final Point selectTo, final Point selectFrom, final boolean appendSelection, final boolean toggleSelection) {
if (selectTo.equals(selectFrom)) {
return;
}
// Sort the press/release coordinates to look like a drag from top-left to bottom-right: pressed<=released.
Point bottomRight = new Point();
if (selectTo.x < selectFrom.x) {
bottomRight.x = selectFrom.x;
selectFrom.x = selectTo.x;
} else {
bottomRight.x = selectTo.x;
}
if (selectTo.y < selectFrom.y) {
bottomRight.y = selectFrom.y;
selectFrom.y = selectTo.y;
} else {
bottomRight.y = selectTo.y;
}
final float[] boxCameraCoordinates = visualInteraction.windowBoxToCameraBox(selectFrom.x, bottomRight.x, selectFrom.y, bottomRight.y);
Plugin plugin = new BoxSelectionPlugin(appendSelection, toggleSelection, VisualGraphUtilities.getCamera(rg), boxCameraCoordinates);
PluginExecution.withPlugin(plugin).executeLater(graph);
}
Aggregations