예제 #1
0
  public static ModFileWriter createBand(
      PlotState state, ImagePlot plot, FileReadInfo readInfo, ActiveFitsReadGroup frGroup)
      throws FitsException, IOException, GeomException {
    ModFileWriter retval = null;
    Band band = readInfo.getBand();

    plot.setThreeColorBand(
        state.isBandVisible(readInfo.getBand()) ? readInfo.getFitsRead() : null,
        readInfo.getBand(),
        frGroup);
    HistogramOps histOps = plot.getHistogramOps(band, frGroup);
    FitsRead tmpFR = histOps.getFitsRead();
    if (tmpFR != readInfo.getFitsRead()
        && readInfo.getWorkingFile()
            != null) { // testing to see it the fits read got geomed when the band was added
      state.setImageIdx(0, band);
      retval =
          new ModFileWriter.GeomFileWriter(
              readInfo.getWorkingFile(), 0, tmpFR, readInfo.getBand(), false);
      FitsCacher.addFitsReadToCache(retval.getTargetFile(), new FitsRead[] {tmpFR});
    }

    RangeValues rv = state.getRangeValues(readInfo.getBand());
    if (rv == null) {
      rv = FitsRead.getDefaultFutureStretch();
      state.setRangeValues(rv, readInfo.getBand());
    }
    histOps.recomputeStretch(rv, true);
    return retval;
  }
예제 #2
0
  static ImagePlotInfo makeOneImagePerBand(
      String workingCtxStr,
      PlotState state,
      Map<Band, FileReadInfo[]> readInfoMap,
      ZoomChoice zoomChoice)
      throws FailedRequestException, FitsException, GeomException, IOException {

    ImagePlotInfo retval;
    ImagePlot plot = null;
    boolean first = true;
    Map<Band, WebFitsData> wfDataMap = new LinkedHashMap<Band, WebFitsData>(5);
    Map<Band, ModFileWriter> fileWriterMap = new LinkedHashMap<Band, ModFileWriter>(5);
    ActiveFitsReadGroup frGroup = new ActiveFitsReadGroup();
    for (Map.Entry<Band, FileReadInfo[]> entry : readInfoMap.entrySet()) {
      Band band = entry.getKey();
      FileReadInfo readInfoAry[] = entry.getValue();
      FileReadInfo readInfo = readInfoAry[state.getImageIdx(band)];
      frGroup.setFitsRead(band, readInfo.getFitsRead());
      if (first) {
        plot =
            createImagePlot(
                state, frGroup, readInfo.getBand(), readInfo.getDataDesc(), zoomChoice, false);
        if (state.isThreeColor()) {
          plot.setThreeColorBand(
              state.isBandVisible(readInfo.getBand()) ? readInfo.getFitsRead() : null,
              readInfo.getBand(),
              frGroup);
        }
        if (readInfo.getModFileWriter() != null) {
          fileWriterMap.put(band, readInfo.getModFileWriter());
        }
        first = false;
      } else {
        ModFileWriter mfw = createBand(state, plot, readInfo, frGroup);
        if (mfw != null) {
          fileWriterMap.put(band, mfw);
        } else if (readInfo.getModFileWriter() != null) {
          fileWriterMap.put(band, readInfo.getModFileWriter());
        }
      }
      WebFitsData wfData =
          makeWebFitsData(plot, frGroup, readInfo.getBand(), readInfo.getOriginalFile());
      wfDataMap.put(band, wfData);
      VisContext.shouldContinue(workingCtxStr);
    }
    String desc = make3ColorDataDesc(readInfoMap);
    retval = new ImagePlotInfo(state, plot, frGroup, desc, wfDataMap, fileWriterMap);

    if (first)
      _log.error("something is wrong, plot not setup correctly - no color bands specified");
    return retval;
  }
예제 #3
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;
  }
예제 #4
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;
    }
  }