A quick question to the Java aficionados in this group:
I have (like others) been using the java.awt.geom package (e.g., Point2D, Color, ...) extensively in many IJ plugins and API code related to geometry. Given the problems with AWT in batch (non-display) mode, I was thinking of using the javafx.geometry package (which apparently is now part of the official Java release) as a future replacement. Any comments if this might be a good idea at all? --Wilhelm -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Java FX is only bundled with Java 8, as far as I understand, ImageJ is built with Java6 (this means it will run with Java 7 and Java 8, but only if you explicitly launch the ij.jar with those Java JVMs)
The ImageJ Mac OS-X app is a wrapper that defaults to launching the ij.jar with a Java 6 JVM. I understand that there are discussion of getting imageJ to drop Java 6 and go with Java 7 (this gets my vote). I myself have been using Java 7 features for ImageJ plugins but (as said) for this to work I have to expressly launch Java with a Java 7 JVM. Despite Java FX not grabbing much of the limelight (when compared to HTML 5) my (limited) experience with it leads me to thinking it is a cracking technology with much to offer. That said, I am not sure Java FX will fair any better in batch (headless mode) as JavaFX initialisation depends on having a valid display available. — Michael Ellis On 12 Jan 2015, at 15:10, Burger Wilhelm <[hidden email]> wrote: > A quick question to the Java aficionados in this group: > > I have (like others) been using the java.awt.geom package (e.g., Point2D, Color, ...) extensively in many IJ plugins and API code related to geometry. Given the problems with AWT in batch (non-display) mode, I was thinking of using the javafx.geometry package (which apparently is now part of the official Java release) as a future replacement. > > Any comments if this might be a good idea at all? > > --Wilhelm > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Wilhelm,
> I have (like others) been using the java.awt.geom package (e.g., > Point2D, Color, ...) extensively in many IJ plugins and API code > related to geometry. Given the problems with AWT in batch > (non-display) mode, I was thinking of using the javafx.geometry > package (which apparently is now part of the official Java release) as > a future replacement. Most of the java.awt classes work headless if you set the java.awt.headless system property to true. The main exceptions are java.awt.Dialog and java.awt.Frame (i.e., the java.awt.Window implementations). You cannot instantiate AWT windows in headless mode. This is why you cannot use vanilla ImageJ 1.x headless: because a couple of its core classes extend those AWT classes. In particular, the ij.ImageJ class extends java.awt.Frame, and the ij.gui.GenericDialog class extends java.awt.Dialog. So you cannot instantiate an instance of ImageJ in headless mode, nor use many plugins that rely on the GenericDialog to harvest their input parameters. The ImageJ2 project (and by extension, Fiji) avoids this issue by patching ImageJ 1.x at runtime to avoid instantiating such classes whenever possible. It replaces GenericDialog with a version that does not extend the AWT Dialog class. TL;DR: The java.awt.geom classes are probably fine. Test it with java.awt.headless set to true and see what happens. Regards, Curtis P.S. There are versions of the JVM, though, which do not include the AWT classes. In particular, Java Micro Edition (JavaME) based distributions do not include it. So e.g. you cannot use AWT classes on Android. For this reason -- future portability -- the ImageJ2 core libraries try very hard to avoid using any AWT classes whatsoever. On Mon, Jan 12, 2015 at 9:33 AM, Michael Ellis <[hidden email]> wrote: > Java FX is only bundled with Java 8, as far as I understand, ImageJ is > built with Java6 (this means it will run with Java 7 and Java 8, but only > if you explicitly launch the ij.jar with those Java JVMs) > > The ImageJ Mac OS-X app is a wrapper that defaults to launching the ij.jar > with a Java 6 JVM. > > I understand that there are discussion of getting imageJ to drop Java 6 > and go with Java 7 (this gets my vote). > > I myself have been using Java 7 features for ImageJ plugins but (as said) > for this to work I have to expressly launch Java with a Java 7 JVM. > > Despite Java FX not grabbing much of the limelight (when compared to HTML > 5) my (limited) experience with it leads me to thinking it is a cracking > technology with much to offer. > > That said, I am not sure Java FX will fair any better in batch (headless > mode) as JavaFX initialisation depends on having a valid display available. > > — Michael Ellis > > > On 12 Jan 2015, at 15:10, Burger Wilhelm <[hidden email]> > wrote: > > > A quick question to the Java aficionados in this group: > > > > I have (like others) been using the java.awt.geom package (e.g., > Point2D, Color, ...) extensively in many IJ plugins and API code related to > geometry. Given the problems with AWT in batch (non-display) mode, I was > thinking of using the javafx.geometry package (which apparently is now part > of the official Java release) as a future replacement. > > > > Any comments if this might be a good idea at all? > > > > --Wilhelm > > > > -- > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Burger Wilhelm
Hi Wilhelm,
for classes like java.awt.geom.Point2D, I don't think that they depend on the display. The code seems to be rather simple, see, e.g. http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/java/awt/geom/Point2D.java Java.awt.Color seems to depend at least partly on the JNI/Toolkit. http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/java/awt/Color.java Michael ________________________________________________________________ On Jan 12, 2015, at 16:10, Burger Wilhelm wrote: > A quick question to the Java aficionados in this group: > > I have (like others) been using the java.awt.geom package (e.g., Point2D, Color, ...) extensively in many IJ plugins and API code related to geometry. Given the problems with AWT in batch (non-display) mode, I was thinking of using the javafx.geometry package (which apparently is now part of the official Java release) as a future replacement. > > Any comments if this might be a good idea at all? > > --Wilhelm > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thanks, Curtis and Michael, for your comments. Since javafx does not seem to offer any real advantage I decided to hold on to the AWT classes ...
Regards! --Wilhelm > -----Original Message----- > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of > Michael Schmid > Sent: Monday, January 12, 2015 6:01 PM > To: [hidden email] > Subject: Re: Java geometry question (awt vs. javafx) > > Hi Wilhelm, > > for classes like java.awt.geom.Point2D, I don't think that they depend on the > display. The code seems to be rather simple, see, e.g. > > > http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/ > 7-b147/java/awt/geom/Point2D.java > > Java.awt.Color seems to depend at least partly on the JNI/Toolkit. > > > http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/ > 7-b147/java/awt/Color.java > > Michael > __________________________________________________________ > ______ > On Jan 12, 2015, at 16:10, Burger Wilhelm wrote: > > > A quick question to the Java aficionados in this group: > > > > I have (like others) been using the java.awt.geom package (e.g., Point2D, > Color, ...) extensively in many IJ plugins and API code related to geometry. > Given the problems with AWT in batch (non-display) mode, I was thinking of > using the javafx.geometry package (which apparently is now part of the > official Java release) as a future replacement. > > > > Any comments if this might be a good idea at all? > > > > --Wilhelm > > > > -- > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
You might be interested in this implementation of Java2D for JavaFX:
https://github.com/jfree/fxgraphics2d Best regards Marcel |
Free forum by Nabble | Edit this page |