6 import ij.plugin.filter.*;
13 public void run(String arg) {
14 if (arg.equals(
"misc"))
15 {miscOptions();
return;}
16 else if (arg.equals(
"width"))
17 {lineWidth();
return;}
18 else if (arg.equals(
"quality"))
19 {jpegQuality();
return;}
20 else if (arg.equals(
"cross"))
22 else if (arg.equals(
"conv"))
23 {conversions();
return;}
24 else if (arg.equals(
"image"))
25 {imageOptions();
return;}
30 GenericDialog gd =
new GenericDialog(
"Miscellaneous Options",
IJ.
getInstance());
31 gd.addStringField(
"Divide by Zero Value:",
""+
FloatBlitter.divideByZeroValue, 10);
34 gd.addCheckbox(
"Debug Mode",
IJ.debugMode);
39 String divValue = gd.getNextString();
40 if (divValue.equalsIgnoreCase(
"infinity") || divValue.equalsIgnoreCase(
"infinite"))
41 FloatBlitter.divideByZeroValue = Float.POSITIVE_INFINITY;
42 else if (divValue.equalsIgnoreCase(
"NaN"))
44 else if (divValue.equalsIgnoreCase(
"max"))
48 try {f =
new Float(divValue);}
49 catch (NumberFormatException e) {f = null;}
51 FloatBlitter.divideByZeroValue = f.floatValue();
54 Prefs.usePointerCursor = gd.getNextBoolean();
55 Prefs.antialiasedText = gd.getNextBoolean();
56 IJ.debugMode = gd.getNextBoolean();
61 int width = (int)IJ.getNumber(
"Line Width:", Line.getWidth());
62 if (width==IJ.CANCELED)
return;
64 ImagePlus imp = IJ.getInstance().getImagePlus();
65 if (imp!=null && imp.isProcessor()) {
66 ImageProcessor ip = imp.getProcessor();
67 ip.setLineWidth(Line.getWidth());
72 int quality = (int)IJ.getNumber(
"JPEG quality (0-100):", JpegWriter.getQuality());
73 if (quality==IJ.CANCELED)
return;
74 JpegWriter.setQuality(quality);
80 int width = (int)IJ.getNumber(
"Mark Width:", Analyzer.markWidth);
81 if (width==IJ.CANCELED)
return;
82 Analyzer.markWidth = width;
88 double[] weights = ColorProcessor.getWeightingFactors();
89 boolean unweighted = weights[0]==1d/3d && weights[1]==1d/3d && weights[2]==1d/3d;
90 GenericDialog gd =
new GenericDialog(
"Conversion Options");
91 gd.addCheckbox(
"Scale When Converting", ImageConverter.getDoScaling());
92 gd.addCheckbox(
"Unweighted RGB to Grayscale Conversion", unweighted);
96 ImageConverter.setDoScaling(gd.getNextBoolean());
97 Prefs.unweightedColor = gd.getNextBoolean();
98 if (
Prefs.unweightedColor)
99 ColorProcessor.setWeightingFactors(1d/3d, 1d/3d, 1d/3d);
101 ColorProcessor.setWeightingFactors(0.299, 0.587, 0.114);
105 void imageOptions() {
106 GenericDialog gd =
new GenericDialog(
"Image Options", IJ.getInstance());
107 gd.addCheckbox(
"Interpolate Images <100%",
Prefs.interpolateScaledImages);
108 gd.addCheckbox(
"Open Images at 100%",
Prefs.open100Percent);
109 gd.addCheckbox(
"Black Canvas",
Prefs.blackCanvas);
111 if (gd.wasCanceled())
113 boolean interpolate = gd.getNextBoolean();
114 Prefs.open100Percent = gd.getNextBoolean();
115 boolean blackCanvas = gd.getNextBoolean();
116 if (interpolate!=
Prefs.interpolateScaledImages) {
117 Prefs.interpolateScaledImages = interpolate;
118 ImagePlus imp = IJ.getInstance().getImagePlus();
122 if (blackCanvas!=
Prefs.blackCanvas) {
123 Prefs.blackCanvas = blackCanvas;
124 ImagePlus imp = IJ.getInstance().getImagePlus();
126 ImageCanvas win = imp.getCanvas();
128 if (
Prefs.blackCanvas) {
129 win.setForeground(Color.white);
130 win.setBackground(Color.black);
132 win.setForeground(Color.black);
133 win.setBackground(Color.white);