use of au.gov.asd.tac.constellation.utilities.graphics.IntArray in project constellation by constellation-app.
the class AttributeReader method populateValues.
private boolean populateValues(final List<GraphElementType> elementTypes, final boolean selectionChanged, final boolean attributeModified, final boolean preferenceChanged, final ReadableGraph rg) {
boolean valueChanged = false;
if (selectionChanged) {
elementAttributeValues.clear();
}
for (final GraphElementType type : ACCEPTED_ELEMENT_TYPES) {
// for graphElement Type (graph,vertex,transaction)
final List<AttributeData> attributes = elementAttributeData.get(type);
final IntArray selectedElement;
if (type.equals(GraphElementType.VERTEX)) {
selectedElement = selectedNodes;
} else if (type.equals(GraphElementType.TRANSACTION)) {
selectedElement = selectedTransactions;
} else {
selectedElement = null;
}
for (final AttributeData data : attributes) {
if (!elementTypes.contains(type)) {
final String attributeValuesKey = type.getLabel() + data.getAttributeName();
elementAttributeValues.put(attributeValuesKey, null);
continue;
}
if (preferenceChanged || selectionChanged || attributeModified || data.attibuteValueHasChanged(rg.getValueModificationCounter(data.getAttributeId()))) {
final Set<Object> values = new HashSet<>();
int valueCountLimit = 11;
// only load 10 values first... if the user wants more then another request is made. we load 11 to know that there are more than 10
if ("boolean".equals(data.getDataType())) {
valueCountLimit = 2;
// boolean only has two possibilities.
}
if (selectedElement != null) {
for (int i = 0; i < selectedElement.size() && values.size() < valueCountLimit; i++) {
values.add(rg.getObjectValue(data.getAttributeId(), selectedElement.get(i)));
}
} else {
// assumed to be graphelementtype of graph.
values.add(rg.getObjectValue(data.getAttributeId(), 0));
}
if (!values.isEmpty()) {
valueChanged = true;
}
final String attributeValuesKey = type.getLabel() + data.getAttributeName();
elementAttributeValues.remove(attributeValuesKey);
elementAttributeValues.put(attributeValuesKey, sortHashMap(values));
}
}
}
return valueChanged;
}
use of au.gov.asd.tac.constellation.utilities.graphics.IntArray in project constellation by constellation-app.
the class DefaultInteractionEventHandler method performPointSelection.
private void performPointSelection(final boolean toggleSelection, final boolean clearSelection, final GraphElementType elementType, final int elementId) {
final IntArray vxIds = new IntArray();
final IntArray txIds = new IntArray();
switch(elementType) {
case VERTEX:
vxIds.add(elementId);
break;
case TRANSACTION:
txIds.add(elementId);
break;
default:
break;
}
if (!(vxIds.isEmpty() && txIds.isEmpty() && !clearSelection)) {
Plugin selectPoint = new PointSelectionPlugin(vxIds, txIds, toggleSelection, clearSelection);
PluginExecution.withPlugin(selectPoint).executeLater(graph);
}
}
use of au.gov.asd.tac.constellation.utilities.graphics.IntArray in project constellation by constellation-app.
the class AttributeReader method loadMoreDataFor.
public Object[] loadMoreDataFor(final AttributeData attribute) {
final int AttributeID = attribute.getAttributeId();
final Set<Object> values = new HashSet<>();
final IntArray selectedElement;
if (attribute.getElementType().equals(GraphElementType.VERTEX)) {
selectedElement = selectedNodes;
} else if (attribute.getElementType().equals(GraphElementType.TRANSACTION)) {
selectedElement = selectedTransactions;
} else {
selectedElement = null;
}
final ReadableGraph rg = graph.getReadableGraph();
try {
if (selectedElement != null) {
int elementSize = selectedElement.size();
for (int i = 0; i < elementSize; i++) {
values.add(rg.getObjectValue(AttributeID, selectedElement.get(i)));
}
}
} finally {
rg.release();
}
return sortHashMap(values);
}
use of au.gov.asd.tac.constellation.utilities.graphics.IntArray in project constellation by constellation-app.
the class PointSelectionPluginNGTest method setUpMethod.
/**
* Creates a basic graph with 3 vertices and 3 transactions with selection
* attributes added for testing.
*
* @throws Exception
*/
@BeforeMethod
public void setUpMethod() throws Exception {
storeGraph = new StoreGraph();
vAttrId = VisualConcept.VertexAttribute.SELECTED.ensure(storeGraph);
tAttrId = VisualConcept.TransactionAttribute.SELECTED.ensure(storeGraph);
vxId1 = storeGraph.addVertex();
vxId2 = storeGraph.addVertex();
vxId3 = storeGraph.addVertex();
txId1 = storeGraph.addTransaction(vxId1, vxId2, false);
txId2 = storeGraph.addTransaction(vxId2, vxId3, false);
txId3 = storeGraph.addTransaction(vxId3, vxId1, false);
// Ensures arrays don't contain IDs from previous tests when going into a subsequent test.
vxIds = new IntArray();
txIds = new IntArray();
selectAllAndAssert(null, false);
}
use of au.gov.asd.tac.constellation.utilities.graphics.IntArray in project constellation by constellation-app.
the class BlazeBatcher method fillBatch.
private void fillBatch(final VisualAccess access) {
blazeColors = new FloatArray();
blazeInfo = new IntArray();
for (int pos = 0; pos < access.getVertexCount(); pos++) {
bufferBlaze(pos, blazeColors, blazeInfo, access);
}
blazeColors.trimToSize();
blazeInfo.trimToSize();
}
Aggregations