Example #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;
  }
Example #2
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;
  }
Example #3
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;
  }