Exemplo n.º 1
0
  static void initPlotTitle(
      PlotState state,
      ImagePlot plot,
      ActiveFitsReadGroup frGroup,
      String dataDesc,
      boolean isMultiImage) {
    WebPlotRequest req = state.getPrimaryWebPlotRequest();
    WebPlotRequest.TitleOptions titleOps = req.getTitleOptions();
    String headerKey = req.getHeaderKeyForTitle();
    if ((isMultiImage
            && (titleOps == WebPlotRequest.TitleOptions.NONE
                || titleOps == WebPlotRequest.TitleOptions.FILE_NAME))
        || (titleOps == WebPlotRequest.TitleOptions.HEADER_KEY && StringUtils.isEmpty(headerKey))) {
      titleOps = WebPlotRequest.TitleOptions.HEADER_KEY;
      headerKey = "EXTNAME";
    }
    String s = req.getPlotDescAppend();
    plot.setPlotDesc("");
    Header header = frGroup.getFitsRead(state.firstBand()).getHeader();

    switch (titleOps) {
      case NONE:
        plot.setPlotDesc("");
        break;
      case PLOT_DESC:
        String base = req.getTitle() == null ? "" : req.getTitle();
        plot.setPlotDesc(base + dataDesc);
        break;
      case FILE_NAME:
        break;
      case HEADER_KEY:
        HeaderCard card = header.findCard(headerKey);
        if (card == null && state.getCubeCnt(state.firstBand()) > 0) {
          card = header.findCard("PLANE" + state.getImageIdx(state.firstBand()));
        }
        String hTitle = card != null ? card.getValue() : "";
        plot.setPlotDesc(hTitle);
        break;
      case PLOT_DESC_PLUS:
        plot.setPlotDesc(req.getTitle() + (s != null ? " " + s : ""));
        break;
      case SERVICE_OBS_DATE:
        if (req.getRequestType() == RequestType.SERVICE) {
          //                    String desc= req.getServiceType()== WebPlotRequest.ServiceType.WISE
          // ? MID_OBS : OBS_DATE;
          String title =
              req.getTitle()
                  + ": "
                  +
                  //                                  desc + ": " +
                  PlotServUtils.getDateValueFromServiceFits(req.getServiceType(), header);
          plot.setPlotDesc(title);
        }
        break;
    }
  }
Exemplo n.º 2
0
  /** Update the display to show the FITS headers of the spectrum */
  public void updateDisplay() {
    Header header = null;
    if (specData != null) {
      header = specData.getHeaders();
    }

    //  Stop with null table if no spectrum or no headers.
    if (specData == null || header == null) {
      table.setModel(new DefaultTableModel());
      return;
    }

    String[] columnNames = {"Keyword", "Value", "Comment"};
    int numKeywords = header.getNumberOfCards();
    String[][] values = new String[numKeywords][3];
    Iterator it = header.iterator();
    int n = 0;
    while (it.hasNext()) {
      HeaderCard card = (HeaderCard) (it.next());
      String key = card.getKey();
      String value = card.getValue();
      String comment = card.getComment();
      //  A blank keyword is really a comment line.
      if ("".equals(key)) {
        value = comment;
        comment = "";
      }
      values[n][0] = key;
      values[n][1] = value;
      values[n++][2] = comment;
    }
    table.setModel(new DefaultTableModel(values, columnNames));

    //  Set default widths, matched to FITS format.
    TableColumn column = table.getColumnModel().getColumn(0);
    column.setPreferredWidth(100);
    column = table.getColumnModel().getColumn(1);
    column.setPreferredWidth(300);
    column = table.getColumnModel().getColumn(2);
    column.setPreferredWidth(450);
  }