Search in sources :

Example 56 with Plugin

use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.

the class DefaultInteractionEventHandler method performFreeformSelection.

/**
 * Performs a selection based on a given polygon in the freeformModel.
 *
 * @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 performFreeformSelection(final GraphReadMethods rg, final boolean appendSelection, final boolean toggleSelection) {
    final float[] boxCameraCoordinates = visualInteraction.windowBoxToCameraBox(freeformModel.getLeftMost(), freeformModel.getRightMost(), freeformModel.getTopMost(), freeformModel.getBottomMost());
    freeformModel.setWindowBoxToCameraBox(boxCameraCoordinates);
    final Float[] transformedVertices = freeformModel.getTransformedVertices();
    final Plugin plugin = new FreeformSelectionPlugin(appendSelection, toggleSelection, VisualGraphUtilities.getCamera(rg), boxCameraCoordinates, transformedVertices, freeformModel.getNumPoints());
    PluginExecution.withPlugin(plugin).executeLater(graph);
}
Also used : FreeformSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.FreeformSelectionPlugin) 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)

Example 57 with Plugin

use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.

the class DefaultInteractionEventHandler method createVertex.

/**
 * Creates a vertex on the graph at a specified point.
 * <p>
 * The vertex will be created via a plugin which will run later (after the
 * event handler gives up its current lock).
 *
 * @param camera The current camera
 * @param createAt The point at which the vertex should be created.
 */
private void createVertex(final Camera camera, final Point createAt) {
    Vector3f position = visualInteraction.windowToGraphCoordinates(camera, createAt);
    Plugin plugin = PluginRegistry.get(InteractiveGraphPluginRegistry.CREATE_VERTEX);
    PluginParameters parameters = DefaultPluginParameters.getDefaultParameters(plugin);
    parameters.getParameters().get(CreateVertexPlugin.X_PARAMETER_ID).setObjectValue(position.getX());
    parameters.getParameters().get(CreateVertexPlugin.Y_PARAMETER_ID).setObjectValue(position.getY());
    parameters.getParameters().get(CreateVertexPlugin.Z_PARAMETER_ID).setObjectValue(position.getZ());
    PluginExecution.withPlugin(plugin).withParameters(parameters).interactively(false).executeLater(graph);
}
Also used : Vector3f(au.gov.asd.tac.constellation.utilities.graphics.Vector3f) DefaultPluginParameters(au.gov.asd.tac.constellation.plugins.parameters.DefaultPluginParameters) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) 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)

Example 58 with Plugin

use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.

the class DefaultInteractionEventHandler method createTransaction.

/**
 * Creates a transaction on the graph between the specified vertices.
 * <p>
 * The vertex will be created via a plugin which will synchronously, holding
 * up the event handler until it is finished. The reason for this is that
 * otherwise the new transaction will not be visible until the event handler
 * gives up its current lock (which if we are creating multiple transactions
 * with the shift/control key down, could be indefinitely).
 *
 * @param fromVertex The graph id of the source vertex
 * @param toVertex The graph id of the destination vertex
 * @param directed Whether or not the transaction should be directed.
 * @param wg Write access to the graph, corresponding to the lock on which
 * gestures are currently being processed.
 */
private void createTransaction(final GraphWriteMethods wg, final int fromVertex, final int toVertex, final boolean directed) {
    Plugin plugin = PluginRegistry.get(InteractiveGraphPluginRegistry.CREATE_TRANSACTION);
    PluginParameters parameters = DefaultPluginParameters.getDefaultParameters(plugin);
    parameters.getParameters().get(CreateTransactionPlugin.SOURCE_PARAMETER_ID).setObjectValue(fromVertex);
    parameters.getParameters().get(CreateTransactionPlugin.DESTINATION_PARAMETER_ID).setObjectValue(toVertex);
    parameters.getParameters().get(CreateTransactionPlugin.DIRECTED_PARAMETER_ID).setObjectValue(directed);
    try {
        PluginExecution.withPlugin(plugin).withParameters(parameters).interactively(false).executeNow(wg);
    } catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
    } catch (PluginException ex) {
    }
    announceNextFlush = true;
}
Also used : PluginException(au.gov.asd.tac.constellation.plugins.PluginException) DefaultPluginParameters(au.gov.asd.tac.constellation.plugins.parameters.DefaultPluginParameters) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) 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)

Example 59 with Plugin

use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.

the class PointSelectionPluginNGTest method testOnlyVerticesSelectedAndVertexSelected.

/**
 * Tests when a vertex is selected and; only vertices are selected, toggle
 * selection is true, and clear selection is true.
 *
 * @throws Exception
 */
@Test
public void testOnlyVerticesSelectedAndVertexSelected() throws Exception {
    selectAllAndAssert(GraphElementType.VERTEX, true);
    vxIds.add(vxId1);
    Plugin selectPoint = new PointSelectionPlugin(vxIds, txIds, true, true);
    PluginExecution.withPlugin(selectPoint).executeNow(storeGraph);
    assertTrue(storeGraph.getBooleanValue(vAttrId, vxId1));
    assertFalse(storeGraph.getBooleanValue(vAttrId, vxId2));
    assertFalse(storeGraph.getBooleanValue(vAttrId, vxId3));
    assertFalse(storeGraph.getBooleanValue(tAttrId, txId1));
    assertFalse(storeGraph.getBooleanValue(tAttrId, txId2));
    assertFalse(storeGraph.getBooleanValue(tAttrId, txId3));
}
Also used : Plugin(au.gov.asd.tac.constellation.plugins.Plugin) Test(org.testng.annotations.Test)

Example 60 with Plugin

use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.

the class PointSelectionPluginNGTest method testNoElementsSelectedAndTransactionSelected.

/**
 * Tests when a transaction is selected and; all vertices and transaction
 * are unselected, toggle selection is true, and clear selection is true.
 *
 * @throws Exception
 */
@Test
public void testNoElementsSelectedAndTransactionSelected() throws Exception {
    txIds.add(txId1);
    Plugin selectPoint = new PointSelectionPlugin(vxIds, txIds, true, true);
    PluginExecution.withPlugin(selectPoint).executeNow(storeGraph);
    assertFalse(storeGraph.getBooleanValue(vAttrId, vxId1));
    assertFalse(storeGraph.getBooleanValue(vAttrId, vxId2));
    assertFalse(storeGraph.getBooleanValue(vAttrId, vxId3));
    assertTrue(storeGraph.getBooleanValue(tAttrId, txId1));
    assertFalse(storeGraph.getBooleanValue(tAttrId, txId2));
    assertFalse(storeGraph.getBooleanValue(tAttrId, txId3));
}
Also used : Plugin(au.gov.asd.tac.constellation.plugins.Plugin) Test(org.testng.annotations.Test)

Aggregations

Plugin (au.gov.asd.tac.constellation.plugins.Plugin)85 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)52 Test (org.testng.annotations.Test)43 Graph (au.gov.asd.tac.constellation.graph.Graph)24 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)19 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)14 SimplePlugin (au.gov.asd.tac.constellation.plugins.templates.SimplePlugin)10 PluginSynchronizer (au.gov.asd.tac.constellation.plugins.PluginSynchronizer)9 Future (java.util.concurrent.Future)9 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)8 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)8 PluginExecution (au.gov.asd.tac.constellation.plugins.PluginExecution)8 PluginGraphs (au.gov.asd.tac.constellation.plugins.PluginGraphs)8 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)7 CompletableFuture (java.util.concurrent.CompletableFuture)7 ExecutorService (java.util.concurrent.ExecutorService)7 ArrayList (java.util.ArrayList)6 Callable (java.util.concurrent.Callable)6 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)5 CopyToNewGraphPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.clipboard.CopyToNewGraphPlugin)5