Package org.jaxen.xom

Examples of org.jaxen.xom.DocumentNavigator$IndexIterator


      logger.severe(e.toString());
      throw (new IOException(
          "Could not read from variable scan_index from file " + file));
    }

    IndexIterator scanIndexIterator = scanIndexArray.getIndexIterator();
    int ind = 0;
    while (scanIndexIterator.hasNext()) {
      scanStartPositions[ind] = ((Integer) scanIndexIterator.next())
          .intValue();
      ind++;
    }
    scanIndexIterator = null;
    scanIndexArray = null;
    scanIndexVariable = null;

    // Calc stop position for the last scan
    // This defines the end index of the last scan
    scanStartPositions[totalScans] = (int) massValueVariable.getSize();

    // Read retention times
    double[] retentionTimes = new double[totalScans];

    Variable scanTimeVariable = inputFile
        .findVariable("scan_acquisition_time");
    if (scanTimeVariable == null) {
      logger.severe("Could not find variable scan_acquisition_time from file "
          + file);
      throw (new IOException(
          "Could not find variable scan_acquisition_time from file "
              + file));
    }
    Array scanTimeArray = null;
    try {
      scanTimeArray = scanTimeVariable.read();
    } catch (Exception e) {
      logger.severe(e.toString());
      throw (new IOException(
          "Could not read from variable scan_acquisition_time from file "
              + file));
    }

    IndexIterator scanTimeIterator = scanTimeArray.getIndexIterator();
    ind = 0;
    while (scanTimeIterator.hasNext()) {
      if (scanTimeVariable.getDataType().getPrimitiveClassType() == float.class) {
        retentionTimes[ind] = ((Double) scanTimeIterator.next()) / 60d;
      }
      if (scanTimeVariable.getDataType().getPrimitiveClassType() == double.class) {
        retentionTimes[ind] = ((Double) scanTimeIterator.next()) / 60d;
      }
      ind++;
    }

    scanTimeIterator = null;
View Full Code Here


                    wrapper.variableDS.read(section);
            } catch (InvalidRangeException e) {
                throw netcdfFailure(e);
            }
            if (flipYAxis) {
                final IndexIterator it = array.getIndexIterator();
                for (int y = ymax; --y >= ymin; ) {
                    for (int x = xmin; x < xmax; x++) {
                        switch (type) {
                            case DataBuffer.TYPE_DOUBLE: {
                                raster.setSample(x, y, dstBand, it.getDoubleNext());
                                break;
                            }
                            case DataBuffer.TYPE_FLOAT: {
                                raster.setSample(x, y, dstBand, it.getFloatNext());
                                break;
                            }
                            case DataBuffer.TYPE_BYTE: {
                                byte b = it.getByteNext();
                                // int myByte = (0x000000FF & ((int) b));
                                // short anUnsignedByte = (short) myByte;
                                // raster.setSample(x, y, dstBand, anUnsignedByte);
                                raster.setSample(x, y, dstBand, b);
                                break;
                            }
                            default: {
                                raster.setSample(x, y, dstBand, it.getIntNext());
                                break;
                            }
                        }
                    }
                }
            }else{
                switch( type ) {
                    case DataBuffer.TYPE_DOUBLE: {
                        DoubleBuffer doubleBuffer = array.getDataAsByteBuffer().asDoubleBuffer();
                        double[] samples = new double[destRegion.width * destRegion.height];
                        doubleBuffer.get(samples);
                        raster.setSamples(xmin, ymin, destRegion.width, destRegion.height, dstBand, samples);
                        break;
                    }
                    case DataBuffer.TYPE_FLOAT:
                        float[] samples = new float[destRegion.width * destRegion.height];
                        FloatBuffer floatBuffer = array.getDataAsByteBuffer().asFloatBuffer();
                        floatBuffer.get(samples);
                        raster.setSamples(xmin,ymin,destRegion.width,destRegion.height,dstBand,samples);
                        break;
                    case DataBuffer.TYPE_BYTE:
                        //THIS ONLY WORKS FOR ONE BAND!!
                        raster.setDataElements(xmin,ymin,destRegion.width,destRegion.height,array.getDataAsByteBuffer().array());
                        break;
                    case DataBuffer.TYPE_INT:
                        IntBuffer intBuffer = array.getDataAsByteBuffer().asIntBuffer();
                        int[] intSamples = new int[destRegion.width * destRegion.height];
                        intBuffer.get(intSamples);
                        raster.setSamples(xmin, ymin, destRegion.width, destRegion.height, dstBand, intSamples);
                        break;
                    default: {
                        final IndexIterator it = array.getIndexIterator();
                        for (int y = ymin; y < ymax; y++ ) {
                            for (int x = xmin; x < xmax; x++) {
                                raster.setSample(x, y, dstBand, it.getIntNext());
                            }
                        }
                        break;
                    }

View Full Code Here

TOP

Related Classes of org.jaxen.xom.DocumentNavigator$IndexIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.