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));
}
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));
}
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);
}
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;
}
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;
}
Aggregations