Changeset 2025


Ignore:
Timestamp:
01/04/07 17:27:34 (13 years ago)
Author:
curtis
Message:

First cut at disallowing mutually exclusive import options.

File:
1 edited

Legend:

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

    r2018 r2025  
    3333import ij.process.*; 
    3434import java.awt.*; 
     35import java.awt.event.ItemEvent; 
     36import java.awt.event.ItemListener; 
    3537import java.awt.image.*; 
    3638import java.io.File; 
     
    4850 * @author Melissa Linkert linkert at wisc.edu 
    4951 */ 
    50 public class Importer { 
     52public class Importer implements ItemListener { 
    5153 
    5254  // -- Constants -- 
     
    6163  private LociImporter plugin; 
    6264  private String stackFormat = ""; 
    63   private String oldId = null; 
     65  private Checkbox mergeBox; 
     66  private Checkbox ignoreBox; 
     67  private Checkbox colorizeBox; 
     68  private Checkbox splitBox; 
     69  private Checkbox metadataBox; 
     70  private Checkbox stitchBox; 
     71  private Checkbox rangeBox; 
     72  private Choice stackChoice; 
    6473 
    6574  // -- Constructor -- 
     
    133142    IJ.showStatus(""); 
    134143 
    135     final String mergeString = "Merge channels to RGB"; 
    136     final String ignoreString = "Ignore color lookup table"; 
    137     final String colorizeString = "Colorize channels"; 
    138     final String splitString = "Open each channel in its own window"; 
    139     final String metadataString = "Display associated metadata"; 
    140     final String stitchString = "Stitch files with similar names"; 
    141     final String rangeString = "Specify range for each series"; 
    142     final String stackString = "View stack with: "; 
    143  
    144144    Vector stackTypes = new Vector(); 
    145145    stackTypes.add(VIEW_STANDARD); 
     
    161161    boolean specifyRanges = Prefs.get("bioformats.specifyRanges", false); 
    162162    stackFormat = Prefs.get("bioformats.stackFormat", VIEW_STANDARD); 
     163 
     164    final String mergeString = "Merge channels to RGB"; 
     165    final String ignoreString = "Ignore color lookup table"; 
     166    final String colorizeString = "Colorize channels"; 
     167    final String splitString = "Open each channel in its own window"; 
     168    final String metadataString = "Display associated metadata"; 
     169    final String stitchString = "Stitch files with similar names"; 
     170    final String rangeString = "Specify range for each series"; 
     171    final String stackString = "View stack with: "; 
    163172 
    164173    // prompt for parameters, if necessary 
     
    172181    gd.addCheckbox(rangeString, specifyRanges); 
    173182    gd.addChoice(stackString, stackFormats, stackFormat); 
     183 
     184    // extract GUI components from dialog and add listeners 
     185    Vector boxes = gd.getCheckboxes(); 
     186    if (boxes != null) { 
     187      mergeBox = (Checkbox) boxes.get(0); 
     188      ignoreBox = (Checkbox) boxes.get(1); 
     189      colorizeBox = (Checkbox) boxes.get(2); 
     190      splitBox = (Checkbox) boxes.get(3); 
     191      metadataBox = (Checkbox) boxes.get(4); 
     192      stitchBox = (Checkbox) boxes.get(5); 
     193      rangeBox = (Checkbox) boxes.get(6); 
     194      for (int i=0; i<boxes.size(); i++) { 
     195        ((Checkbox) boxes.get(i)).addItemListener(this); 
     196      } 
     197    } 
     198    Vector choices = gd.getChoices(); 
     199    if (choices != null) { 
     200      stackChoice = (Choice) choices.get(0); 
     201      for (int i=0; i<choices.size(); i++) { 
     202        ((Choice) choices.get(i)).addItemListener(this); 
     203      } 
     204    } 
     205 
    174206    gd.showDialog(); 
    175207    if (gd.wasCanceled()) { 
     
    195227      if (stackFormat.equals(VIEW_IMAGE_5D)) mergeChannels = false; 
    196228 
    197       oldId = id; 
    198229      FileStitcher fs = null; 
    199230 
     
    439470      // -- Step 4d: read pixel data -- 
    440471       
    441       //test to see if using LociDataBrowser to open images. 
    442       if(!stackFormat.equals(VIEW_BROWSER)) { 
     472      // only read data explicitly if not using 4D Data Browser 
     473      if (!stackFormat.equals(VIEW_BROWSER)) { 
    443474        IJ.showStatus("Reading " + fileName); 
    444475 
     
    752783 
    753784        r.close(); 
    754  
    755785      } 
    756786 
     
    768798 
    769799      if (stackFormat.equals(VIEW_BROWSER)) { 
    770         LociDataBrowser ldb = new LociDataBrowser(r,fs,id); 
     800        LociDataBrowser ldb = new LociDataBrowser(r, fs, id); 
    771801        ldb.run(""); 
    772802      } 
     
    783813        IJ.error("LOCI Bio-Formats", "Sorry, there was a problem " + 
    784814          "reading the data" + (msg == null ? "." : (":\n" + msg))); 
     815      } 
     816    } 
     817  } 
     818 
     819  // -- ItemListener API methods -- 
     820 
     821  /** Handles toggling of mutually exclusive options. */ 
     822  public void itemStateChanged(ItemEvent e) { 
     823    Object src = e.getSource(); 
     824    if (src == mergeBox) { 
     825      if (mergeBox.getState()) { 
     826        colorizeBox.setState(false); 
     827        splitBox.setState(false); 
     828      } 
     829    } 
     830    else if (src == ignoreBox) { 
     831    } 
     832    else if (src == colorizeBox) { 
     833      if (colorizeBox.getState()) { 
     834        mergeBox.setState(false); 
     835        splitBox.setState(true); 
     836        // NB: temporary 
     837        String s = stackChoice.getSelectedItem(); 
     838        if (s.equals(VIEW_BROWSER)) stackChoice.select(VIEW_STANDARD); 
     839      } 
     840    } 
     841    else if (src == splitBox) { 
     842      if (splitBox.getState()) { 
     843        mergeBox.setState(false); 
     844        String s = stackChoice.getSelectedItem(); 
     845        if (s.equals(VIEW_BROWSER)) stackChoice.select(VIEW_STANDARD); 
     846      } 
     847    } 
     848    else if (src == metadataBox) { 
     849    } 
     850    else if (src == stitchBox) { 
     851    } 
     852    else if (src == rangeBox) { 
     853      if (rangeBox.getState()) { 
     854        String s = stackChoice.getSelectedItem(); 
     855        if (s.equals(VIEW_BROWSER)) stackChoice.select(VIEW_STANDARD); 
     856      } 
     857    } 
     858    else if (src == stackChoice) { 
     859      String s = stackChoice.getSelectedItem(); 
     860      if (s.equals(VIEW_STANDARD)) { 
     861      } 
     862      else if (s.equals(VIEW_BROWSER)) { 
     863        colorizeBox.setState(false); // NB: temporary 
     864        splitBox.setState(false); 
     865        rangeBox.setState(false); 
     866      } 
     867      else if (s.equals(VIEW_IMAGE_5D)) { 
     868      } 
     869      else if (s.equals(VIEW_VIEW_5D)) { 
    785870      } 
    786871    } 
Note: See TracChangeset for help on using the changeset viewer.