use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.
the class GraphVisualAccess method getConnectionColor.
@Override
public ConstellationColor getConnectionColor(final int connection) {
ConstellationColor color = null;
final ConstellationColor mixColor;
if (transactionColor != Graph.NOT_FOUND) {
switch(connectionElementTypes[connection]) {
case LINK:
final int linkId = connectionElementIds[connection];
mixColor = graphMixColor != Graph.NOT_FOUND ? accessGraph.getObjectValue(graphMixColor, 0) : VisualGraphDefaults.DEFAULT_MIX_COLOR;
for (int i = 0; i < accessGraph.getLinkTransactionCount(linkId); i++) {
final int transactionId = accessGraph.getLinkTransaction(linkId, i);
final ConstellationColor transColor = accessGraph.getObjectValue(transactionColor, transactionId);
if (color != null && !color.equals(transColor)) {
color = mixColor;
} else {
color = transColor;
}
}
break;
case EDGE:
final int edgeId = connectionElementIds[connection];
mixColor = graphMixColor != Graph.NOT_FOUND ? accessGraph.getObjectValue(graphMixColor, 0) : VisualGraphDefaults.DEFAULT_MIX_COLOR;
for (int i = 0; i < accessGraph.getEdgeTransactionCount(edgeId); i++) {
final int transactionId = accessGraph.getEdgeTransaction(edgeId, i);
final ConstellationColor transColor = accessGraph.getObjectValue(transactionColor, transactionId);
if (color != null && !color.equals(transColor)) {
color = mixColor;
} else {
color = transColor;
}
}
break;
case TRANSACTION:
default:
color = accessGraph.getObjectValue(transactionColor, connectionElementIds[connection]);
break;
}
}
return color != null ? color : VisualGraphDefaults.DEFAULT_TRANSACTION_COLOR;
}
use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.
the class BlazeActions method updateCustomBlazes.
private void updateCustomBlazes() {
for (int idx = 0; idx < BlazeUtilities.MAXIMUM_CUSTOM_BLAZE_COLORS; idx++) {
this.presetCustomBlazeItems[BlazeActions.getPresetCustomColors().size() - 1].setVisible(false);
}
final List<ConstellationColor> colors = getPresetCustomColors();
if (colors != null) {
int panelCounter = 0;
for (final JPanel panel : colorPanels) {
if (panelCounter < colors.size()) {
if (colors.get(panelCounter) != null) {
panel.setBackground(colors.get(panelCounter).getJavaColor());
}
}
panelCounter++;
}
}
setBlazeItems(BlazeActions.getPresetCustomColors(), this.presetCustomBlazeItems);
}
use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor 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;
}
use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.
the class BlazeActions method actionPerformed.
@Override
public void actionPerformed(final ActionEvent e) {
final String command = e.getActionCommand();
final Plugin plugin;
final PluginParameters parameters;
final Pair<BitSet, ConstellationColor> selectionResult = BlazeUtilities.getSelection(graph, null);
switch(command) {
case ADD_CUSTOM_BLAZE_ACTION:
final Pair<Boolean, ConstellationColor> colorResult = BlazeUtilities.colorDialog(selectionResult.getValue());
if (colorResult.getKey()) {
final ConstellationColor color = colorResult.getValue();
plugin = PluginRegistry.get(VisualGraphPluginRegistry.ADD_CUSTOM_BLAZE);
parameters = DefaultPluginParameters.getDefaultParameters(plugin);
parameters.getParameters().get(BlazeUtilities.VERTEX_IDS_PARAMETER_ID).setObjectValue(selectionResult.getKey());
parameters.getParameters().get(BlazeUtilities.COLOR_PARAMETER_ID).setColorValue(color);
PluginExecution.withPlugin(plugin).withParameters(parameters).executeLater(graph);
}
break;
case SELECT_BLAZES_ACTION:
PluginExecution.withPlugin(VisualGraphPluginRegistry.SELECT_BLAZES).executeLater(graph);
break;
case DESELECT_BLAZES_ACTION:
PluginExecution.withPlugin(VisualGraphPluginRegistry.DESELECT_BLAZES).executeLater(graph);
break;
case REMOVE_BLAZES_ACTION:
plugin = PluginRegistry.get(VisualGraphPluginRegistry.REMOVE_BLAZE);
parameters = DefaultPluginParameters.getDefaultParameters(plugin);
parameters.getParameters().get(BlazeUtilities.VERTEX_IDS_PARAMETER_ID).setObjectValue(selectionResult.getKey());
PluginExecution.withPlugin(plugin).withParameters(parameters).executeLater(graph);
break;
default:
// ADD_PRESET_BLAZE_ACTION has the string representation of the color
if (command.startsWith(ADD_PRESET_BLAZE_ACTION)) {
final String colorValStr = command.replaceFirst(ADD_PRESET_BLAZE_ACTION, "");
final ConstellationColor color = ConstellationColor.fromHtmlColor(colorValStr) == null ? ConstellationColor.getColorValue(colorValStr) : ConstellationColor.fromHtmlColor(colorValStr);
plugin = PluginRegistry.get(VisualGraphPluginRegistry.ADD_CUSTOM_BLAZE);
parameters = DefaultPluginParameters.getDefaultParameters(plugin);
parameters.getParameters().get(BlazeUtilities.VERTEX_IDS_PARAMETER_ID).setObjectValue(selectionResult.getKey());
parameters.getParameters().get(BlazeUtilities.COLOR_PARAMETER_ID).setColorValue(color);
PluginExecution.withPlugin(plugin).withParameters(parameters).executeLater(graph);
}
break;
}
}
use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.
the class BlazeActions method setBlazeItems.
/**
* Set the items for the JMenuItem blazeItems with the colors passed in
* throught the colors parameter.
*
* @param colors - the colors to set in the menu
* @param blazeItems - the menu item to set the color of
*/
private void setBlazeItems(final List<ConstellationColor> colors, final JMenuItem[] blazeItems) {
Collections.reverse(colors);
int idx = 0;
for (final ConstellationColor color : colors) {
if (color != null) {
final Color javaColor = color.getJavaColor();
String colorName = "#" + String.format("%02x", javaColor.getRed()) + String.format("%02x", javaColor.getGreen()) + String.format("%02x", javaColor.getBlue());
if (color.getName() != null) {
colorName = color.getName();
}
blazeItems[BlazeUtilities.MAXIMUM_CUSTOM_BLAZE_COLORS - idx - 1].setText(colorName);
blazeItems[BlazeUtilities.MAXIMUM_CUSTOM_BLAZE_COLORS - idx - 1].setActionCommand(ADD_PRESET_BLAZE_ACTION + colorName);
blazeItems[BlazeUtilities.MAXIMUM_CUSTOM_BLAZE_COLORS - idx - 1].setVisible(true);
blazeItems[BlazeUtilities.MAXIMUM_CUSTOM_BLAZE_COLORS - idx - 1].setIcon(generateCustomImage(javaColor));
idx++;
}
}
}
Aggregations