Пример #1
0
 /**
  * return an integer array of the y data (intensities) e.g. for writing to JCAMP (using non-std.
  * 32 bit precision)
  *
  * @param int[] integer array
  * @return double y factor
  */
 public double getYDataAs32BitIntArray(int[] y) {
   int n = yData.getLength();
   Range1D.Double yRange = yData.getRange1D();
   double yWidth = Math.max(yRange.getXMax(), -yRange.getXMin());
   double shortIntWidth = 2 << 30;
   double yf = shortIntWidth / yWidth;
   for (int i = 0; i < n; i++) {
     y[i] = (int) (yData.pointAt(i) * yf + .5);
   }
   return yf;
 }
Пример #2
0
 /**
  * return an integer array of the y data (intensities) e.g. for writing to JCAMP
  *
  * @param int[] integer array
  * @return double y factor
  */
 public double getYDataAs16BitIntArray(int[] y) {
   int n = yData.getLength();
   Range1D.Double yRange = yData.getRange1D();
   double yWidth = Math.max(yRange.getXMax(), -yRange.getXMin());
   double shortIntWidth = 2 << 14; // JCAMP requires 16bit signed int
   // precision?
   double yf = shortIntWidth / yWidth;
   for (int i = 0; i < n; i++) {
     y[i] = (int) (yData.pointAt(i) * yf + .5);
   }
   return yf;
 }
Пример #3
0
 /** adjusts full view to a pretty range. */
 protected void adjustFullViewRange() {
   double w;
   if (isFullSpectrum()) {
     Range1D.Double xrange = xData.getRange1D();
     w = xrange.getXWidth();
     xrange.set(xrange.getXMin() - .05 * w, xrange.getXMax() + .05 * w);
     setXFullViewRange(xrange);
     Range1D.Double yrange = yData.getRange1D();
     w = yrange.getXWidth();
     yrange.set(yrange.getXMin() - .05 * w, yrange.getXMax() + .05 * w);
     setYFullViewRange(yrange);
   } else {
     /* include 0.0 in y-range and add 5% on to all borders */
     int n = xData.getLength();
     if (n > 1) {
       Range1D.Double xrange = xData.getRange1D();
       w = xrange.getXWidth();
       xrange.set(xrange.getXMin() - .05 * w, xrange.getXMax() + .05 * w);
       setXFullViewRange(xrange);
     } else if (n == 1) {
       double x = xData.pointAt(0);
       setXFullViewRange(new Range1D.Double(x - 50, x + 50));
     } else {
       setXFullViewRange(new Range1D.Double(0., 300.));
     }
     if (n > 1) {
       Range1D.Double yrange = yData.getRange1D();
       yrange.set(Math.min(yrange.getXMin(), 0.0), Math.max(yrange.getXMax(), 0.0));
       w = yrange.getXWidth();
       if (yrange.getXMin() == 0.0) {
         yrange.set(yrange.getXMin(), yrange.getXMax() + .05 * w);
       } else {
         yrange.set(yrange.getXMin() - .05 * w, yrange.getXMax());
       }
       setYFullViewRange(yrange);
     } else {
       setYFullViewRange(new Range1D.Double(0., 100.));
     }
   }
 }