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);
}
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");
}
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));
}
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);
}
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();
}
}
Aggregations