Search in sources :

Example 1 with Graph

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);
    }
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph) DialogDescriptor(org.openide.DialogDescriptor)

Example 2 with 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);
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph)

Example 3 with 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);
    }
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph)

Example 4 with Graph

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);
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph)

Example 5 with Graph

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));
        }
    }
}
Also used : GraphWriteMethods(au.gov.asd.tac.constellation.graph.GraphWriteMethods) SchemaTransactionType(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType) TRANSACTION(au.gov.asd.tac.constellation.graph.GraphElementType.TRANSACTION) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) ElementScore(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore) RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore) SchemaTransactionTypeUtilities(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionTypeUtilities) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult) HashMap(java.util.HashMap) SchemaFactory(au.gov.asd.tac.constellation.graph.schema.SchemaFactory) VisualConcept(au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) Graph(au.gov.asd.tac.constellation.graph.Graph) HashSet(java.util.HashSet) SchemaFactoryUtilities(au.gov.asd.tac.constellation.graph.schema.SchemaFactoryUtilities) VERTEX(au.gov.asd.tac.constellation.graph.GraphElementType.VERTEX) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Map(java.util.Map) SubgraphUtilities(au.gov.asd.tac.constellation.graph.utilities.SubgraphUtilities) GraphReadMethods(au.gov.asd.tac.constellation.graph.GraphReadMethods) PluginExecution(au.gov.asd.tac.constellation.plugins.PluginExecution) PluginRegistry(au.gov.asd.tac.constellation.plugins.PluginRegistry) SchemaAttribute(au.gov.asd.tac.constellation.graph.schema.attribute.SchemaAttribute) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) MultiChoiceParameterType(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) Set(java.util.Set) ParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) GraphRecordStoreUtilities(au.gov.asd.tac.constellation.graph.processing.GraphRecordStoreUtilities) Logger(java.util.logging.Logger) PluginException(au.gov.asd.tac.constellation.plugins.PluginException) Collectors(java.util.stream.Collectors) AnalyticResult(au.gov.asd.tac.constellation.views.analyticview.results.AnalyticResult) InvocationTargetException(java.lang.reflect.InvocationTargetException) Objects(java.util.Objects) List(java.util.List) AnalyticConcept(au.gov.asd.tac.constellation.graph.schema.analytic.concept.AnalyticConcept) HashMap(java.util.HashMap) ElementScore(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) SchemaAttribute(au.gov.asd.tac.constellation.graph.schema.attribute.SchemaAttribute)

Aggregations

Graph (au.gov.asd.tac.constellation.graph.Graph)211 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)86 Test (org.testng.annotations.Test)65 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)40 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)36 ArrayList (java.util.ArrayList)32 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)31 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)30 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)26 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)26 TableViewState (au.gov.asd.tac.constellation.views.tableview.state.TableViewState)21 List (java.util.List)21 ExecutionException (java.util.concurrent.ExecutionException)21 PluginExecution (au.gov.asd.tac.constellation.plugins.PluginExecution)20 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)20 IOException (java.io.IOException)20 Schema (au.gov.asd.tac.constellation.graph.schema.Schema)17 VisualConcept (au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept)17 File (java.io.File)17 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)16