Search in sources :

Example 21 with SingleChoiceParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue in project constellation by constellation-app.

the class DirectedShortestPathsPluginNGTest method testUpdateParameters.

/**
 * Test of updateParameters method, of class DirectedShortestPathsPlugin.
 */
@Test
public void testUpdateParameters() {
    System.out.println("updateParameters");
    final DirectedShortestPathsPlugin instance = new DirectedShortestPathsPlugin();
    final PluginParameters params = instance.createParameters();
    final PluginParameter<SingleChoiceParameterValue> sourceNode = (PluginParameter<SingleChoiceParameterType.SingleChoiceParameterValue>) params.getParameters().get(SOURCE_NODE_PARAMETER_ID);
    assertTrue(SingleChoiceParameterType.getOptions(sourceNode).isEmpty());
    instance.updateParameters(new DualGraph(graph.getSchema(), graph), params);
    assertEquals(SingleChoiceParameterType.getOptions(sourceNode).size(), 5);
    graph.setBooleanValue(vertexSelectedAttribute, vxId4, false);
    instance.updateParameters(new DualGraph(graph.getSchema(), graph), params);
    // confirm the options are only set once (i.e. the graph change won't affect this)
    assertEquals(SingleChoiceParameterType.getOptions(sourceNode).size(), 5);
}
Also used : SingleChoiceParameterType(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) Test(org.testng.annotations.Test)

Example 22 with SingleChoiceParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue in project constellation by constellation-app.

the class ArrangeByNodeAttributePlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters parameters = new PluginParameters();
    final PluginParameter<BooleanParameterType.BooleanParameterValue> threeD = BooleanParameterType.build(THREE_D_PARAMETER_ID);
    threeD.setName("Arrange in 3D");
    threeD.setDescription("If checked, arrangement adjusts z-axis positions of nodes rather than organising into groups in 2D");
    threeD.setBooleanValue(false);
    parameters.addParameter(threeD);
    final PluginParameter<SingleChoiceParameterValue> attribute = SingleChoiceParameterType.build(ATTRIBUTE_PARAMETER_ID);
    attribute.setName("Attribute");
    attribute.setDescription("Attribute to arrange by.");
    parameters.addParameter(attribute);
    return parameters;
}
Also used : PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)

Example 23 with SingleChoiceParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue 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 24 with SingleChoiceParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue in project constellation by constellation-app.

the class ArrangeInScatter3dGeneralPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters parameters = new PluginParameters();
    final PluginParameter<SingleChoiceParameterValue> xAttribute = SingleChoiceParameterType.build(SCATTER_3D_X_ATTRIBUTE);
    xAttribute.setName(X_ATTRIBUTE);
    xAttribute.setDescription("The attribute to use for the x dimension");
    xAttribute.setStringValue("");
    parameters.addParameter(xAttribute);
    final PluginParameter<SingleChoiceParameterValue> yAttribute = SingleChoiceParameterType.build(SCATTER_3D_Y_ATTRIBUTE);
    yAttribute.setName(Y_ATTRIBUTE);
    yAttribute.setDescription("The attribute to use for the y dimension");
    yAttribute.setStringValue("");
    parameters.addParameter(yAttribute);
    final PluginParameter<SingleChoiceParameterValue> zAttribute = SingleChoiceParameterType.build(SCATTER_3D_Z_ATTRIBUTE);
    zAttribute.setName(Z_ATTRIBUTE);
    zAttribute.setDescription("The attribute to use for the z dimension");
    zAttribute.setStringValue("");
    parameters.addParameter(zAttribute);
    final PluginParameter<BooleanParameterValue> xLogarithmic = BooleanParameterType.build(SCATTER_3D_X_LOGARITHMIC);
    xLogarithmic.setName(X_LOGARITHMIC);
    xLogarithmic.setDescription("Scale the X axis in Logarithmic Scale");
    xLogarithmic.setBooleanValue(false);
    parameters.addParameter(xLogarithmic);
    final PluginParameter<BooleanParameterValue> yLogarithmic = BooleanParameterType.build(SCATTER_3D_Y_LOGARITHMIC);
    yLogarithmic.setName(Y_LOGARITHMIC);
    yLogarithmic.setDescription("Scale the Y axis in Logarithmic Scale");
    yLogarithmic.setBooleanValue(false);
    parameters.addParameter(yLogarithmic);
    final PluginParameter<BooleanParameterValue> zLogarithmic = BooleanParameterType.build(SCATTER_3D_Z_LOGARITHMIC);
    zLogarithmic.setName(Z_LOGARITHMIC);
    zLogarithmic.setDescription("Scale the Z axis in Logarithmic Scale");
    zLogarithmic.setBooleanValue(false);
    parameters.addParameter(zLogarithmic);
    final PluginParameter<BooleanParameterValue> doNotScale = BooleanParameterType.build(SCATTER_3D_DO_NOT_SCALE);
    doNotScale.setName(DO_NOT_USE_SCALE);
    doNotScale.setDescription("Don't scale resultant scattergram");
    doNotScale.setBooleanValue(false);
    parameters.addParameter(doNotScale);
    return parameters;
}
Also used : BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)

Example 25 with SingleChoiceParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue in project constellation by constellation-app.

the class ExtractWordsFromTextPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters params = new PluginParameters();
    final PluginParameter<SingleChoiceParameterValue> attributeType = SingleChoiceParameterType.build(ATTRIBUTE_PARAMETER_ID);
    attributeType.setName("Content Attribute");
    attributeType.setDescription("Set the attribute from which to extract words");
    params.addParameter(attributeType);
    final PluginParameter<StringParameterValue> text = StringParameterType.build(WORDS_PARAMETER_ID);
    StringParameterType.setLines(text, 15);
    text.setName("Words to Extract");
    text.setDescription("Whitelist of words to extract from content (new line delimited, extract all words if empty)");
    text.setStringValue(null);
    params.addParameter(text);
    final PluginParameter<BooleanParameterValue> useRegex = BooleanParameterType.build(USE_REGEX_PARAMETER_ID);
    useRegex.setName("Use Regular Expressions");
    useRegex.setDescription("Words to Extract will be treated as regex patterns");
    useRegex.setBooleanValue(false);
    useRegex.setEnabled(false);
    params.addParameter(useRegex);
    final PluginParameter<BooleanParameterValue> wholeWordsOnly = BooleanParameterType.build(WHOLE_WORDS_ONLY_PARAMETER_ID);
    wholeWordsOnly.setName("Whole Words Only");
    wholeWordsOnly.setDescription("Words to Extract will be treated as whole words only");
    wholeWordsOnly.setBooleanValue(false);
    wholeWordsOnly.setEnabled(false);
    params.addParameter(wholeWordsOnly);
    final PluginParameter<IntegerParameterValue> minWordLength = IntegerParameterType.build(MIN_WORD_LENGTH_PARAMETER_ID);
    minWordLength.setName("Minimum Word Length");
    minWordLength.setDescription("Only extract words of length equal to or greater than this");
    minWordLength.setIntegerValue(3);
    IntegerParameterType.setMinimum(minWordLength, 1);
    params.addParameter(minWordLength);
    final PluginParameter<BooleanParameterValue> removeSpecialChars = BooleanParameterType.build(REMOVE_SPECIAL_CHARS_PARAMETER_ID);
    removeSpecialChars.setName("Remove Special Characters");
    removeSpecialChars.setDescription("Removes special characters from words before extraction");
    removeSpecialChars.setBooleanValue(true);
    params.addParameter(removeSpecialChars);
    final PluginParameter<BooleanParameterValue> caseInsensitive = BooleanParameterType.build(LOWER_CASE_PARAMETER_ID);
    caseInsensitive.setName("Lower Case");
    caseInsensitive.setDescription("Results are lower-cased");
    caseInsensitive.setBooleanValue(true);
    params.addParameter(caseInsensitive);
    final PluginParameter<BooleanParameterValue> types = BooleanParameterType.build(SCHEMA_TYPES_PARAMETER_ID);
    types.setName("Extract Schema Types");
    types.setDescription("Extract schema types");
    types.setBooleanValue(true);
    params.addParameter(types);
    final PluginParameter<SingleChoiceParameterValue> inOrOutParam = SingleChoiceParameterType.build(IN_OR_OUT_PARAMETER_ID);
    inOrOutParam.setName("Transactions");
    inOrOutParam.setDescription("Link nodes to outgoing or incoming words: 'outgoing' or 'incoming'");
    SingleChoiceParameterType.setOptions(inOrOutParam, List.of(OUTGOING, INCOMING));
    inOrOutParam.setStringValue(OUTGOING);
    params.addParameter(inOrOutParam);
    final PluginParameter<BooleanParameterValue> selected = BooleanParameterType.build(SELECTED_ONLY_PARAMETER_ID);
    selected.setName("Selected Transactions Only");
    selected.setDescription("Only extract words from selected transactions only");
    selected.setBooleanValue(false);
    params.addParameter(selected);
    final PluginParameter<BooleanParameterValue> regexOnlyParam = BooleanParameterType.build(REGEX_ONLY_PARAMETER_ID);
    regexOnlyParam.setName("Regular Expression Only");
    regexOnlyParam.setDescription("The regexes control everything");
    regexOnlyParam.setBooleanValue(false);
    params.addParameter(regexOnlyParam);
    params.addController(WORDS_PARAMETER_ID, (master, parameters, change) -> {
        if (change == ParameterChange.VALUE) {
            final String words = master.getStringValue();
            if (StringUtils.isBlank(words)) {
                parameters.get(USE_REGEX_PARAMETER_ID).setEnabled(false);
                parameters.get(WHOLE_WORDS_ONLY_PARAMETER_ID).setEnabled(false);
                parameters.get(MIN_WORD_LENGTH_PARAMETER_ID).setEnabled(true);
                parameters.get(REMOVE_SPECIAL_CHARS_PARAMETER_ID).setEnabled(true);
            } else {
                parameters.get(USE_REGEX_PARAMETER_ID).setEnabled(true);
                parameters.get(WHOLE_WORDS_ONLY_PARAMETER_ID).setEnabled(true);
                parameters.get(MIN_WORD_LENGTH_PARAMETER_ID).setEnabled(false);
                parameters.get(REMOVE_SPECIAL_CHARS_PARAMETER_ID).setEnabled(false);
            }
        }
    });
    // How well does this interact with the controller above?
    // 
    params.addController(REGEX_ONLY_PARAMETER_ID, (master, parameters, change) -> {
        if (change == ParameterChange.VALUE) {
            final boolean regexOnly = master.getBooleanValue();
            parameters.get(USE_REGEX_PARAMETER_ID).setEnabled(!regexOnly);
            parameters.get(WHOLE_WORDS_ONLY_PARAMETER_ID).setEnabled(!regexOnly);
            parameters.get(MIN_WORD_LENGTH_PARAMETER_ID).setEnabled(!regexOnly);
            parameters.get(REMOVE_SPECIAL_CHARS_PARAMETER_ID).setEnabled(!regexOnly);
            parameters.get(SCHEMA_TYPES_PARAMETER_ID).setEnabled(!regexOnly);
            if (!regexOnly) {
                // If the checkbox is being unchecked, trigger a WORDS_PARAMETER_ID
                // change to set the GUI state.
                // 
                parameters.get(WORDS_PARAMETER_ID).fireChangeEvent(ParameterChange.VALUE);
            }
        }
    });
    return params;
}
Also used : BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) StringParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)

Aggregations

SingleChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)37 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)29 ArrayList (java.util.ArrayList)21 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)19 BooleanParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue)13 IntegerParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue)12 StringParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue)9 ParameterChange (au.gov.asd.tac.constellation.plugins.parameters.ParameterChange)8 Map (java.util.Map)8 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)6 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)6 LinkedHashMap (java.util.LinkedHashMap)5 Test (org.testng.annotations.Test)5 Graph (au.gov.asd.tac.constellation.graph.Graph)4 FloatParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.FloatParameterType.FloatParameterValue)4 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)3 ParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue)3 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)2 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)2 SchemaTransactionType (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType)2