ij.plugin.Colors Java Examples
The following examples show how to use
ij.plugin.Colors.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InteractivePlotter.java From Scripts with GNU General Public License v3.0 | 6 votes |
private void setPreferences() { final GenericDialog gd = new GenericDialog("Preferences"); gd.addChoice("Secondary style color:", Colors.colors, dColor2); gd.setInsets(0, 0, 0); gd.addMessage("(Used by styles 'box', 'circle', 'connected', etc.)"); gd.setInsets(30, 0, 0); gd.addMessage("After plotting a series:"); gd.setInsets(0, 20, 0); gd.addCheckbox("Auto-select_next_Y-values", autoNextValues); gd.addCheckbox("Auto-select_next_shape", autoNextShape); gd.addCheckbox("Auto-select_next_color", autoNextColor); showAsSubDialog(gd); if (gd.wasOKed()) { dColor2 = Colors.colors[gd.getNextChoiceIndex()]; autoNextValues = gd.getNextBoolean(); autoNextShape = gd.getNextBoolean(); autoNextColor = gd.getNextBoolean(); } }
Example #2
Source File: ColorPicker.java From 3Dscript with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void mouseMoved(MouseEvent e) { int x = e.getX(); int y = e.getY(); int p = ip.getPixel(x, y); int r = (p&0xff0000)>>16; int g = (p&0xff00)>>8; int b = p&0xff; String hex = Colors.colorToString(new Color(r,g,b)); IJ.showStatus("red="+pad(r)+", green="+pad(g)+", blue="+pad(b)+" ("+hex+")"); }
Example #3
Source File: SNT.java From SNT with GNU General Public License v3.0 | 5 votes |
protected static String getColorString(final Color color) { String name = "none"; name = Colors.getColorName(color, name); if (!"none".equals(name)) name = Colors.colorToString(color); return name; }
Example #4
Source File: SNT.java From SNT with GNU General Public License v3.0 | 5 votes |
protected static Color getColor(String colorName) { if (colorName == null) colorName = "none"; Color color = null; color = Colors.getColor(colorName, color); if (color == null) color = Colors.decode(colorName, color); return color; }
Example #5
Source File: InteractivePlotter.java From Scripts with GNU General Public License v3.0 | 4 votes |
private void setPlotOptions() { if (plot == null) return; final int DEF_LINE_WIDTH = 1; final int DEF_MAX_INTERVALS = 12; final int DEF_TICK_LENGTH = 7; final int DEF_MINOR_TICK_LENGTH = 3; final int[] NUM_DEFAULTS = { DEF_LINE_WIDTH, DEF_MAX_INTERVALS, DEF_TICK_LENGTH, DEF_MINOR_TICK_LENGTH }; final String DEF_BACKGROUND_COLOR = "white"; final String title = plot.getTitle(); final GenericDialog ogd = new GenericDialog("Options for " + title); ogd.setInsets(0, 10, 10); ogd.addMessage("This prompt allows you access customizations that\n" + "are not accessible through the plot's \"More \u00bb\" menu"); if (!pwClosed) ogd.addStringField("Plot title:", title, 27); ogd.addSlider("Line width:", 1, 20, 1); ogd.addSlider("Max. n. of intervals:", 1, 40, 12); ogd.addSlider("Major ticks length:", 1, 14, 7); ogd.addSlider("Minor ticks length:", 1, 14, 3); ogd.addChoice("Backgrond color:", Colors.colors, DEF_BACKGROUND_COLOR); final Panel buttonPanel = new Panel(); final Button fontButton = new Button(" Text & Font... "); fontButton.addActionListener(ogd); buttonPanel.add(fontButton); final Button templateButton = new Button("Apply Template..."); templateButton.addActionListener(ogd); buttonPanel.add(templateButton); ogd.addPanel(buttonPanel, GridBagConstraints.EAST, new Insets(0, 0, 0, 0)); ogd.hideCancelButton(); ogd.addHelp(""); ogd.setHelpLabel("Apply Defaults"); ogd.addDialogListener(new DialogListener() { @Override public boolean dialogItemChanged(final GenericDialog gd, final AWTEvent e) { if (e != null && e.toString().contains("Apply Defaults")) { @SuppressWarnings("unchecked") final Vector<TextField> nFields = gd.getNumericFields(); for (final TextField field : nFields) field.setText(Integer.toString(NUM_DEFAULTS[nFields.indexOf(field)])); @SuppressWarnings("unchecked") final Vector<Choice> nChoices = gd.getChoices(); nChoices.firstElement().select(DEF_BACKGROUND_COLOR); } else if (e != null && e.toString().contains("Font")) { setPlotFont(); return true; } else if (e != null && e.toString().contains("Template")) { setTemplate(); return true; } plot.setLineWidth((int) ogd.getNextNumber()); plot.setMaxIntervals((int) ogd.getNextNumber()); plot.setTickLength((int) ogd.getNextNumber()); plot.setBackgroundColor(Colors.colors[ogd.getNextChoiceIndex()]); plot.updateImage(); return true; } }); showAsSubDialog(ogd); if (!ogd.wasOKed()) return; if (!pwClosed) plot.getImagePlus().setTitle(WindowManager.makeUniqueName(ogd.getNextString())); }