Skip to content
Commits on Source (8)
......@@ -414,7 +414,6 @@ new_07="Plugin Frame",ij.plugin.NewPlugin("frame")
new_08="Plugin Tool",ij.plugin.NewPlugin("plugin-tool")
new_09=-
new_10="Text Window...",ij.plugin.NewPlugin("text+dialog")
new_11="Table...",ij.plugin.NewPlugin("table")
# Plugins installed in the Help/About submenu
about01="About This Submenu...",ij.plugin.SimpleCommands("about")
......
......@@ -6,7 +6,7 @@
<!-- First, ensure the build directory exists. -->
<mkdir dir="build" />
<!-- Build everything; add debug="on" to debug -->
<javac srcdir="./ij" destdir="build" optimize="on" source="1.5" target="1.5" debug="on" includeantruntime="false" encoding="utf-8">
<javac srcdir="./ij" destdir="build" optimize="on" source="1.6" target="1.6" debug="on" includeantruntime="false" encoding="utf-8">
</javac>
</target>
......
imagej (1.51q-2) UNRELEASED; urgency=medium
imagej (1.52d-1) unstable; urgency=medium
[ David Miguel Susano Pinto ]
* New upstream release
[ Steffen Moeller ]
* debian/upstream/metadata: Added ref to software registries.
-- Steffen Moeller <moeller@debian.org> Sat, 10 Feb 2018 14:58:43 +0100
-- David Miguel Susano Pinto <carandraug+dev@gmail.com> Tue, 19 Jun 2018 17:14:16 +0100
imagej (1.51q-1) unstable; urgency=medium
......
......@@ -9,7 +9,7 @@ Build-Depends-Indep: ant,
default-jdk-headless,
javahelper,
maven-repo-helper
Standards-Version: 4.1.0
Standards-Version: 4.1.4
Vcs-Browser: https://anonscm.debian.org/cgit/debian-med/imagej.git
Vcs-Git: https://anonscm.debian.org/git/debian-med/imagej.git
Homepage: https://imagej.nih.gov/ij
......@@ -17,7 +17,7 @@ Homepage: https://imagej.nih.gov/ij
Package: imagej
Architecture: all
Depends: ${java:Depends}, ${misc:Depends},
default-jre | java5-runtime,
default-jre | java6-runtime,
libij-java (= ${source:Version})
Recommends: ${java:Recommends}
Description: Image processing program with a focus on microscopy images
......
Description: Fix syntax for javadoc
Remove @see link on javadocs for private method since private
methods are excluded from javadocs.
Forwarded: https://list.nih.gov/cgi-bin/wa.exe?A2=ind1709&L=IMAGEJ&F=&S=&P=86853
Author: Carnë Draug <carandraug+dev@gmail.com>
Last-Update: 2017-09-26
--- a/ij/gui/Plot.java
+++ b/ij/gui/Plot.java
@@ -246,7 +246,7 @@
/** Constructs a new plot from an InputStream and closes the stream. If the ImagePlus is
* non-null, its title and ImageProcessor are used, but the image displayed is not modified.
- * @see toStream() */
+ */
public Plot(ImagePlus imp, InputStream is) throws IOException, ClassNotFoundException {
ObjectInputStream in = new ObjectInputStream(is);
pp = (PlotProperties)in.readObject();
drop-mac-plugins.patch
link-javadocs.patch
fix-javadocs-syntax.patch
......@@ -13,6 +13,3 @@ override_dh_auto_build:
override_dh_installchangelogs:
dh_installchangelogs release-notes.html
get-orig-source:
uscan --verbose --force-download --repack --compression xz
......@@ -146,58 +146,19 @@ public class Executer implements Runnable {
if (openRecent(cmd))
return;
// is it an example in Help>Examples menu?
if (openExample(cmd))
if (Editor.openExample(cmd))
return;
if ("Auto Threshold".equals(cmd)&&(String)table.get("Auto Threshold...")!=null)
runCommand("Auto Threshold...");
else if ("Enhance Local Contrast (CLAHE)".equals(cmd)&&(String)table.get("CLAHE ")!=null)
runCommand("CLAHE ");
else {
if ("Table...".equals(cmd))
IJ.runPlugIn("ij.plugin.NewPlugin", "table");
else
IJ.error("Unrecognized command: \"" + cmd+"\"");
}
}
private boolean openExample(String name) {
boolean isMacro = name.endsWith(".ijm");
boolean isJava = name.endsWith(".java");
boolean isJavaScript = name.endsWith(".js");
boolean isBeanShell = name.endsWith(".bsh");
boolean isPython = name.endsWith(".py");
if (!(isMacro||isJava||isJavaScript||isBeanShell||isPython))
return false;
boolean run = !isJava && (Prefs.autoRunExamples||IJ.shiftKeyDown()||IJ.controlKeyDown()||IJ.altKeyDown());
int rows = 24;
int columns = 70;
int options = Editor.MENU_BAR;
String text = null;
Editor ed = new Editor(rows, columns, 0, options);
String dir = "Macro/";
if (isJava)
dir = "Java/";
else if (isJavaScript)
dir = "JavaScript/";
else if (isBeanShell)
dir = "BeanShell/";
else if (isPython)
dir = "Python/";
String url = "http://wsr.imagej.net/download/Examples/"+dir+name;
text = IJ.openUrlAsString(url);
if (text.startsWith("<Error: ")) {
IJ.error("Open Example", text);
return true;
}
ed.create(name, text);
if (run) {
if (isJavaScript)
ed.evaluateScript(".js");
else if (isBeanShell)
ed.evaluateScript(".bsh");
else if (isPython)
ed.evaluateScript(".py");
else if (!name.contains("_Tool"))
IJ.runMacro(text);
}
return true;
}
/** Opens a .lut file from the ImageJ/luts directory and returns 'true' if successful. */
......
......@@ -49,7 +49,8 @@ public class IJ {
private static ProgressBar progressBar;
private static TextPanel textPanel;
private static String osname, osarch;
private static boolean isMac, isWin, isJava16, isJava17, isJava18, isJava19, isLinux, is64Bit;
private static boolean isMac, isWin, isLinux, is64Bit;
private static int javaVersion;
private static boolean controlDown, altDown, spaceDown, shiftDown;
private static boolean macroRunning;
private static Thread previousThread;
......@@ -75,13 +76,23 @@ public class IJ {
isWin = osname.startsWith("Windows");
isMac = !isWin && osname.startsWith("Mac");
isLinux = osname.startsWith("Linux");
String version = System.getProperty("java.version").substring(0,3);
if (version.compareTo("2.9")<=0) { // JVM on Sharp Zaurus PDA claims to be "3.1"!
isJava16 = version.compareTo("1.5")>0;
isJava17 = version.compareTo("1.6")>0;
isJava18 = version.compareTo("1.7")>0;
isJava19 = version.compareTo("1.8")>0;
}
String version = System.getProperty("java.version");
if (version.startsWith("1.8"))
javaVersion = 8;
else if (version.startsWith("1.6"))
javaVersion = 6;
else if (version.startsWith("1.9")||version.startsWith("9"))
javaVersion = 9;
else if (version.startsWith("10"))
javaVersion = 10;
else if (version.startsWith("11"))
javaVersion = 11;
else if (version.startsWith("12"))
javaVersion = 12;
else if (version.startsWith("1.7"))
javaVersion = 7;
else
javaVersion = 6;
dfs = new DecimalFormatSymbols(Locale.US);
df = new DecimalFormat[10];
df[0] = new DecimalFormat("0", dfs);
......@@ -144,8 +155,6 @@ public class IJ {
Returns any string value returned by the macro, or null. Scripts always return null.
The equivalent macro function is runMacro(). */
public static String runMacroFile(String name, String arg) {
if (ij==null && Menus.getCommands()==null)
init();
Macro_Runner mr = new Macro_Runner();
return mr.runMacroFile(name, arg);
}
......@@ -501,7 +510,7 @@ public class IJ {
Frame frame = WindowManager.getFrontWindow();
if (frame!=null && (frame instanceof TextWindow)) {
TextWindow tw = (TextWindow)frame;
if (tw.getTextPanel().getResultsTable()==null) {
if (tw.getResultsTable()==null) {
IJ.error("Rename", "\""+tw.getTitle()+"\" is not a results table");
return;
}
......@@ -513,7 +522,7 @@ public class IJ {
}
}
/** Changes the name of a results window from 'oldTitle' to 'newTitle'. */
/** Changes the name of a table window from 'oldTitle' to 'newTitle'. */
public static void renameResults(String oldTitle, String newTitle) {
Frame frame = WindowManager.getFrame(oldTitle);
if (frame==null) {
......@@ -521,22 +530,20 @@ public class IJ {
return;
} else if (frame instanceof TextWindow) {
TextWindow tw = (TextWindow)frame;
if (tw.getTextPanel().getResultsTable()==null) {
error("Rename", "\""+oldTitle+"\" is not a results table");
if (tw.getResultsTable()==null) {
error("Rename", "\""+oldTitle+"\" is not a table");
return;
}
tw.rename(newTitle);
} else
error("Rename", "\""+oldTitle+"\" is not a results table");
error("Rename", "\""+oldTitle+"\" is not a table");
}
/** Deletes 'row1' through 'row2' of the "Results" window. Arguments
must be in the range 0-Analyzer.getCounter()-1. */
/** Deletes 'row1' through 'row2' of the "Results" window, where
'row1' and 'row2' must be in the range 0-Analyzer.getCounter()-1. */
public static void deleteRows(int row1, int row2) {
int n = row2 - row1 + 1;
ResultsTable rt = Analyzer.getResultsTable();
for (int i=row1; i<row1+n; i++)
rt.deleteRow(row1);
rt.deleteRows(row1, row2);
rt.show("Results");
}
......@@ -956,6 +963,11 @@ public class IJ {
return isWin;
}
/** Returns the Java version (6, 7, 8, 9, 10, etc.). */
public static int javaVersion() {
return javaVersion;
}
/** Always returns true. */
public static boolean isJava2() {
return true;
......@@ -973,22 +985,22 @@ public class IJ {
/** Returns true if ImageJ is running on a Java 1.6 or greater JVM. */
public static boolean isJava16() {
return isJava16;
return javaVersion >= 6;
}
/** Returns true if ImageJ is running on a Java 1.7 or greater JVM. */
public static boolean isJava17() {
return isJava17;
return javaVersion >= 7;
}
/** Returns true if ImageJ is running on a Java 1.8 or greater JVM. */
public static boolean isJava18() {
return isJava18;
return javaVersion >= 8;
}
/** Returns true if ImageJ is running on a Java 1.9 or greater JVM. */
public static boolean isJava19() {
return isJava19;
return javaVersion >= 9;
}
/** Returns true if ImageJ is running on Linux. */
......@@ -1151,6 +1163,16 @@ public class IJ {
img.setRoi(new PointRoi(x, y));
}
/** Creates an Roi. */
public static Roi Roi(double x, double y, double width, double height) {
return new Roi(x, y, width, height);
}
/** Creates an OvalRoi. */
public static OvalRoi OvalRoi(double x, double y, double width, double height) {
return new OvalRoi(x, y, width, height);
}
/** Sets the display range (minimum and maximum displayed pixel values) of the current image. */
public static void setMinAndMax(double min, double max) {
setMinAndMax(getImage(), min, max, 7);
......@@ -1327,8 +1349,11 @@ public class IJ {
if (impC!=null && impC!=imp && impT!=null)
impC.saveRoi();
WindowManager.setTempCurrentImage(imp);
Interpreter.activateImage(imp);
WindowManager.setWindow(null);
} else {
if (imp==null)
return;
ImageWindow win = imp.getWindow();
if (win!=null) {
win.toFront();
......@@ -1821,10 +1846,12 @@ public class IJ {
return;
} else if (format.indexOf("jpeg")!=-1 || format.indexOf("jpg")!=-1) {
path = updateExtension(path, ".jpg");
format = "Jpeg...";
JpegWriter.save(imp, path, FileSaver.getJpegQuality());
return;
} else if (format.indexOf("gif")!=-1) {
path = updateExtension(path, ".gif");
format = "Gif...";
GifWriter.save(imp, path);
return;
} else if (format.indexOf("text image")!=-1) {
path = updateExtension(path, ".txt");
format = "Text Image...";
......@@ -2010,8 +2037,8 @@ public class IJ {
options = NewImage.FILL_BLACK;
else if (type.contains("ramp"))
options = NewImage.FILL_RAMP;
else if (type.contains("random"))
options = NewImage.FILL_RANDOM;
else if (type.contains("noise") || type.contains("random"))
options = NewImage.FILL_NOISE;
options += NewImage.CHECK_AVAILABLE_MEMORY;
return NewImage.createImage(title, width, height, depth, bitDepth, options);
}
......
......@@ -9,7 +9,6 @@ import ij.text.*;
import ij.macro.Interpreter;
import ij.io.Opener;
import ij.util.*;
import ij.macro.MacroRunner;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
......@@ -79,7 +78,7 @@ public class ImageJ extends Frame implements ActionListener,
MouseListener, KeyListener, WindowListener, ItemListener, Runnable {
/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
public static final String VERSION = "1.51q";
public static final String VERSION = "1.52d";
public static final String BUILD = "";
public static Color backgroundColor = new Color(237,237,237);
/** SansSerif, 12-point, plain font. */
......@@ -118,6 +117,7 @@ public class ImageJ extends Frame implements ActionListener,
private boolean embedded;
private boolean windowClosed;
private static String commandName;
private static boolean batchMode;
boolean hotkey;
......@@ -180,7 +180,6 @@ public class ImageJ extends Frame implements ActionListener,
addWindowListener(this);
setFocusTraversalKeysEnabled(false);
m.installStartupMacroSet(); //add custom tools
runStartupMacro();
Point loc = getPreferredLocation();
Dimension tbSize = toolbar.getPreferredSize();
......@@ -195,7 +194,7 @@ public class ImageJ extends Frame implements ActionListener,
Dimension size = getSize();
if (size!=null) {
if (IJ.debugMode) IJ.log("size: "+size);
if (IJ.isWindows() && size.height>108) {
if (IJ.isWindows() && (size.height>108||IJ.javaVersion()>=10)) {
// workaround for IJ window layout and FileDialog freeze problems with Windows 10 Creators Update
IJ.wait(10);
pack();
......@@ -217,23 +216,20 @@ public class ImageJ extends Frame implements ActionListener,
}
if (IJ.isMacintosh()&&applet==null) {
Object qh = null;
try {
qh = IJ.runPlugIn("MacAdapter", "");
} catch(Throwable e) {}
if (qh==null)
IJ.runPlugIn("QuitHandler", "");
}
if (applet==null)
IJ.runPlugIn("ij.plugin.DragAndDrop", "");
String str = m.getMacroCount()==1?" macro":" macros";
IJ.showStatus(version()+ m.getPluginCount() + " commands; " + m.getMacroCount() + str);
configureProxy();
if (applet==null)
loadCursors();
}
private void runStartupMacro() {
String macro = (new Startup()).getStartupMacro();
if (macro!=null && macro.length()>4)
new MacroRunner(macro);
(new ij.macro.StartupRunner()).run(batchMode); // run RunAtStartup and AutoRun macros
IJ.showStatus(version()+ m.getPluginCount() + " commands; " + m.getMacroCount() + str);
}
private void loadCursors() {
......@@ -373,7 +369,7 @@ public class ImageJ extends Frame implements ActionListener,
MenuItem item = (MenuItem)e.getSource();
MenuComponent parent = (MenuComponent)item.getParent();
String cmd = e.getItem().toString();
if ("Autorun".equals(cmd)) // Examples>Autorun
if ("Autorun Examples".equals(cmd)) // Examples>Autorun Examples
Prefs.autoRunExamples = e.getStateChange()==1;
else if ((Menu)parent==Menus.window)
WindowManager.activateWindow(cmd, item);
......@@ -455,7 +451,13 @@ public class ImageJ extends Frame implements ActionListener,
}
}
if ((!Prefs.requireControlKey || control || meta) && keyChar!='+') {
if (keyCode==KeyEvent.VK_SEPARATOR)
keyCode = KeyEvent.VK_DECIMAL;
boolean functionKey = keyCode>=KeyEvent.VK_F1 && keyCode<=KeyEvent.VK_F12;
boolean numPad = keyCode==KeyEvent.VK_DIVIDE || keyCode==KeyEvent.VK_MULTIPLY
|| keyCode==KeyEvent.VK_DECIMAL
|| (keyCode>=KeyEvent.VK_NUMPAD0 && keyCode<=KeyEvent.VK_NUMPAD9);
if ((!Prefs.requireControlKey||control||meta||functionKey||numPad) && keyChar!='+') {
Hashtable shortcuts = Menus.getShortcuts();
if (shift)
cmd = (String)shortcuts.get(new Integer(keyCode+200));
......@@ -477,13 +479,15 @@ public class ImageJ extends Frame implements ActionListener,
if (cmd==null) {
switch (keyCode) {
case KeyEvent.VK_TAB: WindowManager.putBehind(); return;
case KeyEvent.VK_BACK_SPACE: // delete
case KeyEvent.VK_BACK_SPACE: case KeyEvent.VK_DELETE:
if (!(shift||control||alt||meta)) {
if (deleteOverlayRoi(imp))
return;
if (imp!=null&&imp.getOverlay()!=null&&imp==GelAnalyzer.getGelImage())
return;
cmd="Clear";
hotkey=true;
}
break;
//case KeyEvent.VK_BACK_SLASH: cmd=IJ.altKeyDown()?"Animation Options...":"Start Animation"; break;
case KeyEvent.VK_EQUALS: cmd="In [+]"; break;
......@@ -678,31 +682,28 @@ public class ImageJ extends Frame implements ActionListener,
}
public static void main(String args[]) {
if (System.getProperty("java.version").substring(0,3).compareTo("1.5")<0) {
javax.swing.JOptionPane.showMessageDialog(null,"ImageJ "+VERSION+" requires Java 1.5 or later.");
System.exit(0);
}
boolean noGUI = false;
int mode = STANDALONE;
arguments = args;
//System.setProperty("file.encoding", "UTF-8");
int nArgs = args!=null?args.length:0;
boolean commandLine = false;
for (int i=0; i<nArgs; i++) {
String arg = args[i];
if (arg==null) continue;
if (args[i].startsWith("-")) {
if (args[i].startsWith("-batch"))
if (arg.startsWith("-batch")) {
noGUI = true;
else if (args[i].startsWith("-debug"))
batchMode = true;
} else if (arg.startsWith("-macro") || arg.endsWith(".ijm") || arg.endsWith(".txt"))
batchMode = true;
else if (arg.startsWith("-debug"))
IJ.setDebugMode(true);
else if (args[i].startsWith("-ijpath") && i+1<nArgs) {
else if (arg.startsWith("-ijpath") && i+1<nArgs) {
if (IJ.debugMode) IJ.log("-ijpath: "+args[i+1]);
Prefs.setHomeDir(args[i+1]);
commandLine = true;
args[i+1] = null;
} else if (args[i].startsWith("-port")) {
int delta = (int)Tools.parseDouble(args[i].substring(5, args[i].length()), 0.0);
} else if (arg.startsWith("-port")) {
int delta = (int)Tools.parseDouble(arg.substring(5, arg.length()), 0.0);
commandLine = true;
if (delta==0)
mode = EMBEDDED;
......@@ -710,7 +711,6 @@ public class ImageJ extends Frame implements ActionListener,
port = DEFAULT_PORT+delta;
}
}
}
// If existing ImageJ instance, pass arguments to it and quit.
boolean passArgs = mode==STANDALONE && !noGUI;
if (IJ.isMacOSX() && !commandLine)
......
......@@ -93,8 +93,8 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
private static int default16bitDisplayRange;
private boolean antialiasRendering = true;
private boolean ignoreGlobalCalibration;
private boolean oneSliceStack;
public boolean setIJMenuBar = Prefs.setIJMenuBar;
public boolean typeSet;
/** Constructs an uninitialized ImagePlus. */
......@@ -106,10 +106,10 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
/** Constructs an ImagePlus from an Image or BufferedImage. The first
argument will be used as the title of the window that displays the image.
Throws an IllegalStateException if an error occurs while loading the image. */
public ImagePlus(String title, Image img) {
public ImagePlus(String title, Image image) {
this.title = title;
if (img!=null)
setImage(img);
if (image!=null)
setImage(image);
setID();
}
......@@ -194,14 +194,14 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
if (IJ.debugMode) IJ.log(title + ": unlock");
}
private void waitForImage(Image img) {
private void waitForImage(Image image) {
if (comp==null) {
comp = IJ.getInstance();
if (comp==null)
comp = new Canvas();
}
imageLoaded = false;
if (!comp.prepareImage(img, this)) {
if (!comp.prepareImage(image, this)) {
double progress;
waitStart = System.currentTimeMillis();
while (!imageLoaded && !errorLoadingImage) {
......@@ -407,11 +407,10 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
if (isVisible())
return;
win = null;
//if (ip!=null) throw new IllegalArgumentException();
if ((IJ.isMacro() && ij==null) || Interpreter.isBatchMode()) {
if (isComposite()) ((CompositeImage)this).reset();
ImagePlus img = WindowManager.getCurrentImage();
if (img!=null) img.saveRoi();
ImagePlus imp = WindowManager.getCurrentImage();
if (imp!=null) imp.saveRoi();
WindowManager.setTempCurrentImage(this);
Interpreter.addBatchModeImage(this);
return;
......@@ -422,7 +421,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
if ((img!=null) && (width>=0) && (height>=0)) {
activated = false;
int stackSize = getStackSize();
//if (compositeImage) stackSize /= nChannels;
if (stackSize>1)
win = new StackWindow(this);
else if (getProperty(Plot.PROPERTY_KEY) != null)
......@@ -504,9 +502,9 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
/** Replaces the image, if any, with the one specified.
Throws an IllegalStateException if an error occurs
while loading the image. */
public void setImage(Image img) {
if (img instanceof BufferedImage) {
BufferedImage bi = (BufferedImage)img;
public void setImage(Image image) {
if (image instanceof BufferedImage) {
BufferedImage bi = (BufferedImage)image;
if (bi.getType()==BufferedImage.TYPE_USHORT_GRAY) {
setProcessor(null, new ShortProcessor(bi));
return;
......@@ -517,19 +515,17 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
}
roi = null;
errorLoadingImage = false;
waitForImage(img);
waitForImage(image);
if (errorLoadingImage)
throw new IllegalStateException ("Error loading image");
this.img = img;
int newWidth = img.getWidth(ij);
int newHeight = img.getHeight(ij);
int newWidth = image.getWidth(ij);
int newHeight = image.getHeight(ij);
boolean dimensionsChanged = newWidth!=width || newHeight!=height;
width = newWidth;
height = newHeight;
ip = null;
stack = null;
LookUpTable lut = new LookUpTable(img);
int type;
setStackNull();
LookUpTable lut = new LookUpTable(image);
int type = GRAY8;
if (lut.getMapSize() > 0) {
if (lut.isGrayscale())
type = GRAY8;
......@@ -537,8 +533,11 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
type = COLOR_256;
} else
type = COLOR_RGB;
if (image!=null && type==COLOR_RGB)
ip = new ColorProcessor(image);
if (ip==null && image!=null)
ip = new ByteProcessor(image);
setType(type);
setupProcessor();
this.img = ip.createImage();
if (win!=null) {
if (dimensionsChanged)
......@@ -600,7 +599,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
if (stackBitDepth>0 && getBitDepth()!=stackBitDepth)
throw new IllegalArgumentException("Wrong type for this stack");
} else {
stack = null;
setStackNull();
setCurrentSlice(1);
}
setProcessor2(title, ip, null);
......@@ -617,13 +616,15 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
if (ij!=null)
ip.setProgressBar(ij.getProgressBar());
int stackSize = 1;
boolean dimensionsChanged = width>0 && height>0 && (width!=ip.getWidth() || height!=ip.getHeight());
if (stack!=null) {
stackSize = stack.getSize();
if (currentSlice>stackSize)
setCurrentSlice(stackSize);
if (currentSlice>=1 && currentSlice<=stackSize && !dimensionsChanged)
stack.setPixels(ip.getPixels(),currentSlice);
}
img = null;
boolean dimensionsChanged = width>0 && height>0 && (width!=ip.getWidth() || height!=ip.getHeight());
if (dimensionsChanged) roi = null;
int type;
if (ip instanceof ByteProcessor)
......@@ -682,6 +683,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
if (this.stack==null)
newStack.viewers(+1);
this.stack = newStack;
oneSliceStack = false;
setProcessor2(title, ip, newStack);
if (win==null) {
if (resetCurrentSlice) setSlice(currentSlice);
......@@ -731,6 +733,15 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
setStack(null, newStack);
}
private synchronized void setStackNull() {
if (oneSliceStack && stack!=null && stack.size()>0) {
String label = stack.getSliceLabel(1);
setProperty("Label", label);
}
stack = null;
oneSliceStack = false;
}
/** Saves this image's FileInfo so it can be later
retieved using getOriginalFileInfo(). */
public void setFileInfo(FileInfo fi) {
......@@ -771,15 +782,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
}
void setupProcessor() {
if (imageType==COLOR_RGB) {
if (ip==null || ip instanceof ByteProcessor)
ip = new ColorProcessor(getImage());
} else if (ip==null || (ip instanceof ColorProcessor))
ip = new ByteProcessor(getImage());
if (roi!=null && roi.isArea())
ip.setRoi(roi.getBounds());
else
ip.resetRoi();
}
public boolean isProcessor() {
......@@ -792,9 +794,12 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
Sets the line width to the current line width and sets the
calibration table if the image is density calibrated. */
public ImageProcessor getProcessor() {
if (ip==null && img==null)
if (ip==null)
return null;
setupProcessor();
if (roi!=null && roi.isArea())
ip.setRoi(roi.getBounds());
else
ip.resetRoi();
if (!compositeImage)
ip.setLineWidth(Line.getWidth());
if (ij!=null)
......@@ -872,7 +877,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
/* Returns uncalibrated statistics for this image or ROI, including
256 bin histogram, pixelCount, mean, mode, min and max. */
public ImageStatistics getRawStatistics() {
setupProcessor();
if (roi!=null && roi.isArea())
ip.setRoi(roi);
else
......@@ -904,7 +908,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
is fixed at 256 and the histogram range is always 0-255.
*/
public ImageStatistics getStatistics(int mOptions, int nBins, double histMin, double histMax) {
setupProcessor();
if (roi!=null && roi.isArea())
ip.setRoi(roi);
else
......@@ -975,7 +978,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
/** If this is a stack, returns the number of slices, else returns 1. */
public int getStackSize() {
if (stack==null)
if (stack==null || oneSliceStack)
return 1;
else {
int slices = stack.getSize();
......@@ -1021,7 +1024,8 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
if (updateWin) {
if (nSlices!=getImageStackSize())
setOpenAsHyperStack(true);
ip=null; img=null;
ip = null;
img = null;
setPositionWithoutUpdate(getChannel(), getSlice(), getFrame());
if (isComposite()) ((CompositeImage)this).reset();
new StackWindow(this);
......@@ -1113,16 +1117,18 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
/** Returns the bit depth, 8, 16, 24 (RGB) or 32, or 0 if the bit depth
is unknown. RGB images actually use 32 bits per pixel. */
public int getBitDepth() {
if (imageType==GRAY8 && ip==null && img==null && !typeSet)
ImageProcessor ip2 = ip;
if (ip2==null)
return 0;
if (ip2 instanceof ByteProcessor)
return 8;
else if (ip2 instanceof ShortProcessor)
return 16;
else if (ip2 instanceof ColorProcessor)
return 24;
else if (ip2 instanceof FloatProcessor)
return 32;
return 0;
int bitDepth = 0;
switch (imageType) {
case GRAY8: case COLOR_256: bitDepth=8; break;
case GRAY16: bitDepth=16; break;
case GRAY32: bitDepth=32; break;
case COLOR_RGB: bitDepth=24; break;
}
return bitDepth;
}
/** Returns the number of bytes per pixel. */
......@@ -1139,7 +1145,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
return;
int previousType = imageType;
imageType = type;
typeSet = true;
if (imageType!=previousType) {
if (win!=null)
Menus.updateMenus();
......@@ -1159,8 +1164,8 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
if (isDicomTag(key))
return DicomTools.getTag(this, key);
if (getStackSize()>1) {
ImageStack stack = getStack();
String label = stack.getSliceLabel(getCurrentSlice());
ImageStack stack2 = getStack();
String label = stack2.getSliceLabel(getCurrentSlice());
if (label!=null && label.indexOf('\n')>0) {
String value = getStringProperty(key, label);
if (value!=null)
......@@ -1287,12 +1292,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
/** Returns true is this image uses an inverting LUT that
displays zero as white and 255 as black. */
public boolean isInvertedLut() {
if (ip==null) {
if (img==null)
return false;
setupProcessor();
}
return ip.isInvertedLut();
return ip!=null && ip.isInvertedLut();
}
private int[] pvalue = new int[4];
......@@ -1375,10 +1375,16 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
ImageProcessor ip2 = getProcessor();
if (ip2==null)
return s;
String label = (String)getProperty("Label");
if (label==null) {
String info = (String)getProperty("Info");
String label = info!=null?getTitle()+"\n"+info:null;
label = info!=null?getTitle()+"\n"+info:null; // DICOM metadata
}
s.addSlice(label, ip2);
s.update(ip2);
setStack(s);
ip = ip2;
oneSliceStack = true;
} else {
s = stack;
if (ip!=null) {
......@@ -1436,7 +1442,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
}
public void killStack() {
stack = null;
setStackNull();
trimProcessor();
}
......@@ -1520,11 +1526,14 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
ColorModel cm = ip.getColorModel();
double min = ip.getMin();
double max = ip.getMax();
ip = stack.getProcessor(1);
ImageProcessor ip2 = stack.getProcessor(1);
if (ip2!=null) {
ip = ip2;
ip.setColorModel(cm);
ip.setMinAndMax(min, max);
}
}
}
/** Set the current hyperstack position based on the stack index 'n' (one-based). */
public void setPosition(int n) {
......@@ -1563,13 +1572,12 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
roi.endPaste();
if (isProcessor())
stack.setPixels(ip.getPixels(),currentSlice);
ip = getProcessor();
setCurrentSlice(n);
Object pixels = null;
Overlay overlay2 = null;
if (stack.isVirtual() && !((stack instanceof FileInfoVirtualStack)||(stack instanceof AVI_Reader))) {
ImageProcessor ip2 = stack.getProcessor(currentSlice);
overlay2 = ip2.getOverlay();
overlay2 = ip2!=null?ip2.getOverlay():null;
if (overlay2!=null)
setOverlay(overlay2);
if (stack instanceof VirtualStack) {
......@@ -1577,7 +1585,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
if (props!=null)
setProperty("FHT", props.get("FHT"));
}
pixels = ip2.getPixels();
if (ip2!=null) pixels=ip2.getPixels();
} else
pixels = stack.getPixels(currentSlice);
if (ip!=null && pixels!=null) {
......@@ -1585,8 +1593,10 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
ip.setPixels(pixels);
ip.setSnapshotPixels(null);
} catch(Exception e) {}
} else
ip = stack.getProcessor(n);
} else {
ImageProcessor ip2 = stack.getProcessor(n);
if (ip2!=null) ip = ip2;
}
if (compositeImage && getCompositeMode()==IJ.COMPOSITE && ip!=null) {
int channel = getC();
if (channel>0 && channel<=getNChannels())
......@@ -1594,7 +1604,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
}
if (win!=null && win instanceof StackWindow)
((StackWindow)win).updateSliceSelector();
if ((Prefs.autoContrast||IJ.shiftKeyDown()) && nChannels==1 && imageType!=COLOR_RGB) {
if (Prefs.autoContrast && nChannels==1 && imageType!=COLOR_RGB) {
(new ContrastEnhancer()).stretchHistogram(ip,0.35,ip.getStats());
ContrastAdjuster.update();
//IJ.showStatus(n+": min="+ip.getMin()+", max="+ip.getMax());
......@@ -1631,8 +1641,10 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
/** Assigns 'newRoi' to this image and displays it if 'updateDisplay' is true. */
public void setRoi(Roi newRoi, boolean updateDisplay) {
if (newRoi==null)
{deleteRoi(); return;}
if (newRoi==null) {
deleteRoi();
return;
}
if (Recorder.record) {
Recorder recorder = Recorder.getInstance();
if (recorder!=null) recorder.imageUpdated(this);
......@@ -1752,7 +1764,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
if (roi!=null) {
saveRoi();
if (!(IJ.altKeyDown()||IJ.shiftKeyDown())) {
RoiManager rm = RoiManager.getInstance();
RoiManager rm = RoiManager.getRawInstance();
if (rm!=null)
rm.deselect(roi);
}
......@@ -1902,7 +1914,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
fi.nImages = getImageStackSize();
fi.whiteIsZero = isInvertedLut();
fi.intelByteOrder = false;
setupProcessor();
if (fi.nImages==1)
fi.pixels = ip.getPixels();
else
......@@ -2014,7 +2025,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
if (isComposite())
((CompositeImage)this).setChannelsUpdated(); //flush
}
stack = null;
setStackNull();
img = null;
win = null;
if (roi!=null) roi.setImage(null);
......@@ -2185,7 +2196,8 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
ImagePlus subclasses.
*/
public void mouseMoved(int x, int y) {
if (ij!=null)
Roi roi2 = getRoi();
if (ij!=null && (roi2==null || roi2.getState()==Roi.NORMAL))
ij.showStatus(getLocationAsString(x,y) + getValueAsString(x,y));
savex=x; savey=y;
}
......@@ -2222,21 +2234,21 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
Calibration cal = getCalibration();
if (getProperty("FHT")!=null)
return getFFTLocation(x, height-y, cal);
if (!(IJ.altKeyDown()||IJ.shiftKeyDown())) {
String s = " x="+d2s(cal.getX(x)) + ", y=" + d2s(cal.getY(y,height));
if (getStackSize()>1) {
int z = isDisplayedHyperStack()?getSlice()-1:getCurrentSlice()-1;
s += ", z="+d2s(cal.getZ(z));
String xx="", yy="";
if (cal.scaled()) {
xx = " ("+x+")";
yy = " ("+y+")";
}
return s;
} else {
String s = " x="+x+", y=" + y;
String s = " x="+d2s(cal.getX(x)) + xx + ", y=" + d2s(cal.getY(y,height)) + yy;
if (getStackSize()>1) {
Roi roi2 = getRoi();
if (roi2==null || roi2.getState()==Roi.NORMAL) {
int z = isDisplayedHyperStack()?getSlice()-1:getCurrentSlice()-1;
s += ", z=" + z;
String zz = cal.scaled()&&cal.getZ(z)!=z?" ("+z+")":"";
s += ", z="+d2s(cal.getZ(z))+zz;
}
return s;
}
return s;
}
private String d2s(double n) {
......@@ -2525,8 +2537,10 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
}
}
Overlay overlay2 = getOverlay();
if (overlay2!=null && imp2.getRoi()!=null)
if (overlay2!=null && imp2.getRoi()!=null) {
imp2.deleteRoi();
if (getWindow()!=null) IJ.wait(100);
}
setPointScale(imp2.getRoi(), overlay2);
ic2.setOverlay(overlay2);
ImageCanvas ic = getCanvas();
......@@ -2754,4 +2768,8 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
return setIJMenuBar && Prefs.setIJMenuBar;
}
public boolean isStack() {
return stack!=null;
}
}
......@@ -69,8 +69,8 @@ public class Macro {
/** Aborts the currently running macro or any plugin using IJ.run(). */
public static void abort() {
abort = true;
//IJ.log("Abort: "+Thread.currentThread().getName());
abort = true;
if (Thread.currentThread().getName().endsWith("Macro$")) {
table.remove(Thread.currentThread());
throw new RuntimeException(MACRO_CANCELED);
......
......@@ -231,6 +231,7 @@ public class Menus {
addPlugInItem(help, "Macros...", "ij.plugin.BrowserLauncher(\""+IJ.URL+"/macros/\")", 0, false);
addPlugInItem(help, "Macro Functions...", "ij.plugin.BrowserLauncher(\""+IJ.URL+"/developer/macro/functions.html\")", 0, false);
Menu examplesMenu = getExamplesMenu(ij);
addPlugInItem(examplesMenu, "Open as Panel", "ij.plugin.SimpleCommands(\"opencp\")", 0, false);
help.add(examplesMenu);
help.addSeparator();
addPlugInItem(help, "Update ImageJ...", "ij.plugin.ImageJ_Updater", 0, false);
......@@ -264,12 +265,23 @@ public class Menus {
public static Menu getExamplesMenu(ActionListener listener) {
Menu menu = new Menu("Examples");
Menu submenu = new Menu("Macro");
Menu submenu = new Menu("Plots");
addExample(submenu, "Example Plot", "Example_Plot_.ijm");
addExample(submenu, "Semi-log Plot", "Semi-log_Plot_.ijm");
addExample(submenu, "Arrow Plot", "Arrow_Plot_.ijm");
addExample(submenu, "Damped Wave Plot", "Damped_Wave_Plot_.ijm");
addExample(submenu, "Dynamic Plot", "Dynamic_Plot_.ijm");
addExample(submenu, "Dynamic Plot 2D", "Dynamic_Plot_2D_.ijm");
addExample(submenu, "Custom Plot Symbols", "Custom_Plot_Symbols_.ijm");
addExample(submenu, "Histograms", "Histograms_.ijm");
addExample(submenu, "Bar Charts", "Bar_Charts_.ijm");
addExample(submenu, "Shapes", "Plot_Shapes_.ijm");
submenu.addActionListener(listener);
menu.add(submenu);
submenu = new Menu("Macro");
addExample(submenu, "Sphere", "Sphere.ijm");
addExample(submenu, "Dialog Box", "Dialog_Box.ijm");
addExample(submenu, "Example Plot", "Example_Plot.ijm");
addExample(submenu, "Semi-log Plot", "Semi-log_Plot.ijm");
addExample(submenu, "Arrow Plot", "Arrow_Plot.ijm");
addExample(submenu, "Process Folder", "Batch_Process_Folder.ijm");
addExample(submenu, "OpenDialog Demo", "OpenDialog_Demo.ijm");
addExample(submenu, "Sine/Cosine Table", "Sine_Cosine_Table.ijm");
......@@ -280,18 +292,24 @@ public class Menus {
addExample(submenu, "Dual Progress Bars", "Dual_Progress_Bars.ijm");
addExample(submenu, "Grab Viridis Colormap", "Grab_Viridis_Colormap.ijm");
addExample(submenu, "Custom Measurement", "Custom_Measurement.ijm");
addExample(submenu, "Synthetic Images", "Synthetic_Images.ijm");
addExample(submenu, "Spiral Rotation", "Spiral_Rotation.ijm");
submenu.addSeparator();
addExample(submenu, "Circle Tool", "Circle_Tool.ijm");
addExample(submenu, "Star Tool", "Star_Tool.ijm");
submenu.addActionListener(listener);
menu.add(submenu);
submenu = new Menu("JavaScript");
addExample(submenu, "Sphere", "Sphere.js");
addExample(submenu, "Plasma Cloud", "Plasma_Cloud.js");
addExample(submenu, "Cloud Debugger", "Cloud_Debugger.js");
addExample(submenu, "Synthetic Images", "Synthetic_Images.js");
addExample(submenu, "Spiral Rotation", "Spiral_Rotation.js");
addExample(submenu, "Example Plot", "Example_Plot.js");
addExample(submenu, "Semi-log Plot", "Semi-log_Plot.js");
addExample(submenu, "Arrow Plot", "Arrow_Plot.js");
addExample(submenu, "Dynamic Plot", "Dynamic_Plot.js");
addExample(submenu, "Process Folder", "Batch_Process_Folder.js");
addExample(submenu, "Sine/Cosine Table", "Sine_Cosine_Table.js");
addExample(submenu, "Non-numeric Table", "Non-numeric_Table.js");
......@@ -301,6 +319,7 @@ public class Menus {
addExample(submenu, "Gamma Adjuster", "Gamma_Adjuster.js");
addExample(submenu, "Custom Measurement", "Custom_Measurement.js");
addExample(submenu, "Terabyte VirtualStack", "Terabyte_VirtualStack.js");
addExample(submenu, "Event Listener", "Event_Listener.js");
submenu.addActionListener(listener);
menu.add(submenu);
submenu = new Menu("BeanShell");
......@@ -314,7 +333,7 @@ public class Menus {
submenu = new Menu("Python");
addExample(submenu, "Sphere", "Sphere.py");
addExample(submenu, "Animated Gaussian Blur", "Animated_Gaussian_Blur.py");
addExample(submenu, "Rotational Animation", "Rotational_Animation.py");
addExample(submenu, "Spiral Rotation", "Spiral_Rotation.py");
addExample(submenu, "Overlay", "Overlay.py");
submenu.addActionListener(listener);
menu.add(submenu);
......@@ -329,7 +348,7 @@ public class Menus {
submenu.addActionListener(listener);
menu.add(submenu);
menu.addSeparator();
CheckboxMenuItem item = new CheckboxMenuItem("Autorun");
CheckboxMenuItem item = new CheckboxMenuItem("Autorun Examples");
menu.add(item);
item.addItemListener(ij);
item.setState(Prefs.autoRunExamples);
......@@ -427,7 +446,8 @@ public class Menus {
if (applet==null && f.exists() && f.isDirectory())
list = f.list();
if (list==null) return;
if (IJ.isLinux()) StringSorter.sort(list);
if (IJ.isLinux() || IJ.isMacOSX())
Arrays.sort(list);
submenu.addSeparator();
for (int i=0; i<list.length; i++) {
String name = list[i];
......@@ -463,7 +483,6 @@ public class Menus {
boolean functionKey = keyCode>=KeyEvent.VK_F1 && keyCode<=KeyEvent.VK_F12;
if (keyCode>0 && !functionKey)
command = command.substring(0,openBracket);
//IJ.write(command+": "+shortcut);
}
}
if (keyCode>=KeyEvent.VK_F1 && keyCode<=KeyEvent.VK_F12) {
......@@ -1044,7 +1063,6 @@ public class Menus {
v.addElement(dir+name);
classCount++;
className = name;
//IJ.write("File: "+f+"/"+name);
} else if (hasUnderscore && (name.endsWith(".jar") || name.endsWith(".zip"))) {
if (jarFiles==null) jarFiles = new Vector();
jarFiles.addElement(f.getPath() + File.separator + name);
......@@ -1305,7 +1323,6 @@ public class Menus {
window.insertSeparator(WINDOW_MENU_ITEMS+windowMenuItems2);
windowMenuItems2++;
}
//IJ.write("insertWindowMenuItem: "+windowMenuItems2);
}
/** Adds one image to the end of the Window menu. */
......@@ -1521,17 +1538,6 @@ public class Menus {
}
void installStartupMacroSet() {
if (applet!=null) {
String docBase = ""+applet.getDocumentBase();
if (!docBase.endsWith("/")) {
int index = docBase.lastIndexOf("/");
if (index!=-1)
docBase = docBase.substring(0, index+1);
}
IJ.runPlugIn("ij.plugin.URLOpener", docBase+"StartupMacros.txt");
return;
}
if (macrosPath==null) {
try {
(new MacroInstaller()).installFromIJJar("/macros/StartupMacros.txt");
......@@ -1547,6 +1553,9 @@ public class Menus {
(new MacroInstaller()).installFromIJJar("/macros/StartupMacros.txt");
return;
}
} else {
if ("StartupMacros.fiji.ijm".equals(f.getName()))
path = f.getPath();
}
String libraryPath = macrosPath + "Library.txt";
f = new File(libraryPath);
......@@ -1554,7 +1563,7 @@ public class Menus {
try {
MacroInstaller mi = new MacroInstaller();
if (isLibrary) mi.installLibrary(libraryPath);
mi.installFile(path);
mi.installStartupMacros(path);
nMacros += mi.getMacroCount();
} catch (Exception e) {}
}
......
......@@ -217,7 +217,7 @@ public class OtherInstance {
if (s!=null) {
try {
return Integer.decode(s).intValue();
} catch (NumberFormatException e) {IJ.write(""+e);}
} catch (NumberFormatException e) {IJ.log(""+e);}
}
return -1;
}
......
......@@ -55,7 +55,8 @@ public class Prefs {
private static final int USE_SYSTEM_PROXIES=1<<0, USE_FILE_CHOOSER=1<<1,
SUBPIXEL_RESOLUTION=1<<2, ENHANCED_LINE_TOOL=1<<3, SKIP_RAW_DIALOG=1<<4,
REVERSE_NEXT_PREVIOUS_ORDER=1<<5, AUTO_RUN_EXAMPLES=1<<6, SHOW_ALL_POINTS=1<<7,
DO_NOT_SAVE_WINDOW_LOCS=1<<8, JFILE_CHOOSER_CHANGED=1<<9;
DO_NOT_SAVE_WINDOW_LOCS=1<<8, JFILE_CHOOSER_CHANGED=1<<9,
CANCEL_BUTTON_ON_RIGHT=1<<10;
public static final String OPTIONS2 = "prefs.options2";
/** file.separator system property */
......@@ -88,7 +89,7 @@ public class Prefs {
public static boolean antialiasedTools = true;
/** Export TIFF and Raw using little-endian byte order. */
public static boolean intelByteOrder;
/** Double buffer display of selections and overlays. */
/** No longer used */
public static boolean doubleBuffer = true;
/** Do not label multiple points created using point tool. */
public static boolean noPointLabels;
......@@ -142,13 +143,13 @@ public class Prefs {
public static boolean useFileChooser;
/** Use sub-pixel resolution with line selections */
public static boolean subPixelResolution;
/** Adjust contrast when scrolling stacks (or hold shift key down) */
/** Adjust contrast when scrolling stacks */
public static boolean autoContrast;
/** Allow lines to be created with one click at start and another at the end */
public static boolean enhancedLineTool;
/** Keep arrow selection after adding to overlay */
public static boolean keepArrowSelections;
/** Aways paint using double buffering, except on OS X */
/** Aways paint images using double buffering */
public static boolean paintDoubleBuffered;
/** Do not display dialog when opening .raw files */
public static boolean skipRawDialog;
......@@ -173,8 +174,12 @@ public class Prefs {
public static boolean convertToMicrons = true;
/** Wand tool "Smooth if thresholded" option */
public static boolean smoothWand;
/** "Close All" command running */
public static boolean closingAll;
/** Dialog "Cancel" button is on right on Linux */
public static boolean dialogCancelButtonOnRight;
static boolean commandLineMacro;
static Properties ijPrefs = new Properties();
static Properties props = new Properties(ijPrefs);
static String prefsDir;
......@@ -182,7 +187,6 @@ public class Prefs {
static String homeDir; // ImageJ folder
static int threads;
static int transparentIndex = -1;
static boolean commandLineMacro;
private static boolean resetPreferences;
/** Finds and loads the ImageJ configuration file, "IJ_Props.txt".
......@@ -325,7 +329,7 @@ public class Prefs {
if (s!=null) {
try {
return Integer.decode(s).intValue();
} catch (NumberFormatException e) {IJ.write(""+e);}
} catch (NumberFormatException e) {IJ.log(""+e);}
}
return defaultValue;
}
......@@ -403,6 +407,7 @@ public class Prefs {
prefs.put(NOISE_SD, Double.toString(Filters.getSD()));
if (threads>1) prefs.put(THREADS, Integer.toString(threads));
if (IJ.isMacOSX()) useJFileChooser = false;
if (!IJ.isLinux()) dialogCancelButtonOnRight = false;
saveOptions(prefs);
savePluginPrefs(prefs);
IJ.getInstance().savePreferences(prefs);
......@@ -470,8 +475,8 @@ public class Prefs {
multiPointMode = (options&MULTI_POINT_MODE)!=0;
rotateYZ = (options&ROTATE_YZ)!=0;
flipXZ = (options&FLIP_XZ)!=0;
dontSaveHeaders = (options&DONT_SAVE_HEADERS)!=0;
dontSaveRowNumbers = (options&DONT_SAVE_ROW_NUMBERS)!=0;
//dontSaveHeaders = (options&DONT_SAVE_HEADERS)!=0;
//dontSaveRowNumbers = (options&DONT_SAVE_ROW_NUMBERS)!=0;
noClickToGC = (options&NO_CLICK_TO_GC)!=0;
avoidResliceInterpolation = (options&AVOID_RESLICE_INTERPOLATION)!=0;
keepUndoBuffers = (options&KEEP_UNDO_BUFFERS)!=0;
......@@ -488,6 +493,7 @@ public class Prefs {
showAllPoints = (options2&SHOW_ALL_POINTS)!=0;
doNotSaveWindowLocations = (options2&DO_NOT_SAVE_WINDOW_LOCS)!=0;
jFileChooserSettingChanged = (options2&JFILE_CHOOSER_CHANGED)!=0;
dialogCancelButtonOnRight = (options2&CANCEL_BUTTON_ON_RIGHT)!=0;
}
static void saveOptions(Properties prefs) {
......@@ -515,7 +521,8 @@ public class Prefs {
+ (reverseNextPreviousOrder?REVERSE_NEXT_PREVIOUS_ORDER:0)
+ (autoRunExamples?AUTO_RUN_EXAMPLES:0) + (showAllPoints?SHOW_ALL_POINTS:0)
+ (doNotSaveWindowLocations?DO_NOT_SAVE_WINDOW_LOCS:0)
+ (jFileChooserSettingChanged?JFILE_CHOOSER_CHANGED:0);
+ (jFileChooserSettingChanged?JFILE_CHOOSER_CHANGED:0)
+ (dialogCancelButtonOnRight?CANCEL_BUTTON_ON_RIGHT:0);
prefs.put(OPTIONS2, Integer.toString(options2));
}
......
......@@ -22,6 +22,10 @@ public class VirtualStack extends ImageStack {
/** Default constructor. */
public VirtualStack() { }
public VirtualStack(int width, int height) {
super(width, height);
}
/** Creates an empty virtual stack. */
public VirtualStack(int width, int height, ColorModel cm, String path) {
super(width, height, cm);
......@@ -185,10 +189,10 @@ public class VirtualStack extends ImageStack {
String label = labels[n-1];
if (label==null)
return names[n-1];
else if (label.length()<=60)
return label;
else
else if (label.length()>100 && label.indexOf('\n')>0)
return names[n-1]+"\n"+label;
else
return label;
}
/** Returns null. */
......
......@@ -15,6 +15,7 @@ public class WindowManager {
public static boolean checkForDuplicateName;
private static Vector imageList = new Vector(); // list of image windows
private static Vector activations = new Vector(); // list of image windows, ordered by activation time
private static Vector nonImageList = new Vector(); // list of non-image windows (Frames and Dialogs)
private static ImageWindow currentWindow; // active image window
private static Window frontWindow;
......@@ -44,6 +45,8 @@ public class WindowManager {
}
Undo.reset();
currentWindow = win;
activations.remove(win);
activations.add(win);
Menus.updateMenus();
if (Recorder.record && !IJ.isMacro())
Recorder.record("selectWindow", win.getImagePlus().getTitle());
......@@ -51,7 +54,6 @@ public class WindowManager {
/** Returns the active ImageWindow. */
public static ImageWindow getCurrentWindow() {
//if (IJ.debugMode) IJ.write("ImageWindow.getCurrentWindow");
return currentWindow;
}
......@@ -75,7 +77,7 @@ public class WindowManager {
image for this thread. Call again with a null
argument to revert to the previous active image. */
public static void setTempCurrentImage(ImagePlus img) {
//IJ.log("setTempImage: "+(img!=null?img.getTitle():"null")+" "+Thread.currentThread().hashCode());
//IJ.log("setTempImage: "+(img!=null?""+img:"null")+" "+Thread.currentThread().hashCode());
if (img==null)
tempImageTable.remove(Thread.currentThread());
else
......@@ -102,7 +104,7 @@ public class WindowManager {
ImagePlus imp = getFocusManagerActiveImage();
if (imp!=null)
return imp;
ImageWindow win = (ImageWindow)imageList.elementAt(imageList.size()-1);
ImageWindow win = (ImageWindow)imageList.get(imageList.size()-1);
return win.getImagePlus();
} else
return Interpreter.getLastBatchModeImage();
......@@ -157,7 +159,7 @@ public class WindowManager {
list[i] = batchModeImages[i];
int index = 0;
for (int i=nBatchImages; i<nBatchImages+nWindows; i++) {
ImageWindow win = (ImageWindow)imageList.elementAt(index++);
ImageWindow win = (ImageWindow)imageList.get(index++);
list[i] = win.getImagePlus().getID();
}
return list;
......@@ -180,7 +182,7 @@ public class WindowManager {
public synchronized static Frame[] getNonImageWindows() {
ArrayList list = new ArrayList();
for (int i=0; i<nonImageList.size(); i++) {
Object win = nonImageList.elementAt(i);
Object win = nonImageList.get(i);
if (win instanceof Frame)
list.add(win);
}
......@@ -193,7 +195,7 @@ public class WindowManager {
public synchronized static Window[] getAllNonImageWindows() {
ArrayList list = new ArrayList();
for (int i=0; i<nonImageList.size(); i++) {
Object win = nonImageList.elementAt(i);
Object win = nonImageList.get(i);
if (win instanceof Window)
list.add(win);
}
......@@ -206,7 +208,7 @@ public class WindowManager {
public synchronized static String[] getNonImageTitles() {
ArrayList list = new ArrayList();
for (int i=0; i<nonImageList.size(); i++) {
Object win = nonImageList.elementAt(i);
Object win = nonImageList.get(i);
String title = win instanceof Frame?((Frame)win).getTitle():((Dialog)win).getTitle();
list.add(title);
}
......@@ -220,7 +222,6 @@ public class WindowManager {
For IDs greater than zero, returns the Nth ImagePlus. Returns null if
the ID is zero. */
public synchronized static ImagePlus getImage(int imageID) {
//if (IJ.debugMode) IJ.write("ImageWindow.getImage");
if (imageID>0)
imageID = getNthImageID(imageID);
if (imageID==0 || getImageCount()==0)
......@@ -230,7 +231,7 @@ public class WindowManager {
return imp2;
ImagePlus imp = null;
for (int i=0; i<imageList.size(); i++) {
ImageWindow win = (ImageWindow)imageList.elementAt(i);
ImageWindow win = (ImageWindow)imageList.get(i);
imp2 = win.getImagePlus();
if (imageID==imp2.getID()) {
imp = imp2;
......@@ -255,7 +256,7 @@ public class WindowManager {
return list[n-1];
} else {
if (n>imageList.size()) return 0;
ImageWindow win = (ImageWindow)imageList.elementAt(n-1);
ImageWindow win = (ImageWindow)imageList.get(n-1);
if (win!=null)
return win.getImagePlus().getID();
else
......@@ -278,14 +279,13 @@ public class WindowManager {
/** Adds the specified window to the Window menu. */
public synchronized static void addWindow(Window win) {
//IJ.write("addWindow: "+win.getTitle());
if (win==null)
return;
else if (win instanceof ImageWindow)
addImageWindow((ImageWindow)win);
else {
Menus.insertWindowMenuItem(win);
nonImageList.addElement(win);
nonImageList.add(win);
}
}
......@@ -298,7 +298,7 @@ public class WindowManager {
ImagePlus imp = win.getImagePlus();
if (imp==null) return;
checkForDuplicateName(imp);
imageList.addElement(win);
imageList.add(win);
Menus.addWindowMenuItem(imp);
setCurrentWindow(win);
}
......@@ -315,7 +315,7 @@ public class WindowManager {
static boolean isDuplicateName(String name) {
int n = imageList.size();
for (int i=0; i<n; i++) {
ImageWindow win = (ImageWindow)imageList.elementAt(i);
ImageWindow win = (ImageWindow)imageList.get(i);
String name2 = win.getImagePlus().getTitle();
if (name.equals(name2))
return true;
......@@ -353,14 +353,12 @@ public class WindowManager {
/** Removes the specified window from the Window menu. */
public synchronized static void removeWindow(Window win) {
//IJ.write("removeWindow: "+win.getTitle());
if (win instanceof ImageWindow)
removeImageWindow((ImageWindow)win);
else {
int index = nonImageList.indexOf(win);
ImageJ ij = IJ.getInstance();
if (index>=0) {
//if (ij!=null && !ij.quitting())
Menus.removeWindowMenuItem(index);
nonImageList.removeElement(win);
}
......@@ -377,14 +375,13 @@ public class WindowManager {
int index = imageList.indexOf(win);
if (index==-1)
return; // not on the window list
if (imageList.size()>1 && IJ.isMacro()) {
int newIndex = index-1;
if (newIndex<0)
newIndex = imageList.size()-1;
setCurrentWindow((ImageWindow)imageList.elementAt(newIndex));
imageList.removeElementAt(index);
activations.remove(win);
if (imageList.size()>1 && !Prefs.closingAll) {
ImageWindow win2 = activations.size()>0?(ImageWindow)activations.get(activations.size()-1):null;
setCurrentWindow(win2);
} else
currentWindow = null;
imageList.removeElementAt(index);
setTempCurrentImage(null); //???
int nonImageCount = nonImageList.size();
if (nonImageCount>0)
......@@ -396,6 +393,7 @@ public class WindowManager {
/** The specified Window becomes the front window. */
public static void setWindow(Window win) {
//System.out.println("setWindow: "+win);
frontWindow = win;
if (win instanceof Frame)
frontFrame = (Frame)win;
......@@ -405,17 +403,21 @@ public class WindowManager {
public static void setWindow(Frame win) {
frontWindow = win;
frontFrame = win;
//IJ.log("Set window: "+(win!=null?win.getTitle():"null"));
//System.out.println("Set window: "+(win!=null?win.getTitle():"null"));
}
/** Closes all windows. Stops and returns false if an image or Editor "save changes" dialog is canceled. */
public synchronized static boolean closeAllWindows() {
Prefs.closingAll = true;
while (imageList.size()>0) {
if (!((ImageWindow)imageList.elementAt(0)).close())
if (!((ImageWindow)imageList.get(0)).close()) {
Prefs.closingAll = false;
return false;
}
if (!quittingViaMacro())
IJ.wait(100);
}
Prefs.closingAll = false;
Frame[] nonImages = getNonImageWindows();
for (int i=0; i<nonImages.length; i++) {
Frame frame = nonImages[i];
......@@ -460,7 +462,7 @@ public class WindowManager {
do {
index--;
if (index<0) index = imageList.size()-1;
win = (ImageWindow)imageList.elementAt(index);
win = (ImageWindow)imageList.get(index);
if (++count==imageList.size()) return;
} while (win instanceof HistogramWindow || win instanceof PlotWindow);
if (win==null) return;
......@@ -478,7 +480,7 @@ public class WindowManager {
title, or null if a window with that title is not found. */
public static Window getWindow(String title) {
for (int i=0; i<nonImageList.size(); i++) {
Object win = nonImageList.elementAt(i);
Object win = nonImageList.get(i);
String winTitle = win instanceof Frame?((Frame)win).getTitle():((Dialog)win).getTitle();
if (title.equals(winTitle))
return (Window)win;
......@@ -489,7 +491,7 @@ public class WindowManager {
/** Obsolete; replaced by getWindow(). */
public static Frame getFrame(String title) {
for (int i=0; i<nonImageList.size(); i++) {
Object win = nonImageList.elementAt(i);
Object win = nonImageList.get(i);
String winTitle = win instanceof Frame?((Frame)win).getTitle():null;
if (title.equals(winTitle))
return (Frame)win;
......@@ -519,7 +521,7 @@ public class WindowManager {
/** Activates a window selected from the Window menu. */
synchronized static void activateWindow(String menuItemLabel, MenuItem item) {
for (int i=0; i<nonImageList.size(); i++) {
Object win = nonImageList.elementAt(i);
Object win = nonImageList.get(i);
String title = win instanceof Frame?((Frame)win).getTitle():((Dialog)win).getTitle();
if (menuItemLabel.equals(title)) {
if (win instanceof Frame)
......@@ -567,15 +569,20 @@ public class WindowManager {
}
}
static void showList() {
if (IJ.debugMode) {
public static void showList() {
for (int i=0; i<imageList.size(); i++) {
ImageWindow win = (ImageWindow)imageList.elementAt(i);
ImageWindow win = (ImageWindow)imageList.get(i);
ImagePlus imp = win.getImagePlus();
IJ.log(i + " " + imp.getTitle() + (win==currentWindow?"*":""));
IJ.log(i + " " + imp.getTitle() + (win==currentWindow?"*":"")+" "+imp.getID());
}
IJ.log(" ");
for (int i=0; i<activations.size(); i++) {
ImageWindow win = (ImageWindow)activations.get(i);
ImagePlus imp = win.getImagePlus();
IJ.log(i + " " + imp.getTitle() + " " + imp.getID());
}
if (imageList.size()==0) IJ.log("imageList is empty");
if (activations.size()==0) IJ.log("activations list is empty");
IJ.log(" ");
}
public static void toFront(Frame frame) {
......
......@@ -61,6 +61,7 @@ public class Arrow extends Line {
if (fillColor!=null) color = fillColor;
g.setColor(color);
Graphics2D g2 = (Graphics2D)g;
if (!overlay)
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
AffineTransform at = g2.getDeviceConfiguration().getDefaultTransform();
double mag = getMagnification();
......
This diff is collapsed.
......@@ -448,7 +448,6 @@ public class HistogramWindow extends ImageWindow implements Measurements, Action
/** Returns the histogram values as a ResultsTable. */
public ResultsTable getResultsTable() {
ResultsTable rt = new ResultsTable();
rt.showRowNumbers(false);
rt.setPrecision(digits);
String vheading = stats.binSize==1.0?"value":"bin start";
if (cal.calibrated() && !cal.isSigned16Bit()) {
......@@ -459,6 +458,8 @@ public class HistogramWindow extends ImageWindow implements Measurements, Action
}
} else {
for (int i=0; i<stats.nBins; i++) {
if (stats.binSize!=1.0)
rt.setValue("index", i, i);
rt.setValue(vheading, i, cal.getCValue(stats.histMin+i*stats.binSize));
rt.setValue("count", i, histogram[i]);
}
......