use of au.gov.asd.tac.constellation.graph.Graph in project constellation by constellation-app.
the class InfoMapGeneralAction method actionPerformed.
@Override
public void actionPerformed(final ActionEvent ev) {
final InfoMapPanel imp = new InfoMapPanel();
final DialogDescriptor dd = new DialogDescriptor(imp, Bundle.CTL_InfoMapGeneralAction());
final Object result = DialogDisplayer.getDefault().notify(dd);
if (result == DialogDescriptor.OK_OPTION) {
final Graph graph = context.getGraph();
PluginExecutor.startWith(AlgorithmPluginRegistry.CLUSTER_INFO_MAP).set(InfoMapPlugin.CONFIG_PARAMETER_ID, imp.getConfig()).followedBy(new InfoMapGeneralPlugin()).executeWriteLater(graph);
}
}
use of au.gov.asd.tac.constellation.graph.Graph in project constellation by constellation-app.
the class SpanningTreeAction method actionPerformed.
@Override
public void actionPerformed(final ActionEvent e) {
// Note: only works on one component.
final Graph graph = context.getGraph();
PluginExecution.withPlugin(AlgorithmPluginRegistry.SPANNING_TREE).executeLater(graph);
}
use of au.gov.asd.tac.constellation.graph.Graph in project constellation by constellation-app.
the class AnalyticViewTopComponent method handleComponentOpened.
@Override
protected void handleComponentOpened() {
super.handleComponentOpened();
if (needsUpdate()) {
final Graph current = GraphManager.getDefault().getActiveGraph();
if (current != null) {
currentGraphId = current.getId();
}
analyticViewPane.getConfigurationPane().updateState(false);
}
}
use of au.gov.asd.tac.constellation.graph.Graph in project constellation by constellation-app.
the class AnalyticViewTopComponent method componentShowing.
@Override
protected void componentShowing() {
super.componentShowing();
final Graph current = GraphManager.getDefault().getActiveGraph();
if (current != null && !current.getId().equals(currentGraphId)) {
analyticViewPane.reset();
}
analyticViewPane.getConfigurationPane().updateState(false);
}
use of au.gov.asd.tac.constellation.graph.Graph in project constellation by constellation-app.
the class ScoreAnalyticPlugin method computeResultsFromGraph.
protected final void computeResultsFromGraph(final GraphReadMethods graph, final PluginParameters parameters) {
result = new ScoreResult();
result.setIgnoreNullResults(ignoreDefaultValues());
int graphElementCount = 0;
int identifierAttributeId = Graph.NOT_FOUND;
final Set<GraphElementType> graphElementTypes = getAnalyticAttributes(parameters).stream().map(attribute -> attribute.getElementType()).collect(Collectors.toSet());
for (final GraphElementType graphElementType : graphElementTypes) {
switch(graphElementType) {
case VERTEX:
graphElementCount = graph.getVertexCount();
identifierAttributeId = VisualConcept.VertexAttribute.IDENTIFIER.get(graph);
break;
case TRANSACTION:
graphElementCount = graph.getTransactionCount();
identifierAttributeId = VisualConcept.TransactionAttribute.IDENTIFIER.get(graph);
break;
default:
break;
}
for (int graphElementPosition = 0; graphElementPosition < graphElementCount; graphElementPosition++) {
final int graphElementId;
if (graphElementType == GraphElementType.VERTEX) {
graphElementId = graph.getVertex(graphElementPosition);
} else {
graphElementId = graphElementType == GraphElementType.TRANSACTION ? graph.getTransaction(graphElementPosition) : Graph.NOT_FOUND;
}
final String identifier = graph.getStringValue(identifierAttributeId, graphElementId);
final Map<String, Float> namedScores = new HashMap<>();
boolean isNull = true;
for (final SchemaAttribute analyticAttribute : getAnalyticAttributes(parameters)) {
final int scoreAttributeId = analyticAttribute.get(graph);
if (scoreAttributeId == Graph.NOT_FOUND) {
throw new RuntimeException("Expected attribute not found on graph: " + analyticAttribute.getName());
}
final float score = graph.getFloatValue(scoreAttributeId, graphElementId);
final float defaultScore = (float) graph.getAttributeDefaultValue(scoreAttributeId);
if (isNull) {
isNull = ignoreDefaultValues() && score == defaultScore;
}
namedScores.put(analyticAttribute.getName(), score);
}
result.add(new ElementScore(graphElementType, graphElementId, identifier, isNull, namedScores));
}
}
}
Aggregations