use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.
the class ColorPropertyEditor method getCustomEditor.
@Override
public Component getCustomEditor() {
final ConstellationColor cv = (ConstellationColor) getValue();
final Color currentColor = cv != null ? new Color(cv.getRed(), cv.getGreen(), cv.getBlue(), cv.getAlpha()) : Color.BLUE;
chooser.setColor(currentColor);
final DialogDescriptor dd = new DialogDescriptor(chooser, NbBundle.getMessage(ColorPropertyEditor.class, "MSG_SelectColor"), true, this);
return DialogDisplayer.getDefault().createDialog(dd);
}
use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.
the class ColorCriteriaPanel method updateColor.
/**
* Handles any change to the current color.
* <p>
* This method handles GUI updates to ensure that the GUI correctly
* represents the current selected color.
*
* @param color The new color to handle.
* @see Color
*/
private void updateColor(final Color color) {
// Get most current selected color from the chooser:
final ConstellationColor cv = ConstellationColor.fromJavaColor(color);
// Get the color's text value:
final String text = cv.getName() != null ? cv.getName() : String.format("r=%s g=%s b=%s a=%s", formatFloat(cv.getRed()), formatFloat(cv.getGreen()), formatFloat(cv.getBlue()), formatFloat(cv.getAlpha()));
// Update the background color of the color display:
lblColor.setBackground(color);
// Set the text of the color label:
lblColorText.setText(text);
// Things have changed, so save the state to the graph:
parentPanel.saveStateToGraph();
}
use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.
the class CompareGraphPlugin method read.
@Override
protected void read(final GraphReadMethods graph, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
final String originalGraphName = parameters.getParameters().get(ORIGINAL_GRAPH_PARAMETER_ID).getStringValue();
final String compareGraphName = parameters.getParameters().get(COMPARE_GRAPH_PARAMETER_ID).getStringValue();
if (originalGraphName == null || compareGraphName == null) {
throw new PluginException(PluginNotificationLevel.ERROR, "You must choose two graphs to compare");
}
final List<String> ignoreVertexAttributes = new ArrayList<>(parameters.getParameters().get(IGNORE_VERTEX_ATTRIBUTES_PARAMETER_ID).getMultiChoiceValue().getChoices());
final List<String> ignoreTransactionAttributes = new ArrayList<>(parameters.getParameters().get(IGNORE_TRANSACTION_ATTRIBUTES_PARAMETER_ID).getMultiChoiceValue().getChoices());
final ConstellationColor addedColour = parameters.getParameters().get(ADDED_COLOUR_PARAMETER_ID).getColorValue();
final ConstellationColor removedColour = parameters.getParameters().get(REMOVED_COLOUR_PARAMETER_ID).getColorValue();
final ConstellationColor changedColour = parameters.getParameters().get(CHANGED_COLOUR_PARAMETER_ID).getColorValue();
final ConstellationColor unchangedColour = parameters.getParameters().get(UNCHANGED_COLOUR_PARAMETER_ID).getColorValue();
final ConstellationColor addedColourValue = ConstellationColor.getColorValue(addedColour.getRed(), addedColour.getGreen(), addedColour.getBlue(), ConstellationColor.ZERO_ALPHA);
final ConstellationColor removedColourValue = ConstellationColor.getColorValue(removedColour.getRed(), removedColour.getGreen(), removedColour.getBlue(), ConstellationColor.ZERO_ALPHA);
final ConstellationColor changedColourValue = ConstellationColor.getColorValue(changedColour.getRed(), changedColour.getGreen(), changedColour.getBlue(), ConstellationColor.ZERO_ALPHA);
final ConstellationColor unchangedColourValue = ConstellationColor.getColorValue(unchangedColour.getRed(), unchangedColour.getGreen(), unchangedColour.getBlue(), ConstellationColor.ZERO_ALPHA);
final Graph originalGraph = getGraphFromName(originalGraphName);
final Graph compareGraph = getGraphFromName(compareGraphName);
if (originalGraph == null) {
throw new PluginException(PluginNotificationLevel.ERROR, String.format(GRAPH_NOT_FOUND_ERROR, originalGraphName));
}
if (compareGraph == null) {
throw new PluginException(PluginNotificationLevel.ERROR, String.format(GRAPH_NOT_FOUND_ERROR, compareGraphName));
}
final GraphRecordStore originalAll;
final GraphRecordStore compareAll;
final Set<String> vertexPrimaryKeys;
final Set<String> transactionPrimaryKeys;
// get a copy of the graph's record store and statistical info
ReadableGraph rg = originalGraph.getReadableGraph();
try {
originalAll = GraphRecordStoreUtilities.getAll(rg, false, true);
vertexPrimaryKeys = PrimaryKeyUtilities.getPrimaryKeyNames(rg, GraphElementType.VERTEX);
transactionPrimaryKeys = PrimaryKeyUtilities.getPrimaryKeyNames(rg, GraphElementType.TRANSACTION);
} finally {
rg.release();
}
rg = compareGraph.getReadableGraph();
try {
compareAll = GraphRecordStoreUtilities.getAll(rg, false, true);
} finally {
rg.release();
}
// ignore the id attributes to avoid reporting on them
ignoreVertexAttributes.add("[id]");
ignoreTransactionAttributes.add("[id]");
// graph changes
final String title = String.format("Compare: %s <> %s", originalGraphName, compareGraphName);
final GraphRecordStore changes = compareGraphs(title, originalAll, compareAll, vertexPrimaryKeys, transactionPrimaryKeys, ignoreVertexAttributes, ignoreTransactionAttributes, addedColourValue, removedColourValue, changedColourValue, unchangedColourValue);
// create new graph
createComparisonGraph(originalGraph, changes);
interaction.setProgress(1, 0, changes + " changes were found.", true);
}
use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.
the class GraphLabel method valueOf.
public static GraphLabel valueOf(final String graphLabelString) {
if (graphLabelString == null) {
return null;
}
final List<String> labelProperties;
try {
labelProperties = StringUtilities.splitEscaped(graphLabelString, DELIMITER);
} catch (IllegalArgumentException ex) {
throw new IllegalArgumentException("String does not represent a graph label: " + graphLabelString);
}
if (labelProperties.size() == 3) {
final String attributeName = labelProperties.get(0);
final ConstellationColor color = ConstellationColor.getColorValue(labelProperties.get(1));
if (color == null) {
throw new IllegalArgumentException("Undefined colour for label.");
}
final float size;
try {
size = Float.valueOf(labelProperties.get(2));
} catch (NumberFormatException ex) {
throw new IllegalArgumentException("Invalid size for label");
}
return new GraphLabel(attributeName, color, size);
}
throw new IllegalArgumentException("String for graph label has wrong number of fields: " + graphLabelString);
}
use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.
the class NamedColorPanel method setColor.
private void setColor(Color jc) {
final ConstellationColor cv = ConstellationColor.fromJavaColor(jc);
colorList.setSelectedValue(cv, true);
csm.setSelectedColor(jc);
}
Aggregations