Changeset 3875


Ignore:
Timestamp:
04/02/08 21:44:03 (12 years ago)
Author:
melissa
Message:
  • Added setLegacy methods to ND2Reader and PictReader and updated configuration plugin accordingly.
  • Removed LegacyPictReader, since it wasn't being used.
Location:
trunk/loci
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/in/LegacyND2Reader.java

    r3724 r3875  
    5151  private static final int MULTI_PHOTON = 5; 
    5252 
     53  private static final String NO_NIKON_MSG = 
     54    "Nikon ND2 library not found.  Please see " + 
     55    "http://loci.wisc.edu/ome/formats.html for details."; 
     56 
    5357  // -- Static initializers -- 
    5458 
     
    6468    } 
    6569  } 
    66  
    67   // -- Fields -- 
    68  
    69   /** Reader to delegate to if this one fails. */ 
    70   private ND2Reader goodReader; 
    7170 
    7271  // -- Constructor -- 
     
    9796    FormatTools.checkPlaneNumber(this, no); 
    9897    FormatTools.checkBufferSize(this, buf.length, w, h); 
    99  
    100     if (goodReader != null) return goodReader.openBytes(no, buf, x, y, w, h); 
    10198 
    10299    int[] zct = FormatTools.getZCTCoords(this, no); 
     
    180177    } 
    181178    catch (Exception e) { 
    182       goodReader = new ND2Reader(); 
    183       goodReader.setId(currentId); 
    184       core = goodReader.getCoreMetadata(); 
    185       metadata = goodReader.getMetadata(); 
     179      throw new FormatException(NO_NIKON_MSG); 
    186180    } 
    187181 
  • trunk/loci/formats/in/ND2Reader.java

    r3854 r3875  
    157157  private String gain, voltage, mag, na; 
    158158 
     159  private LegacyND2Reader legacyReader; 
     160  private boolean legacy = false; 
     161 
    159162  // -- Constructor -- 
    160163 
    161164  /** Constructs a new ND2 reader. */ 
    162165  public ND2Reader() { super("Nikon ND2", new String[] {"nd2", "jp2"}); } 
     166 
     167  // -- ND2Reader API methods -- 
     168 
     169  public void setLegacy(boolean legacy) { 
     170    this.legacy = legacy; 
     171    if (this.legacy) { 
     172      if (legacyReader == null) legacyReader = new LegacyND2Reader(); 
     173    } 
     174    else legacyReader = null; 
     175  } 
    163176 
    164177  // -- IFormatReader API methods -- 
     
    177190    throws FormatException, IOException 
    178191  { 
     192    if (legacy) return legacyReader.openBytes(no, buf, x, y, w, h); 
    179193    FormatTools.assertId(currentId, true, 1); 
    180194    FormatTools.checkPlaneNumber(this, no); 
     
    242256    throws FormatException, IOException 
    243257  { 
     258    if (legacy) return openImage(no, x, y, w, h); 
    244259    if (!isJPEG) { 
    245260      return ImageTools.makeImage(openBytes(no, x, y, w, h), core.sizeX[series], 
     
    283298  } 
    284299 
     300  /* @see loci.formats.IFormatReader#setNormalized(boolean) */ 
     301  public void setNormalized(boolean normalize) { 
     302    super.setNormalized(normalize); 
     303    if (legacy) legacyReader.setNormalized(normalize); 
     304  } 
     305 
     306  /* @see loci.formats.IFormatReader#setMetadataCollected(boolean) */ 
     307  public void setMetadataCollected(boolean collect) { 
     308    super.setMetadataCollected(collect); 
     309    if (legacy) legacyReader.setMetadataCollected(collect); 
     310  } 
     311 
     312  /* @see loci.formats.IFormatReader#setOriginalMetadataPopulated(boolean) */ 
     313  public void setOriginalMetadataPopulated(boolean populate) { 
     314    super.setOriginalMetadataPopulated(populate); 
     315    if (legacy) legacyReader.setOriginalMetadataPopulated(populate); 
     316  } 
     317 
     318  /* @see loci.formats.IFormatReader#setMetadataFiltered(boolean) */ 
     319  public void setMetadataFiltered(boolean filter) { 
     320    super.setMetadataFiltered(filter); 
     321    if (legacy) legacyReader.setMetadataFiltered(filter); 
     322  } 
     323 
     324  /* @see loci.formats.IFormatReader#setMetadataStore(MetadataStore) */ 
     325  public void setMetadataStore(MetadataStore store) { 
     326    super.setMetadataStore(store); 
     327    if (legacy) legacyReader.setMetadataStore(store); 
     328  } 
     329 
    285330  // -- IFormatHandler API methods -- 
    286331 
     
    288333  public void close() throws IOException { 
    289334    super.close(); 
     335 
     336    if (legacyReader != null) legacyReader.close(); 
     337    legacyReader = null; 
     338    legacy = false; 
    290339 
    291340    offsets = null; 
     
    303352    if (noJ2k) throw new FormatException(NO_J2K_MSG); 
    304353    super.initFile(id); 
     354 
     355    if (legacy) { 
     356      legacyReader.setId(id, true); 
     357      core = legacyReader.getCoreMetadata(); 
     358      metadataStore = legacyReader.getMetadataStore(); 
     359      return; 
     360    } 
    305361 
    306362    in = new RandomAccessStream(id); 
  • trunk/loci/formats/in/PictReader.java

    r3854 r3875  
    114114  protected LegacyQTTools qtTools = new LegacyQTTools(); 
    115115 
     116  private boolean legacy = false; 
     117 
    116118  // -- Constructor -- 
    117119 
     
    120122 
    121123  // -- PictReader API methods -- 
     124 
     125  /** Control whether or not legacy reader (QT Java) is used. */ 
     126  public void setLegacy(boolean legacy) { 
     127    this.legacy = legacy; 
     128  } 
    122129 
    123130  /** Get the dimensions of a PICT file from the first 4 bytes after header. */ 
     
    134141  /** Open a PICT image from an array of bytes (used by OpenlabReader). */ 
    135142  public BufferedImage open(byte[] pix) throws FormatException, IOException { 
     143    if (legacy) return ImageTools.makeBuffered(qtTools.pictToImage(pix)); 
     144 
    136145    // handles case when we call this method directly, instead of 
    137146    // through initFile(String) 
  • trunk/loci/formats/readers.txt

    r3772 r3875  
    7070loci.formats.in.ZeissZVIReader        # zvi [POIFS] 
    7171loci.formats.in.IPWReader             # ipw [POIFS] 
    72 loci.formats.in.LegacyND2Reader       # nd2, jp2 [Nikon SDK - Windows only] 
    7372loci.formats.in.ND2Reader             # nd2, jp2 [JAI-ImageIO] 
    7473loci.formats.in.PCIReader             # cxd [POIFS] 
  • trunk/loci/plugins/Util.java

    r3866 r3875  
    515515      if (r[i] instanceof ND2Reader) { 
    516516        ND2Reader nd2 = (ND2Reader) r[i]; 
    517         //nd2.setLegacy(nd2); 
     517        nd2.setLegacy(nd2Nikon); 
    518518      } 
    519519      else if (r[i] instanceof PictReader) { 
    520520        PictReader pict = (PictReader) r[i]; 
    521         //pict.setLegacy(pictQTJava); 
     521        pict.setLegacy(pictQTJava); 
    522522      } 
    523523      else if (r[i] instanceof QTReader) { 
  • trunk/loci/plugins/config/ND2Widgets.java

    r3866 r3875  
    5858      "Use Nikon's ND2 library instead of native ND2 support"); 
    5959    legacyBox.addItemListener(this); 
    60     legacyBox.setEnabled(false);//TEMP 
     60    legacyBox.setEnabled(true); 
    6161 
    6262    labels = new String[] {legacyLabel}; 
  • trunk/loci/plugins/config/PictWidgets.java

    r3866 r3875  
    5858      "Use QTJava instead of native PICT support", qtJava); 
    5959    legacyBox.addItemListener(this); 
    60     legacyBox.setEnabled(false);//TEMP 
     60    legacyBox.setEnabled(true); 
    6161 
    6262    labels = new String[] {legacyLabel}; 
Note: See TracChangeset for help on using the changeset viewer.