Attempting to modify the ImageJ user interface to create a "mini application"

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

Attempting to modify the ImageJ user interface to create a "mini application"

Grayson_Harrington
Hello all,

I have a plugin that needs to be used by people that aren't familiar with
ImageJ where I work. I made an AutoRun macro that opens the plugin when
ImageJ is first opened, but I would also like to somehow have the main
ImageJ window disabled so only the plugin is visible and able to be
interacted with.

I have the ImageJ source code visible on Eclipse from following this
<https://imagej.net/Developing_ImageJ_in_Eclipse> tutorial, but I don't
have access to the other classes that are listed in the maven dependencies,
such as the awt and swing classes. I think I need to use awt or swing to
modify the UI, but honestly, I'm not sure where to look/what to do to move
forward.

I would really appreciate some advice on how I can progress on the project!

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to modify the ImageJ user interface to create a "mini application"

Wayne Rasband-2
> On Jan 18, 2019, at 2:05 PM, Grayson Harrington <[hidden email]> wrote:
>
> Hello all,
>
> I have a plugin that needs to be used by people that aren't familiar with
> ImageJ where I work. I made an AutoRun macro that opens the plugin when
> ImageJ is first opened, but I would also like to somehow have the main
> ImageJ window disabled so only the plugin is visible and able to be
> interacted with.

You can hide the “ImageJ” window using this Java code

  IJ.getInstance().setVisible(false);

or this macro code

   eval(“js”,”IJ.getInstance().setVisible(false)”);

-wayne


> I have the ImageJ source code visible on Eclipse from following this
> <https://imagej.net/Developing_ImageJ_in_Eclipse> tutorial, but I don't
> have access to the other classes that are listed in the maven dependencies,
> such as the awt and swing classes. I think I need to use awt or swing to
> modify the UI, but honestly, I'm not sure where to look/what to do to move
> forward.
>
> I would really appreciate some advice on how I can progress on the project!

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to modify the ImageJ user interface to create a "mini application"

Grayson_Harrington
Hi Wayne,

Thank you for getting back to me with those tips. I tried using the macro
code solution and inserted the method you should me into my AutoRun macro
that's in the StartupMacros.txt file.

Here is the macro that I have:

   macro "AutoRun" {
        eval(“js”,”IJ.getInstance().setVisible(false)”);
        run ("APC Rating");
  }

Where "APC Rating" is the plugin that I mentioned in my first post.

Below is the Macro Error that shows up when I start ImageJ:
[image: Macro Error.PNG]

It appears to ot recognize "js". Do you know why this is happening?

Thank you,
Grayson

On Fri, Jan 18, 2019 at 6:35 PM Wayne Rasband <[hidden email]> wrote:

> > On Jan 18, 2019, at 2:05 PM, Grayson Harrington <
> [hidden email]> wrote:
> >
> > Hello all,
> >
> > I have a plugin that needs to be used by people that aren't familiar with
> > ImageJ where I work. I made an AutoRun macro that opens the plugin when
> > ImageJ is first opened, but I would also like to somehow have the main
> > ImageJ window disabled so only the plugin is visible and able to be
> > interacted with.
>
> You can hide the “ImageJ” window using this Java code
>
>   IJ.getInstance().setVisible(false);
>
> or this macro code
>
>    eval(“js”,”IJ.getInstance().setVisible(false)”);
>
> -wayne
>
>
> > I have the ImageJ source code visible on Eclipse from following this
> > <https://imagej.net/Developing_ImageJ_in_Eclipse> tutorial, but I don't
> > have access to the other classes that are listed in the maven
> dependencies,
> > such as the awt and swing classes. I think I need to use awt or swing to
> > modify the UI, but honestly, I'm not sure where to look/what to do to
> move
> > forward.
> >
> > I would really appreciate some advice on how I can progress on the
> project!
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

Macro Error.PNG (13K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to modify the ImageJ user interface to create a "mini application"

Cardone, Giovanni
Hi Grayson,

probably you need to fix the double quotes. Some text editors change them into different ones, which are not understood by the macro interpreter.

   macro "AutoRun" {
        eval("js","IJ.getInstance().setVisible(false)");
        run ("APC Rating");
  }

IHTH
Giovanni


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Grayson Harrington
Sent: Montag, 21. Januar 2019 14:59
To: [hidden email]
Subject: Re: Attempting to modify the ImageJ user interface to create a "mini application"

Hi Wayne,

Thank you for getting back to me with those tips. I tried using the macro code solution and inserted the method you should me into my AutoRun macro that's in the StartupMacros.txt file.

Here is the macro that I have:

   macro "AutoRun" {
        eval(“js”,”IJ.getInstance().setVisible(false)”);
        run ("APC Rating");
  }

Where "APC Rating" is the plugin that I mentioned in my first post.

Below is the Macro Error that shows up when I start ImageJ:
[image: Macro Error.PNG]

It appears to ot recognize "js". Do you know why this is happening?

Thank you,
Grayson

On Fri, Jan 18, 2019 at 6:35 PM Wayne Rasband <[hidden email]> wrote:

> > On Jan 18, 2019, at 2:05 PM, Grayson Harrington <
> [hidden email]> wrote:
> >
> > Hello all,
> >
> > I have a plugin that needs to be used by people that aren't familiar
> > with ImageJ where I work. I made an AutoRun macro that opens the
> > plugin when ImageJ is first opened, but I would also like to somehow
> > have the main ImageJ window disabled so only the plugin is visible
> > and able to be interacted with.
>
> You can hide the “ImageJ” window using this Java code
>
>   IJ.getInstance().setVisible(false);
>
> or this macro code
>
>    eval(“js”,”IJ.getInstance().setVisible(false)”);
>
> -wayne
>
>
> > I have the ImageJ source code visible on Eclipse from following this
> > <https://imagej.net/Developing_ImageJ_in_Eclipse> tutorial, but I
> > don't have access to the other classes that are listed in the maven
> dependencies,
> > such as the awt and swing classes. I think I need to use awt or
> > swing to modify the UI, but honestly, I'm not sure where to
> > look/what to do to
> move
> > forward.
> >
> > I would really appreciate some advice on how I can progress on the
> project!
>
> --
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to modify the ImageJ user interface to create a "mini application"

Grayson_Harrington
Thank you for the advice. I changed the double quotes and when I started
ImageJ the error from before was gone, but now I'm getting this
ReferenceError:

ReferenceError: "importPackage" is not defined in <eval> at line number 1

and the main ImageJ window is still visible. Has anyone seen this before or
does anyone know about it?

Thank you


On Mon, Jan 21, 2019 at 8:08 AM Cardone, Giovanni <[hidden email]>
wrote:

> Hi Grayson,
>
> probably you need to fix the double quotes. Some text editors change them
> into different ones, which are not understood by the macro interpreter.
>
>    macro "AutoRun" {
>         eval("js","IJ.getInstance().setVisible(false)");
>         run ("APC Rating");
>   }
>
> IHTH
> Giovanni
>
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Grayson Harrington
> Sent: Montag, 21. Januar 2019 14:59
> To: [hidden email]
> Subject: Re: Attempting to modify the ImageJ user interface to create a
> "mini application"
>
> Hi Wayne,
>
> Thank you for getting back to me with those tips. I tried using the macro
> code solution and inserted the method you should me into my AutoRun macro
> that's in the StartupMacros.txt file.
>
> Here is the macro that I have:
>
>    macro "AutoRun" {
>         eval(“js”,”IJ.getInstance().setVisible(false)”);
>         run ("APC Rating");
>   }
>
> Where "APC Rating" is the plugin that I mentioned in my first post.
>
> Below is the Macro Error that shows up when I start ImageJ:
> [image: Macro Error.PNG]
>
> It appears to ot recognize "js". Do you know why this is happening?
>
> Thank you,
> Grayson
>
> On Fri, Jan 18, 2019 at 6:35 PM Wayne Rasband <[hidden email]> wrote:
>
> > > On Jan 18, 2019, at 2:05 PM, Grayson Harrington <
> > [hidden email]> wrote:
> > >
> > > Hello all,
> > >
> > > I have a plugin that needs to be used by people that aren't familiar
> > > with ImageJ where I work. I made an AutoRun macro that opens the
> > > plugin when ImageJ is first opened, but I would also like to somehow
> > > have the main ImageJ window disabled so only the plugin is visible
> > > and able to be interacted with.
> >
> > You can hide the “ImageJ” window using this Java code
> >
> >   IJ.getInstance().setVisible(false);
> >
> > or this macro code
> >
> >    eval(“js”,”IJ.getInstance().setVisible(false)”);
> >
> > -wayne
> >
> >
> > > I have the ImageJ source code visible on Eclipse from following this
> > > <https://imagej.net/Developing_ImageJ_in_Eclipse> tutorial, but I
> > > don't have access to the other classes that are listed in the maven
> > dependencies,
> > > such as the awt and swing classes. I think I need to use awt or
> > > swing to modify the UI, but honestly, I'm not sure where to
> > > look/what to do to
> > move
> > > forward.
> > >
> > > I would really appreciate some advice on how I can progress on the
> > project!
> >
> > --
> > 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
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to modify the ImageJ user interface to create a "mini application"

Peterbauer Thomas
On 21.01.19 19:12, Grayson Harrington wrote:
> and the main ImageJ window is still visible. Has anyone seen this before or
> does anyone know about it?

It depends how far you want to take all this, but a cleaner solution
would be to revert the hierarchy: rather than running your plugin under
ImageJ, run ImageJ as library in your own app. The following class loads
ImageJ and makes it available for image processing without ever showing
the ImageJ window:

import ij.IJ;
import ij.ImageJ;
import ij.ImagePlus;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class MyApp extends JFrame {

     private ImageJ ij;

     public MyApp() {
         super("My Application");
         this.ij = new ImageJ(ImageJ.NO_SHOW);
         setSize(300, 300);
         setLocationRelativeTo(null);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         addWindowListener(new WindowAdapter() {

             @Override
             public void windowClosing(WindowEvent e) {
                 ij.quit();
                 super.windowClosing(e);
             }
         });
         JButton button = new JButton("Open Image...");
         button.addActionListener(new ActionListener() {

             @Override
             public void actionPerformed(ActionEvent e) {
                 ImagePlus imp = IJ.openImage();
                 imp.show();
             }
         });
         JPanel contentPane = new JPanel(new BorderLayout());
         getContentPane().add(contentPane);
         contentPane.add(button, BorderLayout.NORTH);
         setVisible(true);
     }

     public static void main(String[] args) {
         new MyApp();
     }
}



--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to modify the ImageJ user interface to create a "mini application"

jmutterer
In reply to this post by Grayson_Harrington
Hi Grayson,
You could also consider using an ActionBar that would expose only buttons
useful for your user. It has a mini app mode using the <main> tag that
hides the ImageJ tool bar.

Here's an example code for a mini app. Save this in Plugins>ActionBar, and
launch it at statup using run("mini app"); in Options>Startup...

// Action Bar description file :mini_app
run("Action Bar","/plugins/ActionBar/mini_app.ijm");
exit;

<main>

<DnDAction>
file=getArgument();
open(file);
run("8-bit");
</DnDAction>

<line>
<button>
label=Toggle IJ
icon=noicon
arg=<hide>

<button>
label=hello
icon=noicon
arg=<macro>
showMessage("hello");
</macro>
</line>

Jerome.


Le ven. 18 janv. 2019 à 23:35, Grayson Harrington <
[hidden email]> a écrit :

> Hello all,
>
> I have a plugin that needs to be used by people that aren't familiar with
> ImageJ where I work. I made an AutoRun macro that opens the plugin when
> ImageJ is first opened, but I would also like to somehow have the main
> ImageJ window disabled so only the plugin is visible and able to be
> interacted with.
>
> I have the ImageJ source code visible on Eclipse from following this
> <https://imagej.net/Developing_ImageJ_in_Eclipse> tutorial, but I don't
> have access to the other classes that are listed in the maven dependencies,
> such as the awt and swing classes. I think I need to use awt or swing to
> modify the UI, but honestly, I'm not sure where to look/what to do to move
> forward.
>
> I would really appreciate some advice on how I can progress on the project!
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html