use of au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue in project constellation by constellation-app.
the class ArrangeInGridGeneralPlugin method createParameters.
@Override
public PluginParameters createParameters() {
final PluginParameters parameters = new PluginParameters();
// Use the GridChoiceParameters defaults to set the plugin defaults.
final GridChoiceParameters defaults = GridChoiceParameters.getDefaultParameters();
final PluginParameter<SingleChoiceParameterValue> gridChoiceParam = SingleChoiceParameterType.build(GRID_CHOICE_PARAMETER_ID);
gridChoiceParam.setName("Grid choice");
gridChoiceParam.setDescription("The type of grid arrangement");
SingleChoiceParameterType.setOptions(gridChoiceParam, GridChoice.getChoices());
SingleChoiceParameterType.setChoice(gridChoiceParam, defaults.getGridChoice().toString());
parameters.addParameter(gridChoiceParam);
final PluginParameter<FloatParameterValue> sizeGainParam = FloatParameterType.build(SIZE_GAIN_PARAMETER_ID);
sizeGainParam.setName("Size gain");
sizeGainParam.setDescription("The size gain, the default is " + defaults.getSizeGain());
sizeGainParam.setFloatValue(defaults.getSizeGain());
parameters.addParameter(sizeGainParam);
final PluginParameter<IntegerParameterValue> horizontalGapParam = IntegerParameterType.build(HORIZONTAL_GAP_PARAMETER_ID);
horizontalGapParam.setName("Horizontal gap");
horizontalGapParam.setDescription("The horizontal gap, the default is " + defaults.getHorizontalGap());
horizontalGapParam.setIntegerValue(defaults.getHorizontalGap());
parameters.addParameter(horizontalGapParam);
final PluginParameter<IntegerParameterValue> verticalGapParam = IntegerParameterType.build(VERTICAL_GAP_PARAMETER_ID);
verticalGapParam.setName("Vertical gap");
verticalGapParam.setDescription("The verticle gap, the default is " + defaults.getVerticalGap());
verticalGapParam.setIntegerValue(defaults.getVerticalGap());
parameters.addParameter(verticalGapParam);
final PluginParameter<BooleanParameterValue> offsetRowsParam = BooleanParameterType.build(OFFSET_ROWS_PARAMETER_ID);
offsetRowsParam.setName("Offset even numbered rows");
offsetRowsParam.setDescription("Offset even numbered rows, the default is " + defaults.hasRowOffsets());
offsetRowsParam.setBooleanValue(defaults.hasRowOffsets());
parameters.addParameter(offsetRowsParam);
final PluginParameter<BooleanParameterValue> maintainMeanParam = BooleanParameterType.build(MAINTAIN_MEAN_PARAMETER_ID);
maintainMeanParam.setName("Maintain Mean");
maintainMeanParam.setDescription("Maintain Mean, default is True");
maintainMeanParam.setBooleanValue(true);
parameters.addParameter(maintainMeanParam);
return parameters;
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue in project constellation by constellation-app.
the class LayerByTimePlugin method createParameters.
@Override
public PluginParameters createParameters() {
final PluginParameters parameters = new PluginParameters();
dtAttrParam = SingleChoiceParameterType.build(DATETIME_ATTRIBUTE_PARAMETER_ID);
dtAttrParam.setName(DATETIME_PARAMETER_ID_NAME);
dtAttrParam.setDescription(DATETIME_ATTRIBUTE_PARAMETER_ID_DESCRIPTION);
parameters.addParameter(dtAttrParam);
dateRangeParam = DateTimeRangeParameterType.build(DATE_RANGE_PARAMETER_ID);
dateRangeParam.setName(DATE_RANGE_PARAMETER_ID_NAME);
dateRangeParam.setDescription(DATE_RANGE_PARAM_DESCRIPTION);
dateRangeParam.setDateTimeRangeValue(DATE_RANGE_PARAMETER_ID_DEFAULT);
parameters.addParameter(dateRangeParam);
final PluginParameter<SingleChoiceParameterValue> layerByParam = SingleChoiceParameterType.build(LAYER_BY_PARAMETER_ID);
layerByParam.setName(LAYER_BY_PARAMETER_ID_NAME);
layerByParam.setDescription(LAYER_BY_PARAMETER_ID_DESCRIPTION);
SingleChoiceParameterType.setOptions(layerByParam, LAYER_BY_PARAM_VALUES);
SingleChoiceParameterType.setChoice(layerByParam, LAYER_BY_PARAMETER_ID_DEFAULT);
parameters.addParameter(layerByParam);
final PluginParameter<IntegerParameterValue> amountParam = IntegerParameterType.build(AMOUNT_PARAMETER_ID);
amountParam.setName(AMOUNT_PARAMETER_ID_NAME);
amountParam.setDescription(AMOUNT_PARAMETER_ID_DESCRIPTION);
amountParam.setIntegerValue(AMOUNT_PARAMETER_ID_DEFAULT);
parameters.addParameter(amountParam);
final PluginParameter<SingleChoiceParameterValue> unitParam = SingleChoiceParameterType.build(UNIT_PARAMETER_ID);
unitParam.setName(UNIT_PARAMETER_ID_NAME);
unitParam.setDescription(UNIT_PARAMETER_ID_DESCRIPTION);
SingleChoiceParameterType.setOptions(unitParam, new ArrayList<>(LAYER_INTERVALS.keySet()));
SingleChoiceParameterType.setChoice(unitParam, UNIT_PARAMETER_ID_DEFAULT);
parameters.addParameter(unitParam);
final PluginParameter<BooleanParameterValue> transactionParam = BooleanParameterType.build(TRANSACTION_AS_LAYER_PARAMETER_ID);
transactionParam.setName(TRANSACTION_AS_LAYER_NAME);
transactionParam.setDescription(TRANSACTION_AS_LAYER_DESCRIPTION);
transactionParam.setBooleanValue(TRANSACTION_AS_LAYER_DEFAULT);
parameters.addParameter(transactionParam);
final PluginParameter<BooleanParameterValue> keepTxColorsParam = BooleanParameterType.build(KEEP_TX_COLORS_PARAMETER_ID);
keepTxColorsParam.setName(KEEP_TX_COLORS_NAME);
keepTxColorsParam.setDescription(KEEP_TX_COLORS_DESCRIPTION);
keepTxColorsParam.setBooleanValue(KEEP_TX_COLORS_DEFAULT);
parameters.addParameter(keepTxColorsParam);
final PluginParameter<BooleanParameterValue> drawTxGuidesParam = BooleanParameterType.build(DRAW_TX_GUIDES_PARAMETER_ID);
drawTxGuidesParam.setName(DRAW_TX_GUIDES_NAME);
drawTxGuidesParam.setDescription(DRAW_TX_GUIDES_DESCRIPTION);
drawTxGuidesParam.setBooleanValue(DRAW_TX_GUIDES_DEFAULT);
parameters.addParameter(drawTxGuidesParam);
parameters.addController(LAYER_BY_PARAMETER_ID, (masterId, paramMap, change) -> {
if (change == ParameterChange.VALUE) {
if (paramMap.get(LAYER_BY_PARAMETER_ID).getStringValue().equals(INTERVAL_METHOD)) {
SingleChoiceParameterType.setOptions(unitParam, new ArrayList<>(LAYER_INTERVALS.keySet()));
SingleChoiceParameterType.setChoice(unitParam, UNIT_PARAMETER_ID_INTERVAL_DEFAULT);
parameters.getParameters().get(AMOUNT_PARAMETER_ID).setEnabled(true);
} else if (paramMap.get(LAYER_BY_PARAMETER_ID).getStringValue().equals(BIN_METHOD)) {
SingleChoiceParameterType.setOptions(unitParam, new ArrayList<>(BIN_CALENDAR_UNITS.keySet()));
SingleChoiceParameterType.setChoice(unitParam, UNIT_PARAMETER_ID_BIN_DEFAULT);
parameters.getParameters().get(AMOUNT_PARAMETER_ID).setEnabled(false);
} else {
// Do nothing
}
}
});
return parameters;
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue in project constellation by constellation-app.
the class TestParametersPlugin method createParameters.
@Override
public PluginParameters createParameters() {
final PluginParameters params = new PluginParameters();
final String css = TestParametersPlugin.class.getResource("resources/test.css").toExternalForm();
final BooleanParameterValue selectedpv = new BooleanParameterValue(true);
selectedpv.setGuiInit(control -> {
final CheckBox field = (CheckBox) control;
field.getStylesheets().add(css);
});
final PluginParameter<BooleanParameterValue> selected = BooleanParameterType.build(SELECTED_PARAMETER_ID, selectedpv);
selected.setName("Use selected");
selected.setDescription("Only use selected elements");
params.addParameter(selected);
final PluginParameter<StringParameterValue> queryName = CoreGlobalParameters.QUERY_NAME_PARAMETER;
params.addParameter(queryName);
final PluginParameter<DateTimeRangeParameterValue> dt = CoreGlobalParameters.DATETIME_RANGE_PARAMETER;
params.addParameter(dt);
final PluginParameter<StringParameterValue> string1 = StringParameterType.build(TEST1_PARAMETER_ID);
string1.setName("Test1");
string1.setDescription("A test string");
string1.setStringValue("Plugh.");
params.addParameter(string1);
final StringParameterValue string2pv = new StringParameterValue();
string2pv.setGuiInit(control -> {
final TextArea field = (TextArea) control;
field.getStylesheets().add(css);
});
final PluginParameter<StringParameterValue> string2 = StringParameterType.build(TEST2_PARAMETER_ID, string2pv);
string2.setName("Test2");
string2.setDescription("A two line test string");
StringParameterType.setLines(string2, 2);
params.addParameter(string2);
final PluginParameter<PasswordParameterValue> passwd = PasswordParameterType.build(PASSWORD_PARAMETER_ID);
passwd.setName("Password");
passwd.setDescription("Everyone needs a password");
params.addParameter(passwd);
final PluginParameter<LocalDateParameterValue> date = LocalDateParameterType.build(LOCAL_DATE_PARAMETER_ID);
date.setName("Date");
date.setDescription("Pick a day");
date.setLocalDateValue(LocalDate.of(2001, Month.JANUARY, 1));
params.addParameter(date);
final List<GraphElementTypeParameterValue> elementTypeOptions = new ArrayList<>();
for (final GraphElementType elementType : GraphElementType.values()) {
elementTypeOptions.add(new GraphElementTypeParameterValue(elementType));
}
final PluginParameter<SingleChoiceParameterValue> elementType = SingleChoiceParameterType.build(ELEMENT_TYPE_PARAMETER_ID, GraphElementTypeParameterValue.class);
elementType.setName("Graph element type");
elementType.setDescription("Graph element type");
SingleChoiceParameterType.setOptionsData(elementType, elementTypeOptions);
params.addParameter(elementType);
// A single choice list with a subtype of String.
final SingleChoiceParameterValue robotpv = new SingleChoiceParameterValue(StringParameterValue.class);
robotpv.setGuiInit(control -> {
// control will be of type ComboBox<ParameterValue> which extends from Region
@SuppressWarnings("unchecked") final ComboBox<ParameterValue> field = (ComboBox<ParameterValue>) control;
final Image img = new Image(ALIEN_ICON);
field.setCellFactory((ListView<ParameterValue> param) -> new ListCell<ParameterValue>() {
@Override
protected void updateItem(final ParameterValue item, final boolean empty) {
super.updateItem(item, empty);
this.setText(empty ? "" : item.toString());
final float f = empty ? 0 : item.toString().length() / 11F;
final Color c = Color.color(1 - f / 2F, 0, 0);
setTextFill(c);
setGraphic(new ImageView(img));
}
});
});
final PluginParameter<SingleChoiceParameterValue> robotOptions = SingleChoiceParameterType.build(ROBOT_PARAMETER_ID, robotpv);
robotOptions.setName("Robot options");
robotOptions.setDescription("A list of robots to choose from");
// Use the helper method to add string options.
SingleChoiceParameterType.setOptions(robotOptions, Arrays.asList("Bender", "Gort", "Maximillian", "Robbie", "Tom Servo"));
// Create a ParameterValue of the underlying type (in this case, String) to set the default choice.
final StringParameterValue robotChoice = new StringParameterValue("Gort");
SingleChoiceParameterType.setChoiceData(robotOptions, robotChoice);
params.addParameter(robotOptions);
final PluginParameter<ParameterValue> buttonParam = ActionParameterType.build(REFRESH_PARAMETER_ID);
buttonParam.setName("Refresh");
buttonParam.setDescription("Update the available robots");
params.addParameter(buttonParam);
final PluginParameter<MultiChoiceParameterValue> planetOptions = MultiChoiceParameterType.build(PLANETS_PARAMETER_ID);
planetOptions.setName("Planets");
planetOptions.setDescription("Some planets");
MultiChoiceParameterType.setOptions(planetOptions, Arrays.asList("Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Coruscant"));
final List<String> checked = new ArrayList<>();
checked.add("Earth");
MultiChoiceParameterType.setChoices(planetOptions, checked);
params.addParameter(planetOptions);
final PluginParameter<IntegerParameterValue> diceOptions = IntegerParameterType.build(DICE_PARAMETER_ID);
diceOptions.setName("Dice");
diceOptions.setDescription("2d6");
IntegerParameterType.setMinimum(diceOptions, 2);
IntegerParameterType.setMaximum(diceOptions, 12);
diceOptions.setIntegerValue(7);
params.addParameter(diceOptions);
final PluginParameter<FloatParameterValue> probability = FloatParameterType.build(PROBABILITY_PARAMETER_ID);
probability.setName("Probability");
probability.setDescription("0 <= p <= 1");
FloatParameterType.setMinimum(probability, 0F);
FloatParameterType.setMaximum(probability, 1F);
FloatParameterType.setStep(probability, 0.1F);
probability.setFloatValue(1F);
params.addParameter(probability);
final PluginParameter<FileParameterValue> openFileParam = FileParameterType.build(INPUT_FILE_PARAMETER_ID);
openFileParam.setName("Input file");
openFileParam.setDescription("A file to read stuff from");
params.addParameter(openFileParam);
final PluginParameter<FileParameterValue> saveFileParam = FileParameterType.build(OUTPUT_FILE_PARAMETER_ID);
saveFileParam.setName("Output file");
saveFileParam.setDescription("A file to write stuff to");
FileParameterType.setKind(saveFileParam, FileParameterType.FileParameterKind.SAVE);
FileParameterType.setFileFilters(saveFileParam, new FileChooser.ExtensionFilter("Text files", "*.txt"));
params.addParameter(saveFileParam);
final PluginParameter<ColorParameterValue> color = ColorParameterType.build(COLOR_PARAMETER_ID);
color.setName("Color");
color.setDescription("Your favourite colour");
color.setColorValue(ConstellationColor.BLUE);
params.addParameter(color);
final PluginParameter<BooleanParameterValue> crash = BooleanParameterType.build(CRASH_PARAMETER_ID);
crash.setName("Crash");
crash.setDescription("Simulate plugin failure");
params.addParameter(crash);
final PluginParameter<SingleChoiceParameterValue> interactionOptions = SingleChoiceParameterType.build(INTERACTION_PARAMETER_ID);
interactionOptions.setName("Interaction level");
interactionOptions.setDescription("Interaction level for some interaction with the user");
SingleChoiceParameterType.setOptions(interactionOptions, Arrays.asList(NONE, DEBUG, INFO, WARNING, ERROR, FATAL));
params.addParameter(interactionOptions);
final PluginParameter<SingleChoiceParameterValue> levelOptions = SingleChoiceParameterType.build(LEVEL_PARAMETER_ID);
levelOptions.setName("PluginException level");
levelOptions.setDescription("PluginException level to throw an exception at");
levelOptions.setHelpID("not.actually.helpful");
SingleChoiceParameterType.setOptions(levelOptions, Arrays.asList(NONE, DEBUG, INFO, WARNING, ERROR, FATAL));
params.addParameter(levelOptions);
final PluginParameter<IntegerParameterValue> sleepParam = IntegerParameterType.build(SLEEP_PARAMETER_ID);
sleepParam.setName("Sleep");
sleepParam.setDescription("Seconds");
IntegerParameterType.setMinimum(sleepParam, 0);
IntegerParameterType.setMaximum(sleepParam, 20);
sleepParam.setIntegerValue(0);
params.addParameter(sleepParam);
params.addController(SELECTED_PARAMETER_ID, (final PluginParameter<?> master, final Map<String, PluginParameter<?>> parameters, final ParameterChange change) -> {
if (change == ParameterChange.VALUE) {
final boolean masterBoolean = master.getBooleanValue();
// TEST1_PARAMETER will always be of type StringParameter
@SuppressWarnings("unchecked") final PluginParameter<StringParameterValue> t1 = (PluginParameter<StringParameterValue>) parameters.get(TEST1_PARAMETER_ID);
t1.setEnabled(masterBoolean);
// TEST1_PARAMETER will always be of type StringParameter
@SuppressWarnings("unchecked") final PluginParameter<StringParameterValue> t2 = (PluginParameter<StringParameterValue>) parameters.get(TEST2_PARAMETER_ID);
t2.setEnabled(masterBoolean);
// PLANETS_PARAMETER will always be of type MultiChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> p = (PluginParameter<MultiChoiceParameterValue>) parameters.get(PLANETS_PARAMETER_ID);
p.setEnabled(masterBoolean);
// DICE_PARAMETER will always be of type IntegerParameter
@SuppressWarnings("unchecked") final PluginParameter<IntegerParameterValue> d = (PluginParameter<IntegerParameterValue>) parameters.get(DICE_PARAMETER_ID);
d.setEnabled(masterBoolean);
// COLOR_PARAMETER will always be of type ColorParameter
@SuppressWarnings("unchecked") final PluginParameter<ColorParameterValue> c = (PluginParameter<ColorParameterValue>) parameters.get(COLOR_PARAMETER_ID);
c.setVisible(masterBoolean);
}
});
params.addController(REFRESH_PARAMETER_ID, (final PluginParameter<?> master, final Map<String, PluginParameter<?>> parameters, final ParameterChange change) -> {
if (change == ParameterChange.NO_CHANGE) {
// button pressed
// ROBOT_PARAMETER will always be of type SingleChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<SingleChoiceParameterValue> robot = (PluginParameter<SingleChoiceParameterValue>) parameters.get(ROBOT_PARAMETER_ID);
final int n = (int) (System.currentTimeMillis() % 100);
SingleChoiceParameterType.setOptions(robot, Arrays.asList("Kryton " + n, "C-3PO " + n, "R2-D2 " + n));
SingleChoiceParameterType.setChoice(robot, "C-3PO " + n);
}
});
return params;
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue in project constellation by constellation-app.
the class MergeNodesPlugin method createParameters.
@Override
public PluginParameters createParameters() {
final PluginParameters params = new PluginParameters();
final PluginParameter<SingleChoiceParameterValue> mergeType = SingleChoiceParameterType.build(MERGE_TYPE_PARAMETER_ID);
mergeType.setName("Merge By");
mergeType.setDescription("Nodes will be merged based on this");
List<String> mergeTypes = new ArrayList<>(MERGE_TYPES.keySet());
SingleChoiceParameterType.setOptions(mergeType, mergeTypes);
params.addParameter(mergeType);
final PluginParameter<IntegerParameterValue> threshold = IntegerParameterType.build(THRESHOLD_PARAMETER_ID);
threshold.setName("Threshold");
threshold.setDescription("The maximum nodes to merge");
threshold.setEnabled(false);
params.addParameter(threshold);
final PluginParameter<SingleChoiceParameterValue> mergingRule = SingleChoiceParameterType.build(MERGER_PARAMETER_ID);
mergingRule.setName("Merging Rule");
mergingRule.setDescription("The rule deciding how attributes are merged");
List<String> mergerNames = new ArrayList<>(MERGERS.keySet());
SingleChoiceParameterType.setOptions(mergingRule, mergerNames);
SingleChoiceParameterType.setChoice(mergingRule, mergerNames.get(0));
mergingRule.setEnabled(false);
params.addParameter(mergingRule);
final PluginParameter<SingleChoiceParameterValue> leadNode = SingleChoiceParameterType.build(LEAD_PARAMETER_ID);
leadNode.setName("Lead Node");
leadNode.setDescription("The rule deciding how to choose the lead node");
final List<String> leadVertexChooserNames = new ArrayList<>(VERTEX_CHOOSER.keySet());
SingleChoiceParameterType.setOptions(leadNode, leadVertexChooserNames);
SingleChoiceParameterType.setChoice(leadNode, leadVertexChooserNames.get(0));
leadNode.setEnabled(false);
params.addParameter(leadNode);
final PluginParameter<BooleanParameterValue> selectedOnly = BooleanParameterType.build(SELECTED_PARAMETER_ID);
selectedOnly.setName("Selected Only");
selectedOnly.setDescription("Merge Only Selected Nodes");
selectedOnly.setBooleanValue(true);
selectedOnly.setEnabled(false);
params.addParameter(selectedOnly);
params.addController(MERGE_TYPE_PARAMETER_ID, (final PluginParameter<?> master, final Map<String, PluginParameter<?>> parameters, final ParameterChange change) -> {
if (change == ParameterChange.VALUE) {
final String selectedMergeType = parameters.get(MERGE_TYPE_PARAMETER_ID).getStringValue();
if (MERGE_TYPES.containsKey(selectedMergeType)) {
final MergeNodeType mergeNodeTypeSelected = MERGE_TYPES.get(selectedMergeType);
mergeNodeTypeSelected.updateParameters(parameters);
}
}
});
return params;
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue in project constellation by constellation-app.
the class SplitNodesPlugin method createParameters.
@Override
public PluginParameters createParameters() {
final PluginParameters params = new PluginParameters();
final PluginParameter<StringParameterValue> split = StringParameterType.build(SPLIT_PARAMETER_ID);
split.setName("Split Character(s)");
split.setDescription("A new term will be extracted from the first instance of this character(s) in the Identifier");
split.setStringValue(null);
params.addParameter(split);
final PluginParameter<BooleanParameterValue> duplicateTransactionsParameter = BooleanParameterType.build(DUPLICATE_TRANSACTIONS_PARAMETER_ID);
duplicateTransactionsParameter.setName("Duplicate Transactions");
duplicateTransactionsParameter.setDescription("Duplicate transactions for split nodes");
duplicateTransactionsParameter.setBooleanValue(false);
params.addParameter(duplicateTransactionsParameter);
final PluginParameter<SingleChoiceParameterValue> transactionType = SingleChoiceParameterType.build(TRANSACTION_TYPE_PARAMETER_ID);
transactionType.setName("Transaction Type");
transactionType.setDescription("Set the type of transaction between nodes");
params.addParameter(transactionType);
final PluginParameter<BooleanParameterValue> allOccurrences = BooleanParameterType.build(ALL_OCCURRENCES_PARAMETER_ID);
allOccurrences.setName("Split on All Occurrences");
allOccurrences.setDescription("Choose to split on all instances of the character(s) rather than just the first instance");
allOccurrences.setBooleanValue(false);
params.addParameter(allOccurrences);
final PluginParameter<BooleanParameterValue> completeSchema = BooleanParameterType.build(COMPLETE_WITH_SCHEMA_OPTION_ID);
completeSchema.setName("Complete with Schema");
completeSchema.setDescription("Choose to apply the type schema to the graph");
completeSchema.setBooleanValue(true);
params.addParameter(completeSchema);
params.addController(DUPLICATE_TRANSACTIONS_PARAMETER_ID, (master, parameters, change) -> {
if (change == ParameterChange.VALUE) {
final boolean splitIntoSameLevel = master.getBooleanValue();
parameters.get(TRANSACTION_TYPE_PARAMETER_ID).setEnabled(!splitIntoSameLevel);
}
});
return params;
}
Aggregations