Search in sources :

Example 1 with VisualChange

use of au.gov.asd.tac.constellation.utilities.visual.VisualChange in project constellation by constellation-app.

the class SceneBatcher method updateByteBufferTask.

public static GLRenderableUpdateTask updateByteBufferTask(final VisualChange change, final VisualAccess access, final ByteBufferOperation operation, final ByteBufferConnection connector, final BufferDisconnection disconnector, final boolean[] updateMask) {
    final int width = updateMask.length;
    final int numChanges = change.getSize();
    final ByteBuffer updateBuffer = Buffers.newDirectByteBuffer(width * numChanges);
    final int[] bufferUpdatePositions = new int[numChanges];
    int updatePos = 0;
    for (int i = 0; i < numChanges; i++) {
        int pos = change.getElement(i);
        final int updatedPosition = operation.buffer(pos, updateBuffer, access);
        if (updatedPosition >= 0) {
            bufferUpdatePositions[updatePos++] = updatedPosition;
        }
    }
    final int numUpdates = updatePos;
    updateBuffer.flip();
    return gl -> {
        final ByteBuffer buffer = connector.connect(gl);
        for (int i = 0; i < numUpdates; i++) {
            buffer.position(bufferUpdatePositions[i] * width);
            for (boolean update : updateMask) {
                if (update) {
                    buffer.put(updateBuffer.get());
                } else {
                    buffer.get();
                }
            }
        }
        disconnector.disconnect(gl);
    };
}
Also used : GLRenderableUpdateTask(au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask) Buffers(com.jogamp.common.nio.Buffers) Arrays(java.util.Arrays) GL3(com.jogamp.opengl.GL3) VisualAccess(au.gov.asd.tac.constellation.utilities.visual.VisualAccess) FloatBuffer(java.nio.FloatBuffer) IntBuffer(java.nio.IntBuffer) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) Matrix44f(au.gov.asd.tac.constellation.utilities.graphics.Matrix44f) IOException(java.io.IOException) VisualChange(au.gov.asd.tac.constellation.utilities.visual.VisualChange) ByteBuffer(java.nio.ByteBuffer) ByteBuffer(java.nio.ByteBuffer)

Example 2 with VisualChange

use of au.gov.asd.tac.constellation.utilities.visual.VisualChange in project constellation by constellation-app.

the class GraphVisualAccess method update.

private List<VisualChange> update(final boolean recordChanges) {
    final List<VisualChange> changes = new ArrayList<>();
    final long currentGlobalModCount = accessGraph.getGlobalModificationCounter();
    if (currentGlobalModCount != globalModCount) {
        if (recordChanges) {
            globalModCount = currentGlobalModCount;
        }
        long count;
        boolean attributesChanged = false;
        boolean verticesRebuilding = false;
        boolean connectionsRebuilding = false;
        // Handle structural changes
        count = accessGraph.getStructureModificationCounter();
        if (count != structureModCount) {
            connectionsRebuilding = true;
            verticesRebuilding = true;
            if (recordChanges) {
                structureModCount = count;
            }
        }
        // Handle attribute changes (as distinct from changes to attribute values).
        count = accessGraph.getAttributeModificationCounter();
        if (count != attributeModCount) {
            attributesChanged = true;
            recalculateVisualAttributes(accessGraph);
            if (recordChanges) {
                attributeModCount = count;
            }
        }
        // Handle changes to the connection mode
        count = graphConnectionMode == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphConnectionMode);
        if (!Objects.equals(count, modCounts.get(VisualConcept.GraphAttribute.CONNECTION_MODE))) {
            if (recordChanges) {
                modCounts.put(VisualConcept.GraphAttribute.CONNECTION_MODE, count);
            }
            recalculateConnectionMode(accessGraph);
            connectionsRebuilding = true;
        }
        // Handle changes to max transactions
        count = graphMaxTransactions == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphMaxTransactions);
        if (!Objects.equals(count, modCounts.get(VisualConcept.GraphAttribute.MAX_TRANSACTIONS))) {
            if (recordChanges) {
                modCounts.put(VisualConcept.GraphAttribute.MAX_TRANSACTIONS, count);
            }
            connectionsRebuilding = true;
        }
        // Handle changes to the graph's decorators attribute
        count = graphDecorators == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphDecorators);
        if (!Objects.equals(count, modCounts.get(VisualConcept.GraphAttribute.DECORATORS)) || attributesChanged) {
            final int oldNwDecorator = nwDecorator;
            final int oldNeDecorator = neDecorator;
            final int oldSeDecorator = seDecorator;
            final int oldSwDecorator = swDecorator;
            recalculateDecorators(accessGraph);
            if (recordChanges) {
                modCounts.put(VisualConcept.GraphAttribute.DECORATORS, count);
                if (oldNwDecorator != nwDecorator) {
                    changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_NW_DECORATOR).forItems(accessGraph.getVertexCount()).build());
                }
                if (oldNeDecorator != neDecorator) {
                    changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_NE_DECORATOR).forItems(accessGraph.getVertexCount()).build());
                }
                if (oldSeDecorator != seDecorator) {
                    changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_SE_DECORATOR).forItems(accessGraph.getVertexCount()).build());
                }
                if (oldSwDecorator != swDecorator) {
                    changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_SW_DECORATOR).forItems(accessGraph.getVertexCount()).build());
                }
            }
        }
        // Handle changes to the graph's decorators referred attributes
        if (recordChanges) {
            count = nwDecorator == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(nwDecorator);
            if (count != nwDecoratorModCount) {
                nwDecoratorModCount = count;
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_NW_DECORATOR).forItems(accessGraph.getVertexCount()).build());
            }
            count = neDecorator == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(neDecorator);
            if (count != neDecoratorModCount) {
                neDecoratorModCount = count;
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_NE_DECORATOR).forItems(accessGraph.getVertexCount()).build());
            }
            count = seDecorator == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(seDecorator);
            if (count != seDecoratorModCount) {
                seDecoratorModCount = count;
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_SE_DECORATOR).forItems(accessGraph.getVertexCount()).build());
            }
            count = swDecorator == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(swDecorator);
            if (count != swDecoratorModCount) {
                swDecoratorModCount = count;
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_SW_DECORATOR).forItems(accessGraph.getVertexCount()).build());
            }
        }
        // Handle changes to the graph's top label attribute
        count = graphTopLabels == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphTopLabels);
        final int[] oldTopLabels = Arrays.copyOf(topLabelAttrs, topLabelAttrs.length);
        if (!Objects.equals(count, modCounts.get(VisualConcept.GraphAttribute.TOP_LABELS)) || attributesChanged) {
            final ConstellationColor[] oldTopLabelColors = Arrays.copyOf(topLabelColors, topLabelColors.length);
            final float[] oldTopLabelSizes = Arrays.copyOf(topLabelSizes, topLabelSizes.length);
            recalculateTopLabels(accessGraph);
            if (recordChanges) {
                modCounts.put(VisualConcept.GraphAttribute.TOP_LABELS, count);
                if (!Arrays.equals(topLabelAttrs, oldTopLabels)) {
                    changes.add(new VisualChangeBuilder(VisualProperty.TOP_LABELS_REBUILD).build());
                }
                if (!Arrays.equals(topLabelSizes, oldTopLabelSizes)) {
                    changes.add(new VisualChangeBuilder(VisualProperty.TOP_LABEL_SIZE).forItems(topLabelAttrs.length).build());
                }
                if (!Arrays.equals(topLabelColors, oldTopLabelColors)) {
                    changes.add(new VisualChangeBuilder(VisualProperty.TOP_LABEL_COLOR).forItems(topLabelAttrs.length).build());
                }
            }
        }
        // Handle changes to the attributes referred to for the graph's top labels
        if (recordChanges) {
            boolean labelTextChanged = false;
            topLabelModCounts = Arrays.copyOf(topLabelModCounts, topLabelAttrs.length);
            for (int i = 0; i < topLabelAttrs.length; i++) {
                final int attr = topLabelAttrs[i];
                count = attr == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(attr);
                if (i >= oldTopLabels.length || attr != oldTopLabels[i] || count != topLabelModCounts[i]) {
                    topLabelModCounts[i] = count;
                    labelTextChanged = true;
                }
            }
            if (labelTextChanged) {
                changes.add(new VisualChangeBuilder(VisualProperty.TOP_LABEL_TEXT).forItems(accessGraph.getVertexCount() * topLabelAttrs.length).build());
            }
        }
        // Handle changes to the graph's bottom label attribute
        count = graphBottomLabels == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphBottomLabels);
        final int[] oldBottomLabels = Arrays.copyOf(bottomLabelAttrs, bottomLabelAttrs.length);
        if (!Objects.equals(count, modCounts.get(VisualConcept.GraphAttribute.BOTTOM_LABELS)) || attributesChanged) {
            final ConstellationColor[] oldBottomLabelColors = Arrays.copyOf(bottomLabelColors, bottomLabelColors.length);
            final float[] oldBottomLabelSizes = Arrays.copyOf(bottomLabelSizes, bottomLabelSizes.length);
            recalculateBottomLabels(accessGraph);
            if (recordChanges) {
                modCounts.put(VisualConcept.GraphAttribute.BOTTOM_LABELS, count);
                if (!Arrays.equals(bottomLabelAttrs, oldBottomLabels)) {
                    changes.add(new VisualChangeBuilder(VisualProperty.BOTTOM_LABELS_REBUILD).build());
                }
                if (!Arrays.equals(bottomLabelSizes, oldBottomLabelSizes)) {
                    changes.add(new VisualChangeBuilder(VisualProperty.BOTTOM_LABEL_SIZE).forItems(bottomLabelAttrs.length).build());
                }
                if (!Arrays.equals(bottomLabelColors, oldBottomLabelColors)) {
                    changes.add(new VisualChangeBuilder(VisualProperty.BOTTOM_LABEL_COLOR).forItems(bottomLabelAttrs.length).build());
                }
            }
        }
        // Handle changes to the attributes referred to for the graph's bottom labels
        if (recordChanges) {
            boolean labelTextChanged = false;
            bottomLabelModCounts = Arrays.copyOf(bottomLabelModCounts, bottomLabelAttrs.length);
            for (int i = 0; i < bottomLabelAttrs.length; i++) {
                final int attr = bottomLabelAttrs[i];
                count = attr == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(attr);
                if (i >= oldBottomLabels.length || attr != oldBottomLabels[i] || count != bottomLabelModCounts[i]) {
                    bottomLabelModCounts[i] = count;
                    labelTextChanged = true;
                }
            }
            if (labelTextChanged) {
                changes.add(new VisualChangeBuilder(VisualProperty.BOTTOM_LABEL_TEXT).forItems(accessGraph.getVertexCount() * bottomLabelAttrs.length).build());
            }
        }
        // Handle changes to the graph's connection label attribute
        count = graphConnectionLabels == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphConnectionLabels);
        final int[] oldConnectionLabels = Arrays.copyOf(connectionLabelAttrs, connectionLabelAttrs.length);
        if (!Objects.equals(count, modCounts.get(VisualConcept.GraphAttribute.TRANSACTION_LABELS)) || attributesChanged) {
            final ConstellationColor[] oldConnectionLabelColors = Arrays.copyOf(connectionLabelColors, connectionLabelColors.length);
            final float[] oldConnectionLabelSizes = Arrays.copyOf(connectionLabelSizes, connectionLabelSizes.length);
            recalculateConnectionLabels(accessGraph);
            if (recordChanges) {
                modCounts.put(VisualConcept.GraphAttribute.TRANSACTION_LABELS, count);
                if (!Arrays.equals(connectionLabelAttrs, oldConnectionLabels)) {
                    changes.add(new VisualChangeBuilder(VisualProperty.CONNECTION_LABELS_REBUILD).build());
                }
                if (!Arrays.equals(connectionLabelSizes, oldConnectionLabelSizes)) {
                    changes.add(new VisualChangeBuilder(VisualProperty.CONNECTION_LABEL_SIZE).forItems(connectionLabelAttrs.length).build());
                }
                if (!Arrays.equals(connectionLabelColors, oldConnectionLabelColors)) {
                    changes.add(new VisualChangeBuilder(VisualProperty.CONNECTION_LABEL_COLOR).forItems(connectionLabelAttrs.length).build());
                }
            }
        }
        // Handle changes to the attributes referred to for the graph's connection labels
        if (recordChanges) {
            boolean labelTextChanged = false;
            connectionLabelModCounts = Arrays.copyOf(connectionLabelModCounts, connectionLabelAttrs.length);
            for (int i = 0; i < connectionLabelAttrs.length; i++) {
                final int attr = connectionLabelAttrs[i];
                count = attr == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(attr);
                if (i >= oldConnectionLabels.length || attr != oldConnectionLabels[i] || count != connectionLabelModCounts[i]) {
                    connectionLabelModCounts[i] = count;
                    labelTextChanged = true;
                }
            }
            if (labelTextChanged) {
                changes.add(new VisualChangeBuilder(VisualProperty.CONNECTION_LABEL_TEXT).forItems(connectionElementTypes.length * connectionLabelAttrs.length).build());
            }
        }
        // Handle changes to the graph's referred vertex color attribute
        boolean vertexColorChanged = false;
        count = graphVertexColorRef == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphVertexColorRef);
        if (!Objects.equals(count, modCounts.get(VisualConcept.GraphAttribute.NODE_COLOR_REFERENCE)) || attributesChanged) {
            final int oldVertexColor = vertexColor;
            recalculateVertexColorAttribute(accessGraph);
            if (recordChanges) {
                modCounts.put(VisualConcept.GraphAttribute.NODE_COLOR_REFERENCE, count);
                vertexColorChanged = oldVertexColor != vertexColor;
            }
        }
        // Handle changes to vertex colors
        if (recordChanges) {
            count = vertexColor == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexColor);
            if (!Objects.equals(count, modCounts.put(VisualConcept.VertexAttribute.COLOR, count)) || vertexColorChanged) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_COLOR).forItems(accessGraph.getVertexCount()).build());
            }
        }
        // Handle changes to the graph's referred transaction color attribute
        boolean transactionColorChanged = false;
        count = graphTransactionColorRef == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphTransactionColorRef);
        if (!Objects.equals(count, modCounts.get(VisualConcept.GraphAttribute.TRANSACTION_COLOR_REFERENCE)) || attributesChanged) {
            final int oldTransactionColor = transactionColor;
            recalculateTransactionColorAttribute(accessGraph);
            if (recordChanges) {
                modCounts.put(VisualConcept.GraphAttribute.TRANSACTION_COLOR_REFERENCE, count);
                transactionColorChanged = oldTransactionColor != transactionColor;
            }
        }
        // Handle changes to transaction colors
        if (recordChanges) {
            count = transactionColor == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(transactionColor);
            if (!Objects.equals(count, modCounts.put(VisualConcept.TransactionAttribute.COLOR, count)) || transactionColorChanged) {
                changes.add(new VisualChangeBuilder(VisualProperty.CONNECTION_COLOR).forItems(connectionElementTypes.length).build());
            }
        }
        // Do all structural stuff
        if (verticesRebuilding || connectionsRebuilding) {
            recalculateStructure(accessGraph);
            if (recordChanges && verticesRebuilding) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTICES_REBUILD).build());
            }
            if (recordChanges && connectionsRebuilding) {
                changes.add(new VisualChangeBuilder(VisualProperty.CONNECTIONS_REBUILD).build());
            }
        }
        if (recordChanges) {
            // Handle changes to stand-alone graph visual attributes
            count = graphBackgroundColor == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphBackgroundColor);
            if (!Objects.equals(count, modCounts.put(VisualConcept.GraphAttribute.BACKGROUND_COLOR, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.BACKGROUND_COLOR).forItems(1).build());
            }
            count = graphHighlightColor == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphHighlightColor);
            if (!Objects.equals(count, modCounts.put(VisualConcept.GraphAttribute.HIGHLIGHT_COLOR, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.HIGHLIGHT_COLOUR).forItems(1).build());
            }
            count = graphBlazeOpacity == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphBlazeOpacity);
            if (!Objects.equals(count, modCounts.put(VisualConcept.GraphAttribute.BLAZE_OPACITY, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.BLAZE_OPACITY).forItems(1).build());
            }
            count = graphBlazeSize == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphBlazeSize);
            if (!Objects.equals(count, modCounts.put(VisualConcept.GraphAttribute.BLAZE_SIZE, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.BLAZE_SIZE).forItems(1).build());
            }
            count = graphConnectionOpacity == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphConnectionOpacity);
            if (!Objects.equals(count, modCounts.put(VisualConcept.GraphAttribute.CONNECTION_OPACITY, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.CONNECTIONS_OPACITY).forItems(1).build());
            }
            count = graphDrawFlags == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphDrawFlags);
            if (!Objects.equals(count, modCounts.put(VisualConcept.GraphAttribute.DRAW_FLAGS, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.DRAW_FLAGS).forItems(1).build());
            }
            count = graphCamera == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphCamera);
            if (!Objects.equals(count, modCounts.put(VisualConcept.GraphAttribute.CAMERA, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.CAMERA).forItems(1).build());
            }
            count = graphMixColor == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphMixColor);
            if (!Objects.equals(count, modCounts.put(VisualConcept.GraphAttribute.MIX_COLOR, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.CONNECTION_COLOR).forItems(connectionElementTypes.length).build());
            }
            count = graphVisibleAboveThreshold == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphVisibleAboveThreshold);
            if (!Objects.equals(count, modCounts.put(VisualConcept.GraphAttribute.VISIBLE_ABOVE_THRESHOLD, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VISIBLE_ABOVE_THRESHOLD).forItems(1).build());
            }
            count = graphVisibilityThreshold == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(graphVisibilityThreshold);
            if (!Objects.equals(count, modCounts.put(VisualConcept.GraphAttribute.VISIBILITY_THRESHOLD, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VISIBILITY_THRESHOLD).forItems(1).build());
            }
            // Handle stand-alone changes to vertex visual attributes
            count = vertexX == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexX);
            if (!Objects.equals(count, modCounts.put(VisualConcept.VertexAttribute.X, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_X).forItems(accessGraph.getVertexCount()).build());
            }
            count = vertexY == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexY);
            if (!Objects.equals(count, modCounts.put(VisualConcept.VertexAttribute.Y, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_Y).forItems(accessGraph.getVertexCount()).build());
            }
            count = vertexZ == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexZ);
            if (!Objects.equals(count, modCounts.put(VisualConcept.VertexAttribute.Z, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_Z).forItems(accessGraph.getVertexCount()).build());
            }
            count = vertexX2 == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexX2);
            if (!Objects.equals(count, modCounts.put(VisualConcept.VertexAttribute.X2, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_X2).forItems(accessGraph.getVertexCount()).build());
            }
            count = vertexY2 == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexY2);
            if (!Objects.equals(count, modCounts.put(VisualConcept.VertexAttribute.Y2, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_Y2).forItems(accessGraph.getVertexCount()).build());
            }
            count = vertexZ2 == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexZ2);
            if (!Objects.equals(count, modCounts.put(VisualConcept.VertexAttribute.Z2, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_Z2).forItems(accessGraph.getVertexCount()).build());
            }
            count = vertexBackgroundIcon == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexBackgroundIcon);
            if (!Objects.equals(count, modCounts.put(VisualConcept.VertexAttribute.BACKGROUND_ICON, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_BACKGROUND_ICON).forItems(accessGraph.getVertexCount()).build());
            }
            count = vertexForegroundIcon == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexForegroundIcon);
            if (!Objects.equals(count, modCounts.put(VisualConcept.VertexAttribute.FOREGROUND_ICON, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_FOREGROUND_ICON).forItems(accessGraph.getVertexCount()).build());
            }
            count = vertexSelected == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexSelected);
            if (!Objects.equals(count, modCounts.put(VisualConcept.VertexAttribute.SELECTED, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_SELECTED).forItems(accessGraph.getVertexCount()).build());
            }
            count = vertexVisibility == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexVisibility);
            if (!Objects.equals(count, modCounts.put(VisualConcept.VertexAttribute.VISIBILITY, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_VISIBILITY).forItems(accessGraph.getVertexCount()).build());
            }
            count = vertexLayerVisibility == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexLayerVisibility);
            if (!Objects.equals(count, modCounts.put(LayersConcept.VertexAttribute.LAYER_VISIBILITY, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_VISIBILITY).forItems(accessGraph.getVertexCount()).build());
            }
            count = vertexDimmed == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexDimmed);
            if (!Objects.equals(count, modCounts.put(VisualConcept.VertexAttribute.DIMMED, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_DIM).forItems(accessGraph.getVertexCount()).build());
            }
            count = vertexRadius == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexRadius);
            if (!Objects.equals(count, modCounts.put(VisualConcept.VertexAttribute.NODE_RADIUS, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_RADIUS).forItems(accessGraph.getVertexCount()).build());
            }
            count = vertexBlaze == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(vertexBlaze);
            if (!Objects.equals(count, modCounts.put(VisualConcept.VertexAttribute.BLAZE, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_BLAZED).forItems(accessGraph.getVertexCount()).build());
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_BLAZE_ANGLE).forItems(accessGraph.getVertexCount()).build());
                changes.add(new VisualChangeBuilder(VisualProperty.VERTEX_BLAZE_COLOR).forItems(accessGraph.getVertexCount()).build());
            }
            // Handle stand-alone changes to transaction visual attributes
            count = transactionSelected == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(transactionSelected);
            if (!Objects.equals(count, modCounts.put(VisualConcept.TransactionAttribute.SELECTED, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.CONNECTION_SELECTED).forItems(connectionElementTypes.length).build());
            }
            count = transactionDirected == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(transactionDirected);
            if (!Objects.equals(count, modCounts.put(VisualConcept.TransactionAttribute.DIRECTED, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.CONNECTION_DIRECTED).forItems(connectionElementTypes.length).build());
            }
            count = transactionVisibility == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(transactionVisibility);
            if (!Objects.equals(count, modCounts.put(VisualConcept.TransactionAttribute.VISIBILITY, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.CONNECTION_VISIBILITY).forItems(connectionElementTypes.length).build());
            }
            count = transactionLayerVisibility == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(transactionLayerVisibility);
            if (!Objects.equals(count, modCounts.put(LayersConcept.TransactionAttribute.LAYER_VISIBILITY, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.CONNECTION_VISIBILITY).forItems(connectionElementTypes.length).build());
            }
            count = transactionDimmed == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(transactionDimmed);
            if (!Objects.equals(count, modCounts.put(VisualConcept.TransactionAttribute.DIMMED, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.CONNECTION_DIM).forItems(connectionElementTypes.length).build());
            }
            count = transactionLineStyle == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(transactionLineStyle);
            if (!Objects.equals(count, modCounts.put(VisualConcept.TransactionAttribute.LINE_STYLE, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.CONNECTION_LINESTYLE).forItems(connectionElementTypes.length).build());
            }
            count = transactionWidth == Graph.NOT_FOUND ? -1 : accessGraph.getValueModificationCounter(transactionWidth);
            if (!Objects.equals(count, modCounts.put(VisualConcept.TransactionAttribute.WIDTH, count))) {
                changes.add(new VisualChangeBuilder(VisualProperty.CONNECTION_WIDTH).forItems(connectionElementTypes.length).build());
            }
        }
    }
    return changes;
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) VisualChangeBuilder(au.gov.asd.tac.constellation.utilities.visual.VisualChangeBuilder) ArrayList(java.util.ArrayList) VisualChange(au.gov.asd.tac.constellation.utilities.visual.VisualChange)

Example 3 with VisualChange

use of au.gov.asd.tac.constellation.utilities.visual.VisualChange in project constellation by constellation-app.

the class SceneBatcher method updateIntBufferTask.

public static GLRenderableUpdateTask updateIntBufferTask(final VisualChange change, final VisualAccess access, final IntBufferOperation operation, final IntBufferConnection connector, final BufferDisconnection disconnector, final boolean[] updateMask) {
    final int width = updateMask.length;
    final int numChanges = change.getSize();
    final IntBuffer updateBuffer = Buffers.newDirectIntBuffer(width * numChanges);
    final int[] bufferUpdatePositions = new int[numChanges];
    int updatePos = 0;
    for (int i = 0; i < numChanges; i++) {
        int pos = change.getElement(i);
        final int updatedPosition = operation.buffer(pos, updateBuffer, access);
        if (updatedPosition >= 0) {
            bufferUpdatePositions[updatePos++] = updatedPosition;
        }
    }
    final int numUpdates = updatePos;
    updateBuffer.flip();
    return gl -> {
        final IntBuffer buffer = connector.connect(gl);
        for (int i = 0; i < numUpdates; i++) {
            buffer.position(bufferUpdatePositions[i] * width);
            for (boolean update : updateMask) {
                if (update) {
                    buffer.put(updateBuffer.get());
                } else {
                    buffer.get();
                }
            }
        }
        disconnector.disconnect(gl);
    };
}
Also used : GLRenderableUpdateTask(au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask) Buffers(com.jogamp.common.nio.Buffers) Arrays(java.util.Arrays) GL3(com.jogamp.opengl.GL3) VisualAccess(au.gov.asd.tac.constellation.utilities.visual.VisualAccess) FloatBuffer(java.nio.FloatBuffer) IntBuffer(java.nio.IntBuffer) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) Matrix44f(au.gov.asd.tac.constellation.utilities.graphics.Matrix44f) IOException(java.io.IOException) VisualChange(au.gov.asd.tac.constellation.utilities.visual.VisualChange) ByteBuffer(java.nio.ByteBuffer) IntBuffer(java.nio.IntBuffer)

Example 4 with VisualChange

use of au.gov.asd.tac.constellation.utilities.visual.VisualChange in project constellation by constellation-app.

the class SceneBatcher method updateFloatBufferTask.

public static GLRenderableUpdateTask updateFloatBufferTask(final VisualChange change, final VisualAccess access, final FloatBufferOperation operation, final FloatBufferConnection connector, final BufferDisconnection disconnector, final boolean[] updateMask) {
    final int width = updateMask.length;
    final int numChanges = change.getSize();
    final FloatBuffer updateBuffer = Buffers.newDirectFloatBuffer(width * numChanges);
    final int[] bufferUpdatePositions = new int[numChanges];
    int updatePos = 0;
    for (int i = 0; i < numChanges; i++) {
        int pos = change.getElement(i);
        final int updatedPosition = operation.buffer(pos, updateBuffer, access);
        if (updatedPosition >= 0) {
            bufferUpdatePositions[updatePos++] = updatedPosition;
        }
    }
    final int numUpdates = updatePos;
    updateBuffer.flip();
    return gl -> {
        final FloatBuffer buffer = connector.connect(gl);
        for (int i = 0; i < numUpdates; i++) {
            buffer.position(bufferUpdatePositions[i] * width);
            for (boolean update : updateMask) {
                if (update) {
                    buffer.put(updateBuffer.get());
                } else {
                    buffer.get();
                }
            }
        }
        disconnector.disconnect(gl);
    };
}
Also used : GLRenderableUpdateTask(au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask) Buffers(com.jogamp.common.nio.Buffers) Arrays(java.util.Arrays) GL3(com.jogamp.opengl.GL3) VisualAccess(au.gov.asd.tac.constellation.utilities.visual.VisualAccess) FloatBuffer(java.nio.FloatBuffer) IntBuffer(java.nio.IntBuffer) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) Matrix44f(au.gov.asd.tac.constellation.utilities.graphics.Matrix44f) IOException(java.io.IOException) VisualChange(au.gov.asd.tac.constellation.utilities.visual.VisualChange) ByteBuffer(java.nio.ByteBuffer) FloatBuffer(java.nio.FloatBuffer)

Example 5 with VisualChange

use of au.gov.asd.tac.constellation.utilities.visual.VisualChange in project constellation by constellation-app.

the class GLVisualProcessorTester method main.

public static void main(String[] args) {
    final GLVisualProcessorDemo demo = new GLVisualProcessorDemo();
    final VisualAccess access = new DummyVisualAccess();
    final GLVisualProcessor processor = new GLVisualProcessor();
    final VisualManager visualManager = new VisualManager(access, processor);
    processor.startVisualising(visualManager);
    demo.runDemo(processor, visualManager);
    final List<VisualChange> changeSet = new ArrayList<>();
    changeSet.add(new VisualChangeBuilder(VisualProperty.VERTICES_REBUILD).build());
    changeSet.add(new VisualChangeBuilder(VisualProperty.CONNECTIONS_REBUILD).build());
    changeSet.add(new VisualChangeBuilder(VisualProperty.BACKGROUND_COLOR).build());
    changeSet.add(new VisualChangeBuilder(VisualProperty.HIGHLIGHT_COLOUR).build());
    changeSet.add(new VisualChangeBuilder(VisualProperty.CONNECTIONS_OPACITY).build());
    changeSet.add(new VisualChangeBuilder(VisualProperty.BLAZE_SIZE).build());
    changeSet.add(new VisualChangeBuilder(VisualProperty.DRAW_FLAGS).build());
    changeSet.add(new VisualChangeBuilder(VisualProperty.CAMERA).build());
    changeSet.add(new VisualChangeBuilder(VisualProperty.TOP_LABELS_REBUILD).build());
    changeSet.add(new VisualChangeBuilder(VisualProperty.BOTTOM_LABELS_REBUILD).build());
    changeSet.add(new VisualChangeBuilder(VisualProperty.CONNECTION_LABELS_REBUILD).build());
    visualManager.addMultiChangeOperation(changeSet);
    try {
        Thread.sleep(3000);
    } catch (InterruptedException ex) {
    }
    for (int i = 0; i < 10; i++) {
        ((DummyVisualAccess) access).zoomOut();
        visualManager.addSingleChangeOperation(new VisualChangeBuilder(VisualProperty.CAMERA).build());
        try {
            Thread.sleep(250);
        } catch (InterruptedException ex) {
        }
    }
}
Also used : VisualManager(au.gov.asd.tac.constellation.utilities.visual.VisualManager) VisualChangeBuilder(au.gov.asd.tac.constellation.utilities.visual.VisualChangeBuilder) GLVisualProcessor(au.gov.asd.tac.constellation.visual.opengl.renderer.GLVisualProcessor) ArrayList(java.util.ArrayList) VisualAccess(au.gov.asd.tac.constellation.utilities.visual.VisualAccess) VisualChange(au.gov.asd.tac.constellation.utilities.visual.VisualChange)

Aggregations

VisualChange (au.gov.asd.tac.constellation.utilities.visual.VisualChange)5 VisualAccess (au.gov.asd.tac.constellation.utilities.visual.VisualAccess)4 Camera (au.gov.asd.tac.constellation.utilities.camera.Camera)3 Matrix44f (au.gov.asd.tac.constellation.utilities.graphics.Matrix44f)3 GLRenderableUpdateTask (au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask)3 Buffers (com.jogamp.common.nio.Buffers)3 GL3 (com.jogamp.opengl.GL3)3 IOException (java.io.IOException)3 ByteBuffer (java.nio.ByteBuffer)3 FloatBuffer (java.nio.FloatBuffer)3 IntBuffer (java.nio.IntBuffer)3 Arrays (java.util.Arrays)3 VisualChangeBuilder (au.gov.asd.tac.constellation.utilities.visual.VisualChangeBuilder)2 ArrayList (java.util.ArrayList)2 ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)1 VisualManager (au.gov.asd.tac.constellation.utilities.visual.VisualManager)1 GLVisualProcessor (au.gov.asd.tac.constellation.visual.opengl.renderer.GLVisualProcessor)1