Пример #1
0
  /**
   * Gets the sortable array of the specified column.
   *
   * @param header_value the header value of the column to sort.
   */
  protected SortableArray getSortableArray(String header_value) {
    if (header_value.length() == 0) return null;

    SortableArray array = null;
    if (header_value.equals("R.A.") || header_value.equals("Decl.") || header_value.equals("ID"))
      array = new StringArray(record_list.size());
    else array = new Array(record_list.size());

    for (int i = 0; i < record_list.size(); i++) {
      String value = getCellString(header_value, i);

      if (header_value.equals("R.A.")
          || header_value.equals("Decl.")
          || header_value.equals("ID")) {
        ((StringArray) array).set(i, value);
      } else if (header_value.equals("Max Mag") || header_value.equals("Min Mag")) {
        double mag_value = 0.0;
        if ('0' <= value.charAt(0) && value.charAt(0) <= '9'
            || value.charAt(0) == '-'
            || value.charAt(0) == '+') {
          mag_value = Format.doubleValueOf(value);
        } else {
          mag_value = 100 + Format.doubleValueOf(value.substring(1));
        }
        ((Array) array).set(i, mag_value);
      } else if (header_value.equals("First Date") || header_value.equals("Last Date")) {
        double jd = 0.0;
        if (value.length() > 0) jd = JulianDay.create(value).getJD();
        ((Array) array).set(i, jd);
      } else {
        ((Array) array).set(i, Double.parseDouble(value));
      }
    }

    return array;
  }
Пример #2
0
  /**
   * Gets the output string of the cell.
   *
   * @param header_value the header value of the column.
   * @param row the index of row in original order.
   * @return the output string of the cell.
   */
  protected String getCellString(String header_value, int row) {
    Variability record = (Variability) record_list.elementAt(row);

    if (header_value.equals("R.A.")) {
      String coor = record.getStar().getCoor().getOutputString();
      int p = coor.indexOf(' ');
      return coor.substring(0, p);
    }
    if (header_value.equals("Decl.")) {
      String coor = record.getStar().getCoor().getOutputString();
      int p = coor.indexOf(' ');
      return coor.substring(p + 1);
    }
    if (header_value.equals("ID")) {
      if (record.getIdentifiedStar() != null) return record.getIdentifiedStar().getName();
    }
    if (header_value.equals("Max Mag")) {
      return ((XmlMag) record.getBrightestMagnitude().getMag()).getOutputString();
    }
    if (header_value.equals("Min Mag")) {
      return ((XmlMag) record.getFaintestMagnitude().getMag()).getOutputString();
    }
    if (header_value.equals("Mag Range")) {
      return Format.formatDouble(record.getMagnitudeRange(), 5, 2);
    }
    if (header_value.equals("Observations")) {
      return String.valueOf(record.getObservations());
    }
    if (header_value.equals("Positive Observations")) {
      return String.valueOf(record.getPositiveObservations());
    }
    if (header_value.equals("Arc")) {
      return String.valueOf(record.getArcInDays());
    }
    if (header_value.equals("First Date")) {
      String s = record.getFirstDate();
      if (s != null) return s;
    }
    if (header_value.equals("Last Date")) {
      String s = record.getLastDate();
      if (s != null) return s;
    }
    return "";
  }