String getPlotObjectStyle(PlotObject plotObject) { String styleString = Colors.colorToString(plotObject.color) + "," + Colors.colorToString(plotObject.color2) + "," + plotObject.lineWidth; if (plotObject.type == PlotObject.XY_DATA) styleString += ","+SHAPE_NAMES[plotObject.shape]; if (plotObject.hasFlag(PlotObject.HIDDEN)) styleString += ",hidden"; return styleString; }
/** Sets the color ("blue", "black", etc.) of the font used to label outlines in the next particle analyzer instance. */ public static void setFontColor(String color) { nextFontColor = Colors.decode(color, defaultFontColor); }
@Override public void actionPerformed(final ActionEvent e) { applyColortoSelectPaths(ij.plugin.Colors.getColor(e.getActionCommand(), SimpleNeuriteTracer.DEFAULT_DESELECTED_COLOR)); } });
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; }
public static Color decode(String hexColor, Color defaultColor) { Color color = getColor(hexColor, null); if (color==null) { if (hexColor.startsWith("#")) hexColor = hexColor.substring(1); int len = hexColor.length(); if (!(len==6 || len==8)) return defaultColor; float alpha = len==8?parseHex(hexColor.substring(0,2)):1f; if (len==8) hexColor = hexColor.substring(2); float red = parseHex(hexColor.substring(0,2)); float green = parseHex(hexColor.substring(2,4)); float blue = parseHex(hexColor.substring(4,6)); color = new Color(red, green, blue, alpha); } return color; }
public void showDialog() { Color color = Toolbar.getForegroundColor(); String colorName = Colors.colorToString2(color); String name = isPencil?"Pencil":"Brush"; gd = new NonBlockingGenericDialog(name+" Options"); gd.addSlider(name+" width:", 1, 50, width); //gd.addSlider("Transparency (%):", 0, 100, transparency); gd.addChoice("Color:", Colors.getColors(colorName), colorName); gd.addCheckbox("Paint on overlay", paintOnOverlay); gd.addDialogListener(this); gd.addHelp(getHelp()); Point loc = Prefs.getLocation(LOC_KEY); if (loc!=null) { gd.centerDialog(false); gd.setLocation (loc); } gd.showDialog(); Prefs.saveLocation(LOC_KEY, gd.getLocation()); gd = null; }
/** Sets the 'previousColor', 'previousColor2' with a suggestion for new colors */ private void suggestColor() { boolean[] colorUsed = new boolean[PLOT_COLORS.length]; String[] designations = plot.getPlotObjectDesignations(); for (int i=0; i<designations.length; i++) { if (!(designations[i].toLowerCase().startsWith("data"))) continue; String styleString = plot.getPlotObjectStyle(i); for (int j=0; j<PLOT_COLORS.length; j++) if (styleString.startsWith(PLOT_COLORS[j])) colorUsed[j] = true; } String newColor = previousColor; for (int j=0; j<PLOT_COLORS.length; j++) if (!colorUsed[j]) { newColor = PLOT_COLORS[j]; break; } if (previousColor2 != null && previousColor2.equals(previousColor)) //if fill color was main color, keep it such previousColor2 = newColor; else if (Colors.decode(previousColor2, null) != null) { //if we had a separate fill color, make main color brighter Color newC = Colors.decode(newColor,Color.BLACK); Color newC2 = new Color(makeBrighter(newC.getRed()), makeBrighter(newC.getGreen()), makeBrighter(newC.getBlue())); previousColor2 = Colors.colorToString(newC2); } previousColor = newColor; }
void showDialog() { Color fc =Toolbar.getForegroundColor(); String fname = getColorName(fc, "black"); Color bc =Toolbar.getBackgroundColor(); String bname = getColorName(bc, "white"); Color sc =Roi.getColor(); String sname = getColorName(sc, "yellow"); GenericDialog gd = new GenericDialog("Colors"); gd.addChoice("Foreground:", colors, fname); bname = gd.getNextChoice(); sname = gd.getNextChoice(); fc2 = getColor(fname, Color.black); bc2 = getColor(bname, Color.white); sc2 = getColor(sname, Color.yellow); if (fc2!=fc) Toolbar.setForegroundColor(fc2); if (bc2!=bc) Toolbar.setBackgroundColor(bc2);
multipointTool = true; Color sc =Roi.getColor(); String sname = Colors.getColorName(sc, "Yellow"); Color cc =PointRoi.getDefaultCrossColor(); String cname = Colors.getColorName(cc, "None"); String type = PointRoi.types[PointRoi.getDefaultType()]; String size = PointRoi.sizes[PointRoi.getDefaultSize()]; gd.setInsets(5,0,2); gd.addChoice("Type:", PointRoi.types, type); gd.addChoice("Color:", Colors.getColors(), sname); gd.addChoice("Size:", PointRoi.sizes, size); if (!multipointTool) {
void setColor(Color c) { String name = Colors.getColorName(c, ""); if (name.length() > 0) { Vector choices = gd.getChoices(); Choice ch = (Choice)choices.elementAt(0); ch.select(name); } }
private JMenu colorPopupMenu() { final JMenu menu = new JMenu("Color"); JMenuItem jmi; final String[] colors = ij.plugin.Colors.getColors(); for (final String color : colors) { jmi = new JMenuItem(color);
/** Converts a Color into a string ("red", "green", #aa55ff, etc.). */ public static String colorToString(Color color) { String str = color!=null?"#"+Integer.toHexString(color.getRGB()):"none"; if (str.length()==9 && str.startsWith("#ff")) str = "#"+str.substring(3); String str2 = hexToColor(str); return str2!=null?str2:str; }
private void setColor(Color c) { if (gd==null) return; String name = Colors.colorToString2(c); if (name.length()>0) { Vector choices = gd.getChoices(); Choice ch = (Choice)choices.elementAt(0); ch.select(name); } }
/** Converts a Color into a string ("Red", "Green", #aa55ff, etc.). */ public static String colorToString2(Color color) { String str = color!=null?"#"+Integer.toHexString(color.getRGB()):"None"; if (str.length()==9 && str.startsWith("#ff")) str = "#"+str.substring(3); String str2 = hexToColor2(str); return str2!=null?str2:str; }
public void run(String arg) { showDialog(); }
public void showDialog() { Color color = Toolbar.getForegroundColor(); String colorName = Colors.colorToString2(color); String name = isPencil?"Pencil":"Brush"; gd = new NonBlockingGenericDialog(name+" Options"); gd.addSlider(name+" width:", 1, 50, width); //gd.addSlider("Transparency (%):", 0, 100, transparency); gd.addChoice("Color:", Colors.getColors(colorName), colorName); gd.addCheckbox("Paint on overlay", paintOnOverlay); gd.addDialogListener(this); gd.addHelp(getHelp()); Point loc = Prefs.getLocation(LOC_KEY); if (loc!=null) { gd.centerDialog(false); gd.setLocation (loc); } gd.showDialog(); Prefs.saveLocation(LOC_KEY, gd.getLocation()); gd = null; }
/** Sets the 'previousColor', 'previousColor2' with a suggestion for new colors */ private void suggestColor() { boolean[] colorUsed = new boolean[PLOT_COLORS.length]; String[] designations = plot.getPlotObjectDesignations(); for (int i=0; i<designations.length; i++) { if (!(designations[i].toLowerCase().startsWith("data"))) continue; String styleString = plot.getPlotObjectStyle(i); for (int j=0; j<PLOT_COLORS.length; j++) if (styleString.startsWith(PLOT_COLORS[j])) colorUsed[j] = true; } String newColor = previousColor; for (int j=0; j<PLOT_COLORS.length; j++) if (!colorUsed[j]) { newColor = PLOT_COLORS[j]; break; } if (previousColor2 != null && previousColor2.equals(previousColor)) //if fill color was main color, keep it such previousColor2 = newColor; else if (Colors.decode(previousColor2, null) != null) { //if we had a separate fill color, make main color brighter Color newC = Colors.decode(newColor,Color.BLACK); Color newC2 = new Color(makeBrighter(newC.getRed()), makeBrighter(newC.getGreen()), makeBrighter(newC.getBlue())); previousColor2 = Colors.colorToString(newC2); } previousColor = newColor; }
void showDialog() { Color fc =Toolbar.getForegroundColor(); String fname = getColorName(fc, "black"); Color bc =Toolbar.getBackgroundColor(); String bname = getColorName(bc, "white"); Color sc =Roi.getColor(); String sname = getColorName(sc, "yellow"); GenericDialog gd = new GenericDialog("Colors"); gd.addChoice("Foreground:", colors, fname); bname = gd.getNextChoice(); sname = gd.getNextChoice(); fc2 = getColor(fname, Color.black); bc2 = getColor(bname, Color.white); sc2 = getColor(sname, Color.yellow); if (fc2!=fc) Toolbar.setForegroundColor(fc2); if (bc2!=bc) Toolbar.setBackgroundColor(bc2);
multipointTool = true; Color sc =Roi.getColor(); String sname = Colors.getColorName(sc, "Yellow"); Color cc =PointRoi.getDefaultCrossColor(); String cname = Colors.getColorName(cc, "None"); String type = PointRoi.types[PointRoi.getDefaultType()]; String size = PointRoi.sizes[PointRoi.getDefaultSize()]; gd.setInsets(5,0,2); gd.addChoice("Type:", PointRoi.types, type); gd.addChoice("Color:", Colors.getColors(), sname); gd.addChoice("Size:", PointRoi.sizes, size); if (!multipointTool) {