Using Java object in beanshell script

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Using Java object in beanshell script

phsiao
I had a MM plugin (DualAxisMirror.jar) made with windows, buttons, and other GUI stuffs. Now I want to call a public function from a class (MirrorControlForm) in that jar file, so I did this in my script

addClassPath( "./scripts/DualAxisMirror.jar" );
import cismm.MirrorControlForm;
MirrorControlForm mcf = new MirrorControlForm(mmc, gui);

But I got the error:
Line 27: run-time error : cismm.MirrorControlForm$ExpMode cannot be cast to cismm.MirrorControlForm$ExpMode


I have success before using functions from another class which has mmc as the only parameter in its constructor, so is the issue from the gui object?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Java object in beanshell script

JonD
Administrator
phsiao wrote
I had a MM plugin (DualAxisMirror.jar) made with windows, buttons, and other GUI stuffs. Now I want to call a public function from a class (MirrorControlForm) in that jar file, so I did this in my script
To programmatically launch the plugin frame from your script look at the whatever code in your plugin that does this (probably in a method called "setApp") and/or look at this old thread: http://micro-manager.3463995.n2.nabble.com/run-MMPlugin-from-script-td7330397.html.

Once your plugin frame is created it should be straightforward to reference it in your script.  We do this with the ASIdiSPIM plugin, after the plugin is open, with the following code tidbit, maybe it helps you.

import org.micromanager.asidispim.api.ASIdiSPIMInterface;
import org.micromanager.asidispim.api.ASIdiSPIMImplementation;
ASIdiSPIMInterface diSPIM = new ASIdiSPIMImplementation();
diSPIM.runAcquisition(); // or other API methods in ASIdiSPIMInterface


Jon

-------------------------------------------
Jon Daniels
Applied Scientific Instrumentation
29391 West Enid Rd, Eugene, OR 97402
Phone: (541) 461-8181 x118
-------------------------------------------

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Java object in beanshell script

phsiao
Turns out my problem is the function in the class which queries current directory returns different strings when it is loaded from MM GUI and from the script, so after trimming down necessary characters, the class is writing files to an invalid location.

"file:C:\Program Files\Micro-Manager-1.4\mmplugins\DualAxisMirror.jar!/"  <-- jar queried location when run on GUI
"/C:/Program Files/Micro-Manager-1.4/scripts/DualAxisMirror.jar"               <-- jar queried location when run on script
 
Loading...