NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug.

The Fiji project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Bug 821 - can't get tool macro to start with Fiji
can't get tool macro to start with Fiji
Status: NEW
Product: Fiji
Classification: Unclassified
Component: Other
unspecified
PC Linux
: P5 enhancement
Assigned To: ImageJ Bugs Mailing List
Depends on:
Blocks:
 
Reported: 2014-06-26 01:45 CDT by Ilan Tal
Modified: 2014-07-05 23:44 CDT
1 user (show)

See Also:


Attachments
what I would like to see on start up (8.20 KB, image/png)
2014-06-29 14:14 CDT, Ilan Tal
ignore the fact that I changed the name. It is Postage something.... (94.24 KB, image/png)
2014-06-29 23:45 CDT, Ilan Tal
window level code (824 bytes, text/plain)
2014-07-05 23:39 CDT, Ilan Tal

Description Ilan Tal 2014-06-26 01:45:05 CDT
I've been look at
ImageJ Macro Language Programmer's Reference Guide ...
and trying to get my macro to come up installed in the Fiji buttons when Fiji starts. The macro is trivial, just for testing

macro "Postage Action Tool - R0063R0663R0c63Ra063Ra663Rac63" {
print("Tile");
}

I can put the macro into Fiji.app/macros/toolsets and then I can click on the >> button and choose them to appear on the buttons. The trouble is when I exit Fiji and then return, they are no longer on the buttons.

The next thing to try is to put the macro as part of StartupMacros.ijm in Fiji.App/AutoRun. That gets it to run once and print out "Tile", but doesn't get it to appear on the buttons.

I also tried to add it to StartupMacros.fiji.ijm in Fiji.app/macros but that also gets me nothing.

So, either I still don't understand the documentation, or there is a bug.

Suggestions? Thanks,
Ilan
Comment 1 Wayne Rasband 2014-06-26 09:46:46 CDT
Adding

  macro "Postage Action Tool - R0063R0663R0c63Ra063Ra663Rac63" {
     print("Tile");
  }

to the end of Fiji.app/macros/StartupMacros.fiji.ijm and restarting Fiji works for me. If the tool does not appear in the toolbar, try selecting "Restore Startup Tools" from the ">>" menu in the toolbar.
Comment 2 Ilan Tal 2014-06-26 10:39:35 CDT
Thanks Wayne. What you suggested worked, so I guess I didn't tell the whole story - not that I knew I wasn't telling the whole story.
First, I don't want all the startup tools. I want it simpler, with just 2 additional tools which I need. Never mind, here is what I didn't tell you.

From your documentation I found a Window-Level tool which changes the window-level by dragging the mouse. This is a class file, not a macro.
So, what I did was remove custom tools and add the Window-level tool.

I was delighted to see that it remembered the tool. I had my macro tool in Fiji.App/macros/toolsets. The same macro will do nicely for testing.
Now it nicely agrees to add the macro tool, together with the window-level class tool. But there is your catch-22. There seems to be no way that I can get it to bring up my macro tool when Fiji starts.
I tried putting it into Fiji.app/macros/AutoRun/StartupMacros.ijm where it would execute upon start up but not get put onto the tool bar.

Maybe it doesn't like the mix of class files with macro files?

Ilan
Comment 3 Wayne Rasband 2014-06-26 14:22:48 CDT
Using ImageJ, I can get both the macro tool and Window Level Tool plugin tool to be installed at startup by saving them in Image/plugins/tools, running Help>Refresh Menus and selecting them from the ">>" menu.

I got the Window Level Tool (Window_Level_Tool.class) from

   http://imagej.nih.gov/ij/plugins/window-level-tool/index.html

and the macro tool is a file named Postage_Action_Tool.ijm containing


  macro "Postage Action Tool - R0063R0663R0c63Ra063Ra663Rac63" {
     print("Tile");
  }

Fiji hangs when I select "Postage_Action_Tool" from the ">>" menu but I was able to work around this problem by adding the "Postage Action Tool" to Fiji.app/macros/StartupMacros.fiji.ijm.
Comment 4 Ilan Tal 2014-06-28 23:54:33 CDT
Hi Wayne,
I tried your suggestions and I get different results.
First of all Fiji didn't hang when I added Postage Action Tool from the ">>" menu. That would be very bad if for any reason Fiji hangs, and would need to be investigated as "why?".
On the other hand I gained nothing by adding it to Fiji.app/macros/StartupMacros.fiji.ijm. Adding it there had an effect only if I requested Restore Startup Tools, which I clearly didn't want to do.
I see a check in the menu item Postage Action Tool but the entry gets wiped from the menu bar each time I restart Fiji. On the other hand Window-Level nicely remains available on each Fiji restart - and it doesn't have that check before the menu entry. (I can certainly do without the check mark as it contributes nothing if the entry is there when Fiji starts. Clicking it again doesn't make the entry go away, which is what I might expect. In fact the only way to remove things is click on Remove Custom Tools. Still all of that is an aside.)

I still need a way to have the tool remain on the bar when Fiji starts. The people at Beth Israel have zero tolerance for extra clicks.

Thanks,
Ilan
Comment 5 Wayne Rasband 2014-06-29 12:21:18 CDT
Which custom tools are installed when Fiji starts? Which tools would you like to have installed? You can add more tools later, but only seven are installed at startup.
Comment 6 Ilan Tal 2014-06-29 13:55:59 CDT
Hi Wayne,
I'm not sure how you count 7 tools. What I would like to install is the Window-Level tool together the Postage Action Tool. The Window-Level which is a plugin tool stays on the buttons on start up. The Postage Action which is a macro doesn't appear on the buttons on start up.
My guess, and correct me if I am wrong, is the difference depends if it is a java class or a macro text. If you push me to the wall, I suppose I could convert the macro to a Java program. Seems like a waste, but if the macro won't stick around at start up, what other choice do I have?
Could I write some sort of macro to install the Postage Action at startup? There must be some way around this problem. The people at Beth Israel are starting Fiji all the time and each time to reinstall it is just totally unacceptable.

Maybe the Fiji.app/macros/StartupMacros.fiji.ijm can start some other file as well? Somehow I feel uncomfortable changing a "system file". I think it is this file which determines which macros are on the custom macros. To be barbaric I could erase the file and replace it with my own creation, but that is really barbaric. I don't know how to solve the problem.

Thanks,
Ilan
Comment 7 Ilan Tal 2014-06-29 14:14:51 CDT
Created attachment 169
what I would like to see on start up
Comment 8 Wayne Rasband 2014-06-29 19:28:41 CDT
A maximum of seven custom tools can be installed on startup.

In ImageJ, I can install the Window-Level tool and the Postage Action Tool this way:

  1. Select "Remove Custom Tools" from the ">>" menu.
  2. Select "Window Level Tool" from the ">>" menu.
  3. Select "Postage Action Tool" from the ">>" menu.

I now have two custom tools, and no other custom tools. When I restart ImageJ, these two custom tools are installed in the toolbar.

This assumes you have these two files in the ImageJ/plugins/Tools menu:

  Window_Level_Tool.class
  Postage_Action_Tool.ijm

In Fiji, step 3 does not work. Fiji runs the Postage Action Tool ("Tile" is displayed in the Log window) instead of installing it.
Comment 9 Wayne Rasband 2014-06-29 19:57:14 CDT
It turns out I was running the Life-Line version of Fiji. After running the Updater, Fiji hangs when I perform step 3 ("Select "Postage Action Tool" from the ">>" menu."), with "Running command: Postage Action Tool" displayed in the status bar. Here is the thread dump I get from pressing control+\ after running Fiji from the command line:


Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.14-b01-447 mixed mode):

"SciJava-1915470e-Thread-1" prio=5 tid=113ff7800 nid=0x123301000 in Object.wait() [123300000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <777cbab40> (a java.awt.EventQueue$1AWTInvocationLock)
	at java.lang.Object.wait(Object.java:485)
	at java.awt.EventQueue.invokeAndWait(EventQueue.java:1117)
	- locked <777cbab40> (a java.awt.EventQueue$1AWTInvocationLock)
	at java.awt.EventQueue.invokeAndWait(EventQueue.java:1099)
	at org.scijava.thread.DefaultThreadService.invoke(DefaultThreadService.java:98)
	at org.scijava.event.DefaultEventBus.publishNow(DefaultEventBus.java:191)
	at org.scijava.event.DefaultEventBus.publishNow(DefaultEventBus.java:82)
	at org.scijava.event.DefaultEventService.publish(DefaultEventService.java:91)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:153)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
	at org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:164)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
	at java.lang.Thread.run(Thread.java:680)

"DestroyJavaVM" prio=5 tid=114001000 nid=0x111983000 waiting on condition [00000000]
   java.lang.Thread.State: RUNNABLE

"SciJava-1915470e-Thread-0" prio=5 tid=114285000 nid=0x121dcf000 waiting on condition [121dce000]
   java.lang.Thread.State: TIMED_WAITING (parking)
	at sun.misc.Unsafe.park(Native Method)
	- parking to wait for  <778f33890> (a java.util.concurrent.SynchronousQueue$TransferStack)
	at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:196)
	at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:424)
	at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:323)
	at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:874)
	at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:955)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:917)
	at java.lang.Thread.run(Thread.java:680)

"Timer-0" daemon prio=5 tid=11442e800 nid=0x121ccc000 in Object.wait() [121ccb000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <778f33b10> (a java.util.TaskQueue)
	at java.util.TimerThread.mainLoop(Timer.java:509)
	- locked <778f33b10> (a java.util.TaskQueue)
	at java.util.TimerThread.run(Timer.java:462)

"Run$_AWT-EventQueue-0" prio=6 tid=11460e800 nid=0x122901000 waiting on condition [1228fe000]
   java.lang.Thread.State: WAITING (parking)
	at sun.misc.Unsafe.park(Native Method)
	- parking to wait for  <777c98348> (a java.util.concurrent.FutureTask$Sync)
	at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156)
	at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811)
	at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:969)
	at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1281)
	at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:218)
	at java.util.concurrent.FutureTask.get(FutureTask.java:83)
	at net.imagej.legacy.DefaultLegacyService.runLegacyCompatibleCommand(DefaultLegacyService.java:229)
	at net.imagej.legacy.DefaultLegacyHooks.interceptRunPlugIn(DefaultLegacyHooks.java:168)
	at ij.IJ.runPlugIn(IJ.java)
	at ij.Executer.runCommand(Executer.java:131)
	at ij.Executer.run(Executer.java:64)
	at ij.IJ.run(IJ.java:272)
	at ij.IJ.run(IJ.java:250)
	at ij.gui.Toolbar.itemStateChanged(Toolbar.java:1267)
	at java.awt.CheckboxMenuItem.processItemEvent(CheckboxMenuItem.java:372)
	at java.awt.CheckboxMenuItem.processEvent(CheckboxMenuItem.java:340)
	at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:343)
	at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:331)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:713)
	at java.awt.EventQueue.access$400(EventQueue.java:82)
	at java.awt.EventQueue$2.run(EventQueue.java:669)
	at java.awt.EventQueue$2.run(EventQueue.java:667)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
	at java.awt.EventQueue$3.run(EventQueue.java:683)
	at java.awt.EventQueue$3.run(EventQueue.java:681)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:680)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

"Java2D Disposer" daemon prio=10 tid=114529800 nid=0x121757000 in Object.wait() [121756000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <77b094ed0> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
	- locked <77b094ed0> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
	at sun.java2d.Disposer.run(Disposer.java:127)
	at java.lang.Thread.run(Thread.java:680)

"AWT-Shutdown" prio=5 tid=113c29800 nid=0x11e1e1000 in Object.wait() [11e1e0000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <77b0eb550> (a java.lang.Object)
	at java.lang.Object.wait(Object.java:485)
	at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:265)
	- locked <77b0eb550> (a java.lang.Object)
	at java.lang.Thread.run(Thread.java:680)

"AWT-AppKit" daemon prio=5 tid=113e48000 nid=0x7fff700c5cc0 runnable [00000000]
   java.lang.Thread.State: RUNNABLE

"Low Memory Detector" daemon prio=5 tid=113846000 nid=0x11d6e4000 runnable [00000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" daemon prio=9 tid=11407b800 nid=0x11d5e1000 waiting on condition [00000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" daemon prio=9 tid=113845800 nid=0x11d4de000 waiting on condition [00000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=9 tid=113844800 nid=0x11d3db000 waiting on condition [00000000]
   java.lang.Thread.State: RUNNABLE

"Surrogate Locker Thread (Concurrent GC)" daemon prio=5 tid=11407a800 nid=0x11d2d8000 waiting on condition [00000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=113842000 nid=0x11d1d5000 in Object.wait() [11d1d4000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <77a5f6690> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
	- locked <77a5f6690> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
	at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=113841000 nid=0x11d0d2000 in Object.wait() [11d0d1000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <77a5c1700> (a java.lang.ref.Reference$Lock)
	at java.lang.Object.wait(Object.java:485)
	at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
	- locked <77a5c1700> (a java.lang.ref.Reference$Lock)

"VM Thread" prio=9 tid=11383c800 nid=0x11cfcf000 runnable 

"Gang worker#0 (Parallel GC Threads)" prio=9 tid=114002800 nid=0x1134c4000 runnable 

"Gang worker#1 (Parallel GC Threads)" prio=9 tid=114003000 nid=0x1135c7000 runnable 

"Concurrent Mark-Sweep GC Thread" prio=9 tid=11404d800 nid=0x11cc9d000 runnable 
"VM Periodic Task Thread" prio=10 tid=113850000 nid=0x11d7e7000 waiting on condition 

"Exception Catcher Thread" prio=10 tid=114001800 nid=0x113301000 runnable 
JNI global references: 2456

Heap
 par new generation   total 19136K, used 3022K [777c00000, 7790c0000, 77a590000)
  eden space 17024K,   5% used [777c00000, 777ce3890, 778ca0000)
  from space 2112K, 100% used [778eb0000, 7790c0000, 7790c0000)
  to   space 2112K,   0% used [778ca0000, 778ca0000, 778eb0000)
 concurrent mark-sweep generation total 63872K, used 7666K [77a590000, 77e3f0000, 7f8000000)
 concurrent-mark-sweep perm gen total 131072K, used 27773K [7f8000000, 800000000, 800000000)
Comment 10 Ilan Tal 2014-06-29 23:36:20 CDT
Hi Wayne,
Ignore the stupid print to the log window. That is something I do until I can get it stable. It just lets me know that something is happening.

Something is really screwed up with the Fiji. I don't get any crash, all is clean for me. When I install Postage Action Tool, it gets installed and doesn't print anything. Only when I click on it do I get the stupid print into the log window. However the print shows me that it is doing what I expect, which is good.

I am using a Linux 32 bit machine here. You are using something with 64 bits. The fact that the 2 act differently is definitely not good.

I've got Window_Level_Tool.class in Fiji.app/plugins/Tools and
Postage Action Tool in Fiji.app/macros/toolsets,
i.e. the class in the plugins folder and the macro in the macros folder.

I tried moving the macro to plugins/Tools, but then it no longer appears on the list of available objects to install, so I obviously can't install it. It must be in the macros folder. I'll send you a screen shot of what I see when it is in the macros folder. There it works, and works properly. The only problem is the bloody thing won't stay there when I restart Fiji.

We have a much deeper problem that my 32 bit Linux operates one way and your 64 bit thing works another way. That needs to be looked into very soon.

I'll prepare my screen shot. All is good EXCEPT Postage Action Tool doesn't come back upon start up. Nothing crashes or does any other nasty things.
Ilan
Comment 11 Ilan Tal 2014-06-29 23:45:18 CDT
Created attachment 170
ignore the fact that I changed the name. It is Postage something....
Comment 12 Wayne Rasband 2014-06-30 12:56:46 CDT
Do you have a "Postage_Action_Tool.ijm" file in Fiji.app/plugins/tools? Do you have a "Postage Action Tool" command in the Plugins>Tool menu?

In ImageJ, when I select Plugins>Tools>Postage Action Tool, it install the Postage Action Tool in the toolbar, and that tool remains in the toolbar when I restart ImageJ, as long as there are seven or fewer tools. In Fiji, when I select Plugins>Tools>Postage Action Tool, the tool is not installed. Instead, "Tile" is displayed in the Log window. This is a bug.
Comment 13 Ilan Tal 2014-07-01 00:37:00 CDT
Hi Wayne,
To me it makes no sense that a macro should be in the plugins menu. The only thing which makes sense is that a macro is in the macro menu.
I put "makes sense" aside and tried it. I moved Postage Action from Fiji.app/macros/toolsets to Fiji.app/plugins/Tools. Does it now appear under Plugins->Tools? The answer is "no", not on Linux at least. The one and only way I can get it to appear for installation is to put it in the sensible location of Fiji.app/macros/toolsets. Look at my attachment 170 and you can see what I see when it is in the logic place. Inside plugins there is no way I can install it no matter what I do.

Since for me, I can't duplicate it appearing in the plugins menu, I can't duplicate the bug. It also doesn't make sense to me that a macro is in the plugins menu.
What is even worse is that Linux, and Mac as well which I just checked this morning, are both acting differently from what you have. In both Linux and Mac I can install Postage Action when it is in macros/toolsets, but in neither case does it stay there.
Without staying there, it is totally useless.
I love these Fiji buttons, which I only recently discovered and I am working on improving WL and I may have some requests for you. Still the macro button has to work as well, otherwise the whole idea is useless.
Thanks for all your help,
Ilan
Comment 14 Ilan Tal 2014-07-01 01:08:30 CDT
Hi Wayne,
The Mac which I checked belongs to Jerry Kolodny. I couldn't afford to take a chance at screwing up his machine. He uses it daily to look at several Pet-Cts.
I figured I could live a bit more dangerously with one of the hospital computers. I just went into Beth Israel and checked a Windows7, 64 bit machine. It works exactly the same as my Linux and Jerry's Mac, i.e. Postage Action is not visible and/or installable from inside the plugins/Tools menu. It is visible and installable from inside macros/toolsets, but it doesn't stay there.
Thanks,
Ilan
Comment 15 Ilan Tal 2014-07-01 05:41:03 CDT
Hi Wayne,
Assuming these custom tools will fly, I would like to ask you a favor. I am enhancing the WL plugin tool so that it will have a menu to choose either "Auto" or "Reset". With the WL control the user can easily loose control where his gray scale is, and I want to add functions parallel to the B&C Auto and Reset buttons.

I saw that you have a right click to change the meaning of Rectangle to rounded rectangle and I thought that was a great idea. I thought I could solve the problem of the user loosing control with the WL by adding a popup menu with Auto and Reset.

I had to make a couple of additions to get the popup menu to fly. For built in functions I saw how you were doing it, so I wanted to extend the idea to external functions. The Toolbar takes care of internal functions, so external functions need to take care of themselves. You have something built in for options on macro functions, so I wanted to extend that to plugins as well. The code addition is

    if (isMacroTool(current) && isRightClick) {
	String name = names[current].endsWith(" ")?names[current]:names[current]+" ";
	tools[current].runMacroTool(name+"Options");
	}
	if (isPlugInTool(current) && isRightClick) {
		tools[current].showPopupMenu(e, this);
	}

in the MousePressed routine in Toolbar.java. It comes after the existing isMacroTool and isRightClick. I need to check isPlugInTool and isRightClick

Likewise I need to enter a template
	public void showPopupMenu(MouseEvent e, Toolbar par) {}
in PlugInTool.java

If I can ask these additions, we will be ready to fly once you find what is bothering the macro from being remembered. I can say that I don't know what it is. I also don't understand the magic of how it picks up things inside Fiji.app/plugins/Tools, but it somehow works.
In any case I really like these buttons and I want to use them.
Thanks,
Ilan
Comment 16 Wayne Rasband 2014-07-01 08:01:35 CDT
> To me it makes no sense that a macro should be in the plugins menu.

Plugins can be written in many different languages.

> I moved Postage Action from Fiji.app/macros/toolsets
> to Fiji.app/plugins/Tools. Does it now appear under
> Plugins->Tools? The answer is "no", not on Linux at least.

Change the name of the file in Fiji.app/plugins/Tools to

    Postage_Action_Tool.ijm

and it should appear in both the Plugins>Tools menu and in the toolbar's ">>" menu. ImageJ installs macro files with names ending in "Tool.ijm" in the toolbar. The contents of the file should be:

  macro "Postage Action Tool - R0063R0663R0c63Ra063Ra663Rac63" {
     print("Tile");
  }


> The one and only way I can get it to appear for
> installation is to put it in the sensible location
> of Fiji.app/macros/toolsets.

Toolsets are sets of tools, not a single tool.
Comment 17 Ilan Tal 2014-07-03 02:10:21 CDT
Hi Wayne,
Thanks for the pointing out of the importance of the underscore character. I knew about this for plugins but not for macros.
I changed the name of the macro exactly as you suggested and now I do see it in the list of objects which can be installed to the tool bar.
Installing Window_Level works properly as expected but trying to install Postage_Action_Tool.ijm causes a freeze.
Just for an experiment I copied the file to Fiji.app/macros/toolsets. Now I had a choice of 2 places from which to install it. From the macros/toolsets it would install and operate correctly (print into a log window). It won't remember it after restart. From plugins/Tools it just freezes and I have to go to System Monitor to kill the process.
I ran it from a terminal
ilan@ilan-main:~/Fiji.app$ ./ImageJ-linux32
log4j:WARN No appenders could be found for logger (org.bushe.swing.event.EventService).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[ERROR] Skipping unsupported option -port7

All of the above is at startup and there are no new messages when it freezes.
Thanks,
Ilan
Comment 18 Wayne Rasband 2014-07-03 08:44:27 CDT
This is a bug in Fiji. You can get a thread dump by pressing control+\. You should  submit a new bug report with a title something like "Fiji hangs when installing macro tool", with steps to reproduce the bug and a thread dump.
Comment 19 Wayne Rasband 2014-07-04 19:51:50 CDT
> I saw that you have a right click to change the meaning
> of Rectangle to rounded rectangle and I thought that
> was a great idea. I thought I could solve the problem
> of the user loosing control with the WL by adding a
> popup menu with Auto and Reset.

Can you use a dialog box with a popup menu? Plugin tools can display an options dialog box when the user double clicks on the tool icon. There is an example at
 
   http://imagej.nih.gov/ij/plugins/arrow-tool/index.html

Right clicking is used to switch between tools (e.g., from rectangle tool to/from rounded rectangle too), which is currently not possible with plugin tools.
Comment 20 Ilan Tal 2014-07-04 23:26:05 CDT
Hi Wayne,
Since discovering these plugin tools I really want to use them. They are simply great. In fact I added 2 very small bits of code which extend the idea of the right click to external tools. I have it working on my machine and it is very nice.
I don't want to mix the idea of options (double click) with a popup menu (right click). Both are good and both are necessary. What I added changes nothing in the way the code acts. It simply checks for an additional possibility.

I changed Toolbar.jar to
    if (isMacroTool(current) && isRightClick) {
	String name = names[current].endsWith(" ")?names[current]:names[current]+" ";
	tools[current].runMacroTool(name+"Options");
	}
	if (isPlugInTool(current) && isRightClick) {
		tools[current].showPopupMenu(e, this);
	}

adding the isPlugInTool and isRightClick after the equivalent check for isMacroTool and isRightClick

Likewise I added to the template
	public void showPopupMenu(MouseEvent e, Toolbar par) {}
in PlugInTool.java.

With these 2 additions the popup menu on external plugin tools works. I have 2 popup menu items on my version of Window-Level called Auto and Reset. I haven't yet filled in the code to do the required things, but I don't foresee any problems with it. The question is: will you accept the changes? If so, I don't know if it is easier if I try to make them or you make them.

The difference with the internal tools is that Toolbar.java takes care of the popup menus for internal tools, whereas external tools need to take care of themselves. That is the reason for showPopupMenu(MouseEvent e, Toolbar par).

Let me know what you think.
Thanks,
Ilan
Comment 21 Ilan Tal 2014-07-05 23:39:28 CDT
Created attachment 172
window level code
Comment 22 Ilan Tal 2014-07-05 23:44:00 CDT
Hi Wayne,
I have yet to fill out the code portion of autoItemActionPerformed and resetItemActionPerformed. Originally I wrote to James Norman asking him to expand the code. To date I haven't received any answer so perhaps he is no longer supporting the code. Since I needed it, I decided to expand his code myself.
I have it to the point that it works inside my ImageJ test bed. I use NetBeans to develop code and use ImageJ within NetBeans. In the end everything goes over to Fiji.
Within ImageJ Window_Level_Tool.java works and there is a popup menu with the 2 items from Brightness & Contrast which I need. When I press on the menu entry it reaches the action performed stubs, and now I just need to fill them out with real code.
Clearly for it to work in Fiji, I need the additions in the core code.
Thanks,
Ilan