Search in sources :

Example 1 with VisualChangeBuilder

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

the class FlyingAnimation method animate.

@Override
public List<VisualChange> animate(GraphWriteMethods wg) {
    // dont animate unless there is more than 1 node
    if (wg.getVertexCount() > 1) {
        if (step >= stepsPerLink) {
            // Get the next p3 vertex.
            final Vector3f xyz = getNextVertex(wg, camera.getMix());
            // Remove the old p0 and add the new p3.
            xyzQueue.removeFirst();
            xyzQueue.addLast(xyz);
            // The first step between p1 and p2.
            step = 0;
        }
        // The four control points of the spline.
        final Iterator<Vector3f> it = xyzQueue.iterator();
        final float[] p0 = it.next().a;
        final float[] p1 = it.next().a;
        final float[] p2 = it.next().a;
        final float[] p3 = it.next().a;
        // Determine the new lookAt eye and center.
        final float t = step / (float) stepsPerLink;
        final float t1 = (step + 1) / (float) stepsPerLink;
        final float[] eye = new float[3];
        Mathf.catmullRom(eye, p0, p1, p2, p3, t);
        final float[] centre = new float[3];
        Mathf.catmullRom(centre, p0, p1, p2, p3, t1);
        camera.lookAtEye.set(eye[0], eye[1], eye[2]);
        camera.lookAtCentre.set(centre[0], centre[1], centre[2]);
        step++;
    }
    return Arrays.asList(new VisualChangeBuilder(VisualProperty.CAMERA).forItems(1).withId(flyingAnimationId).build());
}
Also used : VisualChangeBuilder(au.gov.asd.tac.constellation.utilities.visual.VisualChangeBuilder) Vector3f(au.gov.asd.tac.constellation.utilities.graphics.Vector3f)

Example 2 with VisualChangeBuilder

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

the class PanAnimation method animate.

@Override
public List<VisualChange> animate(GraphWriteMethods wg) {
    if (step <= STEPS) {
        final float t = step / (float) STEPS;
        final float mix = reflect(t);
        camera = new Camera(camera);
        camera.lookAtEye.set(Graphics3DUtilities.mix(from.lookAtEye, to.lookAtEye, mix));
        camera.lookAtCentre.set(Graphics3DUtilities.mix(from.lookAtCentre, to.lookAtCentre, mix));
        camera.lookAtUp.set(Graphics3DUtilities.mix(from.lookAtUp, to.lookAtUp, mix));
        camera.lookAtRotation.set(Graphics3DUtilities.mix(from.lookAtRotation, to.lookAtRotation, mix));
        wg.setObjectValue(cameraAttr, 0, camera);
        step++;
        return Arrays.asList(new VisualChangeBuilder(VisualProperty.CAMERA).forItems(1).withId(panAnimationId).build());
    } else {
        setFinished();
        return Collections.emptyList();
    }
}
Also used : VisualChangeBuilder(au.gov.asd.tac.constellation.utilities.visual.VisualChangeBuilder) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera)

Example 3 with VisualChangeBuilder

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

the class DefaultInteractionEventHandler method scheduleCameraChangeOperation.

private void scheduleCameraChangeOperation(final VisualOperation withOperation) {
    final VisualOperation cameraChange = manager.constructSingleChangeOperation(new VisualChangeBuilder(VisualProperty.CAMERA).forItems(1).withId(currentCameraChangeId).build());
    operationQueue.add(withOperation == null ? cameraChange : cameraChange.join(withOperation));
}
Also used : VisualChangeBuilder(au.gov.asd.tac.constellation.utilities.visual.VisualChangeBuilder) VisualOperation(au.gov.asd.tac.constellation.utilities.visual.VisualOperation)

Example 4 with VisualChangeBuilder

use of au.gov.asd.tac.constellation.utilities.visual.VisualChangeBuilder 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 5 with VisualChangeBuilder

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

the class GLVisualProcessorGraphTester method main.

public static void main(String[] args) {
    final GLVisualProcessorDemo demo = new GLVisualProcessorDemo();
    final StoreGraph graph = createGraph();
    final Graph dualGraph = new DualGraph(graph, false);
    final GraphVisualAccess access = new GraphVisualAccess(dualGraph);
    final GLVisualProcessor processor = new GLVisualProcessor();
    final VisualManager visualManager = new VisualManager(access, processor);
    processor.startVisualising(visualManager);
    demo.runDemo(processor, visualManager);
    final GraphChangeListener gct = (event) -> visualManager.updateFromIndigenousChanges();
    gct.graphChanged(null);
    try {
        Thread.sleep(3000);
    } catch (InterruptedException ex) {
    }
    try {
        WritableGraph wg = dualGraph.getWritableGraph("linkmode", false);
        try {
            final int connectionModeAttr = VisualConcept.GraphAttribute.CONNECTION_MODE.ensure(wg);
            wg.setObjectValue(connectionModeAttr, 0, ConnectionMode.LINK);
        } finally {
            wg.commit();
        }
    } catch (InterruptedException ex) {
    }
    gct.graphChanged(null);
    try {
        Thread.sleep(2000);
    } catch (InterruptedException ex) {
    }
    try {
        WritableGraph wg = dualGraph.getWritableGraph("transmode", false);
        try {
            final int connectionModeAttr = VisualConcept.GraphAttribute.CONNECTION_MODE.ensure(wg);
            wg.setObjectValue(connectionModeAttr, 0, ConnectionMode.TRANSACTION);
        } finally {
            wg.commit();
        }
    } catch (InterruptedException ex) {
    }
    gct.graphChanged(null);
    try {
        Thread.sleep(2000);
    } catch (InterruptedException ex) {
    }
    final int[] changed = new int[] { 0, 1 };
    try {
        WritableGraph wg = dualGraph.getWritableGraph("blazin", false);
        try {
            final int blazeAttr = VisualConcept.VertexAttribute.BLAZE.ensure(wg);
            for (int i = 0; i < 10000; i++) {
                try {
                    Thread.sleep(1);
                } catch (InterruptedException ex) {
                }
                wg.setObjectValue(blazeAttr, 0, new Blaze(((Blaze) wg.getObjectValue(blazeAttr, 0)).getAngle() + 1, ConstellationColor.BLUE));
                wg = wg.flush(false);
                visualManager.addSingleChangeOperation(new VisualChangeBuilder(VisualProperty.VERTEX_BLAZE_ANGLE).forItems(changed).build());
            }
        } finally {
            wg.commit();
        }
    } catch (InterruptedException ex) {
    }
}
Also used : WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Frame(java.awt.Frame) GLVisualProcessor(au.gov.asd.tac.constellation.visual.opengl.renderer.GLVisualProcessor) Blaze(au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.Blaze) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) DefaultIconProvider(au.gov.asd.tac.constellation.utilities.icon.DefaultIconProvider) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) WindowAdapter(java.awt.event.WindowAdapter) JFXPanel(javafx.embed.swing.JFXPanel) VisualConcept(au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept) Component(java.awt.Component) WindowEvent(java.awt.event.WindowEvent) VisualProcessor(au.gov.asd.tac.constellation.utilities.visual.VisualProcessor) VisualProperty(au.gov.asd.tac.constellation.utilities.visual.VisualProperty) Graph(au.gov.asd.tac.constellation.graph.Graph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) GraphChangeListener(au.gov.asd.tac.constellation.graph.monitor.GraphChangeListener) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) VisualChangeBuilder(au.gov.asd.tac.constellation.utilities.visual.VisualChangeBuilder) VisualManager(au.gov.asd.tac.constellation.utilities.visual.VisualManager) ConnectionMode(au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.ConnectionMode) GraphVisualAccess(au.gov.asd.tac.constellation.graph.visual.framework.GraphVisualAccess) VisualChangeBuilder(au.gov.asd.tac.constellation.utilities.visual.VisualChangeBuilder) GraphVisualAccess(au.gov.asd.tac.constellation.graph.visual.framework.GraphVisualAccess) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) VisualManager(au.gov.asd.tac.constellation.utilities.visual.VisualManager) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) GLVisualProcessor(au.gov.asd.tac.constellation.visual.opengl.renderer.GLVisualProcessor) GraphChangeListener(au.gov.asd.tac.constellation.graph.monitor.GraphChangeListener) Blaze(au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.Blaze) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph)

Aggregations

VisualChangeBuilder (au.gov.asd.tac.constellation.utilities.visual.VisualChangeBuilder)6 Camera (au.gov.asd.tac.constellation.utilities.camera.Camera)2 ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)2 VisualChange (au.gov.asd.tac.constellation.utilities.visual.VisualChange)2 VisualManager (au.gov.asd.tac.constellation.utilities.visual.VisualManager)2 GLVisualProcessor (au.gov.asd.tac.constellation.visual.opengl.renderer.GLVisualProcessor)2 ArrayList (java.util.ArrayList)2 Graph (au.gov.asd.tac.constellation.graph.Graph)1 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)1 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)1 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)1 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)1 GraphChangeListener (au.gov.asd.tac.constellation.graph.monitor.GraphChangeListener)1 Blaze (au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.Blaze)1 ConnectionMode (au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.ConnectionMode)1 VisualConcept (au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept)1 GraphVisualAccess (au.gov.asd.tac.constellation.graph.visual.framework.GraphVisualAccess)1 Vector3f (au.gov.asd.tac.constellation.utilities.graphics.Vector3f)1 DefaultIconProvider (au.gov.asd.tac.constellation.utilities.icon.DefaultIconProvider)1 VisualAccess (au.gov.asd.tac.constellation.utilities.visual.VisualAccess)1