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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations