Changeset 7363


Ignore:
Timestamp:
12/08/10 20:14:22 (9 years ago)
Author:
aivar
Message:

Added multi-instance plugin implementation. You can choose which implementation you want to use: The original chainable plugin implementation chains one plugin to the next and uses a single thread. The multi-instance plugin creates a new plugin instance as each set of required input images becomes ready.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/maven/projects/deep-zoom-plugin/src/main/java/loci/deepzoomplugin/DeepZoom.java

    r7330 r7363  
    4646 */ 
    4747public class DeepZoom implements PlugIn { 
     48    private static final String FILE = "FILE"; 
    4849    private static final String OUTPUT = "OUTPUT"; 
    4950    private static final String NAME ="NAME"; 
     
    5354    private static final String LAUNCH = "LAUNCH"; 
    5455    private static final String URL = "URL"; 
    55     private enum Implementation { CHAINED, MULTITHREADED, SINGLETHREADED }; 
    56     private static final String[] m_choices = { Implementation.CHAINED.name(), Implementation.MULTITHREADED.name() }; 
     56    private enum Implementation { CHAINED, MULTITHREADED, MULTIINSTANCE }; 
     57    private static final String[] m_choices = { Implementation.CHAINED.name(), Implementation.MULTITHREADED.name(), Implementation.MULTIINSTANCE.name() }; 
    5758    private Preferences m_prefs = Preferences.userRoot().node(this.getClass().getName()); 
    5859 
    5960    public void run(String arg) { 
    60         process(Implementation.CHAINED); 
    61     } 
    62  
    63     private void process(Implementation implementation) 
    64     { 
    6561        ImagePlus imp = WindowManager.getCurrentImage(); 
    6662        if (null == imp) { 
     
    8581        dialog.addCheckbox("Launch browser: ", launch); 
    8682        dialog.addStringField("URL (optional): ", url); 
     83        dialog.addChoice("Implementation: ", m_choices, Implementation.CHAINED.toString()); 
    8784        dialog.showDialog(); 
    8885        if (dialog.wasCanceled()) { 
     
    9794        launch = dialog.getNextBoolean(); 
    9895        url = dialog.getNextString(); 
     96        int choiceIndex = dialog.getNextChoiceIndex(); 
     97        Implementation implementation = Implementation.values()[choiceIndex]; 
    9998 
    10099        m_prefs.put(OUTPUT, folder); 
     
    106105        m_prefs.put(URL, url); 
    107106 
     107        //TODO just define an IDeepZoomExporter interface 
    108108        switch (implementation) { 
    109109            case CHAINED: 
    110110            case MULTITHREADED: 
    111             case SINGLETHREADED: 
    112                 loci.chainableplugin.deepzoom.DeepZoomExporter deepZoomExporter = new loci.chainableplugin.deepzoom.DeepZoomExporter(launch, false, folder, url, name, description, width, height); 
    113                 loci.chainableplugin.ImageWrapper imageWrapper = new loci.chainableplugin.ImageWrapper(ip); 
    114                 deepZoomExporter.process(imageWrapper); 
     111                loci.chainableplugin.deepzoom.DeepZoomExporter 
     112                        deepZoomExporter1 = new loci.chainableplugin.deepzoom.DeepZoomExporter 
     113                                (launch, false, folder, url, name, description, width, height); 
     114                loci.plugin.ImageWrapper imageWrapper1 = new loci.plugin.ImageWrapper(ip); 
     115                deepZoomExporter1.process(imageWrapper1); 
     116                break; 
     117            case MULTIINSTANCE: 
     118                loci.multiinstanceplugin.deepzoom.DeepZoomExporter 
     119                        deepZoomExporter2 = new loci.multiinstanceplugin.deepzoom.DeepZoomExporter 
     120                                (launch, false, folder, url, name, description, width, height); 
     121                loci.plugin.ImageWrapper imageWrapper2 = new loci.plugin.ImageWrapper(ip); 
     122                deepZoomExporter2.process(imageWrapper2); 
    115123                break; 
    116124        } 
     
    129137 
    130138        // ask for file to load 
     139        Preferences prefs = Preferences.userRoot().node("tmp"); 
     140        String file = prefs.get(FILE, ""); 
    131141        GenericDialog dialog = new GenericDialog("Choose Image"); 
    132142        dialog.addStringField("File: ", ""); 
    133         dialog.addChoice("Implementation: ", m_choices, Implementation.CHAINED.toString()); 
    134143        dialog.showDialog(); 
    135144        if (dialog.wasCanceled()) { 
    136145            return; 
    137146        } 
    138         String file = dialog.getNextString(); 
    139         int choiceIndex = dialog.getNextChoiceIndex(); 
     147        file = dialog.getNextString(); 
     148        prefs.put(FILE, file); 
    140149         
    141150        IJ.open(file); 
     
    152161        // run plugin 
    153162        DeepZoom plugin = new DeepZoom(); 
    154         plugin.process(Implementation.values()[choiceIndex]); 
     163        plugin.run(""); 
    155164 
    156165        System.exit(0); //TODO just for testing. 
Note: See TracChangeset for help on using the changeset viewer.