Changeset 2049


Ignore:
Timestamp:
01/09/07 12:30:11 (13 years ago)
Author:
melissa
Message:
  • Fixed several bugs in ND2 reader
  • Tweaked OMEReader.initFile to allow specifying a session key instead of a username and password.
  • Fixed elusive bug in RandomAccessStream.
Location:
trunk/loci/formats
Files:
3 edited

Legend:

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

    r2030 r2049  
    445445        if (valid) { 
    446446          dis.mark(newBufferSize); 
    447           fp = mark; 
    448  
     447          //fp = mark; 
     448 
     449          fp = (int) (length() - dis.available()); 
    449450          while (fp < afp) { 
    450451            int skip = dis.skipBytes(afp - fp); 
  • trunk/loci/formats/in/ND2Reader.java

    r2039 r2049  
    264264    if (off > 0 && off < in.length() - 5) { 
    265265      in.seek(off + 5); 
    266       byte[] b = new byte[(int) (in.length() - off)]; 
     266      byte[] b = new byte[(int) (in.length() - off - 5)]; 
    267267      in.read(b); 
    268268      String xml = new String(b); 
     
    336336    } 
    337337 
    338     sizeX[0] = Integer.parseInt((String) metadata.get( 
    339       "MetadataSeq _SEQUENCE_INDEX=\"0\" right value")); 
    340     sizeY[0] = Integer.parseInt((String) metadata.get( 
    341       "MetadataSeq _SEQUENCE_INDEX=\"0\" bottom value")); 
     338    String m = "MetadataSeq _SEQUENCE_INDEX=\"0\""; 
     339    String x = (String) metadata.get(m + " right value"); 
     340    String y = (String) metadata.get(m + " bottom value"); 
     341    if (x != null) sizeX[0] = Integer.parseInt(x); 
     342    if (y != null) sizeY[0] = Integer.parseInt(y); 
    342343 
    343344    if (sizeX[0] == 0 || sizeY[0] == 0) { 
     
    346347        "Container page_size"); 
    347348      if (s != null) { 
    348         String x = s.substring(1, s.indexOf(",")); 
     349        x = s.substring(1, s.indexOf(",")); 
    349350        sizeX[0] = (int) Float.parseFloat(x); 
    350         String y = s.substring(s.indexOf(",") + 1, s.indexOf(")")); 
     351        y = s.substring(s.indexOf(",") + 1, s.indexOf(")")); 
    351352        sizeY[0] = (int) Float.parseFloat(y); 
    352353      } 
     
    401402    } 
    402403 
    403     sizeC[0] = Integer.parseInt((String) metadata.get( 
    404       "MetadataSeq _SEQUENCE_INDEX=\"0\" uiCompCount value")); 
     404    String c = (String)  
     405      metadata.get("MetadataSeq _SEQUENCE_INDEX=\"0\" uiCompCount value"); 
     406    if (c != null) sizeC[0] = Integer.parseInt(c); 
     407    else sizeC[0] = openImage(id, 0).getRaster().getNumBands(); 
    405408    if (sizeC[0] == 2) sizeC[0] = 1; 
    406409 
     
    409412 
    410413    for (int i=0; i<numImages; i++) { 
    411       timestamps[i] = (long) Float.parseFloat((String) metadata.get( 
    412         "MetadataSeq _SEQUENCE_INDEX=\"" + i + "\" dTimeMSec value")); 
    413       zstamps[i] = (long) Float.parseFloat((String) metadata.get( 
    414         "MetadataSeq _SEQUENCE_INDEX=\"" + i + "\" dZPos value")); 
     414      String pre = "MetadataSeq _SEQUENCE_INDEX=\"" + i + "\" "; 
     415      String tstamp = (String) metadata.get(pre + "dTimeMSec value"); 
     416      String zstamp = (String) metadata.get(pre + "dZPos value"); 
     417      if (tstamp != null) timestamps[i] = (long) Float.parseFloat(tstamp); 
     418      if (zstamp != null) zstamps[i] = (long) Float.parseFloat(zstamp); 
    415419    } 
    416420 
     
    429433 
    430434    currentOrder[0] = "XY"; 
    431     long deltaT = timestamps[1] - timestamps[0]; 
    432     long deltaZ = zstamps[1] - zstamps[0]; 
     435    long deltaT = timestamps.length > 1 ? timestamps[1] - timestamps[0] : 1; 
     436    long deltaZ = zstamps.length > 1 ? zstamps[1] - zstamps[0] : 1;  
    433437 
    434438    if (deltaT < deltaZ || deltaZ == 0) currentOrder[0] += "CTZ"; 
  • trunk/loci/formats/in/OMEReader.java

    r2045 r2049  
    3636 * OMEReader retrieves images on demand from an OME database.  
    3737 * Authentication with the OME server is handled, provided the 'id' parameter 
    38  * is properly formed.  The 'id' parameter should take the following form: 
     38 * is properly formed.   
     39 * The 'id' parameter should take one of the following forms: 
    3940 * 
    4041 * <server>?user=<username>&password=<password>&id=<image id> 
     42 * <server>?key=<session key>&id=<image id> 
    4143 * 
    4244 * where <server> is the URL of the OME data server (not the image server). 
     
    194196    server = id.substring(0, id.lastIndexOf("?")); 
    195197    int ndx = id.indexOf("&"); 
    196     String user = id.substring(id.lastIndexOf("?") + 6, ndx); 
    197     String pass = id.substring(ndx + 10, id.indexOf("&", ndx + 1)); 
    198     ndx = id.indexOf("&", ndx + 1); 
    199     imageId = id.substring(ndx + 4); 
     198    String user = null; 
     199    String pass = null; 
     200    if (id.indexOf("server") != -1) { 
     201      user = id.substring(id.lastIndexOf("?") + 6, ndx); 
     202      pass = id.substring(ndx + 10, id.indexOf("&", ndx + 1)); 
     203      ndx = id.indexOf("&", ndx + 1); 
     204      imageId = id.substring(ndx + 4); 
     205    } 
     206    else { 
     207      sessionKey = id.substring(id.lastIndexOf("?") + 5, ndx); 
     208      ndx = id.indexOf("&", ndx + 1); 
     209      imageId = id.substring(ndx + 4); 
     210    } 
    200211   
    201212    Criteria c = new Criteria(); 
     
    224235 
    225236    rc = rs.getRemoteCaller(); 
    226     rc.login(user, pass); 
     237    if (user != null && pass != null) rc.login(user, pass); 
     238    else if (sessionKey != null) rc.setSessionKey(sessionKey); 
    227239 
    228240    df = (DataFactory) rs.getService(DataFactory.class); 
Note: See TracChangeset for help on using the changeset viewer.