Esempio n. 1
0
  /**
   * Create the ImagePlot. If this is the first time the plot has been created the compute the
   * appropriate zoom, otherwise using the zoom level in the PlotState object. Using the FitsRead in
   * the PlotData object. Record the zoom level in the PlotData object.
   *
   * @param state plot state
   * @param frGroup fits read group
   * @param plotDesc plot description
   * @return the image plot object
   * @throws nom.tam.fits.FitsException if creating plot fails
   */
  static ImagePlot createImagePlot(
      PlotState state,
      ActiveFitsReadGroup frGroup,
      Band band,
      String plotDesc,
      ZoomChoice zoomChoice,
      boolean isMultiImage)
      throws FitsException {

    RangeValues rv = state.getPrimaryRangeValues();
    if (rv == null) {
      rv = FitsRead.getDefaultFutureStretch();
      state.setRangeValues(rv, state.firstBand());
    }

    float zoomLevel = zoomChoice.getZoomLevel();

    ImagePlot plot =
        PlotServUtils.makeImagePlot(
            frGroup, zoomLevel, state.isThreeColor(), band, state.getColorTableId(), rv);

    if (state.isNewPlot()) { // new plot requires computing the zoom level

      zoomLevel = computeZoomLevel(plot, zoomChoice);
      plot.getPlotGroup().setZoomTo(zoomLevel);
      state.setZoomLevel(zoomLevel);
    }

    state.setZoomLevel(zoomLevel);
    initPlotTitle(state, plot, frGroup, plotDesc, isMultiImage);
    return plot;
  }
Esempio n. 2
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;
    }
  }
Esempio n. 3
0
  static ImagePlotInfo[] makeAllNoBand(
      String workingCtxStr, PlotState stateAry[], FileReadInfo[] readAry, ZoomChoice zoomChoice)
      throws FailedRequestException, FitsException, GeomException, IOException {
    // never use this method with three color plots

    ImagePlotInfo piAry[] = new ImagePlotInfo[readAry.length];
    FileReadInfo readInfo;
    Map<Band, WebFitsData> wfDataMap = new LinkedHashMap<Band, WebFitsData>(5);
    for (int i = 0; (i < readAry.length); i++) {
      readInfo = readAry[i];
      WebPlotRequest req = stateAry[i].getPrimaryWebPlotRequest();
      if (readAry.length > 3) {
        PlotServUtils.updateProgress(
            req,
            ProgressStat.PType.CREATING,
            PlotServUtils.CREATING_MSG + ": " + (i + 1) + " of " + readAry.length);
      } else {
        PlotServUtils.updateProgress(req, ProgressStat.PType.CREATING, PlotServUtils.CREATING_MSG);
      }
      ActiveFitsReadGroup frGroup = new ActiveFitsReadGroup();
      frGroup.setFitsRead(readInfo.getBand(), readInfo.getFitsRead());
      ImagePlot plot =
          createImagePlot(
              stateAry[i],
              frGroup,
              readInfo.getBand(),
              readInfo.getDataDesc(),
              zoomChoice,
              readAry.length > 1);
      WebFitsData wfData =
          makeWebFitsData(plot, frGroup, readInfo.getBand(), readInfo.getOriginalFile());
      wfDataMap.put(Band.NO_BAND, wfData);
      Map<Band, ModFileWriter> fileWriterMap = new LinkedHashMap<Band, ModFileWriter>(1);
      if (readInfo.getModFileWriter() != null)
        fileWriterMap.put(Band.NO_BAND, readInfo.getModFileWriter());
      piAry[i] =
          new ImagePlotInfo(
              stateAry[i], plot, frGroup, readInfo.getDataDesc(), wfDataMap, fileWriterMap);
      VisContext.shouldContinue(workingCtxStr);
    }

    return piAry;
  }