Developping new UI for ImageJ

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Developping new UI for ImageJ

Mongis Cyril
Hi everyone,

I'm currently embedding ImageJ in one my application but I use JavaFX for the user interface. I would like to channel the image windows, which are created and handled by ImageJ, to JavaFX elements. In other words, when a plugin wants to display an image, this image would be displayed in a JavaFX element. While JavaFX is relatively easy to handle, it's pretty hard to understand the structure of the ImageJ User Interface stack and the interactions between the classes that composes it. I know that the ImageDisplayService has a certain role but I have troubles to see when practical decisions (like drawing the image in a canvas, or adding a slider for the Z position, or changing the name of the window in the swing part) are taken. I looked in the imagej-ui-swing so I have an idea about the location of some events. But I also don't know how to signal ImageJ that there is an other UI connected to ImageJ/

Which class should I re-implement ? I guess I should re-implement the same classes as the ones implemented in the imagej-swing-ui module then, how to set it in the context ?

Is there any drawing that represent the UI interaction scheme ? ( when a image is opened for instance)

Is there any resources that would provide some base knowledge to better understand the UI stack.

I would of course commit my work to the community.

Cheers,

Cyril MONGIS

_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: Developping new UI for ImageJ

Lee Kamentsky
Just a couple hints - although my name is on a lot of the files, that's from several years ago. Others are far more expert than I.

There are two projects that control the toolkit-specific aspects of the ui: https://github.com/imagej/imagej-ui-swing and https://github.com/scijava/scijava-ui-swing

You might find far more of the bulk of the UI in scijava-ui-swing. Those are the generic parts, things like frames, menus and controls. The root of it all is org.scijava.ui.UserInterface - if you implement this interface and annotate it, it will be the one that's used if your jar is in the classpath instead of the Swing one: https://github.com/scijava/scijava-ui-swing/blob/master/src/main/java/org/scijava/ui/swing/sdi/SwingSDIUI.java#L59
If you want your stuff to show up first, with the other jars being there already, you can develop a plugin with a higher priority (see the documentation for Plugin). For instance, if you want a new display viewer, just implement one derived from DisplayViewer, make its plugin priority higher than SwingSDIImageDisplayViewer and it wil be the one that's used. I thing that might be close to what you want to do.

On Thu, Mar 26, 2015 at 11:48 AM, Mongis Cyril <[hidden email]> wrote:
Hi everyone,

I'm currently embedding ImageJ in one my application but I use JavaFX for the user interface. I would like to channel the image windows, which are created and handled by ImageJ, to JavaFX elements. In other words, when a plugin wants to display an image, this image would be displayed in a JavaFX element. While JavaFX is relatively easy to handle, it's pretty hard to understand the structure of the ImageJ User Interface stack and the interactions between the classes that composes it. I know that the ImageDisplayService has a certain role but I have troubles to see when practical decisions (like drawing the image in a canvas, or adding a slider for the Z position, or changing the name of the window in the swing part) are taken. I looked in the imagej-ui-swing so I have an idea about the location of some events. But I also don't know how to signal ImageJ that there is an other UI connected to ImageJ/

Which class should I re-implement ? I guess I should re-implement the same classes as the ones implemented in the imagej-swing-ui module then, how to set it in the context ?

Is there any drawing that represent the UI interaction scheme ? ( when a image is opened for instance)

Is there any resources that would provide some base knowledge to better understand the UI stack.

I would of course commit my work to the community.

Cheers,

Cyril MONGIS

_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel



_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: Developping new UI for ImageJ

Brian Schlining
In reply to this post by Mongis Cyril

Hi,

On March 26, 2015 at 8:49:21 AM, Mongis Cyril ([hidden email]) wrote:


I'm currently embedding ImageJ in one my application but I use JavaFX for the user interface. I would like to channel the image windows, which are created and handled by ImageJ, to JavaFX elements. In other words, when a plugin wants to display an image, this image would be displayed in a JavaFX element. 


I have some code that may help get you going. The source is under https://github.com/hohonuuli/assignments-openimaj. Specifically, you should take a look at the classes in https://github.com/hohonuuli/assignments-openimaj/tree/master/src/main/java/org/mbari/javafx/scene/image

The code there is pretty straightforward. I wrote this code for an image processing course I was taking. You can display an image in a resizable JavaFX Stage likes so:

import java.net.URL;
import org.mbari.javafx.scene.image.*;

JavaFX.namedWindow("My Window",  
  new URL("https://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png"));

If you need a reference to the Stage you can do the following after you’ve created it:

Optional<ImageStage> stage = JavaFX.getNamedWindow("My Window");

Anyway, it will at least give you a starting point. There’s a method that takes a javafx.scene.image.Image instead of a URL too. You’ll still need to implement a conversion between ImageJ/imglib2 image formats and JavaFX’s Image. There’s also a Swing class the does something similar (e.g. Swing.namedWindow(...) in the project.

Good Luck

– Brian Schlining


_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: Developping new UI for ImageJ

Mongis Cyril
Hello everyone !

I had to put the project on pause for a couple of week but now I'm back on it. First, thank you for your help. Thanks to you, I succeeded to put the FxUI as prior UI. Also the JavaFX App is started in ImageJ. I could even generate a menu and all. I can call the "Open file" plugin and it uses the JavaFX routines to show the file dialogs and all. It's great. However, not much happens after that. My next questions goes about to the ImageDisplay stack. I have troubles understanding the "call stack" after the image has been open. What the difference between the DisplayService, ImageDisplay and ImageDisplayViewer ? An image is open but who decide of what and how ? Do I have to overwrite the ImageDisplayService or is it UI agnostic ?

Cheers

Cyril



2015-03-26 18:23 GMT+01:00 Brian Schlining <[hidden email]>:

Hi,

On March 26, 2015 at 8:49:21 AM, Mongis Cyril ([hidden email]) wrote:


I'm currently embedding ImageJ in one my application but I use JavaFX for the user interface. I would like to channel the image windows, which are created and handled by ImageJ, to JavaFX elements. In other words, when a plugin wants to display an image, this image would be displayed in a JavaFX element. 


I have some code that may help get you going. The source is under https://github.com/hohonuuli/assignments-openimaj. Specifically, you should take a look at the classes in https://github.com/hohonuuli/assignments-openimaj/tree/master/src/main/java/org/mbari/javafx/scene/image

The code there is pretty straightforward. I wrote this code for an image processing course I was taking. You can display an image in a resizable JavaFX Stage likes so:

import java.net.URL;
import org.mbari.javafx.scene.image.*;

JavaFX.namedWindow("My Window",  
  new URL("https://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png"));

If you need a reference to the Stage you can do the following after you’ve created it:

Optional<ImageStage> stage = JavaFX.getNamedWindow("My Window");

Anyway, it will at least give you a starting point. There’s a method that takes a javafx.scene.image.Image instead of a URL too. You’ll still need to implement a conversion between ImageJ/imglib2 image formats and JavaFX’s Image. There’s also a Swing class the does something similar (e.g. Swing.namedWindow(...) in the project.

Good Luck

– Brian Schlining



_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: Developping new UI for ImageJ

Jay Warrick
https://www.overleaf.com/read/prvfqjnzzxwq

I wrote this up a while back. It only touches a bit on your topics (I think) at a high level but maybe it would help. Hopefully it isn't outdated anymore.

Cheers,

Jay

On Apr 7, 2015, at 11:06 AM, Mongis Cyril <[hidden email]> wrote:

Hello everyone !

I had to put the project on pause for a couple of week but now I'm back on it. First, thank you for your help. Thanks to you, I succeeded to put the FxUI as prior UI. Also the JavaFX App is started in ImageJ. I could even generate a menu and all. I can call the "Open file" plugin and it uses the JavaFX routines to show the file dialogs and all. It's great. However, not much happens after that. My next questions goes about to the ImageDisplay stack. I have troubles understanding the "call stack" after the image has been open. What the difference between the DisplayService, ImageDisplay and ImageDisplayViewer ? An image is open but who decide of what and how ? Do I have to overwrite the ImageDisplayService or is it UI agnostic ?

Cheers

Cyril



2015-03-26 18:23 GMT+01:00 Brian Schlining <[hidden email]>:

Hi,

On March 26, 2015 at 8:49:21 AM, Mongis Cyril ([hidden email]) wrote:


I'm currently embedding ImageJ in one my application but I use JavaFX for the user interface. I would like to channel the image windows, which are created and handled by ImageJ, to JavaFX elements. In other words, when a plugin wants to display an image, this image would be displayed in a JavaFX element. 



I have some code that may help get you going. The source is under https://github.com/hohonuuli/assignments-openimaj. Specifically, you should take a look at the classes in https://github.com/hohonuuli/assignments-openimaj/tree/master/src/main/java/org/mbari/javafx/scene/image

The code there is pretty straightforward. I wrote this code for an image processing course I was taking. You can display an image in a resizable JavaFX Stage likes so:

import java.net.URL;
import org.mbari.javafx.scene.image.*;

JavaFX.namedWindow("My Window",  
  new URL("https://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png"));

If you need a reference to the Stage you can do the following after you’ve created it:

Optional<ImageStage> stage = JavaFX.getNamedWindow("My Window");

Anyway, it will at least give you a starting point. There’s a method that takes a javafx.scene.image.Image instead of a URL too. You’ll still need to implement a conversion between ImageJ/imglib2 image formats and JavaFX’s Image. There’s also a Swing class the does something similar (e.g. Swing.namedWindow(...) in the project.

Good Luck

– Brian Schlining


_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel


_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: Developping new UI for ImageJ

Curtis Rueden
In reply to this post by Mongis Cyril
Hi Cyril,

> What the difference between the DisplayService, ImageDisplay and
> ImageDisplayViewer ?

The DisplayService is the service for working with Displays. It is UI agnostic, and should not need to be overridden.

ImageDisplay is a Display for image objects. These are UI agnostic.

ImageDisplayViewer is the actual UI-specific implementation (e.g., SwingImageDisplayViewer in imagej-ui-swing), which creates and shows the UI components for the desired ImageDisplay.

> An image is open but who decide of what and how ?

The UIService responds to DisplayCreatedEvents, creating and showing a DisplayViewer for each currently visible UI [1, 2, 3].

> Do I have to overwrite the ImageDisplayService or is it UI agnostic ?

The ImageDisplayService is a convenience service for working specifically with ImageDisplays (rather than the more general Displays). It is UI agnostic, and should not need to be overridden.

What you need to do is implement a JavaFXImageDisplayViewer, which will then be used to display the UI component that visualizes the image (i.e., the Dataset, which is wrapped in a DatasetView, which is wrapped in an ImageDisplay).

The current type hierarchy is at least one level too complex. FWIW, it evolved this way so that ImageDisplays could be fully headless [4]. But there are definitely ways to simplify the hierarchy. We will do it before the ImageJ2 data model comes out of beta.

See also these issues:

Regards,
Curtis




On Tue, Apr 7, 2015 at 11:06 AM, Mongis Cyril <[hidden email]> wrote:
Hello everyone !

I had to put the project on pause for a couple of week but now I'm back on it. First, thank you for your help. Thanks to you, I succeeded to put the FxUI as prior UI. Also the JavaFX App is started in ImageJ. I could even generate a menu and all. I can call the "Open file" plugin and it uses the JavaFX routines to show the file dialogs and all. It's great. However, not much happens after that. My next questions goes about to the ImageDisplay stack. I have troubles understanding the "call stack" after the image has been open. What the difference between the DisplayService, ImageDisplay and ImageDisplayViewer ? An image is open but who decide of what and how ? Do I have to overwrite the ImageDisplayService or is it UI agnostic ?

Cheers

Cyril



2015-03-26 18:23 GMT+01:00 Brian Schlining <[hidden email]>:

Hi,

On March 26, 2015 at 8:49:21 AM, Mongis Cyril ([hidden email]) wrote:


I'm currently embedding ImageJ in one my application but I use JavaFX for the user interface. I would like to channel the image windows, which are created and handled by ImageJ, to JavaFX elements. In other words, when a plugin wants to display an image, this image would be displayed in a JavaFX element. 


I have some code that may help get you going. The source is under https://github.com/hohonuuli/assignments-openimaj. Specifically, you should take a look at the classes in https://github.com/hohonuuli/assignments-openimaj/tree/master/src/main/java/org/mbari/javafx/scene/image

The code there is pretty straightforward. I wrote this code for an image processing course I was taking. You can display an image in a resizable JavaFX Stage likes so:

import java.net.URL;
import org.mbari.javafx.scene.image.*;

JavaFX.namedWindow("My Window",  
  new URL("https://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png"));

If you need a reference to the Stage you can do the following after you’ve created it:

Optional<ImageStage> stage = JavaFX.getNamedWindow("My Window");

Anyway, it will at least give you a starting point. There’s a method that takes a javafx.scene.image.Image instead of a URL too. You’ll still need to implement a conversion between ImageJ/imglib2 image formats and JavaFX’s Image. There’s also a Swing class the does something similar (e.g. Swing.namedWindow(...) in the project.

Good Luck

– Brian Schlining



_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel



_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: Developping new UI for ImageJ

Mongis Cyril
Hi, Jay and Curtis,

Thanks for your explanations, I could implement the triggering of the view. But since this part of the software may change in the future, I just overrode the  methods "show(Display<?> display)" ,which originally searches among the different Viewers, and made it create my own viewer. Now I'm attacking pixel drawing, and again, many components seems to interacts with each other. The low-level part of the software seems to have a lot of  control over the view. From what I saw, ImageJ proposes an abstraction of the ImageCanvas (which does not seems to hold any pixels) and publish modification of the canvas ( zoom, or drawn pixels ? ) as events, which should be then handled by the view. Am I correct ? I was just wondering : will this whole structure will be also modified in the future when implementing the guideline of the issue #154 ?

I implemented my own Canvas that uses JavaFx display elements. I guess I will just find a way to retrieve from the ImageDisplay the DatasetView which is already a pretty useful object.

What do you think ?

Cheers,

Cyril


2015-04-08 19:20 GMT+02:00 Curtis Rueden <[hidden email]>:
Hi Cyril,

> What the difference between the DisplayService, ImageDisplay and
> ImageDisplayViewer ?

The DisplayService is the service for working with Displays. It is UI agnostic, and should not need to be overridden.

ImageDisplay is a Display for image objects. These are UI agnostic.

ImageDisplayViewer is the actual UI-specific implementation (e.g., SwingImageDisplayViewer in imagej-ui-swing), which creates and shows the UI components for the desired ImageDisplay.

> An image is open but who decide of what and how ?

The UIService responds to DisplayCreatedEvents, creating and showing a DisplayViewer for each currently visible UI [1, 2, 3].

> Do I have to overwrite the ImageDisplayService or is it UI agnostic ?

The ImageDisplayService is a convenience service for working specifically with ImageDisplays (rather than the more general Displays). It is UI agnostic, and should not need to be overridden.

What you need to do is implement a JavaFXImageDisplayViewer, which will then be used to display the UI component that visualizes the image (i.e., the Dataset, which is wrapped in a DatasetView, which is wrapped in an ImageDisplay).

The current type hierarchy is at least one level too complex. FWIW, it evolved this way so that ImageDisplays could be fully headless [4]. But there are definitely ways to simplify the hierarchy. We will do it before the ImageJ2 data model comes out of beta.

See also these issues:

Regards,
Curtis




On Tue, Apr 7, 2015 at 11:06 AM, Mongis Cyril <[hidden email]> wrote:
Hello everyone !

I had to put the project on pause for a couple of week but now I'm back on it. First, thank you for your help. Thanks to you, I succeeded to put the FxUI as prior UI. Also the JavaFX App is started in ImageJ. I could even generate a menu and all. I can call the "Open file" plugin and it uses the JavaFX routines to show the file dialogs and all. It's great. However, not much happens after that. My next questions goes about to the ImageDisplay stack. I have troubles understanding the "call stack" after the image has been open. What the difference between the DisplayService, ImageDisplay and ImageDisplayViewer ? An image is open but who decide of what and how ? Do I have to overwrite the ImageDisplayService or is it UI agnostic ?

Cheers

Cyril



2015-03-26 18:23 GMT+01:00 Brian Schlining <[hidden email]>:

Hi,

On March 26, 2015 at 8:49:21 AM, Mongis Cyril ([hidden email]) wrote:


I'm currently embedding ImageJ in one my application but I use JavaFX for the user interface. I would like to channel the image windows, which are created and handled by ImageJ, to JavaFX elements. In other words, when a plugin wants to display an image, this image would be displayed in a JavaFX element. 


I have some code that may help get you going. The source is under https://github.com/hohonuuli/assignments-openimaj. Specifically, you should take a look at the classes in https://github.com/hohonuuli/assignments-openimaj/tree/master/src/main/java/org/mbari/javafx/scene/image

The code there is pretty straightforward. I wrote this code for an image processing course I was taking. You can display an image in a resizable JavaFX Stage likes so:

import java.net.URL;
import org.mbari.javafx.scene.image.*;

JavaFX.namedWindow("My Window",  
  new URL("https://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png"));

If you need a reference to the Stage you can do the following after you’ve created it:

Optional<ImageStage> stage = JavaFX.getNamedWindow("My Window");

Anyway, it will at least give you a starting point. There’s a method that takes a javafx.scene.image.Image instead of a URL too. You’ll still need to implement a conversion between ImageJ/imglib2 image formats and JavaFX’s Image. There’s also a Swing class the does something similar (e.g. Swing.namedWindow(...) in the project.

Good Luck

– Brian Schlining



_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel




_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel