Changeset 2984 for trunk


Ignore:
Timestamp:
07/16/07 12:27:24 (13 years ago)
Author:
curtis
Message:

Simply cache source interface a bit.

Location:
trunk/loci/formats/cache
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/cache/BufferedImageSource.java

    r2961 r2984  
    99 
    1010/** 
    11  * Retrieves BufferedImages from a data source (e.g., a file) using Bio-Formats. 
     11 * Retrieves BufferedImages from a data source 
     12 * (e.g., a file) using Bio-Formats. 
    1213 */ 
    1314public class BufferedImageSource extends CacheSource { 
    14  
    15   // -- Fields -- 
    16  
    17   /** Reader from which to draw BufferedImages. */ 
    18   private IFormatReader reader; 
    1915 
    2016  // -- Constructors -- 
    2117 
    2218  /** Constructs a BufferedImage source from the given Bio-Formats reader. */ 
    23   public BufferedImageSource(IFormatReader r) throws CacheException { 
    24     super(r); 
    25     reader = r; 
    26   } 
     19  public BufferedImageSource(IFormatReader r) { super(r); } 
    2720 
    28   /** Constructs a BufferedImage source drawing from the given file. */ 
    29   public BufferedImageSource(String id) throws CacheException { 
    30     this(new FileStitcher()); 
    31     try { reader.setId(id); } 
    32     catch (FormatException exc) { throw new CacheException(exc); } 
    33     catch (IOException exc) { throw new CacheException(exc); } 
    34   } 
     21  /** Constructs a BufferedImage source that draws from the given file. */ 
     22  public BufferedImageSource(String id) throws CacheException { super(id); } 
    3523 
    3624  // -- ICacheSource API methods -- 
    37  
    38   /* @see loci.formats.cache.ICacheSource#getObjectCount() */ 
    39   public int getObjectCount() { 
    40     return reader.getImageCount(); 
    41   } 
    4225 
    4326  /* @see loci.formats.cache.ICacheSource#getObject(int[], int[]) */ 
  • trunk/loci/formats/cache/ByteArraySource.java

    r2961 r2984  
    88import loci.formats.*; 
    99 
    10 /** Retrieves byte arrays from a file, using Bio-Formats. */ 
     10/** 
     11 * Retrieves byte arrays from a data source 
     12 * (e.g., a file) using Bio-Formats. 
     13 */ 
    1114public class ByteArraySource extends CacheSource { 
    12  
    13   // -- Fields -- 
    14  
    15   /** Reader from which to draw byte arrays. */ 
    16   private IFormatReader reader; 
    1715 
    1816  // -- Constructors -- 
    1917 
    2018  /** Constructs a byte array source from the given Bio-Formats reader. */ 
    21   public ByteArraySource(IFormatReader r) throws CacheException { 
    22     super(r); 
    23     reader = r; 
    24   } 
     19  public ByteArraySource(IFormatReader r) { super(r); } 
    2520 
    26   /** Constructs a byte array source drawing from the given file. */ 
    27   public ByteArraySource(String id) throws CacheException { 
    28     this(new FileStitcher()); 
    29     try { reader.setId(id); } 
    30     catch (FormatException exc) { throw new CacheException(exc); } 
    31     catch (IOException exc) { throw new CacheException(exc); } 
    32   } 
     21  /** Constructs a byte array source that draws from the given file. */ 
     22  public ByteArraySource(String id) throws CacheException { super(id); } 
    3323 
    3424  // -- ICacheSource API methods -- 
    35  
    36   /* @see loci.formats.cache.ICacheSource#getObjectCount() */ 
    37   public int getObjectCount() { 
    38     return reader.getImageCount(); 
    39   } 
    4025 
    4126  /* @see loci.formats.cache.ICacheSource#getObject(int[], int[]) */ 
  • trunk/loci/formats/cache/CacheSource.java

    r2969 r2984  
    55package loci.formats.cache; 
    66 
     7import java.io.IOException; 
     8import loci.formats.*; 
     9 
     10/** 
     11 * Retrieves image planes from a data source 
     12 * (e.g., a file) using Bio-Formats. 
     13 */ 
    714public abstract class CacheSource implements ICacheSource { 
     15 
     16  // -- Fields -- 
     17 
     18  /** Reader from which to draw image planes. */ 
     19  protected IFormatReader reader; 
    820 
    921  // -- Constructors -- 
    1022 
    11   public CacheSource(Object o) { } 
     23  /** Constructs a cache source from the given Bio-Formats reader. */ 
     24  public CacheSource(IFormatReader r) { reader = r; } 
     25 
     26  /** Constructs a cache source that draws from the given file. */ 
     27  public CacheSource(String id) throws CacheException { 
     28    this(new FileStitcher()); 
     29    try { reader.setId(id); } 
     30    catch (FormatException exc) { throw new CacheException(exc); } 
     31    catch (IOException exc) { throw new CacheException(exc); } 
     32  } 
    1233 
    1334  // -- ICacheSource API methods -- 
    1435 
    15   /* @see ICacheSource#getObjectCount() */ 
    16   public abstract int getObjectCount() throws CacheException; 
     36  /* @see loci.formats.cache.ICacheSource#getObjectCount() */ 
     37  public int getObjectCount() { return reader.getImageCount(); } 
    1738 
    1839  /* @see ICacheSource#getObject(int[], int[]) */ 
    1940  public abstract Object getObject(int[] len, int[] pos) throws CacheException; 
    2041 
    21   /* @see ICacheSource#getObject(int[], int[][]) */ 
    22   public Object[] getObjects(int[] len, int[][] pos) throws CacheException { 
    23     Object[] o = new Object[pos.length]; 
    24     for (int i=0; i<o.length; i++) { 
    25       o[i] = getObject(len, pos[i]); 
    26     } 
    27     return o; 
    28   } 
    29  
    3042} 
  • trunk/loci/formats/cache/ICacheSource.java

    r2866 r2984  
    1313  Object getObject(int[] len, int[] pos) throws CacheException; 
    1414 
    15   /** Get the objects corresponding to the given indices. */ 
    16   Object[] getObjects(int[] len, int[][] pos) throws CacheException; 
    17  
    1815} 
  • trunk/loci/formats/cache/ImageProcessorSource.java

    r2969 r2984  
    99import loci.formats.*; 
    1010 
    11 /** Retrieves ImageJ image processors from a file, using Bio-Formats. */ 
     11/** 
     12 * Retrieves ImageJ image processors from a data source 
     13 * (e.g., a file) using Bio-Formats. 
     14 */ 
    1215public class ImageProcessorSource extends CacheSource { 
    1316 
     
    4043  } 
    4144 
    42   // -- Fields -- 
    43  
    44   /** Reader from which to draw ImageProcessors. */ 
    45   private IFormatReader reader; 
    46  
    4745  // -- Constructors -- 
    4846 
    4947  /** Constructs an ImageProcessor source from the given Bio-Formats reader. */ 
    50   public ImageProcessorSource(IFormatReader r) throws CacheException { 
    51     super(r); 
    52     reader = r; 
    53   } 
    54  
    55   /** Constructs an ImageProcessor source drawing from the given file. */ 
    56   public ImageProcessorSource(String id) throws CacheException { 
    57     this(new FileStitcher()); 
    58     try { reader.setId(id); } 
    59     catch (FormatException exc) { throw new CacheException(exc); } 
    60     catch (IOException exc) { throw new CacheException(exc); } 
    61   } 
     48  public ImageProcessorSource(IFormatReader r) { super(r); } 
     49 
     50  /** Constructs an ImageProcessor source that draws from the given file. */ 
     51  public ImageProcessorSource(String id) throws CacheException { super(id); } 
    6252 
    6353  // -- ICacheSource API methods -- 
    64  
    65   /* @see loci.formats.cache.ICacheSource#getObjectCount() */ 
    66   public int getObjectCount() { 
    67     return reader.getImageCount(); 
    68   } 
    6954 
    7055  /** 
     
    233218      return r.getVar("ip"); 
    234219    } 
    235     catch (Exception e) { throw new CacheException(e); } 
     220    catch (FormatException e) { throw new CacheException(e); } 
     221    catch (IOException e) { throw new CacheException(e); } 
     222    catch (ReflectException e) { throw new CacheException(e); } 
    236223  } 
    237224 
Note: See TracChangeset for help on using the changeset viewer.