Search in sources :

Example 26 with GraphElementType

use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.

the class AttributeSelectionPanel method getAttributeId.

/**
 * Return the id of the selected attribute.
 *
 * @return The id of the selected attribute.
 */
public int getAttributeId() {
    final GraphElementType et = getElementType();
    final String item = (String) attributeCombo.getSelectedItem();
    final int attrId;
    if (!item.isEmpty()) {
        ReadableGraph rg = graph.getReadableGraph();
        try {
            attrId = rg.getAttribute(et, item);
        } finally {
            rg.release();
        }
    } else {
        attrId = Graph.NOT_FOUND;
    }
    return attrId;
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType)

Example 27 with GraphElementType

use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.

the class AttributeSelectionPanel method getElementType.

/**
 * Return the selected element type.
 *
 * @return The selected element type.
 */
private GraphElementType getElementType() {
    final String elementTypeChoice = (String) elementTypeCombo.getSelectedItem();
    final GraphElementType graphElementType;
    if (elementTypeChoice.equals(VERTEX)) {
        graphElementType = GraphElementType.VERTEX;
    } else {
        graphElementType = GraphElementType.TRANSACTION;
    }
    return graphElementType;
}
Also used : GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType)

Example 28 with GraphElementType

use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.

the class AttributeUtilitiesNGTest method testGetRegisteredAttributeIdsFromGraphWithOneNode.

@Test
public void testGetRegisteredAttributeIdsFromGraphWithOneNode() {
    final StoreGraph graph = new StoreGraph(SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema());
    final int vx0 = graph.addVertex();
    graph.getSchema().completeVertex(graph, vx0);
    final GraphElementType graphElementType = GraphElementType.VERTEX;
    final Map<String, Integer> expResult = new HashMap<>();
    expResult.put(VisualConcept.VertexAttribute.LABEL.getName(), graph.getAttribute(graphElementType, VisualConcept.VertexAttribute.LABEL.getName()));
    expResult.put(VisualConcept.VertexAttribute.IDENTIFIER.getName(), graph.getAttribute(graphElementType, VisualConcept.VertexAttribute.IDENTIFIER.getName()));
    expResult.put(AnalyticConcept.VertexAttribute.RAW.getName(), graph.getAttribute(graphElementType, AnalyticConcept.VertexAttribute.RAW.getName()));
    expResult.put(AnalyticConcept.VertexAttribute.TYPE.getName(), graph.getAttribute(graphElementType, AnalyticConcept.VertexAttribute.TYPE.getName()));
    expResult.put(VisualConcept.VertexAttribute.COLOR.getName(), graph.getAttribute(graphElementType, VisualConcept.VertexAttribute.COLOR.getName()));
    expResult.put(VisualConcept.VertexAttribute.FOREGROUND_ICON.getName(), graph.getAttribute(graphElementType, VisualConcept.VertexAttribute.FOREGROUND_ICON.getName()));
    expResult.put(VisualConcept.VertexAttribute.BACKGROUND_ICON.getName(), graph.getAttribute(graphElementType, VisualConcept.VertexAttribute.BACKGROUND_ICON.getName()));
    final Map<String, Integer> result = AttributeUtilities.getRegisteredAttributeIdsFromGraph(graph, graphElementType);
    assertEquals(result, expResult);
}
Also used : HashMap(java.util.HashMap) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Test(org.testng.annotations.Test)

Example 29 with GraphElementType

use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.

the class AttributeUtilitiesNGTest method testGetRegisteredAttributeIdsFromGraphWithZeroNodes.

/**
 * Test of getRegisteredAttributeIdsFromGraph method, of class
 * AttributeUtilities.
 */
@Test
public void testGetRegisteredAttributeIdsFromGraphWithZeroNodes() {
    final StoreGraph graph = new StoreGraph(SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema());
    final GraphElementType graphElementType = GraphElementType.VERTEX;
    final Map<String, Integer> expResult = new HashMap<>();
    final Map<String, Integer> result = AttributeUtilities.getRegisteredAttributeIdsFromGraph(graph, graphElementType);
    assertEquals(result, expResult);
}
Also used : HashMap(java.util.HashMap) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Test(org.testng.annotations.Test)

Example 30 with GraphElementType

use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.

the class HistogramClearFilterPlugin method edit.

@Override
protected void edit(final GraphWriteMethods graph, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
    final GraphElementType elementType = (GraphElementType) ((ElementTypeParameterValue) parameters.getSingleChoice(ELEMENT_TYPE_PARAMETER_ID)).getObjectValue();
    final int histogramStateAttribute = HistogramConcept.MetaAttribute.HISTOGRAM_STATE.ensure(graph);
    HistogramState histogramState = (HistogramState) graph.getObjectValue(histogramStateAttribute, 0);
    histogramState = new HistogramState(histogramState);
    histogramState.setFilter(elementType, null);
    graph.setObjectValue(histogramStateAttribute, 0, histogramState);
}
Also used : GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType)

Aggregations

GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)85 Test (org.testng.annotations.Test)34 ArrayList (java.util.ArrayList)28 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)17 Attribute (au.gov.asd.tac.constellation.graph.Attribute)16 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)12 HashMap (java.util.HashMap)11 AdvancedFindTab (au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab)10 FindCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues)9 GraphManager (au.gov.asd.tac.constellation.graph.manager.GraphManager)8 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)8 Graph (au.gov.asd.tac.constellation.graph.Graph)7 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)5 SchemaAttribute (au.gov.asd.tac.constellation.graph.schema.attribute.SchemaAttribute)5 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)5 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)5 FindViewController (au.gov.asd.tac.constellation.views.find2.FindViewController)5 AdvancedCriteriaBorderPane (au.gov.asd.tac.constellation.views.find2.components.advanced.AdvancedCriteriaBorderPane)5 BasicFindReplaceParameters (au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters)5 List (java.util.List)5