Exemplo n.º 1
0
 private void showDates1D(CoordinateAxis1D axis1D, CalendarDateUnit cdu) {
   if (!axis1D.isInterval()) {
     for (double val : axis1D.getCoordValues()) {
       if (Double.isNaN(val)) infoTA.appendLine(" N/A");
       else infoTA.appendLine(" " + cdu.makeCalendarDate(val));
     }
   } else { // is interval
     Formatter f = new Formatter();
     double[] b1 = axis1D.getBound1();
     double[] b2 = axis1D.getBound2();
     for (int i = 0; i < b1.length; i++)
       f.format(
           " (%f, %f) == (%s, %s)%n",
           b1[i], b2[i], cdu.makeCalendarDate((b1[i])), cdu.makeCalendarDate((b2[i])));
     infoTA.appendLine(f.toString());
   }
 }
Exemplo n.º 2
0
  private void showValuesAsDates(CoordinateAxis axis) {
    String units = axis.getUnitsString();
    String cal = getCalendarAttribute(axis);
    CalendarDateUnit cdu = CalendarDateUnit.of(cal, units);

    try {
      infoTA.appendLine(units);
      infoTA.appendLine(NCdumpW.printVariableData(axis, null));

      if (axis.getDataType().isNumeric()) {
        if (axis instanceof CoordinateAxis2D) {
          showDates2D((CoordinateAxis2D) axis, cdu);

        } else if (axis instanceof CoordinateAxis1D) { // 1D
          showDates1D((CoordinateAxis1D) axis, cdu);

        } else { // > 2D
          Array data = axis.read();
          IndexIterator ii = data.getIndexIterator();
          while (ii.hasNext()) {
            double val = ii.getDoubleNext();
            infoTA.appendLine(makeCalendarDateStringOrMissing(cdu, val));
          }
        }

      } else { // must be iso dates
        Array data = axis.read();
        Formatter f = new Formatter();
        if (data instanceof ArrayChar) {
          ArrayChar dataS = (ArrayChar) data;
          ArrayChar.StringIterator iter = dataS.getStringIterator();
          while (iter.hasNext()) f.format(" %s%n", iter.next());
          infoTA.appendLine(f.toString());

        } else if (data instanceof ArrayObject) {
          IndexIterator iter = data.getIndexIterator();
          while (iter.hasNext()) f.format(" %s%n", iter.next());
          infoTA.appendLine(f.toString());
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      infoTA.appendLine(ex.getMessage());
    }
  }
Exemplo n.º 3
0
 private String makeCalendarDateStringOrMissing(CalendarDateUnit cdu, double value) {
   if (Double.isNaN(value)) return "missing";
   return cdu.makeCalendarDate(value).toString();
 }