Changeset 2936


Ignore:
Timestamp:
07/05/07 12:39:34 (12 years ago)
Author:
melissa
Message:

Fixed channel merging prompt to work with macros.

Location:
trunk/loci/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/plugins/Importer.java

    r2921 r2936  
    2727 
    2828import ij.*; 
    29 import ij.gui.GenericDialog; 
    3029import ij.io.FileInfo; 
    3130import ij.measure.Calibration; 
     
    553552 
    554553      options.savePreferences(); 
    555  
     554   
    556555      if (viewBrowser) { 
    557556        boolean first = true; 
     
    729728      if (planes2 * 3 < r.getImageCount()) planes2++; 
    730729 
    731       GenericDialog gd = new GenericDialog("Merging Options..."); 
    732       gd.addMessage("How would you like to merge this data?"); 
    733       gd.addChoice("", new String[] { 
    734         planes1 + " planes, 2 channels per plane", 
    735         planes2 + " planes, 3 channels per plane", "Do not merge"}, ""); 
    736       gd.showDialog(); 
    737  
    738       if (gd.wasCanceled()) return; 
    739  
    740       int idx = gd.getNextChoiceIndex(); 
    741  
    742       switch (idx) { 
    743         case 0: 
    744           makeRGB(imp, r, 2); 
    745           break; 
    746         case 1: 
    747           makeRGB(imp, r, 3); 
    748           break; 
     730      if (options.promptMergeOption(planes1, planes2) ==  
     731        ImporterOptions.STATUS_OK)  
     732      { 
     733        String option = options.getMergeOption(); 
     734        if (option.indexOf("2 channels") != -1) makeRGB(imp, r, 2); 
     735        else if (option.indexOf("3 channels") != -1) makeRGB(imp, r, 3); 
    749736      } 
    750737    } 
  • trunk/loci/plugins/ImporterOptions.java

    r2825 r2936  
    6060  public static final String VIEW_VIEW_5D = "View5D"; 
    6161 
     62  public static final String MERGE_DEFAULT = "Do not merge"; 
     63   
    6264  // class to check for each viewing option 
    6365  private static final String CLASS_BROWSER = 
     
    8486  public static final String PREF_RANGE = "bioformats.specifyRanges"; 
    8587  public static final String PREF_THUMBNAIL = "bioformats.forceThumbnails"; 
     88  public static final String PREF_MERGE_OPTION = "bioformats.mergeOption"; 
    8689 
    8790  // labels for user dialog; when trimmed these double as argument & macro keys 
     
    99102  public static final String LABEL_LOCATION = "Location: "; 
    100103  public static final String LABEL_ID = "Open"; 
     104  public static final String LABEL_MERGE_OPTION = "Merging Options"; 
    101105 
    102106  // -- Fields - GUI components -- 
     
    110114  private Checkbox concatenateBox; 
    111115  private Checkbox rangeBox; 
     116  private Choice mergeChoice; 
    112117 
    113118  // -- Fields - core options -- 
     
    122127  private boolean specifyRanges; 
    123128  private boolean forceThumbnails; 
     129  private String mergeOption; 
    124130 
    125131  private String location; 
     
    142148  public boolean isSpecifyRanges() { return specifyRanges; } 
    143149  public boolean isForceThumbnails() { return forceThumbnails; } 
     150  public String getMergeOption() { return mergeOption; } 
    144151 
    145152  public boolean isViewNone() { return VIEW_NONE.equals(stackFormat); } 
     
    162169 
    163170  // -- ImporterOptions API methods - mutators -- 
     171 
     172  public void setStackFormat(String s) { stackFormat = s; } 
     173  public void setMergeChannels(boolean b) { mergeChannels = b; } 
     174  public void setColorize(boolean b) { colorize = b; } 
     175  public void setSplitWindows(boolean b) { splitWindows = b; } 
     176  public void setShowMetadata(boolean b) { showMetadata = b; } 
     177  public void setGroupFiles(boolean b) { groupFiles = b; } 
     178  public void setConcatenate(boolean b) { concatenate = b; } 
     179  public void setSpecifyRanges(boolean b) { specifyRanges = b; } 
     180  public void setForceThumbnails(boolean b) { forceThumbnails = b; } 
    164181 
    165182  /** Loads default option values from IJ_Prefs.txt. */ 
     
    174191    specifyRanges = Prefs.get(PREF_RANGE, false); 
    175192    forceThumbnails = Prefs.get(PREF_THUMBNAIL, false);  
     193    mergeOption = Prefs.get(PREF_MERGE_OPTION, MERGE_DEFAULT);  
    176194  } 
    177195 
     
    186204    Prefs.set(PREF_CONCATENATE, concatenate); 
    187205    Prefs.set(PREF_RANGE, specifyRanges); 
     206    Prefs.set(PREF_MERGE_OPTION, mergeOption);  
    188207  } 
    189208 
     
    221240      specifyRanges = getMacroValue(arg, LABEL_RANGE, specifyRanges); 
    222241      stackFormat = Macro.getValue(arg, LABEL_STACK, stackFormat); 
     242      mergeOption = Macro.getValue(arg, LABEL_MERGE_OPTION, mergeOption); 
    223243 
    224244      location = Macro.getValue(arg, LABEL_LOCATION, location); 
     
    335355    idType = "OME address"; 
    336356    return STATUS_OK; 
     357  } 
     358 
     359  public int promptMergeOption(int one, int two) { 
     360    GenericDialog gd = new GenericDialog("Merging Options..."); 
     361     
     362    String[] options = new String[] {one + " planes, 2 channels per plane", 
     363      two + " planes, 3 channels per plane", MERGE_DEFAULT}; 
     364     
     365    gd.addMessage("How would you like to merge this data?"); 
     366    gd.addChoice(LABEL_MERGE_OPTION, options, MERGE_DEFAULT);  
     367    gd.showDialog(); 
     368    if (gd.wasCanceled()) return STATUS_CANCELED; 
     369 
     370    mergeOption = options[gd.getNextChoiceIndex()];  
     371    return STATUS_OK;  
    337372  } 
    338373 
Note: See TracChangeset for help on using the changeset viewer.