|
Bugzilla – Bug 821 |
can't get tool macro to start with Fiji |
Last modified: 2014-07-05 23:44:00 CDT |
| ⚠ |
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. |
|
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||
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, IlanAdding 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.Created attachment 169 what I would like to see on start upA 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.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)Created attachment 170 ignore the fact that I changed the name. It is Postage something....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, IlanHi 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, IlanHi 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, IlanCreated attachment 172 window level code