Search in sources :

Example 16 with SingleChoiceParameterValue

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

the class MapViewTopComponent method createParameters.

private PluginParameters createParameters() {
    final PluginParameters parameters = new PluginParameters();
    final PluginParameter<SingleChoiceParameterValue> geoTypeParameter = SingleChoiceParameterType.build(PARAMETER_TYPE);
    geoTypeParameter.setName("Geo Type");
    SingleChoiceParameterType.setOptions(geoTypeParameter, Arrays.asList(GEO_TYPE_COORDINATE, GEO_TYPE_GEOHASH, GEO_TYPE_MGRS));
    SingleChoiceParameterType.setChoice(geoTypeParameter, GEO_TYPE_COORDINATE);
    parameters.addParameter(geoTypeParameter);
    final PluginParameter<StringParameterValue> locationParameter = StringParameterType.build(PARAMETER_LOCATION);
    locationParameter.setName("Location");
    locationParameter.setDescription("Enter a coordinate in decimal degrees (and optionally " + "a radius in kilometers) with components separated by spaces or commas");
    locationParameter.setStringValue(null);
    parameters.addParameter(locationParameter);
    PluginParameterController controller = ((master, params, change) -> {
        // master will need to be of type SingleChoiceParameter
        @SuppressWarnings("unchecked") final PluginParameter<SingleChoiceParameterValue> typedMaster = (PluginParameter<SingleChoiceParameterValue>) master;
        switch(SingleChoiceParameterType.getChoice(typedMaster)) {
            case GEO_TYPE_COORDINATE:
                params.get(PARAMETER_LOCATION).setDescription("Enter a coordinate in decimal degrees (and optionally a radius " + "in kilometers) with components separated by spaces or commas");
                break;
            case GEO_TYPE_GEOHASH:
                params.get(PARAMETER_LOCATION).setDescription("Enter a base-16 geohash value");
                break;
            case GEO_TYPE_MGRS:
                params.get(PARAMETER_LOCATION).setDescription("Enter an MGRS value");
                break;
            default:
                break;
        }
    });
    parameters.addController(PARAMETER_TYPE, controller);
    return parameters;
}
Also used : StringParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameterController(au.gov.asd.tac.constellation.plugins.parameters.PluginParameterController) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)

Example 17 with SingleChoiceParameterValue

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

the class SingleChoiceParameterType method setOptions.

/**
 * Set the collection of options for the given parameter from a list of
 * strings.
 *
 * @param parameter A {@link PluginParameter} of this type.
 * @param options A list of Strings to set as the options for the given
 * parameter.
 */
public static void setOptions(final PluginParameter<SingleChoiceParameterValue> parameter, final List<String> options) {
    // Change only if the options are changed.
    if (optionsChanged(parameter, options)) {
        final SingleChoiceParameterValue parameterValue = parameter.getParameterValue();
        // Clear the existing selection
        parameter.setObjectValue(null);
        parameterValue.setOptions(options);
        parameter.setProperty(CHOICES, new Object());
    }
}
Also used : SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)

Example 18 with SingleChoiceParameterValue

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

the class SmallWorldGraphBuilderPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters params = new PluginParameters();
    final PluginParameter<IntegerParameterValue> n = IntegerParameterType.build(N_PARAMETER_ID);
    n.setName("Number of nodes");
    n.setDescription("The number of nodes on the graph");
    n.setIntegerValue(10);
    IntegerParameterType.setMinimum(n, 0);
    params.addParameter(n);
    final PluginParameter<IntegerParameterValue> k = IntegerParameterType.build(K_PARAMETER_ID);
    k.setName("Nearest neighbours to attach");
    k.setDescription("The number of nearest neighbours to connect each node to");
    k.setIntegerValue(4);
    IntegerParameterType.setMinimum(k, 0);
    params.addParameter(k);
    final PluginParameter<FloatParameterValue> p = FloatParameterType.build(P_PARAMETER_ID);
    p.setName("Rewiring probability");
    p.setDescription("Probability of re-wiring each edge (low for a long shortest paths lattice structure, high for higher clustering coefficient random graph)");
    p.setFloatValue(0.5F);
    FloatParameterType.setMinimum(p, 0F);
    FloatParameterType.setMaximum(p, 1F);
    params.addParameter(p);
    final List<String> modes = new ArrayList<>();
    modes.add("Default");
    modes.add("Newman");
    modes.add(CONNECTED);
    final PluginParameter<SingleChoiceParameterValue> buildMode = SingleChoiceParameterType.build(BUILD_MODE_PARAMETER_ID);
    buildMode.setName("Build mode");
    buildMode.setDescription("Newman: Adds edges instead of rewiring. Connected: Attempts to build a connected graph.");
    SingleChoiceParameterType.setOptions(buildMode, modes);
    SingleChoiceParameterType.setChoice(buildMode, modes.get(0));
    params.addParameter(buildMode);
    final PluginParameter<IntegerParameterValue> t = IntegerParameterType.build(T_PARAMETER_ID);
    t.setName("Number of attempts to build connected graph");
    t.setDescription("Number of attempts to build a connected graph");
    t.setIntegerValue(100);
    IntegerParameterType.setMinimum(t, 1);
    t.setEnabled(false);
    params.addParameter(t);
    final PluginParameter<BooleanParameterValue> randomWeights = BooleanParameterType.build(RANDOM_WEIGHTS_PARAMETER_ID);
    randomWeights.setName("Random edge weight/direction");
    randomWeights.setDescription("Edges have a random number of transactions going in random directions");
    randomWeights.setBooleanValue(true);
    params.addParameter(randomWeights);
    final PluginParameter<MultiChoiceParameterValue> nodeTypes = MultiChoiceParameterType.build(NODE_TYPES_PARAMETER_ID);
    nodeTypes.setName("Node types");
    nodeTypes.setDescription("Node types to add to the graph");
    params.addParameter(nodeTypes);
    final PluginParameter<MultiChoiceParameterValue> transactionTypes = MultiChoiceParameterType.build(TRANSACTION_TYPES_PARAMETER_ID);
    transactionTypes.setName("Transaction types");
    transactionTypes.setDescription("Transaction types to add to the graph");
    params.addParameter(transactionTypes);
    params.addController(BUILD_MODE_PARAMETER_ID, (master, parameters, change) -> {
        if (change == ParameterChange.VALUE) {
            final String mode = master.getStringValue();
            parameters.get(T_PARAMETER_ID).setEnabled(mode.equals(CONNECTED));
        }
    });
    return params;
}
Also used : FloatParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.FloatParameterType.FloatParameterValue) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) ArrayList(java.util.ArrayList) BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)

Example 19 with SingleChoiceParameterValue

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

the class ChangeSelectionPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters parameters = new PluginParameters();
    final PluginParameter<ObjectParameterValue> elementBitSet = ObjectParameterType.build(ELEMENT_BIT_SET_PARAMETER_ID);
    elementBitSet.setName("Element Ids");
    elementBitSet.setDescription("A set of the element id's, such as the vertex ids");
    parameters.addParameter(elementBitSet);
    final PluginParameter<SingleChoiceParameterValue> elementTypeParameter = SingleChoiceParameterType.build(ELEMENT_TYPE_PARAMETER_ID, ElementTypeParameterValue.class);
    elementTypeParameter.setName("Element Type");
    elementTypeParameter.setDescription("The graph element type");
    final List<ElementTypeParameterValue> elementTypes = new ArrayList<>();
    elementTypes.add(new ElementTypeParameterValue(GraphElementType.TRANSACTION));
    elementTypes.add(new ElementTypeParameterValue(GraphElementType.VERTEX));
    SingleChoiceParameterType.setOptionsData(elementTypeParameter, elementTypes);
    parameters.addParameter(elementTypeParameter);
    final PluginParameter<ObjectParameterValue> selectionMode = ObjectParameterType.build(SELECTION_MODE_PARAMETER_ID);
    selectionMode.setName("Selection Mode");
    selectionMode.setDescription("The selection mode being ADD, REMOVE, REPLACE or INVERT");
    parameters.addParameter(selectionMode);
    return parameters;
}
Also used : ElementTypeParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ElementTypeParameterValue) ArrayList(java.util.ArrayList) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue) ObjectParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ObjectParameterType.ObjectParameterValue)

Example 20 with SingleChoiceParameterValue

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

the class LevenshteinDistancePlugin method updateParameters.

@Override
public void updateParameters(final Graph graph, final PluginParameters parameters) {
    final List<String> stringAttributes = new ArrayList<>();
    if (graph.getSchema() != null) {
        final Map<String, SchemaAttribute> attributes = graph.getSchema().getFactory().getRegisteredAttributes(GraphElementType.VERTEX);
        for (final String attr : attributes.keySet()) {
            final SchemaAttribute attribute = attributes.get(attr);
            final String attributeType = attribute.getAttributeType();
            if (attributeType.equals(StringAttributeDescription.ATTRIBUTE_NAME)) {
                stringAttributes.add(attr);
            }
        }
    }
    stringAttributes.sort(String::compareTo);
    if (parameters != null && parameters.getParameters() != null) {
        // ATTRIBUTE_PARAMETER_ID is created as a SingleChoiceParmeter in this class on line 71.
        @SuppressWarnings("unchecked") final PluginParameter<SingleChoiceParameterValue> compareAttribute = (PluginParameter<SingleChoiceParameterValue>) parameters.getParameters().get(ATTRIBUTE_PARAMETER_ID);
        SingleChoiceParameterType.setOptions(compareAttribute, stringAttributes);
        if (stringAttributes.contains(VisualConcept.VertexAttribute.IDENTIFIER.getName())) {
            SingleChoiceParameterType.setChoice(compareAttribute, VisualConcept.VertexAttribute.IDENTIFIER.getName());
        }
    }
}
Also used : ArrayList(java.util.ArrayList) SchemaAttribute(au.gov.asd.tac.constellation.graph.schema.attribute.SchemaAttribute) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) 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