Changeset 1356


Ignore:
Timestamp:
08/25/06 12:46:12 (14 years ago)
Author:
curtis
Message:

Add simple metadata view option to Bio-Formats Importer plugin
(just what we needed, another MetadataPane.java).

Location:
trunk/loci/plugins
Files:
1 added
1 edited

Legend:

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

    r1355 r1356  
    3131import ij.plugin.PlugIn; 
    3232import ij.process.*; 
    33 import java.awt.BorderLayout; 
    3433import java.awt.event.ItemEvent; 
    3534import java.awt.event.ItemListener; 
    3635import java.awt.image.*; 
    3736import java.io.File; 
     37import java.util.Hashtable; 
    3838import javax.swing.*; 
    3939import loci.formats.*; 
     
    4343 * 
    4444 * @author Curtis Rueden ctrueden at wisc.edu 
     45 * @author Melissa Linkert linkert at cs.wisc.edu 
    4546 */ 
    4647public class LociImporter implements PlugIn, ItemListener { 
     
    5354  private JCheckBox merge = null; 
    5455  private JCheckBox newWindows = null; 
     56  private JCheckBox showMeta = null; 
    5557  private JCheckBox stitching = null; 
    5658  private boolean mergeChannels = true; 
    5759  private boolean splitWindows = false; 
    58   private boolean stitchFiles = true; 
     60  private boolean showMetadata = true; 
     61  private boolean stitchFiles = false; 
    5962 
    6063  // -- PlugIn API methods -- 
     
    6871    ImageReader reader = new ImageReader(); 
    6972 
     73    String mergeString = "Merge channels"; 
     74    String splitString = "Open each channel in its own window"; 
     75    String metadataString = "Display associated metadata"; 
     76    String stitchString = "Stitch files with similar names"; 
    7077    if ((new File(arg)).exists()) { 
    7178      id = arg; 
    7279 
    7380      // we still want to prompt for channel merge/split 
    74  
    7581      GenericDialog gd = new GenericDialog("LOCI Bio-Formats Import Options"); 
    76       gd.addCheckbox("Merge channels", true); 
    77       gd.addCheckbox("Open each channel in a new window", false); 
    78       gd.addCheckbox("Stitch together files with a similar name", true); 
     82      gd.addCheckbox(mergeString, mergeChannels); 
     83      gd.addCheckbox(splitString, splitWindows); 
     84      gd.addCheckbox(metadataString, showMetadata); 
     85      gd.addCheckbox(stitchString, stitchFiles); 
    7986      gd.showDialog(); 
    8087      mergeChannels = gd.getNextBoolean(); 
    8188      splitWindows = gd.getNextBoolean(); 
     89      showMetadata = gd.getNextBoolean(); 
    8290      stitchFiles = gd.getNextBoolean(); 
    8391    } 
     
    8694 
    8795      // add some additional options to the file chooser 
    88       JPanel panel = new JPanel(new BorderLayout()); 
    89       merge = new JCheckBox("Merge channels", true); 
    90       newWindows = new JCheckBox("Open each channel in a new window", false); 
    91       stitching = new JCheckBox("Stitch together files with a similar name", 
    92         true); 
     96      JPanel panel = new JPanel(); 
     97      panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); 
     98      merge = new JCheckBox(mergeString, mergeChannels); 
     99      newWindows = new JCheckBox(splitString, splitWindows); 
     100      showMeta = new JCheckBox(metadataString, showMetadata); 
     101      stitching = new JCheckBox(stitchString, stitchFiles); 
    93102      merge.addItemListener(this); 
    94103      newWindows.addItemListener(this); 
     104      showMeta.addItemListener(this); 
    95105      stitching.addItemListener(this); 
    96       panel.add(merge, BorderLayout.NORTH); 
    97       panel.add(newWindows, BorderLayout.EAST); 
    98       panel.add(stitching, BorderLayout.SOUTH); 
     106      panel.add(merge); 
     107      panel.add(newWindows); 
     108      panel.add(showMeta); 
     109      panel.add(stitching); 
    99110      chooser.setAccessory(panel); 
    100111 
     
    128139 
    129140      int num = cm.getImageCount(id); 
     141      if (showMetadata) { 
     142        Hashtable meta = cm.getMetadata(id); 
     143        MetadataPane mp = new MetadataPane(meta); 
     144        JFrame frame = new JFrame(id + " Metadata"); 
     145        frame.setContentPane(mp); 
     146        frame.pack(); 
     147        frame.setVisible(true); 
     148        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 
     149      } 
    130150      ImageStack stackB = null, stackS = null, stackF = null, stackO = null; 
    131151      long start = System.currentTimeMillis(); 
     
    272292  public void itemStateChanged(ItemEvent e) { 
    273293    Object source = e.getItemSelectable(); 
    274     if (source == merge) { 
    275       mergeChannels = e.getStateChange() == ItemEvent.SELECTED; 
    276     } 
    277     else if (source == newWindows) { 
    278       splitWindows = e.getStateChange() == ItemEvent.SELECTED; 
    279     } 
    280     else if (source == stitching) { 
    281       stitchFiles = e.getStateChange() == ItemEvent.SELECTED; 
    282     } 
     294    boolean selected = e.getStateChange() == ItemEvent.SELECTED; 
     295    if (source == merge) mergeChannels = selected; 
     296    else if (source == newWindows) splitWindows = selected; 
     297    else if (source == showMeta) showMetadata = selected; 
     298    else if (source == stitching) stitchFiles = selected; 
    283299  } 
    284300 
Note: See TracChangeset for help on using the changeset viewer.