Launcher: skip the class launcher when its .jar file is not present

It makes little sense to call the -- otherwise useful -- ClassLauncher
class when the ij-launcher .jar file is not present, as it is pretty
unlikely that said class will be found in that case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher: avoid segmentation fault when there is no jars/ directory

There is no jars/ directory in the plain ImageJ 1.x case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher: find ImageJ 1.x' shipped JRE

ImageJ 1.x comes in a variant where the JRE is shipped, living in
<ij.dir>/jre/. Of course, this prevents multi-platform installations
or portable applications, but let's support it nevertheless.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher: allow for legacy location of ij.jar

ImageJ 1.x has ij.jar in the ImageJ root directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher: special-case legacy .cfg files' -cp option

The option -cp is not understood by the JVM itself, but only by the Java
launcher. So we have to special-case it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher: don't repeat yourself

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher: fall back to ImageJ 1.x when neither Fiji nor ImageJ2 are found

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher: show certain messages only in verbose mode

Both the LD_LIBRARY_PATH message and the one about re-executing with
less reserved heap space can be pretty annoying.

Introduce the --verbose option and show them only when that option was
passed to the launcher.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher (Windows): only open console by default if the name is debug.exe

We had some cute code that would automatically open the console if the
executable was named ImageJ.exe. The idea was actually to open the
console if it was *not* named ImageJ.exe, but even that was misguided.

Instead, only launch the console if the name is 'debug.exe' which we can
tell users to do easily (it is much easier to rename a file on Windows
than to start it with command-line options).

Noticed by Wayne Rasband.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher: in verbose mode, tell us where you found the JRE

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher (Windows): be verbose when started as 'debug.exe'

The idea of being able to rename the executable to 'debug.exe' for
debugging suggests that we should be much more chatty in that case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher: let local jre/ have precendence over all other options

The jre/ subdirectory was established as the place where the JRE lives
by the ImageJ 1.x installer.

Obviously, this cannot support multi-platform installations (e.g. a
portable application for all supported platforms).

Hence we need to make sure that the jre/ subdirectory actually contains
a valid libjvm before going with it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher: remember result of the first get_jre_home() call

In verbose mode, it is a little annoying if the same result is reported
a couple of times. Instead, only try to find the JRE once and if none
was found, remember that fact (we already remembered when it was found).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher: heed the JRE setting in legacy ImageJ.cfg

The second line of the (not very well-documented) ImageJ.cfg format
is supposed to specify the path to javaw.exe.

If it points to java.exe instead, the launcher is expected to open
a console.

This entails basically a rewrite of the parse_legacy_config() function
since we used to only ever look at the third line. As a bonus, we
handle the case correctly now where ImageJ options were specified
after the main class.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher: heed the ImageJ options in legacy ImageJ.cfg

The third line of ImageJ.cfg specifies not only the Java options,
but optionally ImageJ options after the class name, e.g. '-debug'. For
backwards-compatibility, we want to support that, too.

Asked-for by Wayne Rasband.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Launcher: show the command-line in verbose mode

In contrast to the dry-run mode, we go forward and run with said
command-line, though.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Experimental code for implementing thresholding

This code tries to see how PointSets could be used to implement
thresholding.
Add some TODO notes
Make it possible to draw the threshold overlay in curr plane
Define an interface that allows Overlays to redraw

There might be better ways of doing this. But this allows an Overlay
to update its graphics in the graphic library of choice.