use of au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue in project constellation by constellation-app.
the class SmallWorldGraphBuilderPluginNGTest method testUpdateParameters.
/**
* Test of updateParameters method, of class SmallWorldGraphBuilderPlugin.
*/
@Test
public void testUpdateParameters() {
System.out.println("updateParameters");
final SmallWorldGraphBuilderPlugin instance = new SmallWorldGraphBuilderPlugin();
final PluginParameters params = instance.createParameters();
final PluginParameter<MultiChoiceParameterValue> nAttribute = (PluginParameter<MultiChoiceParameterValue>) params.getParameters().get(NODE_TYPES_PARAMETER_ID);
final PluginParameter<MultiChoiceParameterValue> tAttribute = (PluginParameter<MultiChoiceParameterValue>) params.getParameters().get(TRANSACTION_TYPES_PARAMETER_ID);
assertTrue(MultiChoiceParameterType.getOptions(nAttribute).isEmpty());
assertTrue(MultiChoiceParameterType.getOptions(tAttribute).isEmpty());
instance.updateParameters(new DualGraph(graph.getSchema(), graph), params);
assertEquals(MultiChoiceParameterType.getOptions(nAttribute).size(), 27);
assertEquals(MultiChoiceParameterType.getChoices(nAttribute).size(), 1);
assertEquals(MultiChoiceParameterType.getOptions(tAttribute).size(), 9);
assertEquals(MultiChoiceParameterType.getChoices(tAttribute).size(), 1);
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue in project constellation by constellation-app.
the class CompleteGraphBuilderPluginNGTest method testUpdateParameters.
/**
* Test of updateParameters method, of class CompleteGraphBuilderPlugin.
*/
@Test
public void testUpdateParameters() {
System.out.println("updateParameters");
final CompleteGraphBuilderPlugin instance = new CompleteGraphBuilderPlugin();
final PluginParameters params = instance.createParameters();
final PluginParameter<MultiChoiceParameterValue> nAttribute = (PluginParameter<MultiChoiceParameterValue>) params.getParameters().get(NODE_TYPES_PARAMETER_ID);
final PluginParameter<MultiChoiceParameterValue> tAttribute = (PluginParameter<MultiChoiceParameterValue>) params.getParameters().get(TRANSACTION_TYPES_PARAMETER_ID);
assertTrue(MultiChoiceParameterType.getOptions(nAttribute).isEmpty());
assertTrue(MultiChoiceParameterType.getOptions(tAttribute).isEmpty());
instance.updateParameters(new DualGraph(graph.getSchema(), graph), params);
assertEquals(MultiChoiceParameterType.getOptions(nAttribute).size(), 27);
assertEquals(MultiChoiceParameterType.getChoices(nAttribute).size(), 1);
assertEquals(MultiChoiceParameterType.getOptions(tAttribute).size(), 9);
assertEquals(MultiChoiceParameterType.getChoices(tAttribute).size(), 1);
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue 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;
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue in project constellation by constellation-app.
the class ScoreAnalyticPlugin method onPrerequisiteAttributeChange.
@Override
public void onPrerequisiteAttributeChange(final Graph graph, final PluginParameters parameters) {
final Set<TransactionTypeParameterValue> transactionTypes = new HashSet<>();
if (graph != null) {
final ReadableGraph readableGraph = graph.getReadableGraph();
try {
final int typeAttributeId = AnalyticConcept.TransactionAttribute.TYPE.get(readableGraph);
final int transactionCount = readableGraph.getTransactionCount();
for (int transactionPosition = 0; transactionPosition < transactionCount; transactionPosition++) {
final int transactionId = readableGraph.getTransaction(transactionPosition);
if (typeAttributeId != Graph.NOT_FOUND) {
final SchemaTransactionType type = readableGraph.getObjectValue(typeAttributeId, transactionId);
transactionTypes.add(new TransactionTypeParameterValue(type));
}
}
} finally {
readableGraph.release();
}
}
// TRANSACTION_TYPES_PARAMETER always of type MultiChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> transactionTypesParam = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(TRANSACTION_TYPES_PARAMETER_ID);
MultiChoiceParameterType.setOptionsData(transactionTypesParam, new ArrayList<>(transactionTypes));
MultiChoiceParameterType.setChoicesData(transactionTypesParam, new ArrayList<>(transactionTypes));
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue in project constellation by constellation-app.
the class SelectTopNPlugin method createParameters.
@Override
public PluginParameters createParameters() {
final PluginParameters params = new PluginParameters();
final List<String> modes = new ArrayList<>();
modes.add(NODE);
modes.add(TRANSACTION);
final PluginParameter<SingleChoiceParameterValue> modeParameter = SingleChoiceParameterType.build(MODE_PARAMETER_ID);
modeParameter.setName("Mode");
modeParameter.setDescription("Select either the Node or Transaction mode");
SingleChoiceParameterType.setOptions(modeParameter, modes);
params.addParameter(modeParameter);
final PluginParameter<SingleChoiceParameterValue> typeCategoryParameter = SingleChoiceParameterType.build(TYPE_CATEGORY_PARAMETER_ID);
typeCategoryParameter.setName("Type Category");
typeCategoryParameter.setDescription("The high level type category");
params.addParameter(typeCategoryParameter);
final PluginParameter<MultiChoiceParameterValue> typeParameter = MultiChoiceParameterType.build(TYPE_PARAMETER_ID);
typeParameter.setName("Specific Types");
typeParameter.setDescription("The specific types to include when calculating the top N");
params.addParameter(typeParameter);
final PluginParameter<IntegerParameterValue> limitParameter = IntegerParameterType.build(LIMIT_PARAMETER_ID);
limitParameter.setName("Limit");
limitParameter.setDescription("The limit, default being 10");
limitParameter.setIntegerValue(10);
params.addParameter(limitParameter);
params.addController(MODE_PARAMETER_ID, (PluginParameter<?> master, Map<String, PluginParameter<?>> parameters, ParameterChange change) -> {
if (change == ParameterChange.VALUE) {
final String mode = parameters.get(MODE_PARAMETER_ID).getStringValue();
if (mode != null) {
final List<String> types = new ArrayList<>();
switch(mode) {
case NODE:
for (final SchemaVertexType type : SchemaVertexTypeUtilities.getTypes()) {
if (type.isTopLevelType()) {
types.add(type.getName());
}
}
break;
case TRANSACTION:
for (final SchemaTransactionType type : SchemaTransactionTypeUtilities.getTypes()) {
if (type.isTopLevelType()) {
types.add(type.getName());
}
}
break;
default:
LOGGER.severe("Invalid mode provided. Mode values accepted are " + NODE + " or " + TRANSACTION);
}
// TYPE_CATEGORY_PARAMETER will always be of type SingleChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<SingleChoiceParameterValue> typeCategoryParamter = (PluginParameter<SingleChoiceParameterValue>) parameters.get(TYPE_CATEGORY_PARAMETER_ID);
types.sort(String::compareTo);
SingleChoiceParameterType.setOptions(typeCategoryParamter, types);
}
}
});
params.addController(TYPE_CATEGORY_PARAMETER_ID, (PluginParameter<?> master, Map<String, PluginParameter<?>> parameters, ParameterChange change) -> {
if (change == ParameterChange.VALUE) {
final String mode = parameters.get(MODE_PARAMETER_ID).getStringValue();
final String typeCategory = parameters.get(TYPE_CATEGORY_PARAMETER_ID).getStringValue();
if (mode != null && typeCategory != null) {
final List<String> types = new ArrayList<>();
switch(mode) {
case NODE:
final SchemaVertexType typeCategoryVertexType = SchemaVertexTypeUtilities.getType(typeCategory);
for (final SchemaVertexType type : SchemaVertexTypeUtilities.getTypes()) {
if (type.getSuperType().equals(typeCategoryVertexType)) {
types.add(type.getName());
}
}
break;
case TRANSACTION:
final SchemaTransactionType typeCategoryTransactionType = SchemaTransactionTypeUtilities.getType(typeCategory);
for (final SchemaTransactionType type : SchemaTransactionTypeUtilities.getTypes()) {
if (type.getSuperType().equals(typeCategoryTransactionType)) {
types.add(type.getName());
}
}
break;
default:
break;
}
// update the sub level types
// TYPE_PARAMETER will always be of type MultiChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> typeParamter = (PluginParameter<MultiChoiceParameterValue>) parameters.get(TYPE_PARAMETER_ID);
types.sort(String::compareTo);
MultiChoiceParameterType.setOptions(typeParamter, types);
MultiChoiceParameterType.setChoices(typeParamter, types);
}
}
});
return params;
}
Aggregations