Search in sources :

Example 21 with IntegerParameterValue

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

the class IntegerParameterTypeNGTest method testValidateString.

/**
 * Test of validateString method, of class IntegerParameterType.
 */
@Test
public void testValidateString() {
    System.out.println("validateString");
    String id = "validate string";
    IntegerParameterType instance = new IntegerParameterType();
    PluginParameter<IntegerParameterType.IntegerParameterValue> parameter = new PluginParameter<>(new IntegerParameterValue(), INSTANCE, id);
    IntegerParameterType.setMaximum(parameter, 5);
    IntegerParameterType.setMinimum(parameter, 0);
    // test valid integer in min-max range
    // should return null
    String passingValue = "2";
    String result = instance.validateString(parameter, passingValue);
    assertEquals(result, null);
    // test invalid integer under min range
    // should return value too small
    passingValue = "-1";
    result = instance.validateString(parameter, passingValue);
    assertEquals(result, "Value too small");
    // test invalid integer over max range
    // should return value too small
    passingValue = "6";
    result = instance.validateString(parameter, passingValue);
    assertEquals(result, "Value too large");
    // test invalid integer
    // should return Not a valid integer
    passingValue = "This is a Test";
    result = instance.validateString(parameter, passingValue);
    assertEquals(result, "Not a valid integer");
    // test a 0
    // should return null
    passingValue = "0";
    result = instance.validateString(parameter, passingValue);
    assertEquals(result, null);
}
Also used : IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Test(org.testng.annotations.Test)

Example 22 with IntegerParameterValue

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

the class CompleteGraphBuilderPlugin 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(5);
    IntegerParameterType.setMinimum(n, 0);
    params.addParameter(n);
    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);
    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) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)

Example 23 with IntegerParameterValue

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

the class SleepEditPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters params = new PluginParameters();
    final PluginParameter<IntegerParameterValue> secondsParam = IntegerParameterType.build(SECONDS_PARAMETER_ID);
    secondsParam.setName("Seconds to sleep");
    secondsParam.setDescription("The number of seconds to sleep on the graph");
    secondsParam.setIntegerValue(10);
    IntegerParameterType.setMinimum(secondsParam, 0);
    params.addParameter(secondsParam);
    return params;
}
Also used : IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)

Example 24 with IntegerParameterValue

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

the class StructuredGraphBuilderPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters params = new PluginParameters();
    final PluginParameter<IntegerParameterValue> backboneSize = IntegerParameterType.build(BACKBONE_SIZE_PARAMETER_ID);
    backboneSize.setName("Backbone size");
    backboneSize.setDescription("Backbone size");
    backboneSize.setIntegerValue(1000);
    IntegerParameterType.setMinimum(backboneSize, 0);
    params.addParameter(backboneSize);
    final PluginParameter<IntegerParameterValue> backboneDensity = IntegerParameterType.build(BACKBONE_DENSITY_PARAMETER_ID);
    backboneDensity.setName("Backbone density");
    backboneDensity.setDescription("Backbone density");
    backboneDensity.setIntegerValue(300);
    IntegerParameterType.setMinimum(backboneDensity, 0);
    params.addParameter(backboneDensity);
    final PluginParameter<IntegerParameterValue> radius = IntegerParameterType.build(RADIUS);
    radius.setName("Radius");
    radius.setDescription("Radius");
    radius.setIntegerValue(100);
    IntegerParameterType.setMinimum(radius, 0);
    params.addParameter(radius);
    return params;
}
Also used : IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)

Example 25 with IntegerParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue 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)

Aggregations

IntegerParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue)51 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)44 BooleanParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue)27 SingleChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)13 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)11 FloatParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.FloatParameterType.FloatParameterValue)8 ArrayList (java.util.ArrayList)8 Test (org.testng.annotations.Test)8 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)5 ObjectParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.ObjectParameterType.ObjectParameterValue)5 ParameterChange (au.gov.asd.tac.constellation.plugins.parameters.ParameterChange)4 Map (java.util.Map)4 StringParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue)3 LinkedHashMap (java.util.LinkedHashMap)3 ColorParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.ColorParameterType.ColorParameterValue)2 LocalDateParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.LocalDateParameterType.LocalDateParameterValue)2 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)1 SchemaTransactionType (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType)1 SchemaVertexType (au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType)1 PluginParametersPane (au.gov.asd.tac.constellation.plugins.gui.PluginParametersPane)1