Search in sources :

Example 26 with BooleanParameterValue

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

the class BooleanParameterTypeNGTest method testValidateString.

/**
 * Always returns null because there will never be an error when validating
 * a boolean string. Mostly because it is not used for the boolean parameter
 * type.
 */
@Test
public void testValidateString() {
    BooleanParameterValue instance = new BooleanParameterValue();
    assertNull(instance.validateString("standard string"));
    assertNull(instance.validateString(""));
    assertNull(instance.validateString(null));
}
Also used : BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) Test(org.testng.annotations.Test)

Example 27 with BooleanParameterValue

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

the class BooleanParameterTypeNGTest method testSetStringValue.

@Test
public void testSetStringValue() {
    BooleanParameterValue instance = new BooleanParameterValue();
    // test empty string
    String newValue = "";
    assertFalse(instance.setStringValue(newValue));
    // test null string
    newValue = null;
    assertFalse(instance.setStringValue(newValue));
    // test invalid string
    newValue = "words";
    assertFalse(instance.setStringValue(newValue));
    // test valid string
    newValue = "true";
    assertTrue(instance.setStringValue(newValue));
    // test valid string
    newValue = "false";
    assertTrue(instance.setStringValue(newValue));
    // test valid string case sensitive
    newValue = "trUe";
    assertTrue(instance.setStringValue(newValue));
    // test valid string
    newValue = "false";
    assertTrue(instance.setStringValue(newValue));
    // test valid string when previously set as same value
    newValue = "false";
    assertFalse(instance.setStringValue(newValue));
}
Also used : BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) Test(org.testng.annotations.Test)

Example 28 with BooleanParameterValue

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

the class BooleanParameterTypeNGTest method testBuild_String_BooleanParameterTypeBooleanParameterValue.

/**
 * Test of build method, of class BooleanParameterType.
 */
@Test
public void testBuild_String_BooleanParameterTypeBooleanParameterValue() {
    System.out.println("build_string_parametertype");
    String id = "booleanParameter";
    BooleanParameterValue parameterValue = new BooleanParameterValue();
    PluginParameter result = BooleanParameterType.build(id, parameterValue);
    assertEquals(result.getId(), id);
    assertTrue(result.getType() instanceof BooleanParameterType);
    assertEquals(result.getParameterValue(), parameterValue);
}
Also used : BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Test(org.testng.annotations.Test)

Example 29 with BooleanParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue 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 30 with BooleanParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue 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

BooleanParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue)65 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)56 IntegerParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue)27 SingleChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)14 StringParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue)13 Test (org.testng.annotations.Test)11 FloatParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.FloatParameterType.FloatParameterValue)9 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)7 ArrayList (java.util.ArrayList)7 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 ColorParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.ColorParameterType.ColorParameterValue)3 FileParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue)3 Graph (au.gov.asd.tac.constellation.graph.Graph)2 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)2 ParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue)2 ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)2 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)1