Search in sources :

Example 6 with ConstellationColor

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);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) Color(java.awt.Color) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) DialogDescriptor(org.openide.DialogDescriptor)

Example 7 with ConstellationColor

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();
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor)

Example 8 with ConstellationColor

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);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) PluginException(au.gov.asd.tac.constellation.plugins.PluginException) ArrayList(java.util.ArrayList) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)

Example 9 with ConstellationColor

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);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor)

Example 10 with ConstellationColor

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);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor)

Aggregations

ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)67 ArrayList (java.util.ArrayList)13 Test (org.testng.annotations.Test)11 Color (java.awt.Color)9 BitSet (java.util.BitSet)9 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)8 IOException (java.io.IOException)7 Graph (au.gov.asd.tac.constellation.graph.Graph)6 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)6 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)6 List (java.util.List)6 File (java.io.File)5 HashMap (java.util.HashMap)5 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)4 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)4 Camera (au.gov.asd.tac.constellation.utilities.camera.Camera)4 Matrix44f (au.gov.asd.tac.constellation.utilities.graphics.Matrix44f)4 VisualAccess (au.gov.asd.tac.constellation.utilities.visual.VisualAccess)4 GLRenderableUpdateTask (au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask)4 TextureUnits (au.gov.asd.tac.constellation.visual.opengl.renderer.TextureUnits)4