Search in sources :

Example 1 with IntArray

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;
}
Also used : IntArray(au.gov.asd.tac.constellation.utilities.graphics.IntArray) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) HashSet(java.util.HashSet)

Example 2 with IntArray

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);
    }
}
Also used : IntArray(au.gov.asd.tac.constellation.utilities.graphics.IntArray) PointSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.PointSelectionPlugin) PointSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.PointSelectionPlugin) BoxSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.BoxSelectionPlugin) CreateTransactionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.draw.CreateTransactionPlugin) FreeformSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.FreeformSelectionPlugin) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) CreateVertexPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.draw.CreateVertexPlugin) SimplePlugin(au.gov.asd.tac.constellation.plugins.templates.SimplePlugin)

Example 3 with IntArray

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);
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) IntArray(au.gov.asd.tac.constellation.utilities.graphics.IntArray) HashSet(java.util.HashSet)

Example 4 with IntArray

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);
}
Also used : IntArray(au.gov.asd.tac.constellation.utilities.graphics.IntArray) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 5 with IntArray

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();
}
Also used : FloatArray(au.gov.asd.tac.constellation.utilities.graphics.FloatArray) IntArray(au.gov.asd.tac.constellation.utilities.graphics.IntArray)

Aggregations

IntArray (au.gov.asd.tac.constellation.utilities.graphics.IntArray)5 HashSet (java.util.HashSet)2 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)1 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)1 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)1 CreateTransactionPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.draw.CreateTransactionPlugin)1 CreateVertexPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.draw.CreateVertexPlugin)1 BoxSelectionPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.select.BoxSelectionPlugin)1 FreeformSelectionPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.select.FreeformSelectionPlugin)1 PointSelectionPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.select.PointSelectionPlugin)1 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)1 SimplePlugin (au.gov.asd.tac.constellation.plugins.templates.SimplePlugin)1 FloatArray (au.gov.asd.tac.constellation.utilities.graphics.FloatArray)1 BeforeMethod (org.testng.annotations.BeforeMethod)1