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