Changeset 1196


Ignore:
Timestamp:
07/26/06 13:59:22 (14 years ago)
Author:
curtis
Message:
  • Some tweaks to reduce memory usage.
  • Add ability to compile TIFF datasets into a single stack.
  • More changes to build script due to Bio-Formats refactoring.
  • Add QTConverter.jar to ignore list.
Location:
trunk/loci/qt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/qt

    • Property svn:ignore
      •  

        old new  
        11*.class 
         2QTConverter.jar 
  • trunk/loci/qt/QTConverter.java

    r1149 r1196  
    1212import javax.swing.*; 
    1313import javax.swing.border.EmptyBorder; 
     14import javax.swing.filechooser.FileFilter; 
     15import loci.formats.FormatHandler; 
    1416import loci.formats.FormatReader; 
    1517import loci.formats.LegacyQTTools; 
    16 import loci.formats.in.LegacyQTReader; 
    1718import loci.formats.in.QTReader; 
    1819import loci.formats.in.TiffReader; 
     
    2324public class QTConverter extends JFrame implements ActionListener, Runnable { 
    2425 
     26  // -- Constants -- 
     27 
     28  private static final String TITLE = "QT TIFF Converter"; 
     29 
    2530  // -- Fields -- 
    2631 
    27   private LegacyQTReader legacyReader = new LegacyQTReader(); 
    2832  private QTReader qtReader = new QTReader(); 
    2933  private TiffReader tiffReader = new TiffReader(); 
    3034  private TiffWriter writer = new TiffWriter(); 
    31   private JFileChooser rc = qtReader.getFileChooser(); 
    32   private JFileChooser wc = writer.getFileChooser(); 
     35  private JFileChooser rc, wc; 
    3336  private boolean shutdown; 
    3437 
     
    3841  private JButton convert; 
    3942 
    40  
    4143  // -- Constructor -- 
    4244 
    4345  public QTConverter() { 
    44     super("QuickTime to TIFF Converter"); 
     46    super(TITLE); 
     47 
     48    // file choosers 
     49    FileFilter[] qtFilters = qtReader.getFileFilters(); 
     50    FileFilter[] tiffFilters = tiffReader.getFileFilters(); 
     51    FileFilter[] ff = new FileFilter[qtFilters.length + tiffFilters.length]; 
     52    System.arraycopy(qtFilters, 0, ff, 0, qtFilters.length); 
     53    System.arraycopy(tiffFilters, 0, ff, qtFilters.length, tiffFilters.length); 
     54    rc = FormatHandler.buildFileChooser(ff); 
     55    wc = writer.getFileChooser(); 
     56 
    4557    JPanel pane = new JPanel(); 
    4658    pane.setBorder(new EmptyBorder(5, 5, 5, 5)); 
     
    144156    pack(); 
    145157  } 
    146  
    147158 
    148159  // -- ActionListener methods -- 
     
    154165      if (rval != JFileChooser.APPROVE_OPTION) return; 
    155166      File file = rc.getSelectedFile(); 
     167      if (file != null) wc.setCurrentDirectory(file); 
    156168      String pattern = FilePattern.findPattern(file); 
    157169      input.setText(pattern); 
     
    161173      if (rval != JFileChooser.APPROVE_OPTION) return; 
    162174      File file = wc.getSelectedFile(); 
     175      if (file != null) rc.setCurrentDirectory(file); 
    163176      String s = file.getPath(); 
    164  
    165       // determine file extension 
    166177      String name = file.getName(); 
    167       int dot = name.lastIndexOf("."); 
    168       String ext = dot < 0 ? "" : name.substring(dot); 
    169  
    170178      boolean isTiff = writer.isThisType(s); 
    171       if (dot >= 0) s = s.substring(0, s.lastIndexOf(".")); 
    172       s += "*" + ext; 
    173179      if (!isTiff) s += ".tif"; 
    174180      output.setText(s); 
    175181    } 
    176     else if ("convert".equals(cmd)) { 
    177       new Thread(this).start(); 
    178     } 
     182    else if ("convert".equals(cmd)) new Thread(this).start(); 
    179183    else if ("quit".equals(cmd)) { 
    180184      shutdown = true; 
     
    184188    } 
    185189  } 
    186  
    187190 
    188191  // -- Runnable methods -- 
     
    198201      String[] inFiles = fp.getFiles(); 
    199202 
    200       FormatReader reader = null; 
    201       boolean useQTJ = qtJava.isSelected(); 
    202       reader = useQTJ ? (FormatReader) legacyReader : (FormatReader) qtReader; 
     203      boolean  isTiff = tiffReader.isThisType(in); 
     204      FormatReader reader = isTiff ? (FormatReader) tiffReader : qtReader; 
     205      boolean useQTJ = !isTiff && qtJava.isSelected(); 
     206      qtReader.setLegacy(useQTJ); 
    203207 
    204208      int numT = reader.getImageCount(inFiles[0]); 
     
    208212      int outPlanes = swap ? numZ : numT; 
    209213 
    210       int star = out.lastIndexOf("*"); 
    211       if (star < 0) { 
    212         msg("Please use an asterisk in the output name " + 
    213           "to indicate where the file numbers should go."); 
    214         convert.setEnabled(true); 
    215         return; 
    216       } 
     214      int star = out.lastIndexOf("."); 
     215      if (star < 0) star = out.length(); 
    217216      String pre = out.substring(0, star); 
    218       String post = out.substring(star + 1); 
     217      String post = out.substring(star); 
    219218 
    220219      progress.setMaximum(2 * numZ * numT); 
     
    238237          readers = new FormatReader[inFiles.length]; 
    239238          readers[0] = reader; 
    240           for (int i=1; i<readers.length; i++) readers[i] = new QTReader(); 
     239          for (int i=1; i<readers.length; i++) { 
     240            readers[i] = outFiles == 1 ? reader : 
     241              (isTiff ? (FormatReader) new TiffReader() : new QTReader()); 
     242          } 
    241243        } 
    242244      } 
     
    249251            String num = "" + (o + 1); 
    250252            while (num.length() < digits) num = "0" + num; 
    251             String outFile = pre + num + post; 
     253            String outFile = outFiles == 1 ? (pre + post) : (pre + num + post); 
    252254            String outName = new File(outFile).getName(); 
    253255            progress.setString(outName + " " + (p + 1) + "/" + outPlanes); 
     
    267269          String num = "" + (o + 1); 
    268270          while (num.length() < digits) num = "0" + num; 
    269           String outFile = pre + num + post; 
     271          String outFile = outFiles == 1 ? (pre + post) : (pre + num + post); 
    270272          String outName = new File(outFile).getName(); 
    271273          for (int p=0; p<outPlanes; p++) { 
     
    305307  } 
    306308 
    307  
    308309  // -- Helper methods -- 
    309310 
     
    315316 
    316317  private void msg(String msg) { 
    317     JOptionPane.showMessageDialog(this, msg, 
    318       "QuickTime to TIFF Converter", JOptionPane.ERROR_MESSAGE); 
    319   } 
    320  
     318    JOptionPane.showMessageDialog(this, msg, TITLE, JOptionPane.ERROR_MESSAGE); 
     319  } 
    321320 
    322321  // -- Helper classes -- 
     
    330329  } 
    331330 
    332  
    333331  // -- Main method -- 
    334332 
  • trunk/loci/qt/build

    r1089 r1196  
    1111loci/util/FilePattern*.class \ 
    1212loci/util/NumberFilter*.class \ 
    13 loci/formats/BaseTiffReader*.class \ 
    1413loci/formats/BitBuffer*.class \ 
    1514loci/formats/BitWriter*.class \ 
     
    1817loci/formats/Compression*.class \ 
    1918loci/formats/DataTools*.class \ 
     19loci/formats/DummyMetadataStore*.class \ 
    2020loci/formats/ExtensionFileFilter*.class \ 
     21loci/formats/FileStitcher*.class \ 
    2122loci/formats/FormatException*.class \ 
    2223loci/formats/FormatFileFilter*.class \ 
     
    2627loci/formats/ImageTools*.class \ 
    2728loci/formats/LZWTreeNode*.class \ 
    28 loci/formats/LegacyQTReader*.class \ 
    2929loci/formats/LegacyQTTools*.class \ 
    30 loci/formats/OMETools*.class \ 
    31 loci/formats/QTReader*.class \ 
     30loci/formats/MetadataStore*.class \ 
     31loci/formats/OMEXMLMetadataStore*.class \ 
    3232loci/formats/RandomAccessArray*.class \ 
     33loci/formats/RandomAccessStream*.class \ 
    3334loci/formats/ReflectException*.class \ 
    3435loci/formats/ReflectedUniverse*.class \ 
    3536loci/formats/TiffRational*.class \ 
    36 loci/formats/TiffReader*.class \ 
    3737loci/formats/TiffTools*.class \ 
    38 loci/formats/TiffWriter*.class \ 
     38loci/formats/in/BaseTiffReader*.class \ 
     39loci/formats/in/LegacyQTReader*.class \ 
     40loci/formats/in/QTReader*.class \ 
     41loci/formats/in/TiffReader*.class \ 
     42loci/formats/out/TiffWriter*.class \ 
    3943loci/qt/*.java loci/util/FilePattern.java loci/util/NumberFilter.java \ 
    4044loci/qt/build 
Note: See TracChangeset for help on using the changeset viewer.