Example #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;
  }
Example #2
0
 static float computeZoomLevel(ImagePlot plot, ZoomChoice zoomChoice) {
   int width = plot.getImageDataWidth();
   int height = plot.getImageDataHeight();
   float retval = zoomChoice.getZoomLevel();
   if (zoomChoice.isSmartZoom()) {
     retval = computeSmartZoom(width, height, zoomChoice.getZoomType());
   } else if (zoomChoice.getZoomType() == ZoomType.TO_WIDTH) {
     retval = (float) zoomChoice.getWidth() / (float) width;
     if (zoomChoice.hasMaxZoomLevel()) {
       if (retval > zoomChoice.getMaxZoomLevel()) retval = zoomChoice.getMaxZoomLevel();
     }
   } else if (zoomChoice.getZoomType() == ZoomType.FULL_SCREEN) {
     retval =
         VisUtil.getEstimatedFullZoomFactor(
             VisUtil.FullType.WIDTH_HEIGHT,
             width,
             height,
             zoomChoice.getWidth(),
             zoomChoice.getHeight());
     if (zoomChoice.hasMaxZoomLevel()) {
       if (retval > zoomChoice.getMaxZoomLevel()) retval = zoomChoice.getMaxZoomLevel();
     }
   } else if (zoomChoice.getZoomType() == ZoomType.ARCSEC_PER_SCREEN_PIX) {
     retval = (float) plot.getPixelScale() / zoomChoice.getArcsecPerScreenPix();
   }
   return retval;
 }