Search in sources :

Example 51 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class NewNebulaAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final PluginParameters params = new PluginParameters();
    final PluginParameter<FileParameterValue> fileParam = FileParameterType.build(NEBULA_FILE_PARAMETER_ID);
    fileParam.setName("Nebula file");
    FileParameterType.setFileFilters(fileParam, new ExtensionFilter("Nebula file", "*.nebula"));
    fileParam.getParameterValue().setKind(FileParameterKind.SAVE);
    fileParam.setHelpID("au.gov.asd.tac.constellation.file.nebula");
    params.addParameter(fileParam);
    final PluginParameter<ColorParameterValue> colorParam = ColorParameterType.build(COLOR_PARAMETER_ID);
    colorParam.setName("Nebula colour");
    params.addParameter(colorParam);
    final PluginParametersSwingDialog dialog = new PluginParametersSwingDialog(Bundle.CTL_NewNebulaAction(), params);
    dialog.showAndWait();
    if (PluginParametersDialog.OK.equals(dialog.getResult())) {
        final FileParameterValue fpv = fileParam.getParameterValue();
        if (!fpv.get().isEmpty()) {
            final Properties props = new Properties();
            final ConstellationColor c = colorParam.getColorValue();
            props.setProperty("colour", String.format("%f,%f,%f", c.getRed(), c.getGreen(), c.getBlue()));
            File f = fpv.get().get(0);
            if (!StringUtils.endsWithIgnoreCase(f.getName(), FileExtensionConstants.NEBULA)) {
                f = new File(f.getAbsoluteFile() + FileExtensionConstants.NEBULA);
            }
            try {
                try (final FileOutputStream fos = new FileOutputStream(f)) {
                    props.store(fos, null);
                    NebulaDataObject.addRecent(f);
                }
            } catch (final IOException ex) {
                LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
            }
        }
    }
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) PluginParametersSwingDialog(au.gov.asd.tac.constellation.plugins.gui.PluginParametersSwingDialog) FileParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) FileOutputStream(java.io.FileOutputStream) ColorParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ColorParameterType.ColorParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) IOException(java.io.IOException) Properties(java.util.Properties) File(java.io.File)

Example 52 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class AddBlazeAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final Pair<BitSet, ConstellationColor> selectionResult = BlazeUtilities.getSelection(context.getGraph(), null);
    final BitSet selectedVertices = selectionResult.getKey();
    final ConstellationColor blazeColor = selectionResult.getValue();
    if (!selectedVertices.isEmpty()) {
        PluginExecution.withPlugin(VisualGraphPluginRegistry.ADD_CUSTOM_BLAZE).withParameter(BlazeUtilities.VERTEX_IDS_PARAMETER_ID, selectedVertices).withParameter(BlazeUtilities.COLOR_PARAMETER_ID, blazeColor).executeLater(context.getGraph());
    }
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) BitSet(java.util.BitSet)

Example 53 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class AddCustomBlazeAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final Pair<BitSet, ConstellationColor> selectionResult = BlazeUtilities.getSelection(context.getGraph(), null);
    final BitSet selectedVertices = selectionResult.getKey();
    ConstellationColor blazeColor = selectionResult.getValue();
    if (!selectedVertices.isEmpty()) {
        final Pair<Boolean, ConstellationColor> colorResult = BlazeUtilities.colorDialog(blazeColor);
        if (colorResult.getKey()) {
            blazeColor = colorResult.getValue();
            PluginExecution.withPlugin(VisualGraphPluginRegistry.ADD_CUSTOM_BLAZE).withParameter(BlazeUtilities.VERTEX_IDS_PARAMETER_ID, selectedVertices).withParameter(BlazeUtilities.COLOR_PARAMETER_ID, blazeColor).executeLater(context.getGraph());
        }
    }
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) BitSet(java.util.BitSet)

Example 54 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class AddCustomBlazePlugin method edit.

@Override
public void edit(final GraphWriteMethods wg, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException {
    final int blazeAttr = VisualConcept.VertexAttribute.BLAZE.ensure(wg);
    final ConstellationColor cv = parameters.getColorValue(COLOR_PARAMETER_ID);
    final int vxId = parameters.getIntegerValue(VERTEX_ID_PARAMETER_ID);
    if (vxId != Graph.NOT_FOUND) {
        setBlazeColor(wg, blazeAttr, vxId, cv);
    } else {
        final BitSet vertices = BlazePluginUtilities.verticesParam(parameters);
        if (vertices != null) {
            for (int ix = vertices.nextSetBit(0); ix >= 0; ix = vertices.nextSetBit(ix + 1)) {
                setBlazeColor(wg, blazeAttr, ix, cv);
            }
        } else {
            final int selectedAttr = VisualConcept.VertexAttribute.SELECTED.get(wg);
            if (selectedAttr != Graph.NOT_FOUND) {
                int vertexCount = wg.getVertexCount();
                for (int i = 0; i < vertexCount; i++) {
                    int v = wg.getVertex(i);
                    if (wg.getBooleanValue(selectedAttr, v)) {
                        setBlazeColor(wg, blazeAttr, v, cv);
                    }
                }
            }
        }
    }
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) BitSet(java.util.BitSet)

Example 55 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class BlazeContextMenu method getIcons.

/**
 * Produce list of custom blaze color icons based on supplied color.
 *
 * @param graph the graph that has been right-clicked on.
 * @param elementType the type of element that has been right-clicked on.
 * @param elementId the id of the element that has been right-clicked on.
 * @return list of custom colored blaze color icons.
 */
@Override
public List<ImageIcon> getIcons(final GraphReadMethods graph, final GraphElementType elementType, final int elementId) {
    if (elementType == GraphElementType.VERTEX) {
        final List<ImageIcon> icons = new ArrayList<>();
        for (final ConstellationColor color : BlazeActions.getPresetCustomColors()) {
            if (color != null) {
                final Color javaColor = color.getJavaColor();
                final BufferedImage customImage = BlazeActions.copyImageBuffer((BufferedImage) ImageUtilities.loadImage(ADD_RECENT_BLAZE_ICON, false));
                for (int x = 0; x < customImage.getWidth(); x++) {
                    for (int y = 0; y < customImage.getHeight(); y++) {
                        if (customImage.getRGB(x, y) == BLACK_COLOR) {
                            customImage.setRGB(x, y, javaColor.getRGB());
                        }
                    }
                }
                final ImageIcon icon = new ImageIcon(customImage);
                icons.add(icon);
            }
        }
        icons.add(ImageUtilities.loadImageIcon(ADD_CUSTOM_BLAZE_ICON, false));
        icons.add(ImageUtilities.loadImageIcon(REMOVE_BLAZE_ICON, false));
        return icons;
    } else {
        return Collections.emptyList();
    }
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) ImageIcon(javax.swing.ImageIcon) Color(java.awt.Color) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) ArrayList(java.util.ArrayList) BufferedImage(java.awt.image.BufferedImage)

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