Changeset 6951


Ignore:
Timestamp:
09/16/10 13:43:33 (9 years ago)
Author:
melissa
Message:

Backported r6714, r6716, r6948, and r6949 to 4.2. See #557.

Location:
branches/4.2/components/loci-plugins
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2/components/loci-plugins

  • branches/4.2/components/loci-plugins/src/loci/plugins

  • branches/4.2/components/loci-plugins/src/loci/plugins/in/Calibrator.java

  • branches/4.2/components/loci-plugins/src/loci/plugins/in/ImagePlusReader.java

    r6950 r6951  
    5656import loci.plugins.util.BFVirtualStack; 
    5757import loci.plugins.util.ImageProcessorReader; 
     58import loci.plugins.util.LuraWave; 
    5859import loci.plugins.util.VirtualImagePlus; 
    5960 
     
    349350 
    350351      // get image processor for ith plane 
    351       final ImageProcessor[] p = reader.openProcessors(i, 
    352         region.x, region.y, region.width, region.height); 
     352      final ImageProcessor[] p = readProcessors(process, i, region); 
    353353      if (p == null || p.length == 0) { 
    354354        throw new FormatException("Cannot read plane #" + i); 
     
    365365 
    366366    return createStack(procs, labels, luts); 
     367  } 
     368 
     369  /** 
     370   * HACK: This method mainly exists to prompt the user for a missing 
     371   * LuraWave license code, in the case of LWF-compressed Flex. 
     372   * 
     373   * @see ImportProcess#setId() 
     374   */ 
     375  private ImageProcessor[] readProcessors(ImportProcess process, 
     376    int no, Region r) throws FormatException, IOException 
     377  { 
     378    final ImageProcessorReader reader = process.getReader(); 
     379    final ImporterOptions options = process.getOptions(); 
     380 
     381    boolean first = true; 
     382    for (int i=0; i<LuraWave.MAX_TRIES; i++) { 
     383      String code = LuraWave.initLicenseCode(); 
     384      try { 
     385        return reader.openProcessors(no, r.x, r.y, r.width, r.height); 
     386      } 
     387      catch (FormatException exc) { 
     388        if (options.isQuiet() || options.isWindowless()) throw exc; 
     389        if (!LuraWave.isLicenseCodeException(exc)) throw exc; 
     390 
     391        // prompt user for LuraWave license code 
     392        code = LuraWave.promptLicenseCode(code, first); 
     393        if (code == null) throw exc; 
     394        if (first) first = false; 
     395      } 
     396    } 
     397    throw new FormatException(LuraWave.TOO_MANY_TRIES); 
    367398  } 
    368399 
  • branches/4.2/components/loci-plugins/src/loci/plugins/in/ImportProcess.java

    r6677 r6951  
    5454import loci.plugins.util.ImageProcessorReader; 
    5555import loci.plugins.util.LociPrefs; 
     56import loci.plugins.util.LuraWave; 
    5657import loci.plugins.util.VirtualReader; 
    5758import loci.plugins.util.WindowTools; 
     
    468469    r = virtualReader = new VirtualReader(r); 
    469470    reader = new ImageProcessorReader(r); 
    470     reader.setId(options.getId()); 
     471    setId(); 
    471472 
    472473    computeSeriesLabels(reader); 
     
    541542      BF.status(options.isQuiet(), "Identifying " + idName); 
    542543      imageReader = LociPrefs.makeImageReader(); 
    543       try { baseReader = imageReader.getReader(options.getId()); } 
     544      try { 
     545        baseReader = imageReader.getReader(options.getId()); 
     546      } 
    544547      catch (FormatException exc) { 
    545548        WindowTools.reportException(exc, options.isQuiet(), 
     
    559562      return; 
    560563    } 
     564 
     565    // attach OME-XML metadata store 
    561566    Exception exc = null; 
    562567    try { 
     
    591596 
    592597  // -- Helper methods -- ImportStep.STACK -- 
     598 
     599  /** 
     600   * HACK: This method mainly exists to prompt the user for a missing 
     601   * LuraWave license code, in the case of LWF-compressed Flex. 
     602   * 
     603   * @see ImagePlusReader#readProcessors(ImportProcess, int, Region) 
     604   */ 
     605  private void setId() throws FormatException, IOException { 
     606    boolean first = true; 
     607    for (int i=0; i<LuraWave.MAX_TRIES; i++) { 
     608      String code = LuraWave.initLicenseCode(); 
     609      try { 
     610        reader.setId(options.getId()); 
     611        return; 
     612      } 
     613      catch (FormatException exc) { 
     614        if (options.isQuiet() || options.isWindowless()) throw exc; 
     615        if (!LuraWave.isLicenseCodeException(exc)) throw exc; 
     616 
     617        // prompt user for LuraWave license code 
     618        code = LuraWave.promptLicenseCode(code, first); 
     619        if (code == null) throw exc; 
     620        if (first) first = false; 
     621        reader.close(); 
     622      } 
     623    } 
     624    throw new FormatException(LuraWave.TOO_MANY_TRIES); 
     625  } 
    593626 
    594627  private void computeSeriesLabels(IFormatReader r) { 
  • branches/4.2/components/loci-plugins/src/loci/plugins/util/ImageProcessorReader.java

    r6626 r6951  
    9595  { 
    9696    // read byte array 
    97     byte[] b = null; 
    98     boolean first = true; 
    99     while (true) { 
    100       // TODO: This is the wrong place to prompt for the LuraWave code. 
    101       // This logic should be moved to a higher, GUI-specific level. 
    102  
    103       // read LuraWave license code, if available 
    104       String code = LuraWave.initLicenseCode(); 
    105       try { 
    106         b = openBytes(no, x, y, w, h); 
    107         break; 
    108       } 
    109       catch (FormatException exc) { 
    110         if (LuraWave.isLicenseCodeException(exc)) { 
    111           // prompt user for LuraWave license code 
    112           code = LuraWave.promptLicenseCode(code, first); 
    113           if (code == null) return null; 
    114           if (first) first = false; 
    115         } 
    116         else throw exc; 
    117       } 
    118     } 
     97    byte[] b = openBytes(no, x, y, w, h); 
    11998 
    12099    int c = getRGBChannelCount(); 
  • branches/4.2/components/loci-plugins/src/loci/plugins/util/LuraWave.java

    r6589 r6951  
    4040public final class LuraWave { 
    4141 
     42  // -- Constants -- 
     43 
     44  public static final int MAX_TRIES = 5; 
     45  public static final String TOO_MANY_TRIES = 
     46    "Too many LuraWave license code attempts; giving up."; 
     47 
    4248  // -- Constructor -- 
    4349 
     
    4955  public static String initLicenseCode() { 
    5056    String code = Prefs.get(LuraWaveServiceImpl.LICENSE_PROPERTY, null); 
    51     if (code != null) { 
     57    if (code != null && code.length() >= 6) { 
    5258      System.setProperty(LuraWaveServiceImpl.LICENSE_PROPERTY, code); 
    5359    } 
Note: See TracChangeset for help on using the changeset viewer.