Search in sources :

Example 51 with PluginParameter

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

the class ArrangeInGridGeneralPlugin method edit.

@Override
public void edit(final GraphWriteMethods graph, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException {
    final SetRadiusForArrangement radiusSetter = new SetRadiusForArrangement(graph);
    radiusSetter.setRadii();
    final Map<String, PluginParameter<?>> pp = parameters.getParameters();
    final GridChoiceParameters gridParams = GridChoiceParameters.getDefaultParameters();
    gridParams.setGridChoice(GridChoice.getValue(pp.get(GRID_CHOICE_PARAMETER_ID).getStringValue()));
    gridParams.setSizeGain(pp.get(SIZE_GAIN_PARAMETER_ID).getFloatValue());
    gridParams.setHorizontalGap(pp.get(HORIZONTAL_GAP_PARAMETER_ID).getIntegerValue());
    gridParams.setVerticalGap(pp.get(VERTICAL_GAP_PARAMETER_ID).getIntegerValue());
    gridParams.setRowOffsets(pp.get(OFFSET_ROWS_PARAMETER_ID).getBooleanValue());
    final GridArranger arranger = new GridArranger(gridParams);
    final Boolean maintainMean = pp.get(MAINTAIN_MEAN_PARAMETER_ID).getBooleanValue();
    arranger.setMaintainMean(maintainMean);
    final SelectedInclusionGraph selectedGraph = new SelectedInclusionGraph(graph, SelectedInclusionGraph.Connections.NONE);
    arranger.arrange(selectedGraph.getInclusionGraph());
    selectedGraph.retrieveCoords();
}
Also used : SetRadiusForArrangement(au.gov.asd.tac.constellation.plugins.arrangements.SetRadiusForArrangement) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) SelectedInclusionGraph(au.gov.asd.tac.constellation.plugins.arrangements.SelectedInclusionGraph)

Example 52 with PluginParameter

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

the class ScoreAnalyticPlugin method onPrerequisiteAttributeChange.

@Override
public void onPrerequisiteAttributeChange(final Graph graph, final PluginParameters parameters) {
    final Set<TransactionTypeParameterValue> transactionTypes = new HashSet<>();
    if (graph != null) {
        final ReadableGraph readableGraph = graph.getReadableGraph();
        try {
            final int typeAttributeId = AnalyticConcept.TransactionAttribute.TYPE.get(readableGraph);
            final int transactionCount = readableGraph.getTransactionCount();
            for (int transactionPosition = 0; transactionPosition < transactionCount; transactionPosition++) {
                final int transactionId = readableGraph.getTransaction(transactionPosition);
                if (typeAttributeId != Graph.NOT_FOUND) {
                    final SchemaTransactionType type = readableGraph.getObjectValue(typeAttributeId, transactionId);
                    transactionTypes.add(new TransactionTypeParameterValue(type));
                }
            }
        } finally {
            readableGraph.release();
        }
    }
    // TRANSACTION_TYPES_PARAMETER always of type MultiChoiceParameter
    @SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> transactionTypesParam = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(TRANSACTION_TYPES_PARAMETER_ID);
    MultiChoiceParameterType.setOptionsData(transactionTypesParam, new ArrayList<>(transactionTypes));
    MultiChoiceParameterType.setChoicesData(transactionTypesParam, new ArrayList<>(transactionTypes));
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) SchemaTransactionType(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) HashSet(java.util.HashSet)

Example 53 with PluginParameter

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

the class ArrangeByNodeAttributePlugin method updateParameters.

@Override
public void updateParameters(final Graph graph, final PluginParameters parameters) {
    final List<String> attributes = new ArrayList<>();
    if (graph != null) {
        final ReadableGraph readableGraph = graph.getReadableGraph();
        try {
            final int axCount = readableGraph.getAttributeCount(GraphElementType.VERTEX);
            for (int i = 0; i < axCount; i++) {
                final int ax = readableGraph.getAttribute(GraphElementType.VERTEX, i);
                attributes.add(readableGraph.getAttributeName(ax));
            }
        } finally {
            readableGraph.release();
        }
    }
    Collections.sort(attributes);
    if (parameters != null && parameters.getParameters() != null) {
        // ATTRIBUTE_PARAMETER always of type SingleChoiceParameter
        @SuppressWarnings("unchecked") final PluginParameter<SingleChoiceParameterValue> attribute = (PluginParameter<SingleChoiceParameterValue>) parameters.getParameters().get(ATTRIBUTE_PARAMETER_ID);
        SingleChoiceParameterType.setOptions(attribute, attributes);
        SingleChoiceParameterType.setChoice(attribute, attributes.get(0));
    }
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) ArrayList(java.util.ArrayList) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)

Example 54 with PluginParameter

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

the class UncollidePlugin method edit.

@Override
public void edit(final GraphWriteMethods wg, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException {
    final Map<String, PluginParameter<?>> params = parameters.getParameters();
    final Dimensions dimensions = Dimensions.valueOf(params.get(DIMENSION_PARAMETER_ID).getStringValue());
    final int maxExpansions = params.get(MAX_EXPANSIONS_PARAMETR_ID).getIntegerValue();
    final Arranger arranger = new UncollideArrangement(dimensions, maxExpansions);
    ((UncollideArrangement) arranger).setInteraction(interaction);
    final SelectedInclusionGraph selectedGraph = new SelectedInclusionGraph(wg, SelectedInclusionGraph.Connections.NONE);
    arranger.setMaintainMean(!selectedGraph.isArrangingAll());
    arranger.arrange(selectedGraph.getInclusionGraph());
    selectedGraph.retrieveCoords();
}
Also used : Arranger(au.gov.asd.tac.constellation.plugins.arrangements.Arranger) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) SelectedInclusionGraph(au.gov.asd.tac.constellation.plugins.arrangements.SelectedInclusionGraph)

Example 55 with PluginParameter

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

the class ExtractTypesFromTextPlugin method query.

@Override
protected RecordStore query(final RecordStore query, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
    final RecordStore result = new GraphRecordStore();
    interaction.setProgress(0, 0, "Importing...", true);
    final Map<String, PluginParameter<?>> extractEntityParameters = parameters.getParameters();
    final String text = extractEntityParameters.get(TEXT_PARAMETER_ID).getStringValue();
    if (text == null) {
        throw new PluginException(PluginNotificationLevel.ERROR, "No text provided from which to extract types.");
    }
    final List<ExtractedVertexType> extractedTypes = SchemaVertexTypeUtilities.extractVertexTypes(text);
    final Map<String, SchemaVertexType> identifiers = new HashMap<>();
    extractedTypes.forEach(extractedType -> identifiers.put(extractedType.getIdentifier(), extractedType.getType()));
    for (final String identifier : identifiers.keySet()) {
        result.add();
        result.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.IDENTIFIER, identifier);
        result.set(GraphRecordStoreUtilities.SOURCE + AnalyticConcept.VertexAttribute.TYPE, identifiers.get(identifier));
        result.set(GraphRecordStoreUtilities.SOURCE + AnalyticConcept.VertexAttribute.SEED, "true");
    }
    ConstellationLoggerHelper.createPropertyBuilder(this, result.getAll(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.IDENTIFIER), ConstellationLoggerHelper.SUCCESS);
    interaction.setProgress(1, 0, "Completed successfully - imported " + result.size() + " entities.", true);
    return result;
}
Also used : SchemaVertexType(au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType) HashMap(java.util.HashMap) RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) PluginException(au.gov.asd.tac.constellation.plugins.PluginException) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) ExtractedVertexType(au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexTypeUtilities.ExtractedVertexType)

Aggregations

PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)93 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)53 Test (org.testng.annotations.Test)52 ArrayList (java.util.ArrayList)36 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)25 SingleChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)21 Map (java.util.Map)16 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)15 IntegerParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue)13 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)12 SchemaTransactionType (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType)11 ParameterChange (au.gov.asd.tac.constellation.plugins.parameters.ParameterChange)11 Graph (au.gov.asd.tac.constellation.graph.Graph)10 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)10 BooleanParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue)10 HashMap (java.util.HashMap)10 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)9 List (java.util.List)9 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)8 StringParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue)8