use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.
the class ChangeSelectionPlugin method edit.
@Override
protected void edit(final GraphWriteMethods graph, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
final BitSet elementBitSet = (BitSet) parameters.getParameters().get(ELEMENT_BIT_SET_PARAMETER_ID).getObjectValue();
final GraphElementType elementType = (GraphElementType) ((ElementTypeParameterValue) parameters.getSingleChoice(ELEMENT_TYPE_PARAMETER_ID)).getObjectValue();
final SelectionMode selectionMode = (SelectionMode) parameters.getParameters().get(SELECTION_MODE_PARAMETER_ID).getObjectValue();
final int selectedAttribute = graph.getAttribute(elementType, "selected");
if (selectedAttribute == Graph.NOT_FOUND) {
return;
}
final int elementCount = elementType.getElementCount(graph);
for (int elementPosition = 0; elementPosition < elementCount; elementPosition++) {
final int elementId = elementType.getElement(graph, elementPosition);
final boolean currentlySelected = graph.getBooleanValue(selectedAttribute, elementId);
final boolean newSelected = elementBitSet.get(elementId);
graph.setBooleanValue(selectedAttribute, elementId, selectionMode.calculateSelection(currentlySelected, newSelected));
}
}
use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.
the class ElementTypeParameterValue method setObjectValue.
@Override
public boolean setObjectValue(final Object o) {
if (o instanceof GraphElementType) {
final GraphElementType type = (GraphElementType) o;
final boolean equal = Objects.equals(type, elementType);
if (!equal) {
elementType = type;
}
return equal;
}
return false;
}
use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.
the class ElementTypeParameterValue method setStringValue.
@Override
public boolean setStringValue(final String s) {
final GraphElementType stringElementType = GraphElementType.getValue(s);
final boolean equal = Objects.equals(stringElementType, elementType);
if (!equal) {
elementType = stringElementType;
}
return equal;
}
use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.
the class AttributeFillBuilder method fillAttribute.
public static AttributeFillBuilder fillAttribute(final GraphWriteMethods graph, final int attrID, final Object lower, final Object upper) {
final GraphElementType elementType = graph.getAttributeElementType(attrID);
final int[] elementsToFill = elementType == GraphElementType.VERTEX ? new int[graph.getVertexCount()] : new int[graph.getTransactionCount()];
for (int i = 0; i < elementsToFill.length; i++) {
elementsToFill[i] = elementType == GraphElementType.VERTEX ? graph.getVertex(i) : graph.getTransaction(i);
}
return fillAttribute(graph, attrID, elementsToFill, lower, upper);
}
use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.
the class AttributeFillBuilder method fillAttribute.
public static AttributeFillBuilder fillAttribute(final GraphWriteMethods graph, final int attrID, final List<Object> options, final boolean sequential) {
final GraphElementType elementType = graph.getAttributeElementType(attrID);
final int[] elementsToFill = elementType == GraphElementType.VERTEX ? new int[graph.getVertexCount()] : new int[graph.getTransactionCount()];
for (int i = 0; i < elementsToFill.length; i++) {
elementsToFill[i] = elementType == GraphElementType.VERTEX ? graph.getVertex(i) : graph.getTransaction(i);
}
return fillAttribute(graph, attrID, elementsToFill, options, sequential);
}
Aggregations