Changeset 2695


Ignore:
Timestamp:
04/27/07 11:43:54 (13 years ago)
Author:
melissa
Message:

Moved assertId implementation to FormatTools and added assertId calls to appropriate methods.

Location:
trunk/loci/formats
Files:
50 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/ChannelMerger.java

    r2672 r2695  
    5151  /* @see IFormatReader#getImageCount() */ 
    5252  public int getImageCount() { 
     53    FormatTools.assertId(getCurrentFile(), true, 2);  
    5354    int no = reader.getImageCount(); 
    5455    if (canMerge()) no /= getSizeC(); 
     
    5859  /* @see IFormatReader#getDimensionOrder() */ 
    5960  public String getDimensionOrder() { 
     61    FormatTools.assertId(getCurrentFile(), true, 2);  
    6062    String order = reader.getDimensionOrder(); 
    6163    if (canMerge()) { 
     
    7375  /* @see IFormatReader#isRGB() */ 
    7476  public boolean isRGB() { 
     77    FormatTools.assertId(getCurrentFile(), true, 2);  
    7578    return canMerge() || reader.isRGB(); 
    7679  } 
     
    7881  /* @see IFormatReader#openImage(int) */ 
    7982  public BufferedImage openImage(int no) throws FormatException, IOException { 
     83    FormatTools.assertId(getCurrentFile(), true, 2);  
    8084    if (!canMerge()) return super.openImage(no); 
    8185    int sizeC = getSizeC(); 
     
    100104   */ 
    101105  public byte[] openBytes(int no) throws FormatException, IOException { 
     106    FormatTools.assertId(getCurrentFile(), true, 2);  
    102107    if (!canMerge()) return super.openBytes(no); 
    103108    int sizeC = getSizeC(); 
     
    123128    throws FormatException, IOException 
    124129  { 
     130    FormatTools.assertId(getCurrentFile(), true, 2);  
    125131    if (!canMerge()) return super.openThumbImage(no); 
    126132    return ImageTools.scale(openImage(no), getThumbSizeX(), 
  • trunk/loci/formats/ChannelSeparator.java

    r2672 r2695  
    5454  /* @see IFormatReader#getImageCount() */ 
    5555  public int getImageCount() { 
     56    FormatTools.assertId(getCurrentFile(), true, 2);  
    5657    return reader.isRGB() ? 
    5758      (getSizeC() / reader.getEffectiveSizeC()) * reader.getImageCount() : 
     
    6162  /* @see IFormatReader#getDimensionOrder() */ 
    6263  public String getDimensionOrder() { 
     64    FormatTools.assertId(getCurrentFile(), true, 2);  
    6365    String order = super.getDimensionOrder(); 
    6466    if (reader.isRGB()) { 
     
    7274 
    7375  /* @see IFormatReader#isRGB() */ 
    74   public boolean isRGB() { return false; } 
     76  public boolean isRGB() {  
     77    FormatTools.assertId(getCurrentFile(), true, 2);  
     78    return false;  
     79  } 
    7580 
    7681  /* @see IFormatReader#openImage(int) */ 
    7782  public BufferedImage openImage(int no) throws FormatException, IOException { 
     83    FormatTools.assertId(getCurrentFile(), true, 2);  
    7884    if (no < 0 || no >= getImageCount()) { 
    7985      throw new FormatException("Invalid image number: " + no); 
     
    118124  /* @see IFormatReader#openBytes(int) */ 
    119125  public byte[] openBytes(int no) throws FormatException, IOException { 
     126    FormatTools.assertId(getCurrentFile(), true, 2);  
    120127    if (no < 0 || no >= getImageCount()) { 
    121128      throw new FormatException("Invalid image number: " + no); 
     
    144151    throws FormatException, IOException 
    145152  { 
     153    FormatTools.assertId(getCurrentFile(), true, 2);  
    146154    return ImageTools.scale(openImage(no), getThumbSizeX(), 
    147155      getThumbSizeY(), true); 
  • trunk/loci/formats/DimensionSwapper.java

    r2672 r2695  
    4040  /* @see loci.formats.IFormatReader#getSizeX() */ 
    4141  public int getSizeX() { 
     42    FormatTools.assertId(getCurrentFile(), true, 2);  
    4243    return getCoreMetadata().sizeX[getSeries()]; 
    4344  } 
     
    4546  /* @see loci.formats.IFormatReader#getSizeY() */ 
    4647  public int getSizeY() { 
     48    FormatTools.assertId(getCurrentFile(), true, 2);  
    4749    return getCoreMetadata().sizeY[getSeries()]; 
    4850  } 
     
    5052  /* @see loci.formats.IFormatReader#getSizeZ() */ 
    5153  public int getSizeZ() { 
     54    FormatTools.assertId(getCurrentFile(), true, 2);  
    5255    return getCoreMetadata().sizeZ[getSeries()]; 
    5356  } 
     
    5558  /* @see loci.formats.IFormatReader#getSizeC() */ 
    5659  public int getSizeC() { 
     60    FormatTools.assertId(getCurrentFile(), true, 2);  
    5761    return getCoreMetadata().sizeC[getSeries()]; 
    5862  } 
     
    6064  /* @see loci.formats.IFormatReader#getSizeT() */ 
    6165  public int getSizeT() { 
     66    FormatTools.assertId(getCurrentFile(), true, 2);  
    6267    return getCoreMetadata().sizeT[getSeries()]; 
    6368  } 
     
    6570  /* @see loci.formats.IFormatReader#getDimensionOrder() */ 
    6671  public String getDimensionOrder() { 
     72    FormatTools.assertId(getCurrentFile(), true, 2);  
    6773    return getCoreMetadata().currentOrder[getSeries()]; 
    6874  } 
     
    7783   */ 
    7884  public void swapDimensions(String order) { 
     85    FormatTools.assertId(getCurrentFile(), true, 2);  
    7986    if (order == null) return; 
    8087 
  • trunk/loci/formats/FileStitcher.java

    r2687 r2695  
    136136   */ 
    137137  public int[] getAxisTypes() { 
     138    FormatTools.assertId(currentId, true, 2);  
    138139    return ag[getSeries()].getAxisTypes(); 
    139140  } 
     
    149150   */ 
    150151  public void setAxisTypes(int[] axes) throws FormatException { 
     152    FormatTools.assertId(currentId, true, 2);  
    151153    ag[getSeries()].setAxisTypes(axes); 
    152154    computeAxisLengths(); 
     
    155157  /** Gets the file pattern object used to build the list of files. */ 
    156158  public FilePattern getFilePattern() { 
     159    FormatTools.assertId(currentId, true, 2);  
    157160    return fp; 
    158161  } 
     
    163166   */ 
    164167  public AxisGuesser getAxisGuesser() { 
     168    FormatTools.assertId(currentId, true, 2);  
    165169    return ag[getSeries()]; 
    166170  } 
     
    171175   */ 
    172176  public FilePattern findPattern(String id) { 
     177    FormatTools.assertId(currentId, true, 2);  
    173178    if (!patternIds) { 
    174179      // find the containing pattern 
     
    215220  /* @see IFormatReader#getImageCount() */ 
    216221  public int getImageCount() { 
     222    FormatTools.assertId(currentId, true, 2);  
    217223    return core.imageCount[getSeries()]; 
    218224  } 
     
    220226  /* @see IFormatReader#isRGB() */ 
    221227  public boolean isRGB() { 
     228    FormatTools.assertId(currentId, true, 2);  
    222229    return core.rgb[getSeries()]; 
    223230  } 
     
    225232  /* @see IFormatReader#getSizeX() */ 
    226233  public int getSizeX() { 
     234    FormatTools.assertId(currentId, true, 2);  
    227235    return core.sizeX[getSeries()]; 
    228236  } 
     
    230238  /* @see IFormatReader#getSizeY() */ 
    231239  public int getSizeY() { 
     240    FormatTools.assertId(currentId, true, 2);  
    232241    return core.sizeY[getSeries()]; 
    233242  } 
     
    235244  /* @see IFormatReader#getSizeZ() */ 
    236245  public int getSizeZ() { 
     246    FormatTools.assertId(currentId, true, 2);  
    237247    return core.sizeZ[getSeries()]; 
    238248  } 
     
    240250  /* @see IFormatReader#getSizeC() */ 
    241251  public int getSizeC() { 
     252    FormatTools.assertId(currentId, true, 2);  
    242253    return core.sizeC[getSeries()]; 
    243254  } 
     
    245256  /* @see IFormatReader#getSizeT() */ 
    246257  public int getSizeT() { 
     258    FormatTools.assertId(currentId, true, 2);  
    247259    return core.sizeT[getSeries()]; 
    248260  } 
     
    250262  /* @see IFormatReader#getPixelType() */ 
    251263  public int getPixelType() { 
     264    FormatTools.assertId(currentId, true, 2);  
    252265    return core.pixelType[getSeries()]; 
    253266  } 
     
    255268  /* @see IFormatReader#getEffectiveSizeC() */ 
    256269  public int getEffectiveSizeC() { 
     270    FormatTools.assertId(currentId, true, 2);  
    257271    return getImageCount() / (getSizeZ() * getSizeT()); 
    258272  } 
     
    260274  /* @see IFormatReader#getRGBChannelCount() */ 
    261275  public int getRGBChannelCount() { 
     276    FormatTools.assertId(currentId, true, 2);  
    262277    return getSizeC() / getEffectiveSizeC(); 
    263278  } 
     
    265280  /* @see IFormatReader#getChannelDimLengths() */ 
    266281  public int[] getChannelDimLengths() { 
     282    FormatTools.assertId(currentId, true, 2);  
    267283    int sno = getSeries(); 
    268284    int len = lenC[sno].length; 
     
    274290  /* @see IFormatReader#getChannelDimTypes() */ 
    275291  public String[] getChannelDimTypes() { 
     292    FormatTools.assertId(currentId, true, 2);  
    276293    int sno = getSeries(); 
    277294    int len = lenC[sno].length; 
     
    283300  /* @see IFormatReader#getThumbSizeX() */ 
    284301  public int getThumbSizeX() { 
     302    FormatTools.assertId(currentId, true, 2);  
    285303    return reader.getThumbSizeX(); 
    286304  } 
     
    288306  /* @see IFormatReader#getThumbSizeY() */ 
    289307  public int getThumbSizeY() { 
     308    FormatTools.assertId(currentId, true, 2);  
    290309    return reader.getThumbSizeY(); 
    291310  } 
     
    293312  /* @see IFormatReader#isLittleEndian() */ 
    294313  public boolean isLittleEndian() { 
     314    FormatTools.assertId(currentId, true, 2);  
    295315    return reader.isLittleEndian(); 
    296316  } 
     
    298318  /* @see IFormatReader#getDimensionOrder() */ 
    299319  public String getDimensionOrder() { 
     320    FormatTools.assertId(currentId, true, 2);  
    300321    return core.currentOrder[getSeries()]; 
    301322  } 
     
    303324  /* @see IFormatReader#isOrderCertain() */ 
    304325  public boolean isOrderCertain() { 
     326    FormatTools.assertId(currentId, true, 2);  
    305327    return ag[getSeries()].isCertain(); 
    306328  } 
     
    308330  /* @see IFormatReader#isInterleaved() */ 
    309331  public boolean isInterleaved() { 
     332    FormatTools.assertId(currentId, true, 2);  
    310333    return reader.isInterleaved(); 
    311334  } 
     
    313336  /* @see IFormatReader#isInterleaved(int) */ 
    314337  public boolean isInterleaved(int subC) { 
     338    FormatTools.assertId(currentId, true, 2);  
    315339    return reader.isInterleaved(subC); 
    316340  } 
     
    318342  /* @see IFormatReader#openImage(int) */ 
    319343  public BufferedImage openImage(int no) throws FormatException, IOException { 
     344    FormatTools.assertId(currentId, true, 2);  
    320345    int[] q = computeIndices(no); 
    321346    int fno = q[0], ino = q[1]; 
     
    336361  /* @see IFormatReader#openBytes(int) */ 
    337362  public byte[] openBytes(int no) throws FormatException, IOException { 
     363    FormatTools.assertId(currentId, true, 2);  
    338364    int[] q = computeIndices(no); 
    339365    int fno = q[0], ino = q[1]; 
     
    357383    throws FormatException, IOException 
    358384  { 
     385    FormatTools.assertId(currentId, true, 2);  
    359386    int[] q = computeIndices(no); 
    360387    int fno = q[0], ino = q[1]; 
     
    367394    throws FormatException, IOException 
    368395  { 
     396    FormatTools.assertId(currentId, true, 2);  
    369397    int[] q = computeIndices(no); 
    370398    int fno = q[0], ino = q[1]; 
     
    385413  /* @see IFormatReader#openThumbBytes(int) */ 
    386414  public byte[] openThumbBytes(int no) throws FormatException, IOException { 
     415    FormatTools.assertId(currentId, true, 2);  
    387416    int[] q = computeIndices(no); 
    388417    int fno = q[0], ino = q[1]; 
     
    430459  /* @see IFormatReader#getSeriesCount() */ 
    431460  public int getSeriesCount() { 
     461    FormatTools.assertId(currentId, true, 2);  
    432462    return reader.getSeriesCount(); 
    433463  } 
     
    435465  /* @see IFormatReader#setSeries(int) */ 
    436466  public void setSeries(int no) throws FormatException { 
     467    FormatTools.assertId(currentId, true, 2);  
    437468    reader.setSeries(no); 
    438469  } 
     
    440471  /* @see IFormatReader#getSeries() */ 
    441472  public int getSeries() { 
     473    FormatTools.assertId(currentId, true, 2);  
    442474    return reader.getSeries(); 
    443475  } 
     
    445477  /* @see IFormatReader#setNormalized(boolean) */ 
    446478  public void setNormalized(boolean normalize) { 
     479    FormatTools.assertId(currentId, false, 2);  
    447480    if (readers == null) reader.setNormalized(normalize); 
    448481    else { 
     
    458491  /* @see IFormatReader#setMetadataCollected(boolean) */ 
    459492  public void setMetadataCollected(boolean collect) { 
     493    FormatTools.assertId(currentId, false, 2);  
    460494    if (readers == null) reader.setMetadataCollected(collect); 
    461495    else { 
     
    473507  /* @see IFormatReader#getUsedFiles() */ 
    474508  public String[] getUsedFiles() { 
     509    FormatTools.assertId(currentId, true, 2);  
     510     
    475511    // returning the files list directly here is fast, since we do not 
    476512    // have to call initFile on each constituent file; but we can only do so 
     
    528564  /* @see IFormatReader#getMetadataValue(String) */ 
    529565  public Object getMetadataValue(String field) { 
     566    FormatTools.assertId(currentId, true, 2);  
    530567    return reader.getMetadataValue(field); 
    531568  } 
     
    533570  /* @see IFormatReader#getMetadata() */ 
    534571  public Hashtable getMetadata() { 
     572    FormatTools.assertId(currentId, true, 2);  
    535573    return reader.getMetadata(); 
    536574  } 
     
    538576  /* @see IFormatReader#getCoreMetadata() */ 
    539577  public CoreMetadata getCoreMetadata() { 
     578    FormatTools.assertId(currentId, true, 2);  
    540579    return core; 
    541580  } 
     
    543582  /* @see IFormatReader#setMetadataFiltered(boolean) */ 
    544583  public void setMetadataFiltered(boolean filter) { 
     584    FormatTools.assertId(currentId, false, 2);  
    545585    reader.setMetadataFiltered(filter); 
    546586  } 
     
    553593  /* @see IFormatReader#setMetadataStore(MetadataStore) */ 
    554594  public void setMetadataStore(MetadataStore store) { 
     595    FormatTools.assertId(currentId, false, 2);  
    555596    reader.setMetadataStore(store); 
    556597  } 
     
    558599  /* @see IFormatReader#getMetadataStore() */ 
    559600  public MetadataStore getMetadataStore() { 
     601    FormatTools.assertId(currentId, true, 2);  
    560602    return reader.getMetadataStore(); 
    561603  } 
     
    563605  /* @see IFormatReader#getMetadataStoreRoot() */ 
    564606  public Object getMetadataStoreRoot() { 
     607    FormatTools.assertId(currentId, true, 2);  
    565608    return reader.getMetadataStoreRoot(); 
    566609  } 
     
    585628  /* @see IFormatHandler#getFormat() */ 
    586629  public String getFormat() { 
     630    FormatTools.assertId(currentId, true, 2);  
    587631    return reader.getFormat(); 
    588632  } 
  • trunk/loci/formats/FormatHandler.java

    r2694 r2695  
    8282    StatusListener[] l = getStatusListeners(); 
    8383    for (int i=0; i<l.length; i++) l[i].statusUpdated(e); 
    84   } 
    85  
    86   /** 
    87    * Asserts that the current file is either null, nor not, according to the 
    88    * given flag. If the assertion fails, an IllegalStateException is thrown. 
    89    * @param notNull True iff id should be non-null. 
    90    * @param depth How far back in the stack the calling method is; this name 
    91    *   is reported as part of the exception message, if available. Use zero 
    92    *   to suppress output of the calling method name. 
    93    */ 
    94   protected void assertId(boolean notNull, int depth) { 
    95     String msg = null; 
    96     if (currentId == null && notNull) { 
    97       msg = "Current file should not be null; call setId(String) first"; 
    98     } 
    99     else if (currentId != null && !notNull) { 
    100       msg = "Current file should be null, but is '" + 
    101         currentId + "'; call close() first"; 
    102     } 
    103     if (msg == null) return; 
    104  
    105     StackTraceElement[] ste = new Exception().getStackTrace(); 
    106     String header; 
    107     if (depth > 0 && ste.length > depth) { 
    108       String c = ste[depth].getClassName(); 
    109       if (c.startsWith("loci.formats.")) { 
    110         c = c.substring(c.lastIndexOf(".") + 1); 
    111       } 
    112       header = c + "." + ste[depth].getMethodName() + ": "; 
    113     } 
    114     else header = ""; 
    115     throw new IllegalStateException(header + msg); 
    11684  } 
    11785 
  • trunk/loci/formats/FormatReader.java

    r2687 r2695  
    182182  /* @see IFormatReader#getImageCount() */ 
    183183  public int getImageCount() { 
     184    FormatTools.assertId(currentId, true, 1);  
    184185    return core.imageCount[series]; 
    185186  } 
     
    187188  /* @see IFormatReader#isRGB() */ 
    188189  public boolean isRGB() { 
     190    FormatTools.assertId(currentId, true, 1);  
    189191    return core.rgb[series]; 
    190192  } 
     
    192194  /* @see IFormatReader#getSizeX() */ 
    193195  public int getSizeX() { 
     196    FormatTools.assertId(currentId, true, 1);  
    194197    return core.sizeX[series]; 
    195198  } 
     
    197200  /* @see IFormatReader#getSizeY() */ 
    198201  public int getSizeY() { 
     202    FormatTools.assertId(currentId, true, 1);  
    199203    return core.sizeY[series]; 
    200204  } 
     
    202206  /* @see IFormatReader#getSizeZ() */ 
    203207  public int getSizeZ() { 
     208    FormatTools.assertId(currentId, true, 1);  
    204209    return core.sizeZ[series]; 
    205210  } 
     
    207212  /* @see IFormatReader#getSizeC() */ 
    208213  public int getSizeC() { 
     214    FormatTools.assertId(currentId, true, 1);  
    209215    return core.sizeC[series]; 
    210216  } 
     
    212218  /* @see IFormatReader#getSizeT() */ 
    213219  public int getSizeT() { 
     220    FormatTools.assertId(currentId, true, 1);  
    214221    return core.sizeT[series]; 
    215222  } 
     
    217224  /* @see IFormatReader#getPixelType() */ 
    218225  public int getPixelType() { 
     226    FormatTools.assertId(currentId, true, 1);  
    219227    return core.pixelType[series]; 
    220228  } 
     
    233241  /* @see IFormatReader#getChannelDimLengths() */ 
    234242  public int[] getChannelDimLengths() { 
     243    FormatTools.assertId(currentId, true, 1);  
    235244    if (core.cLengths[series] == null) { 
    236245      core.cLengths[series] = new int[] {core.sizeC[series]}; 
     
    241250  /* @see IFormatReader#getChannelDimTypes() */ 
    242251  public String[] getChannelDimTypes() { 
     252    FormatTools.assertId(currentId, true, 1);  
    243253    if (core.cTypes[series] == null) { 
    244254      core.cTypes[series] = new String[] {FormatTools.CHANNEL}; 
     
    249259  /* @see IFormatReader#getThumbSizeX() */ 
    250260  public int getThumbSizeX() { 
     261    FormatTools.assertId(currentId, true, 1);  
    251262    if (core.thumbSizeX[series] == 0) { 
    252263      int sx = getSizeX(); 
     
    260271  /* @see IFormatReader#getThumbSizeY() */ 
    261272  public int getThumbSizeY() { 
     273    FormatTools.assertId(currentId, true, 1);  
    262274    if (core.thumbSizeY[series] == 0) { 
    263275      int sx = getSizeX(); 
     
    271283  /* @see IFormatReader.isLittleEndian() */ 
    272284  public boolean isLittleEndian() { 
     285    FormatTools.assertId(currentId, true, 1);  
    273286    return core.littleEndian[series]; 
    274287  } 
     
    276289  /* @see IFormatReader#getDimensionOrder() */ 
    277290  public String getDimensionOrder() { 
     291    FormatTools.assertId(currentId, true, 1);  
    278292    return core.currentOrder[series]; 
    279293  } 
     
    281295  /* @see IFormatReader.isOrderCertain() */ 
    282296  public boolean isOrderCertain() { 
     297    FormatTools.assertId(currentId, true, 1);  
    283298    return core.orderCertain[series]; 
    284299  } 
     
    291306  /* @see IFormatReader#isInterleaved(int) */ 
    292307  public boolean isInterleaved(int subC) { 
     308    FormatTools.assertId(currentId, true, 1);  
    293309    return core.interleaved[series]; 
    294310  } 
     
    305321    throws FormatException, IOException 
    306322  { 
     323    FormatTools.assertId(currentId, true, 1);  
    307324    return ImageTools.scale(openImage(no), getThumbSizeX(), 
    308325      getThumbSizeY(), false); 
     
    311328  /* @see IFormatReader#openThumbBytes(int) */ 
    312329  public byte[] openThumbBytes(int no) throws FormatException, IOException { 
     330    FormatTools.assertId(currentId, true, 1);  
    313331    BufferedImage img = openThumbImage(no); 
    314332    byte[][] bytes = ImageTools.getBytes(img); 
     
    331349  /* @see IFormatReader#getSeriesCount() */ 
    332350  public int getSeriesCount() { 
     351    FormatTools.assertId(currentId, true, 1);  
    333352    return core.sizeX.length; 
    334353  } 
     
    349368  /* @see IFormatReader#setNormalized(boolean) */ 
    350369  public void setNormalized(boolean normalize) { 
     370    FormatTools.assertId(currentId, false, 1);  
    351371    if (currentId != null) { 
    352372      String s = "setNormalized called with open file."; 
     
    364384  /* @see IFormatReader#setMetadataCollected(boolean) */ 
    365385  public void setMetadataCollected(boolean collect) { 
     386    FormatTools.assertId(currentId, false, 1);  
    366387    if (currentId != null) { 
    367388      String s = "setMetadataCollected called with open file."; 
     
    379400  /* @see IFormatReader#getUsedFiles() */ 
    380401  public String[] getUsedFiles() { 
     402    FormatTools.assertId(currentId, true, 1);  
    381403    return new String[] {currentId}; 
    382404  } 
     
    389411  /* @see IFormatReader#getIndex(int, int, int) */ 
    390412  public int getIndex(int z, int c, int t) throws FormatException { 
     413    FormatTools.assertId(currentId, true, 1);  
    391414    return FormatTools.getIndex(this, z, c, t); 
    392415  } 
     
    394417  /* @see IFormatReader#getZCTCoords(int) */ 
    395418  public int[] getZCTCoords(int index) throws FormatException { 
     419    FormatTools.assertId(currentId, true, 1);  
    396420    return FormatTools.getZCTCoords(this, index); 
    397421  } 
     
    399423  /* @see IFormatReader#getMetadataValue(String) */ 
    400424  public Object getMetadataValue(String field) { 
     425    FormatTools.assertId(currentId, true, 1);  
    401426    return getMeta(field); 
    402427  } 
     
    404429  /* @see IFormatReader#getMetadata() */ 
    405430  public Hashtable getMetadata() { 
     431    FormatTools.assertId(currentId, true, 1);  
    406432    return metadata; 
    407433  } 
     
    409435  /* @see IFormatReader#getCoreMetadata() */ 
    410436  public CoreMetadata getCoreMetadata() { 
     437    FormatTools.assertId(currentId, true, 1);  
    411438    return core; 
    412439  } 
     
    414441  /* @see IFormatReader#setMetadataFiltered(boolean) */ 
    415442  public void setMetadataFiltered(boolean filter) { 
     443    FormatTools.assertId(currentId, false, 1);  
    416444    if (currentId != null) { 
    417445      String s = "setMetadataFiltered called with open file."; 
     
    429457  /* @see IFormatReader#setMetadataStore(MetadataStore) */ 
    430458  public void setMetadataStore(MetadataStore store) { 
     459    FormatTools.assertId(currentId, false, 1);  
    431460    if (currentId != null) { 
    432461      String s = "setMetadataStore called with open file."; 
     
    444473  /* @see IFormatReader#getMetadataStoreRoot() */ 
    445474  public Object getMetadataStoreRoot() { 
     475    FormatTools.assertId(currentId, true, 1);  
    446476    return getMetadataStore().getRoot(); 
    447477  } 
  • trunk/loci/formats/FormatTools.java

    r2689 r2695  
    937937  } 
    938938 
     939  // -- Utility methods - sanity checking 
     940 
     941  /** 
     942   * Asserts that the current file is either null, nor not, according to the 
     943   * given flag. If the assertion fails, an IllegalStateException is thrown. 
     944   * @param currentId File name to test.  
     945   * @param notNull True iff id should be non-null. 
     946   * @param depth How far back in the stack the calling method is; this name 
     947   *   is reported as part of the exception message, if available. Use zero 
     948   *   to suppress output of the calling method name. 
     949   */ 
     950  public static void assertId(String currentId, boolean notNull, int depth) { 
     951    String msg = null; 
     952    if (currentId == null && notNull) { 
     953      msg = "Current file should not be null; call setId(String) first"; 
     954    } 
     955    else if (currentId != null && !notNull) { 
     956      msg = "Current file should be null, but is '" + 
     957        currentId + "'; call close() first"; 
     958    } 
     959    if (msg == null) return; 
     960 
     961    StackTraceElement[] ste = new Exception().getStackTrace(); 
     962    String header; 
     963    if (depth > 0 && ste.length > depth) { 
     964      String c = ste[depth].getClassName(); 
     965      if (c.startsWith("loci.formats.")) { 
     966        c = c.substring(c.lastIndexOf(".") + 1); 
     967      } 
     968      header = c + "." + ste[depth].getMethodName() + ": "; 
     969    } 
     970    else header = ""; 
     971    throw new IllegalStateException(header + msg); 
     972  } 
     973 
    939974} 
  • trunk/loci/formats/ImageReader.java

    r2687 r2695  
    165165  /* @see IFormatReader#getImageCount() */ 
    166166  public int getImageCount() { 
     167    FormatTools.assertId(currentId, true, 2);  
    167168    return getReader().getImageCount(); 
    168169  } 
     
    170171  /* @see IFormatReader#isRGB() */ 
    171172  public boolean isRGB() { 
     173    FormatTools.assertId(currentId, true, 2);  
    172174    return getReader().isRGB(); 
    173175  } 
     
    175177  /* @see IFormatReader#getSizeX() */ 
    176178  public int getSizeX() { 
     179    FormatTools.assertId(currentId, true, 2);  
    177180    return getReader().getSizeX(); 
    178181  } 
     
    180183  /* @see IFormatReader#getSizeY() */ 
    181184  public int getSizeY() { 
     185    FormatTools.assertId(currentId, true, 2);  
    182186    return getReader().getSizeY(); 
    183187  } 
     
    185189  /* @see IFormatReader#getSizeC() */ 
    186190  public int getSizeC() { 
     191    FormatTools.assertId(currentId, true, 2);  
    187192    return getReader().getSizeC(); 
    188193  } 
     
    190195  /* @see IFormatReader#getSizeZ() */ 
    191196  public int getSizeZ() { 
     197    FormatTools.assertId(currentId, true, 2);  
    192198    return getReader().getSizeZ(); 
    193199  } 
     
    195201  /* @see IFormatReader#getSizeT() */ 
    196202  public int getSizeT() { 
     203    FormatTools.assertId(currentId, true, 2);  
    197204    return getReader().getSizeT(); 
    198205  } 
     
    200207  /* @see IFormatReader#getPixelType() */ 
    201208  public int getPixelType() { 
     209    FormatTools.assertId(currentId, true, 2);  
    202210    return getReader().getPixelType(); 
    203211  } 
     
    205213  /* @see IFormatReader#getEffectiveSizeC() */ 
    206214  public int getEffectiveSizeC() { 
     215    FormatTools.assertId(currentId, true, 2);  
    207216    return getReader().getEffectiveSizeC(); 
    208217  } 
     
    210219  /* @see IFormatReader#getRGBChannelCount() */ 
    211220  public int getRGBChannelCount() { 
     221    FormatTools.assertId(currentId, true, 2);  
    212222    return getReader().getRGBChannelCount(); 
    213223  } 
     
    215225  /* @see IFormatReader#getChannelDimLengths() */ 
    216226  public int[] getChannelDimLengths() { 
     227    FormatTools.assertId(currentId, true, 2);  
    217228    return getReader().getChannelDimLengths(); 
    218229  } 
     
    220231  /* @see IFormatReader#getChannelDimTypes() */ 
    221232  public String[] getChannelDimTypes() { 
     233    FormatTools.assertId(currentId, true, 2);  
    222234    return getReader().getChannelDimTypes(); 
    223235  } 
     
    225237  /* @see IFormatReader#getThumbSizeX() */ 
    226238  public int getThumbSizeX() { 
     239    FormatTools.assertId(currentId, true, 2);  
    227240    return getReader().getThumbSizeX(); 
    228241  } 
     
    230243  /* @see IFormatReader#getThumbSizeY() */ 
    231244  public int getThumbSizeY() { 
     245    FormatTools.assertId(currentId, true, 2);  
    232246    return getReader().getThumbSizeY(); 
    233247  } 
     
    235249  /* @see IFormatReader#isLittleEndian() */ 
    236250  public boolean isLittleEndian() { 
     251    FormatTools.assertId(currentId, true, 2);  
    237252    return getReader().isLittleEndian(); 
    238253  } 
     
    240255  /* @see IFormatReader#getDimensionOrder() */ 
    241256  public String getDimensionOrder() { 
     257    FormatTools.assertId(currentId, true, 2);  
    242258    return getReader().getDimensionOrder(); 
    243259  } 
     
    245261  /* @see IFormatReader#isOrderCertain() */ 
    246262  public boolean isOrderCertain() { 
     263    FormatTools.assertId(currentId, true, 2);  
    247264    return getReader().isOrderCertain(); 
    248265  } 
     
    250267  /* @see IFormatReader#isInterleaved() */ 
    251268  public boolean isInterleaved() { 
     269    FormatTools.assertId(currentId, true, 2);  
    252270    return getReader().isInterleaved(); 
    253271  } 
     
    255273  /* @see IFormatReader#isInterleaved(int) */ 
    256274  public boolean isInterleaved(int subC) { 
     275    FormatTools.assertId(currentId, true, 2);  
    257276    return getReader().isInterleaved(subC); 
    258277  } 
     
    260279  /* @see IFormatReader#openImage(int) */ 
    261280  public BufferedImage openImage(int no) throws FormatException, IOException { 
     281    FormatTools.assertId(currentId, true, 2);  
    262282    return getReader().openImage(no); 
    263283  } 
     
    265285  /* @see IFormatReader#openBytes(int) */ 
    266286  public byte[] openBytes(int no) throws FormatException, IOException { 
     287    FormatTools.assertId(currentId, true, 2);  
    267288    return getReader().openBytes(no); 
    268289  } 
     
    272293    throws FormatException, IOException 
    273294  { 
     295    FormatTools.assertId(currentId, true, 2);  
    274296    return getReader().openBytes(no, buf); 
    275297  } 
     
    279301    throws FormatException, IOException 
    280302  { 
     303    FormatTools.assertId(currentId, true, 2);  
    281304    return getReader().openThumbImage(no); 
    282305  } 
     
    284307  /* @see IFormatReader#openThumbBytes(int) */ 
    285308  public byte[] openThumbBytes(int no) throws FormatException, IOException { 
     309    FormatTools.assertId(currentId, true, 2);  
    286310    return getReader().openThumbBytes(no); 
    287311  } 
     
    289313  /* @see IFormatReader#getSeriesCount() */ 
    290314  public int getSeriesCount() { 
     315    FormatTools.assertId(currentId, true, 2);  
    291316    return getReader().getSeriesCount(); 
    292317  } 
     
    294319  /* @see IFormatReader#setSeries(int) */ 
    295320  public void setSeries(int no) throws FormatException { 
     321    FormatTools.assertId(currentId, true, 2);  
    296322    getReader().setSeries(no); 
    297323  } 
     
    304330  /* @see IFormatReader#getUsedFiles() */ 
    305331  public String[] getUsedFiles() { 
     332    FormatTools.assertId(currentId, true, 2);  
    306333    return getReader().getUsedFiles(); 
    307334  } 
     
    309336  /* @see IFormatReader#getIndex(int, int, int) */ 
    310337  public int getIndex(int z, int c, int t) throws FormatException { 
     338    FormatTools.assertId(currentId, true, 2);  
    311339    return getReader().getIndex(z, c, t); 
    312340  } 
     
    314342  /* @see IFormatReader#getZCTCoords(int) */ 
    315343  public int[] getZCTCoords(int index) throws FormatException { 
     344    FormatTools.assertId(currentId, true, 2);  
    316345    return getReader().getZCTCoords(index); 
    317346  } 
     
    319348  /* @see IFormatReader#getMetadataValue(String) */ 
    320349  public Object getMetadataValue(String field) { 
     350    FormatTools.assertId(currentId, true, 2);  
    321351    return getReader().getMetadataValue(field); 
    322352  } 
     
    324354  /* @see IFormatReader#getMetadata() */ 
    325355  public Hashtable getMetadata() { 
     356    FormatTools.assertId(currentId, true, 2);  
    326357    return getReader().getMetadata(); 
    327358  } 
     
    329360  /* @see IFormatReader#getCoreMetadata() */ 
    330361  public CoreMetadata getCoreMetadata() { 
     362    FormatTools.assertId(currentId, true, 2);  
    331363    return getReader().getCoreMetadata(); 
    332364  } 
     
    334366  /* @see IFormatReader#getMetadataStore() */ 
    335367  public MetadataStore getMetadataStore() { 
     368    FormatTools.assertId(currentId, true, 2);  
    336369    return getReader().getMetadataStore(); 
    337370  } 
     
    339372  /* @see IFormatReader#getMetadataStoreRoot() */ 
    340373  public Object getMetadataStoreRoot() { 
     374    FormatTools.assertId(currentId, true, 2);  
    341375    return getReader().getMetadataStoreRoot(); 
    342376  } 
     
    349383  /* @see IFormatReader#setNormalized(boolean) */ 
    350384  public void setNormalized(boolean normalize) { 
     385    FormatTools.assertId(currentId, false, 2);  
    351386    for (int i=0; i<readers.length; i++) readers[i].setNormalized(normalize); 
    352387  } 
     
    360395  /* @see IFormatReader#setMetadataCollected(boolean) */ 
    361396  public void setMetadataCollected(boolean collect) { 
     397    FormatTools.assertId(currentId, false, 2);  
    362398    for (int i=0; i<readers.length; i++) { 
    363399      readers[i].setMetadataCollected(collect); 
     
    377413  /* @see IFormatReader#setMetadataFiltered(boolean) */ 
    378414  public void setMetadataFiltered(boolean filter) { 
     415    FormatTools.assertId(currentId, false, 2);  
    379416    for (int i=0; i<readers.length; i++) readers[i].setMetadataFiltered(filter); 
    380417  } 
     
    388425  /* @see IFormatReader#setMetadataStore(MetadataStore) */ 
    389426  public void setMetadataStore(MetadataStore store) { 
     427    FormatTools.assertId(currentId, false, 2);  
    390428    for (int i=0; i<readers.length; i++) readers[i].setMetadataStore(store); 
    391429  } 
  • trunk/loci/formats/MinMaxCalculator.java

    r2673 r2695  
    6666    throws FormatException, IOException 
    6767  { 
     68    FormatTools.assertId(getCurrentFile(), true, 2);  
    6869    if (theC < 0 || theC >= getSizeC()) { 
    6970      throw new FormatException("Invalid channel index: " + theC); 
     
    8485    throws FormatException, IOException 
    8586  { 
     87    FormatTools.assertId(getCurrentFile(), true, 2);  
    8688    if (theC < 0 || theC >= getSizeC()) { 
    8789      throw new FormatException("Invalid channel index: " + theC); 
     
    102104    throws FormatException, IOException 
    103105  { 
     106    FormatTools.assertId(getCurrentFile(), true, 2);  
    104107    return chanMin == null ? null : new Double(chanMin[getSeries()][theC]); 
    105108  } 
     
    112115    throws FormatException, IOException 
    113116  { 
     117    FormatTools.assertId(getCurrentFile(), true, 2);  
    114118    return chanMax == null ? null : new Double(chanMax[getSeries()][theC]); 
    115119  } 
     
    122126   */ 
    123127  public Double[] getPlaneMinimum(int no) throws FormatException, IOException { 
     128    FormatTools.assertId(getCurrentFile(), true, 2);  
    124129    if (planeMin == null) return null; 
    125130 
     
    144149   */ 
    145150  public Double[] getPlaneMaximum(int no) throws FormatException, IOException { 
     151    FormatTools.assertId(getCurrentFile(), true, 2);  
    146152    if (planeMax == null) return null; 
    147153 
     
    164170   */ 
    165171  public boolean isMinMaxPopulated() throws FormatException, IOException { 
     172    FormatTools.assertId(getCurrentFile(), true, 2);  
    166173    return minMaxDone != null && minMaxDone[getSeries()] == getImageCount(); 
    167174  } 
     
    171178  /* @see IFormatReader#openImage(int) */ 
    172179  public BufferedImage openImage(int no) throws FormatException, IOException { 
     180    FormatTools.assertId(getCurrentFile(), true, 2);  
    173181    BufferedImage b = super.openImage(no); 
    174182    updateMinMax(b, no); 
     
    178186  /* @see IFormatReader#openBytes(int) */ 
    179187  public byte[] openBytes(int no) throws FormatException, IOException { 
     188    FormatTools.assertId(getCurrentFile(), true, 2);  
    180189    byte[] b = super.openBytes(no); 
    181190    updateMinMax(b, no); 
     
    187196    throws FormatException, IOException 
    188197  { 
     198    FormatTools.assertId(getCurrentFile(), true, 2);  
    189199    super.openBytes(no, buf); 
    190200    updateMinMax(buf, no); 
  • trunk/loci/formats/in/AVIReader.java

    r2691 r2695  
    9595  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    9696  public byte[] openBytes(int no) throws FormatException, IOException { 
     97    FormatTools.assertId(currentId, true, 1);  
    9798    byte[] buf = 
    9899      new byte[core.sizeY[0] * bmpScanLineSize * (bmpBitsPerPixel / 8)]; 
     
    104105    throws FormatException, IOException 
    105106  { 
     107    FormatTools.assertId(currentId, true, 1);  
    106108    if (no < 0 || no >= getImageCount()) { 
    107109      throw new FormatException("Invalid image number: " + no); 
     
    142144  /* @see loci.formats.IFormatReader#openImage(int) */ 
    143145  public BufferedImage openImage(int no) throws FormatException, IOException { 
     146    FormatTools.assertId(currentId, true, 1);  
    144147    return ImageTools.makeImage(openBytes(no), 
    145148      core.sizeX[0], core.sizeY[0], core.sizeC[0], true); 
  • trunk/loci/formats/in/AliconaReader.java

    r2687 r2695  
    5555  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    5656  public byte[] openBytes(int no) throws FormatException, IOException { 
     57    FormatTools.assertId(currentId, true, 1);  
    5758    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * numBytes]; 
    5859    return openBytes(no, buf); 
     
    6364    throws FormatException, IOException 
    6465  { 
     66    FormatTools.assertId(currentId, true, 1);  
    6567    if (no < 0 || no >= getImageCount()) { 
    6668      throw new FormatException("Invalid image number: " + no); 
     
    8890  /* @see loci.formats.IFormatReader#openImage(int) */ 
    8991  public BufferedImage openImage(int no) throws FormatException, IOException { 
     92    FormatTools.assertId(currentId, true, 1);  
    9093    return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    9194      1, false, numBytes, true); 
  • trunk/loci/formats/in/BMPReader.java

    r2694 r2695  
    7979  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    8080  public byte[] openBytes(int no) throws FormatException, IOException { 
     81    FormatTools.assertId(currentId, true, 1);  
    8182    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * core.sizeC[0]]; 
    8283    return openBytes(no, buf); 
     
    8788    throws FormatException, IOException 
    8889  { 
     90    FormatTools.assertId(currentId, true, 1);  
    8991    if (no < 0 || no >= getImageCount()) { 
    9092      throw new FormatException("Invalid image number: " + no); 
     
    139141  /* @see loci.formats.IFormatReader#openImage(int) */ 
    140142  public BufferedImage openImage(int no) throws FormatException, IOException { 
    141     assertId(true, 1); 
     143    FormatTools.assertId(currentId, true, 1);  
    142144    return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    143145      core.sizeC[0], false); 
  • trunk/loci/formats/in/BaseTiffReader.java

    r2687 r2695  
    7878  /* @see loci.formats.IFormatReader#getMetadataValue(String) */ 
    7979  public Object getMetadataValue(String field) { 
     80    FormatTools.assertId(currentId, true, 1);  
    8081    return getMeta(field); 
    8182  } 
     
    8384  /* @see loci.formats.FormatReader#openBytes(int) */ 
    8485  public byte[] openBytes(int no) throws FormatException, IOException { 
     86    FormatTools.assertId(currentId, true, 1);  
    8587    if (no < 0 || no >= getImageCount()) { 
    8688      throw new FormatException("Invalid image number: " + no); 
     
    9799    throws FormatException, IOException 
    98100  { 
     101    FormatTools.assertId(currentId, true, 1);  
    99102    if (no < 0 || no >= getImageCount()) { 
    100103      throw new FormatException("Invalid image number: " + no); 
     
    107110  /* @see loci.formats.IFormatReader#openImage(int) */ 
    108111  public BufferedImage openImage(int no) throws FormatException, IOException { 
     112    FormatTools.assertId(currentId, true, 1);  
    109113    if (no < 0 || no >= getImageCount()) { 
    110114      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/BioRadReader.java

    r2687 r2695  
    8383  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    8484  public byte[] openBytes(int no) throws FormatException, IOException { 
     85    FormatTools.assertId(currentId, true, 1);  
    8586    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * (byteFormat ? 1 : 2)]; 
    8687    return openBytes(no, buf); 
     
    9192    throws FormatException, IOException 
    9293  { 
     94    FormatTools.assertId(currentId, true, 1);  
    9395    if (no < 0 || no >= core.imageCount[0]) { 
    9496      throw new FormatException("Invalid image number: " + no); 
     
    106108  /* @see loci.formats.IFormatReader#openImage(int) */ 
    107109  public BufferedImage openImage(int no) throws FormatException, IOException { 
    108     BufferedImage b = ImageTools.makeImage(openBytes(no), core.sizeX[0], 
     110    FormatTools.assertId(currentId, true, 1);  
     111    return ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    109112      core.sizeY[0], 1, false, byteFormat ? 1 : 2, LITTLE_ENDIAN); 
    110     return b; 
    111113  } 
    112114 
  • trunk/loci/formats/in/DeltavisionReader.java

    r2687 r2695  
    9090  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    9191  public byte[] openBytes(int no) throws FormatException, IOException { 
     92    FormatTools.assertId(currentId, true, 1);  
    9293    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * bytesPerPixel]; 
    9394    return openBytes(no, buf); 
     
    9899    throws FormatException, IOException 
    99100  { 
     101    FormatTools.assertId(currentId, true, 1);  
    100102    if (no < 0 || no >= core.imageCount[0]) { 
    101103      throw new FormatException("Invalid image number: " + no); 
     
    115117    throws FormatException, IOException 
    116118  { 
     119    FormatTools.assertId(currentId, true, 1);  
    117120    return ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    118121      core.sizeY[0], 1, false, bytesPerPixel, core.littleEndian[0]); 
  • trunk/loci/formats/in/DicomReader.java

    r2687 r2695  
    105105  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    106106  public byte[] openBytes(int no) throws FormatException, IOException { 
     107    FormatTools.assertId(currentId, true, 1);  
    107108    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * (bitsPerPixel / 8)]; 
    108109    return openBytes(no, buf); 
     
    113114    throws FormatException, IOException 
    114115  { 
     116    FormatTools.assertId(currentId, true, 1);  
    115117    if (no < 0 || no >= getImageCount()) { 
    116118      throw new FormatException("Invalid image number: " + no); 
     
    130132  /* @see loci.formats.IFormatReader#openImage(int) */ 
    131133  public BufferedImage openImage(int no) throws FormatException, IOException { 
     134    FormatTools.assertId(currentId, true, 1);  
    132135    return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    133136      1, false, bitsPerPixel / 8, core.littleEndian[0]); 
  • trunk/loci/formats/in/EPSReader.java

    r2690 r2695  
    6565  /* @see loci.formats.IFormatRaeder#openBytes(int) */ 
    6666  public byte[] openBytes(int no) throws FormatException, IOException { 
     67    FormatTools.assertId(currentId, true, 1);  
    6768    byte[] buf = 
    6869      new byte[core.sizeX[0] * core.sizeY[0] * core.sizeC[0] * (bps / 8)]; 
     
    7475    throws FormatException, IOException 
    7576  { 
     77    FormatTools.assertId(currentId, true, 1);  
    7678    if (no < 0 || no >= getImageCount()) { 
    7779      throw new FormatException("Invalid image number: " + no); 
     
    115117  /* @see loci.formats.IFormatReader#openImage(int) */ 
    116118  public BufferedImage openImage(int no) throws FormatException, IOException { 
     119    FormatTools.assertId(currentId, true, 1);  
    117120    return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    118121      isRGB() ? 3 : 1, true); 
  • trunk/loci/formats/in/GIFReader.java

    r2687 r2695  
    137137  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    138138  public byte[] openBytes(int no) throws FormatException, IOException { 
     139    FormatTools.assertId(currentId, true, 1);  
    139140    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * core.sizeC[0]]; 
    140141    return openBytes(no, buf); 
     
    145146    throws FormatException, IOException 
    146147  { 
     148    FormatTools.assertId(currentId, true, 1);  
    147149    if (no < 0 || no >= getImageCount()) { 
    148150      throw new FormatException("Invalid image number: " + no); 
     
    166168    throws FormatException, IOException 
    167169  { 
     170    FormatTools.assertId(currentId, true, 1);  
    168171    byte[] bytes = openBytes(no); 
    169172    return ImageTools.makeImage(bytes, core.sizeX[0], core.sizeY[0], 
  • trunk/loci/formats/in/GatanReader.java

    r2687 r2695  
    7373  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    7474  public byte[] openBytes(int no) throws FormatException, IOException { 
     75    FormatTools.assertId(currentId, true, 1);  
    7576    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * bytesPerPixel]; 
    7677    return openBytes(no, buf); 
     
    8182    throws FormatException, IOException 
    8283  { 
     84    FormatTools.assertId(currentId, true, 1);  
    8385    if (no != 0) { 
    8486      throw new FormatException("Invalid image number: " + no); 
     
    9597  /* @see loci.formats.IFormatReader#openImage(int) */ 
    9698  public BufferedImage openImage(int no) throws FormatException, IOException { 
     99    FormatTools.assertId(currentId, true, 1);  
    97100    if (no < 0 || no >= getImageCount()) { 
    98101      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/ICSReader.java

    r2687 r2695  
    9797  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    9898  public byte[] openBytes(int no) throws FormatException, IOException { 
     99    FormatTools.assertId(currentId, true, 1);  
    99100    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * (bitsPerPixel / 8) * 
    100101      getRGBChannelCount()]; 
     
    106107    throws FormatException, IOException 
    107108  { 
     109    FormatTools.assertId(currentId, true, 1);  
    108110    if (no < 0 || no >= getImageCount()) { 
    109111      throw new FormatException("Invalid image number: " + no); 
     
    144146  /* @see loci.formats.IFormatReader#openImage(int) */ 
    145147  public BufferedImage openImage(int no) throws FormatException, IOException { 
     148    FormatTools.assertId(currentId, true, 1);  
    146149    byte[] plane = openBytes(no); 
    147150    int channels = core.rgb[0] ? core.sizeC[0] : 1; 
     
    169172  /* @see loci.formats.IFormatReader#getUsedFiles() */ 
    170173  public String[] getUsedFiles() { 
     174    FormatTools.assertId(currentId, true, 1);  
    171175    if (versionTwo) { 
    172176      return new String[] {currentIdsId == null ? "" : currentIdsId}; 
  • trunk/loci/formats/in/IPLabReader.java

    r2687 r2695  
    6868  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    6969  public byte[] openBytes(int no) throws FormatException, IOException { 
     70    FormatTools.assertId(currentId, true, 1);  
    7071    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * bps * core.sizeC[0]]; 
    7172    return openBytes(no, buf); 
     
    7677    throws FormatException, IOException 
    7778  { 
     79    FormatTools.assertId(currentId, true, 1);  
    7880    if (no < 0 || no >= getImageCount()) { 
    7981      throw new FormatException("Invalid image number: " + no); 
     
    9294  /* @see loci.formats.IFormatReader#openImage(int) */ 
    9395  public BufferedImage openImage(int no) throws FormatException, IOException { 
     96    FormatTools.assertId(currentId, true, 1);  
    9497    return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    9598      core.rgb[0] ? core.sizeC[0] : 1, false, bps, core.littleEndian[0]); 
  • trunk/loci/formats/in/IPWReader.java

    r2687 r2695  
    8787  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    8888  public byte[] openBytes(int no) throws FormatException, IOException { 
     89    FormatTools.assertId(currentId, true, 1);  
    8990    int c = getRGBChannelCount(); 
    9091    if (c == 2) c++; 
     
    9899    throws FormatException, IOException 
    99100  { 
     101    FormatTools.assertId(currentId, true, 1);  
    100102    if (no < 0 || no >= getImageCount()) { 
    101103      throw new FormatException("Invalid image number: " + no); 
     
    141143  /* @see loci.formats.IFormatReader#openImage(int) */ 
    142144  public BufferedImage openImage(int no) throws FormatException, IOException { 
     145    FormatTools.assertId(currentId, true, 1);  
    143146    if (no < 0 || no >= getImageCount()) { 
    144147      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/ImageIOReader.java

    r2687 r2695  
    5757  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    5858  public byte[] openBytes(int no) throws FormatException, IOException { 
     59    FormatTools.assertId(currentId, true, 1);  
    5960    byte[] b = ImageTools.getBytes(openImage(no), false, no); 
    6061    int bytesPerChannel = core.sizeX[0] * core.sizeY[0]; 
     
    7273  /* @see loci.formats.IFormatReader#openImage(int) */ 
    7374  public BufferedImage openImage(int no) throws FormatException, IOException { 
     75    FormatTools.assertId(currentId, true, 1);  
    7476    if (no < 0 || no >= getImageCount()) { 
    7577      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/ImageJReader.java

    r2687 r2695  
    8080  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    8181  public byte[] openBytes(int no) throws FormatException, IOException { 
     82    FormatTools.assertId(currentId, true, 1);  
    8283    byte[] b = ImageTools.getBytes(openImage(no), false, no); 
    8384    return b; 
     
    8889    throws FormatException, IOException 
    8990  { 
     91    FormatTools.assertId(currentId, true, 1);  
    9092    if (no < 0 || no >= getImageCount()) { 
    9193      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/ImarisReader.java

    r2687 r2695  
    6565  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    6666  public byte[] openBytes(int no) throws FormatException, IOException { 
     67    FormatTools.assertId(currentId, true, 1);  
    6768    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0]]; 
    6869    return openBytes(no, buf); 
     
    7374    throws FormatException, IOException 
    7475  { 
     76    FormatTools.assertId(currentId, true, 1);  
    7577    if (no < 0 || no >= getImageCount()) { 
    7678      throw new FormatException("Invalid image number: " + no); 
     
    9193  /* @see loci.formats.IFormatReader#openImage(int) */ 
    9294  public BufferedImage openImage(int no) throws FormatException, IOException { 
     95    FormatTools.assertId(currentId, true, 1);  
    9396    return ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    9497      core.sizeY[0], 1, false); 
  • trunk/loci/formats/in/LIFReader.java

    r2687 r2695  
    7474  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    7575  public byte[] openBytes(int no) throws FormatException, IOException { 
     76    FormatTools.assertId(currentId, true, 1);  
    7677    bpp = bitsPerPixel[series]; 
    7778    while (bpp % 8 != 0) bpp++; 
     
    8586    throws FormatException, IOException 
    8687  { 
     88    FormatTools.assertId(currentId, true, 1);  
    8789    if (no < 0 || no >= getImageCount()) { 
    8890      throw new FormatException("Invalid image number: " + no); 
     
    107109  /* @see loci.formats.IFormatReader#openImage(int) */ 
    108110  public BufferedImage openImage(int no) throws FormatException, IOException { 
     111    FormatTools.assertId(currentId, true, 1);  
    109112    return ImageTools.makeImage(openBytes(no), core.sizeX[series], 
    110113      core.sizeY[series], isRGB() ? core.sizeC[series] : 1, false, bpp / 8, 
    111114      core.littleEndian[series], validBits[series]); 
    112   } 
    113  
    114   /* @see loci.formats.IFormatReader#getSeriesCount() */ 
    115   public int getSeriesCount() { 
    116     return core.sizeX.length; 
    117115  } 
    118116 
  • trunk/loci/formats/in/LegacyPictReader.java

    r2687 r2695  
    5454  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    5555  public byte[] openBytes(int no) throws FormatException, IOException { 
     56    FormatTools.assertId(currentId, true, 1);  
    5657    return ImageTools.getBytes(openImage(no), false, 3); 
    5758  } 
     
    5960  /* @see loci.formats.IFormatReader#openImage(int) */ 
    6061  public BufferedImage openImage(int no) throws FormatException, IOException { 
     62    FormatTools.assertId(currentId, true, 1);  
    6163    if (no < 0 || no >= getImageCount()) { 
    6264      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/LegacyQTReader.java

    r2687 r2695  
    7373  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    7474  public byte[] openBytes(int no) throws FormatException, IOException { 
     75    FormatTools.assertId(currentId, true, 1);  
    7576    return ImageTools.getBytes(openImage(no), false, 3); 
    7677  } 
     
    7879  /* @see loci.formats.IFormatReader#openImage(int) */ 
    7980  public BufferedImage openImage(int no) throws FormatException, IOException { 
     81    FormatTools.assertId(currentId, true, 1);  
    8082    if (no < 0 || no >= getImageCount()) { 
    8183      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/LegacyZVIReader.java

    r2687 r2695  
    9494  } 
    9595 
    96   /* @see loci.formats.IFormatReader#getImageCount() */ 
    97   public int getImageCount() { 
    98     return blockList.size(); 
    99   } 
    100  
    10196  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    10297  public byte[] openBytes(int no) throws FormatException, IOException { 
     98    FormatTools.assertId(currentId, true, 1);  
    10399    byte[] buf = new byte[((ZVIBlock) blockList.elementAt(no)).imageSize]; 
    104100    return openBytes(no, buf); 
     
    109105    throws FormatException, IOException 
    110106  { 
     107    FormatTools.assertId(currentId, true, 1);  
    111108    if (no < 0 || no >= getImageCount()) { 
    112109      throw new FormatException("Invalid image number: " + no); 
     
    120117  /* @see loci.formats.IFormatReader#openImage(int) */ 
    121118  public BufferedImage openImage(int no) throws FormatException, IOException { 
     119    FormatTools.assertId(currentId, true, 1);  
    122120    if (no < 0 || no >= getImageCount()) { 
    123121      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/LeicaReader.java

    r2687 r2695  
    109109  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    110110  public byte[] openBytes(int no) throws FormatException, IOException { 
     111    FormatTools.assertId(currentId, true, 1);  
    111112    if (no < 0 || no >= getImageCount()) { 
    112113      throw new FormatException("Invalid image number: " + no); 
     
    125126    throws FormatException, IOException 
    126127  { 
     128    FormatTools.assertId(currentId, true, 1);  
    127129    if (no < 0 || no >= getImageCount()) { 
    128130      throw new FormatException("Invalid image number: " + no); 
     
    140142  /* @see loci.formats.IFormatReader#openImage(int) */ 
    141143  public BufferedImage openImage(int no) throws FormatException, IOException { 
     144    FormatTools.assertId(currentId, true, 1);  
    142145    if (no < 0 || no >= getImageCount()) { 
    143146      throw new FormatException("Invalid image number: " + no); 
     
    156159  /* @see loci.formats.IFormatReader#getUsedFiles() */ 
    157160  public String[] getUsedFiles() { 
     161    FormatTools.assertId(currentId, true, 1);  
    158162    Vector v = new Vector(); 
    159163    v.add(leiFilename); 
  • trunk/loci/formats/in/MNGReader.java

    r2687 r2695  
    6262  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    6363  public byte[] openBytes(int no) throws FormatException, IOException { 
     64    FormatTools.assertId(currentId, true, 1);  
    6465    return ImageTools.getBytes(openImage(no), true, core.sizeC[0]); 
    6566  } 
     
    6768  /* @see loci.formats.IFormatReader#openImage(int) */ 
    6869  public BufferedImage openImage(int no) throws FormatException, IOException { 
     70    FormatTools.assertId(currentId, true, 1);  
    6971    if (no < 0 || no >= getImageCount()) { 
    7072      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/MRCReader.java

    r2687 r2695  
    6363  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    6464  public byte[] openBytes(int no) throws FormatException, IOException { 
     65    FormatTools.assertId(currentId, true, 1);  
    6566    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * bpp]; 
    6667    return openBytes(no, buf); 
     
    7172    throws FormatException, IOException 
    7273  { 
     74    FormatTools.assertId(currentId, true, 1);  
    7375    if (no < 0 || no >= getImageCount()) { 
    7476      throw new FormatException("Invalid image number: " + no); 
     
    8486  /* @see loci.formats.IFormatReader#openImage(int) */ 
    8587  public BufferedImage openImage(int no) throws FormatException, IOException { 
     88    FormatTools.assertId(currentId, true, 1);  
    8689    return ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    8790      core.sizeY[0], 1, true, bpp, core.littleEndian[0]); 
  • trunk/loci/formats/in/MicromanagerReader.java

    r2687 r2695  
    6262  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    6363  public byte[] openBytes(int no) throws FormatException, IOException { 
     64    FormatTools.assertId(currentId, true, 1);  
    6465    if (no < 0 || no >= getImageCount()) { 
    6566      throw new FormatException("Invalid image number: " + no); 
     
    7273    throws FormatException, IOException 
    7374  { 
     75    FormatTools.assertId(currentId, true, 1);  
    7476    if (no < 0 || no >= getImageCount()) { 
    7577      throw new FormatException("Invalid image number: " + no); 
     
    8082  /* @see loci.formats.IFormatReader#openImage(int) */ 
    8183  public BufferedImage openImage(int no) throws FormatException, IOException { 
     84    FormatTools.assertId(currentId, true, 1);  
    8285    if (no < 0 || no >= getImageCount()) { 
    8386      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/ND2Reader.java

    r2687 r2695  
    137137  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    138138  public byte[] openBytes(int no) throws FormatException, IOException { 
     139    FormatTools.assertId(currentId, true, 1);  
    139140    if (no < 0 || no >= getImageCount()) { 
    140141      throw new FormatException("Invalid image number: " + no); 
     
    156157  /* @see loci.formats.IFormatReader#openImage(int) */ 
    157158  public BufferedImage openImage(int no) throws FormatException, IOException { 
     159    FormatTools.assertId(currentId, true, 1);  
    158160    if (no < 0 || no >= getImageCount()) { 
    159161      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/NRRDReader.java

    r2687 r2695  
    6363  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    6464  public byte[] openBytes(int no) throws FormatException, IOException { 
     65    FormatTools.assertId(currentId, true, 1);  
    6566    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * core.sizeC[0] * 
    6667      FormatTools.getBytesPerPixel(core.pixelType[0])]; 
     
    7273    throws FormatException, IOException 
    7374  { 
     75    FormatTools.assertId(currentId, true, 1);  
    7476    if (no < 0 || no >= core.imageCount[0]) { 
    7577      throw new FormatException("Invalid image number: " + no); 
     
    9698  /* @see loci.formats.IFormatReader#openImage(int) */ 
    9799  public BufferedImage openImage(int no) throws FormatException, IOException { 
     100    FormatTools.assertId(currentId, true, 1);  
    98101    if (core.pixelType[0] == FormatTools.FLOAT) { 
    99102      byte[] b = openBytes(no); 
  • trunk/loci/formats/in/OIBReader.java

    r2687 r2695  
    138138  /* @see loci.formats.IFormatReader#openImage(int) */ 
    139139  public BufferedImage openImage(int no) throws FormatException, IOException { 
     140    FormatTools.assertId(currentId, true, 1);  
    140141    if (no < 0 || no >= getImageCount()) { 
    141142      throw new FormatException("Invalid image number: " + no); 
     
    153154  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    154155  public byte[] openBytes(int no) throws FormatException, IOException { 
     156    FormatTools.assertId(currentId, true, 1);  
    155157    byte[] buf = new byte[core.sizeX[series] * core.sizeY[series] * 
    156158      getRGBChannelCount() * 
     
    163165    throws FormatException, IOException 
    164166  { 
     167    FormatTools.assertId(currentId, true, 1);  
    165168    if (no < 0 || no >= getImageCount()) { 
    166169      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/OIFReader.java

    r2687 r2695  
    7575  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    7676  public byte[] openBytes(int no) throws FormatException, IOException { 
     77    FormatTools.assertId(currentId, true, 1);  
    7778    byte[] b = tiffReader[no].openBytes(0); 
    7879    tiffReader[no].close(); 
     
    8485    throws FormatException, IOException 
    8586  { 
     87    FormatTools.assertId(currentId, true, 1);  
    8688    if (no < 0 || no >= getImageCount()) { 
    8789      throw new FormatException("Invalid image number: " + no); 
     
    9597  /* @see loci.formats.IFormatReader#openImage(int) */ 
    9698  public BufferedImage openImage(int no) throws FormatException, IOException { 
     99    FormatTools.assertId(currentId, true, 1);  
    97100    if (no < 0 || no >= getImageCount()) { 
    98101      throw new FormatException("Invalid image number: " + no); 
     
    111114    throws FormatException, IOException 
    112115  { 
     116    FormatTools.assertId(currentId, true, 1);  
    113117    if (no < 0 || no >= getImageCount()) { 
    114118      throw new FormatException("Invalid image number: " + no); 
     
    128132  /* @see loci.formats.IFormatReader#getUsedFiles() */ 
    129133  public String[] getUsedFiles() { 
     134    FormatTools.assertId(currentId, true, 1);  
    130135    return (String[]) usedFiles.toArray(new String[0]); 
    131136  } 
  • trunk/loci/formats/in/OMEXMLReader.java

    r2687 r2695  
    8383  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    8484  public byte[] openBytes(int no) throws FormatException, IOException { 
     85    FormatTools.assertId(currentId, true, 1);  
    8586    if (no < 0 || no >= core.imageCount[series]) { 
    8687      throw new FormatException("Invalid image number: " + no); 
     
    149150  /* @see loci.formats.IFormatReader#openImage(int) */ 
    150151  public BufferedImage openImage(int no) throws FormatException, IOException { 
     152    FormatTools.assertId(currentId, true, 1);  
    151153    return ImageTools.makeImage(openBytes(no), core.sizeX[series], 
    152154      core.sizeY[series], 1, false, bpp[series], core.littleEndian[series]); 
  • trunk/loci/formats/in/OpenlabRawReader.java

    r2687 r2695  
    6464  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    6565  public byte[] openBytes(int no) throws FormatException, IOException { 
     66    FormatTools.assertId(currentId, true, 1);  
    6667    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * bytesPerPixel]; 
    6768    return openBytes(no, buf); 
     
    7273    throws FormatException, IOException 
    7374  { 
     75    FormatTools.assertId(currentId, true, 1);  
    7476    if (no < 0 || no >= getImageCount()) { 
    7577      throw new FormatException("Invalid image number: " + no); 
     
    9395  /* @see loci.formats.IFormatReader#openImage(int) */ 
    9496  public BufferedImage openImage(int no) throws FormatException, IOException { 
     97    FormatTools.assertId(currentId, true, 1);  
    9598    return ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    9699      core.sizeY[0], core.sizeC[0], false, bytesPerPixel, false); 
  • trunk/loci/formats/in/OpenlabReader.java

    r2687 r2695  
    8686  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    8787  public byte[] openBytes(int no) throws FormatException, IOException { 
     88    FormatTools.assertId(currentId, true, 1);  
    8889    if (no < 0 || no >= getImageCount()) { 
    8990      throw new FormatException("Invalid image number: " + no); 
     
    289290  /* @see loci.formats.IFormatReader#openImage(int) */ 
    290291  public BufferedImage openImage(int no) throws FormatException, IOException { 
     292    FormatTools.assertId(currentId, true, 1);  
    291293    if (no < 0 || no >= getImageCount()) { 
    292294      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/PerkinElmerReader.java

    r2687 r2695  
    7070  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    7171  public byte[] openBytes(int no) throws FormatException, IOException { 
     72    FormatTools.assertId(currentId, true, 1);  
    7273    if (isTiff) { 
    7374      return tiff[no / core.sizeC[0]].openBytes(0); 
     
    8586  /* @see loci.formats.IFormatReader#openImage(int) */ 
    8687  public BufferedImage openImage(int no) throws FormatException, IOException { 
     88    FormatTools.assertId(currentId, true, 1);  
    8789    if (no < 0 || no >= getImageCount()) { 
    8890      throw new FormatException("Invalid image number: " + no); 
     
    102104  /* @see loci.formats.IFormatReader#getUsedFiles() */ 
    103105  public String[] getUsedFiles() { 
     106    FormatTools.assertId(currentId, true, 1);  
    104107    return (String[]) allFiles.toArray(new String[0]); 
    105108  } 
  • trunk/loci/formats/in/PictReader.java

    r2687 r2695  
    275275  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    276276  public byte[] openBytes(int no) throws FormatException, IOException { 
     277    FormatTools.assertId(currentId, true, 1);  
    277278    return ImageTools.getBytes(openImage(no), false, no % 3); 
    278279  } 
     
    280281  /* @see loci.formats.IFormatReader#openImage(int) */ 
    281282  public BufferedImage openImage(int no) throws FormatException, IOException { 
     283    FormatTools.assertId(currentId, true, 1);  
    282284    if (no < 0 || no >= getImageCount()) { 
    283285      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/PrairieReader.java

    r2687 r2695  
    104104  /* @see loci.formats.IFormatReader#getUsedFiles() */ 
    105105  public String[] getUsedFiles() { 
     106    FormatTools.assertId(currentId, true, 1);  
    106107    String[] s = new String[files.length + 2]; 
    107108    System.arraycopy(files, 0, s, 0, files.length); 
     
    113114  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    114115  public byte[] openBytes(int no) throws FormatException, IOException { 
     116    FormatTools.assertId(currentId, true, 1);  
    115117    if (no < 0 || no >= getImageCount()) { 
    116118      throw new FormatException("Invalid image number: " + no); 
     
    124126    throws FormatException, IOException 
    125127  { 
     128    FormatTools.assertId(currentId, true, 1);  
    126129    if (no < 0 || no >= getImageCount()) { 
    127130      throw new FormatException("Invalid image number: " + no); 
     
    134137  /* @see loci.formats.IFormatReader#openImage(int) */ 
    135138  public BufferedImage openImage(int no) throws FormatException, IOException { 
     139    FormatTools.assertId(currentId, true, 1);  
    136140    if (no < 0 || no >= getImageCount()) { 
    137141      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/QTReader.java

    r2690 r2695  
    141141  /* @see loci.formats.IFormatReader#setMetadataStore(MetadataStore) */ 
    142142  public void setMetadataStore(MetadataStore store) { 
     143    FormatTools.assertId(currentId, false, 1);  
    143144    super.setMetadataStore(store); 
    144145    if (useLegacy) legacy.setMetadataStore(store); 
     
    147148  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    148149  public byte[] openBytes(int no) throws FormatException, IOException { 
     150    FormatTools.assertId(currentId, true, 1);  
    149151    if (no < 0 || no >= getImageCount()) { 
    150152      throw new FormatException("Invalid image number: " + no); 
     
    336338  /* @see loci.formats.IFormatReader#openImage(int) */ 
    337339  public BufferedImage openImage(int no) throws FormatException, IOException { 
     340    FormatTools.assertId(currentId, true, 1);  
    338341    if (no < 0 || no >= getImageCount()) { 
    339342      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/SDTReader.java

    r2687 r2695  
    9595  /* @see loci.formats.IFormatReader#getRGBChannelCount(String) */ 
    9696  public int getRGBChannelCount() { 
     97    FormatTools.assertId(currentId, true, 1);  
    9798    return intensity ? 1 : timeBins; 
    9899  } 
     
    100101  /* @see loci.formats.IFormatReader#getChannelDimLengths() */ 
    101102  public int[] getChannelDimLengths() { 
     103    FormatTools.assertId(currentId, true, 1);  
    102104    return intensity ? new int[] {channels} : new int[] {timeBins, channels}; 
    103105  } 
     
    105107  /* @see loci.formats.IFormatReader#getChannelDimTypes() */ 
    106108  public String[] getChannelDimTypes() { 
     109    FormatTools.assertId(currentId, true, 1);  
    107110    return intensity ? new String[] {FormatTools.SPECTRA} : 
    108111      new String[] {FormatTools.LIFETIME, FormatTools.SPECTRA}; 
     
    111114  /* @see loci.formats.IFormatReader#isInterleaved(int) */ 
    112115  public boolean isInterleaved(int subC) { 
     116    FormatTools.assertId(currentId, true, 1);  
    113117    return !intensity && subC == 0; 
    114118  } 
     
    116120  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    117121  public byte[] openBytes(int no) throws FormatException, IOException { 
     122    FormatTools.assertId(currentId, true, 1);  
    118123    int c = getRGBChannelCount(); 
    119124    byte[] buf = new byte[2 * c * core.sizeX[series] * core.sizeY[series]]; 
     
    125130    throws FormatException, IOException 
    126131  { 
     132    FormatTools.assertId(currentId, true, 1);  
    127133    if (no < 0 || no >= timeBins * channels) { 
    128134      throw new FormatException("Invalid image number: " + no); 
     
    167173  /* @see loci.formats.IFormatReader#openImage(int) */ 
    168174  public BufferedImage openImage(int no) throws FormatException, IOException { 
     175    FormatTools.assertId(currentId, true, 1);  
    169176    return ImageTools.makeImage(openBytes(no), core.sizeX[series], 
    170177      core.sizeY[series], getRGBChannelCount(), false, 2, true); 
  • trunk/loci/formats/in/SlidebookReader.java

    r2687 r2695  
    6363  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    6464  public byte[] openBytes(int no) throws FormatException, IOException { 
     65    FormatTools.assertId(currentId, true, 1);  
    6566    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * 2]; 
    6667    return openBytes(no, buf); 
     
    7172    throws FormatException, IOException 
    7273  { 
     74    FormatTools.assertId(currentId, true, 1);  
    7375    if (no < 0 || no >= getImageCount()) { 
    7476      throw new FormatException("Invalid image number: " + no); 
     
    8486  /* @see loci.formats.IFormatReader#openImage(int) */ 
    8587  public BufferedImage openImage(int no) throws FormatException, IOException { 
     88    FormatTools.assertId(currentId, true, 1);  
    8689    return ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    8790      core.sizeY[0], 1, true, bpp, true); 
  • trunk/loci/formats/in/TiffReader.java

    r2687 r2695  
    6161    if (core.sizeZ == null) core.sizeZ = new int[1]; 
    6262    core.sizeZ[0] = zSize; 
    63   } 
    64  
    65   // -- IFormatReader API methods -- 
    66  
    67   /* @see loci.formats.IFormatReader#getSeriesCount() */ 
    68   public int getSeriesCount() { 
    69     return core.currentOrder.length; 
    7063  } 
    7164 
  • trunk/loci/formats/in/ZeissLSMReader.java

    r2687 r2695  
    7979  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    8080  public byte[] openBytes(int no) throws FormatException, IOException { 
     81    FormatTools.assertId(currentId, true, 1);  
    8182    if (no < 0 || no >= getImageCount()) { 
    8283      throw new FormatException("Invalid image number: " + no); 
     
    9293    throws FormatException, IOException 
    9394  { 
     95    FormatTools.assertId(currentId, true, 1);  
    9496    if (no < 0 || no >= getImageCount()) { 
    9597      throw new FormatException("Invalid image number: " + no); 
     
    109111  /* @see loci.formats.IFormatReader#openImage(int) */ 
    110112  public BufferedImage openImage(int no) throws FormatException, IOException { 
     113    FormatTools.assertId(currentId, true, 1);  
    111114    if (no < 0 || no >= getImageCount()) { 
    112115      throw new FormatException("Invalid image number: " + no); 
     
    121124    throws FormatException, IOException 
    122125  { 
     126    FormatTools.assertId(currentId, true, 1);  
    123127    if (no < 0 || no >= getImageCount()) { 
    124128      throw new FormatException("Invalid image number: " + no); 
  • trunk/loci/formats/in/ZeissZVIReader.java

    r2687 r2695  
    120120  /* @see loci.formats.IFormatReader#setMetadataStore(MetadataStore) */ 
    121121  public void setMetadataStore(MetadataStore store) { 
     122    FormatTools.assertId(currentId, false, 1);  
    122123    super.setMetadataStore(store); 
    123124    if (noPOI || needLegacy) legacy.setMetadataStore(store); 
     
    126127  /* @see loci.formats.IFormatReader#openBytes(int) */ 
    127128  public byte[] openBytes(int no) throws FormatException, IOException { 
     129    FormatTools.assertId(currentId, true, 1);  
    128130    byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * 
    129131      FormatTools.getBytesPerPixel(core.pixelType[0]) * getRGBChannelCount()]; 
     
    135137    throws FormatException, IOException 
    136138  { 
     139    FormatTools.assertId(currentId, true, 1);  
    137140    if (noPOI || needLegacy) return legacy.openBytes(no, buf); 
    138141    if (no < 0 || no >= getImageCount()) { 
     
    183186  /* @see loci.formats.IFormatReader#openImage(int) */ 
    184187  public BufferedImage openImage(int no) throws FormatException, IOException { 
     188    FormatTools.assertId(currentId, true, 1);  
    185189    return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    186190      getRGBChannelCount(), true, bpp == 3 ? 1 : bpp, true, 
  • trunk/loci/formats/reader-guide.txt

    r2655 r2695  
    2020  the given file name (i.e. every file needed to display the current dataset). 
    2121  For an example of how this works, see loci.formats.in.PerkinElmerReader. 
     22  It is recommended that the first line of this method be 
     23  "FormatTools.assertId(currentId, true, 1)" - this ensures that the file name 
     24  is non-null. 
    2225 
    2326byte[] openBytes(int) throws FormatException, IOException : 
     
    2831  isLittleEndian() and isInterleaved().  Also, the length of the 
    2932  byte array should be [image width * image height * bytes per pixel].  Extra 
    30   bytes will generally be truncated. 
     33  bytes will generally be truncated. It is recommended that the first line of  
     34  this method be "FormatTools.asserId(currentId, true, 1)" - this ensures that  
     35  the file name is non-null. 
    3136 
    3237BufferedImage openImage(int) throws FormatException, IOException : 
     
    3641  loci.formats.ImageTools.makeImage(byte[], int width, int height, int 
    3742  numberOfChannels, boolean isInterleaved, int bytesPerPixel, boolean 
    38   isLittleEndian). 
     43  isLittleEndian). It is recommended that the first line of this method be 
     44  "FormatTools.assertId(currentId, true, 1)" - this ensures that the file name 
     45  is non-null. 
    3946 
    4047protected void initFile(String) throws FormatException, IOException : 
Note: See TracChangeset for help on using the changeset viewer.