/* 
 * A simple example that shows how to use the JAVA reflection API to load
 * a ZEISS LSM image using LSM_Toolbox at ImageJ runtime. Questions and
 * comments to patrick@image-archive.org
 */
 
import ij.ImagePlus;
import ij.plugin.PlugIn;
 
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
 
public class test_OpenLSM implements PlugIn{
    void test_openLSM(){
    }
    public void testRun() {
        Class readerClass;
        try {
            // we want to execute public ImagePlus[] open(String directory,
            // String filename,boolean showInfoFrames, boolean verbose, boolean
            // thumb)
            readerClass = Class.forName("org.imagearchive.lsm.toolbox.Reader");
            Object readerObject = readerClass.newInstance();
            Class[] parameters = { String.class, String.class, Boolean.TYPE,
                    Boolean.TYPE, Boolean.TYPE };
            Method openMethod = readerClass.getMethod("open", parameters);
            Object[] arguments = {"directory_of_lsm_file", "my_lsmfile.lsm",
                    false, false, false };
            ImagePlus[] imps = (ImagePlus[]) openMethod.invoke(readerObject,
                    arguments);
 
            // the following lines are just to show that it opened the files
            // correctly. Remove this in your plugin and do whatever you wish
            // with the ImagePlus[]
            if (imps != null) {
                for (int i = 0; i < imps.length; i++) {
                    imps[i].show();
                    imps[i].updateAndDraw();
                }
            }
 
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
 
    @Override
    public void run(String arg) {
        testRun();
    }
}
plugin/inputoutput/lsmtoolbox/load_zeiss.txt · Last modified: 2010/01/26 11:18 (external edit)
Back to top
CC Attribution-Noncommercial-Share Alike 3.0 Unported
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0