Search in sources :

Example 1 with BoxSelectionPlugin

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);
}
Also used : Point(java.awt.Point) BoxSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.BoxSelectionPlugin) PointSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.PointSelectionPlugin) BoxSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.BoxSelectionPlugin) CreateTransactionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.draw.CreateTransactionPlugin) FreeformSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.FreeformSelectionPlugin) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) CreateVertexPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.draw.CreateVertexPlugin) SimplePlugin(au.gov.asd.tac.constellation.plugins.templates.SimplePlugin)

Aggregations

CreateTransactionPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.draw.CreateTransactionPlugin)1 CreateVertexPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.draw.CreateVertexPlugin)1 BoxSelectionPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.select.BoxSelectionPlugin)1 FreeformSelectionPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.select.FreeformSelectionPlugin)1 PointSelectionPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.select.PointSelectionPlugin)1 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)1 SimplePlugin (au.gov.asd.tac.constellation.plugins.templates.SimplePlugin)1 Point (java.awt.Point)1