Changeset 5142


Ignore:
Timestamp:
06/01/09 08:49:08 (11 years ago)
Author:
melissa
Message:

Fixed bugs exposed by test suite.

Location:
trunk/components
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/DimensionSwapper.java

    r5093 r5142  
    104104    int oldT = oldOrder.indexOf("T"); 
    105105 
    106     if (oldC != newC && getRGBChannelCount() > 1) { 
     106    if (oldC != newC && reader.getRGBChannelCount() > 1) { 
    107107      throw new IllegalArgumentException( 
    108108        "Cannot swap C dimension when RGB channel count > 1"); 
     
    131131    if (oldC != newC) { 
    132132      // C was overridden; clear the sub-C dimensional metadata 
    133       core[series].cLengths = null; 
    134       core[series].cTypes = null; 
     133      core[series].cLengths = new int[] {getSizeC()}; 
     134      core[series].cTypes = new String[] {FormatTools.CHANNEL}; 
    135135    } 
    136136 
     
    200200  } 
    201201 
     202  /* @see loci.formats.IFormatReader#getChannelDimLengths() */ 
     203  public int[] getChannelDimLengths() { 
     204    FormatTools.assertId(getCurrentFile(), true, 2); 
     205    int[] cLengths = getCoreMetadata()[getSeries()].cLengths; 
     206    return cLengths == null ? super.getChannelDimLengths() : cLengths; 
     207  } 
     208 
     209  /* @see loci.formats.IFormatReader#getChannelDimTypes() */ 
     210  public String[] getChannelDimTypes() { 
     211    FormatTools.assertId(getCurrentFile(), true, 2); 
     212    String[] cTypes = getCoreMetadata()[getSeries()].cTypes; 
     213    return cTypes == null ? super.getChannelDimTypes() : cTypes; 
     214  } 
     215 
    202216  /* @see loci.formats.IFormatReader#getDimensionOrder() */ 
    203217  public String getDimensionOrder() { 
     
    232246    int width, int height) throws FormatException, IOException 
    233247  { 
    234     return super.openBytes(reorder(no)); 
     248    return super.openBytes(reorder(no), buf, x, y, width, height); 
    235249  } 
    236250 
  • trunk/components/bio-formats/src/loci/formats/NumberFilter.java

    r4953 r5142  
    6565    try { return new BigInteger(name.substring(ndx, end)); } 
    6666    catch (NumberFormatException exc) { return null; } 
     67    catch (IndexOutOfBoundsException exc) { return null; } 
    6768  } 
    6869 
  • trunk/components/bio-formats/src/loci/formats/in/GelReader.java

    r5093 r5142  
    112112  /* @see BaseTiffReader#initMetadata() */ 
    113113  protected void initMetadata() throws FormatException, IOException { 
     114    ifds = TiffTools.getIFDs(in); 
    114115    if (ifds.length > 1) { 
    115116      Hashtable[] tmpIFDs = ifds; 
  • trunk/components/bio-formats/src/loci/formats/in/ImprovisionTiffReader.java

    r5114 r5142  
    131131    if (tt == null) tt = "1"; 
    132132 
     133    core[0].sizeT = 1; 
    133134    if (getSizeZ() == 0) core[0].sizeZ = 1; 
    134     if (getSizeT() == 0) core[0].sizeT = 1; 
     135    if (getSizeC() == 0) core[0].sizeC = 1; 
    135136 
    136137    core[0].sizeZ *= Integer.parseInt(tz); 
    137     if (!isRGB()) core[0].sizeC *= Integer.parseInt(tc); 
     138    core[0].sizeC *= Integer.parseInt(tc); 
    138139    core[0].sizeT *= Integer.parseInt(tt); 
    139140 
  • trunk/components/bio-formats/src/loci/formats/in/MetamorphReader.java

    r5124 r5142  
    236236      for (int i=0; i<list.length; i++) { 
    237237        if (checkSuffix(list[i], ND_SUFFIX)) { 
    238           ndfile = new Location(parent, list[i]).getAbsoluteFile(); 
    239           break; 
     238          String prefix = list[i].substring(0, list[i].lastIndexOf(".")); 
     239          if (currentId.startsWith(prefix)) { 
     240            ndfile = new Location(parent, list[i]).getAbsoluteFile(); 
     241            break; 
     242          } 
    240243        } 
    241244      } 
  • trunk/components/bio-formats/src/loci/formats/in/NativeND2Reader.java

    r5126 r5142  
    572572 
    573573      sb.append("</NIKON>"); 
    574       String xml = sb.toString(); 
    575574 
    576575      status("Finished assembling XML string"); 
     
    580579      // strip out invalid characters 
    581580      int offset = 0; 
    582       byte[] b = xml.getBytes(); 
    583       int len = b.length; 
     581      int len = sb.length(); 
    584582      for (int i=0; i<len; i++) { 
    585         char ch = (char) b[i]; 
     583        char ch = sb.charAt(i); 
    586584        if (offset == 0 && ch == '!') offset = i + 1; 
    587585 
    588586        if (Character.isISOControl(ch) || !Character.isDefined(ch)) { 
    589           b[i] = (byte) ' '; 
    590         } 
    591       } 
    592  
    593       xml = new String(b, offset, len - offset); 
     587          sb.setCharAt(i, ' '); 
     588        } 
     589      } 
     590 
     591      String xml = sb.toString().substring(offset, len - offset); 
    594592      DataTools.parseXML(xml, handler); 
    595593      xml = null; 
     
    937935      } 
    938936      objectiveModel = model.toString(); 
    939       immersion = tokens[magIndex + 1]; 
     937      if (magIndex + 1 < tokens.length) immersion = tokens[magIndex + 1]; 
    940938    } 
    941939    else if (key.endsWith("dTimeMSec")) { 
  • trunk/components/bio-formats/src/loci/formats/in/SDTReader.java

    r5093 r5142  
    144144    boolean little = isLittleEndian(); 
    145145 
     146    // HACK 
     147    // adjust the number of time bins if DimensionSwapper was used 
     148    if (buf.length == sizeY * sizeX * bpp && timeBins > 1) { 
     149      timeBins = 1; 
     150    } 
     151 
    146152    int paddedWidth = sizeX + ((4 - (sizeX % 4)) % 4); 
    147153    int planeSize = paddedWidth * sizeY * timeBins * bpp; 
    148154 
    149     boolean direct = !intensity && x == 0 && y == 0 && w == sizeX && h == sizeY; 
     155    boolean direct = !intensity; 
    150156    byte[] b = direct ? buf : new byte[sizeY * sizeX * timeBins * bpp]; 
    151157    in.seek(off + no * planeSize + y * paddedWidth * bpp * timeBins); 
  • trunk/components/bio-formats/src/loci/formats/in/TCSReader.java

    r5121 r5142  
    207207      Location parent = l.getParentFile(); 
    208208      String[] list = parent.list(); 
    209       for (int i=0; i<list.length; i++) { 
    210         if (checkSuffix(list[i], XML_SUFFIX)) { 
    211           initFile(new Location(parent, list[i]).getAbsolutePath()); 
    212           return; 
     209      if (list != null) { 
     210        for (int i=0; i<list.length; i++) { 
     211          if (checkSuffix(list[i], XML_SUFFIX)) { 
     212            initFile(new Location(parent, list[i]).getAbsolutePath()); 
     213            return; 
     214          } 
    213215        } 
    214216      } 
  • trunk/components/bio-formats/src/loci/formats/in/TillVisionReader.java

    r5093 r5142  
    379379      } 
    380380      String date = i < dates.size() ? (String) dates.get(i) : ""; 
    381       if (!date.equals("")) { 
     381      if (date != null && !date.equals("")) { 
    382382        store.setImageCreationDate(date, i); 
    383383      } 
  • trunk/components/bio-formats/src/loci/formats/out/OMEXMLWriter.java

    r5093 r5142  
    7575    out = null; 
    7676    xmlFragments = null; 
     77    initialized = false; 
    7778  } 
    7879 
     
    9394      currentFragment = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; 
    9495      DataTools.parseXML(xml, new OMEHandler()); 
     96 
    9597      xmlFragments.add(currentFragment); 
    9698 
     
    149151    if (lastInSeries) { 
    150152      out.writeBytes((String) xmlFragments.get(series + 1)); 
    151       close(); 
    152153    } 
     154    if (last) close(); 
    153155  } 
    154156 
  • trunk/components/bio-formats/src/loci/formats/out/QTWriter.java

    r5093 r5142  
    168168 
    169169    if (needLegacy) { 
     170      legacy.setMetadataRetrieve(getMetadataRetrieve()); 
    170171      legacy.setId(currentId); 
    171172      legacy.saveBytes(buf, last); 
     
    216217        needLegacy = true; 
    217218        legacy.setCodec(codec); 
     219        legacy.setMetadataRetrieve(getMetadataRetrieve()); 
    218220        legacy.setId(currentId); 
    219221        legacy.saveBytes(buf, series, lastInSeries, last); 
  • trunk/components/common/src/loci/common/DataTools.java

    r5135 r5142  
    728728    DefaultHandler handler) throws IOException 
    729729  { 
    730     byte[] b = new byte[(int) (stream.getFilePointer() - stream.length())]; 
     730    byte[] b = new byte[(int) (stream.length() - stream.getFilePointer())]; 
    731731    stream.read(b); 
    732732    parseXML(b, handler); 
  • trunk/components/test-suite/src/loci/tests/testng/FormatWriterTest.java

    r5093 r5142  
    201201          int expectedY = config.getY(); 
    202202          boolean expectRGB = config.isRGB(); 
     203          if (TestTools.shortClassName(writer).equals("OMEXMLWriter")) { 
     204            expectRGB = false; 
     205          } 
    203206          int expectedPixelType = config.getPixelType(); 
    204207          int expectedCount = 
    205208            config.getZ() * config.getT() * (expectRGB ? 1 : config.getC()); 
    206           if (TestTools.shortClassName(writer).equals("OMEXMLWriter")) { 
    207             expectedCount *= config.getC(); 
    208             expectRGB = false; 
    209           } 
    210209 
    211210          String expectedMD5 = config.getMD5(); 
Note: See TracChangeset for help on using the changeset viewer.