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