Search in sources :

Example 1 with DrawFlags

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

the class GraphVisualAccessNGTest method testGetDrawFlagsAttributeNotFound.

/**
 * Test of getDrawFlags method when attribute is not found, of class
 * GraphVisualAccess.
 *
 * @throws InterruptedException
 */
@Test
public void testGetDrawFlagsAttributeNotFound() throws InterruptedException {
    System.out.println("getDrawFlagsAttributeNotFound");
    final GraphVisualAccess instance = new GraphVisualAccess(graph);
    instance.beginUpdate();
    final DrawFlags flags = instance.getDrawFlags();
    instance.endUpdate();
    assertEquals(flags, VisualGraphDefaults.DEFAULT_DRAW_FLAGS);
}
Also used : DrawFlags(au.gov.asd.tac.constellation.utilities.visual.DrawFlags) Test(org.testng.annotations.Test)

Example 2 with DrawFlags

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

the class DrawFlagsModeAttributeInteractionNGTest method testGetDisplayText.

/**
 * Test of getDisplayText method, of class DrawFlagsModeAttributeInteraction.
 */
@Test
public void testGetDisplayText() {
    System.out.println("getDisplayText");
    final DrawFlagsModeAttributeInteraction instance = new DrawFlagsModeAttributeInteraction();
    final String nullResult = instance.getDisplayText(null);
    assertNull(nullResult);
    final DrawFlags flags = new DrawFlags(25);
    final String namedResult = instance.getDisplayText(flags);
    assertEquals(namedResult, "nodes: true; connections: false; node_labels: false; connection_labels: true; blazes: true");
}
Also used : DrawFlags(au.gov.asd.tac.constellation.utilities.visual.DrawFlags) Test(org.testng.annotations.Test)

Example 3 with DrawFlags

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

the class DrawFlagsAttributeDescriptionNGTest method testConvertFromString.

/**
 * Test of convertFromString method, of class DrawFlagsAttributeDescription.
 */
@Test
public void testConvertFromString() {
    System.out.println("convertFromString");
    final DrawFlagsAttributeDescription instance = new DrawFlagsAttributeDescription();
    final DrawFlags nullResult = instance.convertFromString(null);
    // should be the default here
    assertEquals(nullResult, DrawFlags.ALL);
    final DrawFlags blankResult = instance.convertFromString("   ");
    // should be the default here as well
    assertEquals(blankResult, DrawFlags.ALL);
    final DrawFlags validResult = instance.convertFromString("3");
    assertEquals(validResult, new DrawFlags(3));
}
Also used : DrawFlags(au.gov.asd.tac.constellation.utilities.visual.DrawFlags) Test(org.testng.annotations.Test)

Example 4 with DrawFlags

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

the class DrawFlagsIOProviderNGTest method testReadObject.

/**
 * Test of readObject method, of class DrawFlagsIOProvider.
 */
@Test
public void testReadObject() throws Exception {
    System.out.println("DrawFlagsIOProviderNGTest.testReadObject");
    // isNull returns true, default flags returned
    resetMocking();
    when(mockJsonNode.isNull()).thenReturn(true);
    when(mockGraphWriteMethods.getAttributeDefaultValue(anyInt())).thenReturn(new DrawFlags(flagId));
    instance.readObject(attributeId, elementId, mockJsonNode, mockGraphWriteMethods, null, null, null, null);
    Mockito.verify(mockGraphWriteMethods, times(1)).getAttributeDefaultValue(attributeId);
    Mockito.verify(mockGraphWriteMethods, times(1)).setIntValue(attributeId, elementId, flagId);
    // isNull returns false, flag value returned from node
    resetMocking();
    when(mockJsonNode.isNull()).thenReturn(false);
    when(mockJsonNode.intValue()).thenReturn(flagId);
    instance.readObject(attributeId, elementId, mockJsonNode, mockGraphWriteMethods, null, null, null, null);
    Mockito.verify(mockGraphWriteMethods, times(0)).getAttributeDefaultValue(anyInt());
    Mockito.verify(mockGraphWriteMethods, times(1)).setIntValue(attributeId, elementId, flagId);
}
Also used : DrawFlags(au.gov.asd.tac.constellation.utilities.visual.DrawFlags) Test(org.testng.annotations.Test)

Example 5 with DrawFlags

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

the class VisualGraphTopComponent method visualUpdate.

private void visualUpdate() {
    final ReadableGraph rg = graph.getReadableGraph();
    try {
        final int drawFlagsAttribute = VisualConcept.GraphAttribute.DRAW_FLAGS.get(rg);
        final int visibleAboveThresholdAttribute = VisualConcept.GraphAttribute.VISIBLE_ABOVE_THRESHOLD.get(rg);
        final int displayModeIs3DAttribute = VisualConcept.GraphAttribute.DISPLAY_MODE_3D.get(rg);
        final int drawingModeAttribute = VisualConcept.GraphAttribute.DRAWING_MODE.get(rg);
        final int drawDirectedAttribute = VisualConcept.GraphAttribute.DRAW_DIRECTED_TRANSACTIONS.get(rg);
        final int connectionModeAttribute = VisualConcept.GraphAttribute.CONNECTION_MODE.get(rg);
        // Read relevant visual attributes from the graph and update the sidebar.
        final DrawFlags drawFlags;
        final ConnectionMode connectionMode;
        final boolean visibleAboveThreshold;
        final boolean isDisplay3D;
        final boolean isDrawingMode;
        final boolean isDrawingDirectedTransactions;
        drawFlags = drawFlagsAttribute != Graph.NOT_FOUND ? rg.getObjectValue(drawFlagsAttribute, 0) : VisualGraphDefaults.DEFAULT_DRAW_FLAGS;
        visibleAboveThreshold = visibleAboveThresholdAttribute != Graph.NOT_FOUND ? rg.getBooleanValue(visibleAboveThresholdAttribute, 0) : VisualGraphDefaults.DEFAULT_GRAPH_VISIBILITY;
        isDisplay3D = displayModeIs3DAttribute != Graph.NOT_FOUND ? rg.getBooleanValue(displayModeIs3DAttribute, 0) : VisualGraphDefaults.DEFAULT_DISPLAY_MODE_3D;
        isDrawingMode = drawingModeAttribute != Graph.NOT_FOUND ? rg.getBooleanValue(drawingModeAttribute, 0) : VisualGraphDefaults.DEFAULT_DRAWING_MODE;
        isDrawingDirectedTransactions = drawDirectedAttribute != Graph.NOT_FOUND ? rg.getBooleanValue(drawDirectedAttribute, 0) : VisualGraphDefaults.DEFAULT_DRAWING_DIRECTED_TRANSACTIONS;
        connectionMode = connectionModeAttribute != Graph.NOT_FOUND ? rg.getObjectValue(connectionModeAttribute, 0) : VisualGraphDefaults.DEFAULT_CONNECTION_MODE;
        drawNodesAction.putValue(Action.SELECTED_KEY, drawFlags.drawNodes());
        drawConnectionsAction.putValue(Action.SELECTED_KEY, drawFlags.drawConnections());
        drawNodeLabelsAction.putValue(Action.SELECTED_KEY, drawFlags.drawNodeLabels());
        drawNodeLabelsAction.putValue(Action.SHORT_DESCRIPTION, drawFlags.drawNodeLabels() ? HIDE_NODE_LABELS_SHORT_DESCRIPTION : SHOW_NODE_LABELS_SHORT_DESCRIPTION);
        drawConnectionLabelsAction.putValue(Action.SELECTED_KEY, drawFlags.drawConnectionLabels());
        drawConnectionLabelsAction.putValue(Action.SHORT_DESCRIPTION, drawFlags.drawConnectionLabels() ? HIDE_CONNECTION_LABELS_SHORT_DESCRIPTION : SHOW_CONNECTION_LABELS_SHORT_DESCRIPTION);
        drawBlazesAction.putValue(Action.SELECTED_KEY, drawFlags.drawBlazes());
        drawBlazesAction.putValue(Action.SHORT_DESCRIPTION, drawFlags.drawBlazes() ? HIDE_BLAZES_SHORT_DESCRIPTION : SHOW_BLAZES_SHORT_DESCRIPTION);
        display3dAction.putValue(Action.SELECTED_KEY, isDisplay3D);
        display3dAction.putValue(Action.SMALL_ICON, isDisplay3D ? MODE_3D_ICON : MODE_2D_ICON);
        display3dAction.putValue(Action.SHORT_DESCRIPTION, isDisplay3D ? MODE_3D_SHORT_DESCRIPTION : MODE_2D_SHORT_DESCRIPTION);
        toggleGraphVisibilityAction.putValue(Action.SELECTED_KEY, visibleAboveThreshold);
        toggleGraphVisibilityAction.putValue(Action.SMALL_ICON, visibleAboveThreshold ? VISIBLE_ICON : HIDDEN_ICON);
        toggleGraphVisibilityAction.putValue(Action.SHORT_DESCRIPTION, visibleAboveThreshold ? DISABLE_GRAPH_VISIBILITY_THRESHOLD_LABELS_SHORT_DESCRIPTION : ENABLE_GRAPH_VISIBILITY_THRESHOLD_LABELS_SHORT_DESCRIPTION);
        toggleSelectModeAction.putValue(Action.SELECTED_KEY, isDrawingMode);
        toggleSelectModeAction.putValue(Action.SMALL_ICON, isDrawingMode ? DRAWING_MODE_ICON : SELECT_MODE_ICON);
        toggleSelectModeAction.putValue(Action.SHORT_DESCRIPTION, isDrawingMode ? DRAWING_MODE_SHORT_DESCRIPTION : SELECTION_MODE_SHORT_DESCRIPTION);
        toggleDrawDirectedAction.putValue(Action.SELECTED_KEY, isDrawingDirectedTransactions);
        toggleDrawDirectedAction.putValue(Action.SMALL_ICON, isDrawingDirectedTransactions ? DIRECTED_ICON : UNDIRECTED_ICON);
        toggleDrawDirectedAction.putValue(Action.SHORT_DESCRIPTION, isDrawingDirectedTransactions ? DIRECTED_SHORT_DESCRIPTION : UNDIRECTED_SHORT_DESCRIPTION);
        toggleDrawDirectedAction.setEnabled(isDrawingMode);
        switch(connectionMode) {
            case LINK:
                drawLinksAction.putValue(Action.SELECTED_KEY, true);
                break;
            case EDGE:
                drawEdgesAction.putValue(Action.SELECTED_KEY, true);
                break;
            case TRANSACTION:
                drawTransactionsAction.putValue(Action.SELECTED_KEY, true);
                break;
            default:
                throw new IllegalStateException("Unknown ConnectionMode: " + connectionMode);
        }
    } finally {
        rg.release();
    }
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) ConnectionMode(au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.ConnectionMode) DrawFlags(au.gov.asd.tac.constellation.utilities.visual.DrawFlags)

Aggregations

DrawFlags (au.gov.asd.tac.constellation.utilities.visual.DrawFlags)6 Test (org.testng.annotations.Test)5 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)1 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)1 ConnectionMode (au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.ConnectionMode)1