Changeset 5918 for branches/cleanup


Ignore:
Timestamp:
02/16/10 12:10:16 (10 years ago)
Author:
callan
Message:

#464 NetCDFService implemented with relevant readers adjusted

Location:
branches/cleanup/components
Files:
2 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • branches/cleanup/components/bio-formats/src/loci/formats/in/ImarisHDFReader.java

    r5624 r5918  
    3030import loci.common.Location; 
    3131import loci.common.RandomAccessInputStream; 
     32import loci.common.dependency.DependencyException; 
     33import loci.common.dependency.ServiceException; 
     34import loci.common.dependency.ServiceFactory; 
    3235import loci.formats.CoreMetadata; 
    3336import loci.formats.FormatException; 
     
    3538import loci.formats.FormatTools; 
    3639import loci.formats.MetadataTools; 
    37 import loci.formats.NetcdfTools; 
     40import loci.formats.MissingLibraryException; 
     41import loci.formats.NetCDFService; 
     42import loci.formats.NetCDFServiceImpl; 
    3843import loci.formats.meta.FilterMetadata; 
    3944import loci.formats.meta.MetadataStore; 
     
    5762  private double minX, minY, minZ, maxX, maxY, maxZ; 
    5863  private int seriesCount; 
    59   private NetcdfTools netcdf; 
     64  private NetCDFService netcdf; 
    6065 
    6166  // channel parameters 
     
    95100    String path = "/DataSet/ResolutionLevel_" + series + "/TimePoint_" + 
    96101      zct[2] + "/Channel_" + zct[1] + "/Data"; 
    97     Object image = netcdf.getArray(path, new int[] {zct[0], 0, 0}, 
    98       new int[] {1, getSizeY(), getSizeX()}); 
     102    Object image; 
     103    try { 
     104      image = netcdf.getArray(path, new int[] {zct[0], 0, 0}, 
     105          new int[] {1, getSizeY(), getSizeX()}); 
     106    } 
     107    catch (ServiceException e) { 
     108      throw new FormatException(e); 
     109    } 
    99110 
    100111    boolean big = !isLittleEndian(); 
     
    166177    super.initFile(id); 
    167178 
    168     netcdf = new NetcdfTools(id); 
     179    try { 
     180      ServiceFactory factory = new ServiceFactory(); 
     181      netcdf = factory.getInstance(NetCDFService.class); 
     182      netcdf.setFile(id); 
     183    } 
     184    catch (DependencyException e) { 
     185      throw new MissingLibraryException(NetCDFServiceImpl.NO_NETCDF_MSG, e); 
     186    } 
    169187 
    170188    pixelSizeX = pixelSizeY = pixelSizeZ = 1; 
     
    183201    // read all of the metadata key/value pairs 
    184202 
    185     Vector attributes = netcdf.getAttributeList(); 
     203    Vector<String> attributes = netcdf.getAttributeList(); 
    186204    for (int i=0; i<attributes.size(); i++) { 
    187       String attr = (String) attributes.get(i); 
     205      String attr = attributes.get(i); 
    188206      String name = attr.substring(attr.lastIndexOf("/") + 1); 
    189207      String value = netcdf.getAttributeValue(attr); 
     
    286304    int type = -1; 
    287305 
    288     Object pix = netcdf.getVariableValue("/DataSet/ResolutionLevel_" + 
    289       (getSeriesCount() - 1) + "/TimePoint_0/Channel_0/Data"); 
     306    Object pix; 
     307    try { 
     308      pix = netcdf.getVariableValue("/DataSet/ResolutionLevel_" + 
     309          (getSeriesCount() - 1) + "/TimePoint_0/Channel_0/Data"); 
     310    } 
     311    catch (ServiceException e) { 
     312      throw new FormatException(e); 
     313    } 
    290314    if (pix instanceof byte[][][]) type = FormatTools.UINT8; 
    291315    else if (pix instanceof short[][][]) type = FormatTools.UINT16; 
  • branches/cleanup/components/bio-formats/src/loci/formats/in/MINCReader.java

    r5848 r5918  
    2929import java.util.Vector; 
    3030 
     31import loci.common.dependency.DependencyException; 
     32import loci.common.dependency.ServiceException; 
     33import loci.common.dependency.ServiceFactory; 
    3134import loci.formats.FormatException; 
    3235import loci.formats.FormatReader; 
    3336import loci.formats.FormatTools; 
    3437import loci.formats.MetadataTools; 
    35 import loci.formats.NetcdfTools; 
     38import loci.formats.MissingLibraryException; 
     39import loci.formats.NetCDFService; 
    3640import loci.formats.meta.FilterMetadata; 
    3741import loci.formats.meta.MetadataStore; 
     
    4852  // -- Fields -- 
    4953 
    50   private NetcdfTools netcdf; 
     54  private NetCDFService netcdf; 
    5155  private byte[][][] pixelData; 
    5256 
     
    96100    super.initFile(id); 
    97101 
    98     netcdf = new NetcdfTools(id); 
     102    try { 
     103      ServiceFactory factory = new ServiceFactory(); 
     104      netcdf = factory.getInstance(NetCDFService.class); 
     105      netcdf.setFile(id); 
     106    } 
     107    catch (DependencyException e) { 
     108      throw new MissingLibraryException(e); 
     109    } 
    99110 
    100     Vector variableList = netcdf.getVariableList(); 
     111    Vector<String> variableList = netcdf.getVariableList(); 
    101112 
    102113    for (int i=0; i<variableList.size(); i++) { 
    103114      String variable = (String) variableList.get(i); 
    104       Hashtable attributes = netcdf.getVariableAttributes(variable); 
    105       String[] keys = (String[]) attributes.keySet().toArray(new String[0]); 
     115      Hashtable<String, Object> attributes = netcdf.getVariableAttributes(variable); 
     116      String[] keys = attributes.keySet().toArray(new String[0]); 
    106117      Arrays.sort(keys); 
    107118 
     
    118129    } 
    119130 
    120     pixelData = (byte[][][]) netcdf.getVariableValue("/image"); 
     131    try { 
     132      pixelData = (byte[][][]) netcdf.getVariableValue("/image"); 
     133    } 
     134    catch (ServiceException e) { 
     135      throw new FormatException(e); 
     136    } 
    121137 
    122138    core[0].sizeX = netcdf.getDimension("/zspace"); 
  • branches/cleanup/components/common/src/loci/common/dependency/services.properties

    r5913 r5918  
    99# POI service (interface and implementation in bio-formats component) 
    1010loci.formats.POIService=loci.formats.POIServiceImpl 
     11# NetCDF service (interface and implementation in bio-formats component) 
     12loci.formats.NetCDFService=loci.formats.NetCDFServiceImpl 
Note: See TracChangeset for help on using the changeset viewer.