예제 #1
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 "";
  }
예제 #2
0
    /** Runs this thread. */
    public void run() {
      CommonFileChooser file_chooser = new CommonFileChooser();
      file_chooser.setDialogTitle("Save selected data.");
      file_chooser.setMultiSelectionEnabled(false);

      if (file_chooser.showSaveDialog(pane) == JFileChooser.APPROVE_OPTION) {
        try {
          File file = file_chooser.getSelectedFile();
          if (file.exists()) {
            String message = "Overwrite to " + file.getPath() + " ?";
            if (0
                != JOptionPane.showConfirmDialog(
                    pane, message, "Confirmation", JOptionPane.YES_NO_OPTION)) {
              return;
            }
          }

          AstrometricaWriter writer = new AstrometricaWriter(file);
          writer.open();

          int check_column = getCheckColumn();
          for (int i = 0; i < model.getRowCount(); i++) {
            if (((Boolean) getValueAt(i, check_column)).booleanValue()) {
              Variability record = (Variability) record_list.elementAt(index.get(i));
              writer.write(record.getStar());
            }
          }

          writer.close();

          String message = "Completed.";
          JOptionPane.showMessageDialog(pane, message);
        } catch (IOException exception) {
          String message = "Failed to save file.";
          JOptionPane.showMessageDialog(pane, message, "Error", JOptionPane.ERROR_MESSAGE);
        } catch (UnsupportedStarClassException exception) {
          String message = "Failed to save file.";
          JOptionPane.showMessageDialog(pane, message, "Error", JOptionPane.ERROR_MESSAGE);
        }
      }
    }