use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameter in project constellation by constellation-app.
the class ArrangeInGridGeneralPlugin method edit.
@Override
public void edit(final GraphWriteMethods graph, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException {
final SetRadiusForArrangement radiusSetter = new SetRadiusForArrangement(graph);
radiusSetter.setRadii();
final Map<String, PluginParameter<?>> pp = parameters.getParameters();
final GridChoiceParameters gridParams = GridChoiceParameters.getDefaultParameters();
gridParams.setGridChoice(GridChoice.getValue(pp.get(GRID_CHOICE_PARAMETER_ID).getStringValue()));
gridParams.setSizeGain(pp.get(SIZE_GAIN_PARAMETER_ID).getFloatValue());
gridParams.setHorizontalGap(pp.get(HORIZONTAL_GAP_PARAMETER_ID).getIntegerValue());
gridParams.setVerticalGap(pp.get(VERTICAL_GAP_PARAMETER_ID).getIntegerValue());
gridParams.setRowOffsets(pp.get(OFFSET_ROWS_PARAMETER_ID).getBooleanValue());
final GridArranger arranger = new GridArranger(gridParams);
final Boolean maintainMean = pp.get(MAINTAIN_MEAN_PARAMETER_ID).getBooleanValue();
arranger.setMaintainMean(maintainMean);
final SelectedInclusionGraph selectedGraph = new SelectedInclusionGraph(graph, SelectedInclusionGraph.Connections.NONE);
arranger.arrange(selectedGraph.getInclusionGraph());
selectedGraph.retrieveCoords();
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameter 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.PluginParameter in project constellation by constellation-app.
the class ArrangeByNodeAttributePlugin method updateParameters.
@Override
public void updateParameters(final Graph graph, final PluginParameters parameters) {
final List<String> attributes = new ArrayList<>();
if (graph != null) {
final ReadableGraph readableGraph = graph.getReadableGraph();
try {
final int axCount = readableGraph.getAttributeCount(GraphElementType.VERTEX);
for (int i = 0; i < axCount; i++) {
final int ax = readableGraph.getAttribute(GraphElementType.VERTEX, i);
attributes.add(readableGraph.getAttributeName(ax));
}
} finally {
readableGraph.release();
}
}
Collections.sort(attributes);
if (parameters != null && parameters.getParameters() != null) {
// ATTRIBUTE_PARAMETER always of type SingleChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<SingleChoiceParameterValue> attribute = (PluginParameter<SingleChoiceParameterValue>) parameters.getParameters().get(ATTRIBUTE_PARAMETER_ID);
SingleChoiceParameterType.setOptions(attribute, attributes);
SingleChoiceParameterType.setChoice(attribute, attributes.get(0));
}
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameter in project constellation by constellation-app.
the class UncollidePlugin method edit.
@Override
public void edit(final GraphWriteMethods wg, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException {
final Map<String, PluginParameter<?>> params = parameters.getParameters();
final Dimensions dimensions = Dimensions.valueOf(params.get(DIMENSION_PARAMETER_ID).getStringValue());
final int maxExpansions = params.get(MAX_EXPANSIONS_PARAMETR_ID).getIntegerValue();
final Arranger arranger = new UncollideArrangement(dimensions, maxExpansions);
((UncollideArrangement) arranger).setInteraction(interaction);
final SelectedInclusionGraph selectedGraph = new SelectedInclusionGraph(wg, SelectedInclusionGraph.Connections.NONE);
arranger.setMaintainMean(!selectedGraph.isArrangingAll());
arranger.arrange(selectedGraph.getInclusionGraph());
selectedGraph.retrieveCoords();
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameter in project constellation by constellation-app.
the class ExtractTypesFromTextPlugin method query.
@Override
protected RecordStore query(final RecordStore query, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
final RecordStore result = new GraphRecordStore();
interaction.setProgress(0, 0, "Importing...", true);
final Map<String, PluginParameter<?>> extractEntityParameters = parameters.getParameters();
final String text = extractEntityParameters.get(TEXT_PARAMETER_ID).getStringValue();
if (text == null) {
throw new PluginException(PluginNotificationLevel.ERROR, "No text provided from which to extract types.");
}
final List<ExtractedVertexType> extractedTypes = SchemaVertexTypeUtilities.extractVertexTypes(text);
final Map<String, SchemaVertexType> identifiers = new HashMap<>();
extractedTypes.forEach(extractedType -> identifiers.put(extractedType.getIdentifier(), extractedType.getType()));
for (final String identifier : identifiers.keySet()) {
result.add();
result.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.IDENTIFIER, identifier);
result.set(GraphRecordStoreUtilities.SOURCE + AnalyticConcept.VertexAttribute.TYPE, identifiers.get(identifier));
result.set(GraphRecordStoreUtilities.SOURCE + AnalyticConcept.VertexAttribute.SEED, "true");
}
ConstellationLoggerHelper.createPropertyBuilder(this, result.getAll(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.IDENTIFIER), ConstellationLoggerHelper.SUCCESS);
interaction.setProgress(1, 0, "Completed successfully - imported " + result.size() + " entities.", true);
return result;
}
Aggregations