Exemple #1
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;
 }
Exemple #2
0
  @Override
  protected File loadDataFile(TableServerRequest request) throws IOException, DataAccessException {

    File file = createFile(request);

    WorldPt pt = request.getWorldPtParam(ServerParams.USER_TARGET_WORLD_PT);
    pt = VisUtil.convertToJ2000(pt);
    doGetData(file, request.getParams(), pt);
    return file;
  }
Exemple #3
0
  private List<DrawObj> makeSelectedObj(WebPlot plot) {
    List<DrawObj> retval;
    _ptAry[0] = _firstPt;
    _ptAry[1] = _currentPt;

    Projection proj = plot.getProjection();
    Pt anyPt1;
    Pt anyPt2;
    double dist;
    boolean world;
    if (proj.isSpecified()) {
      anyPt1 = plot.getWorldCoords(_ptAry[0]);
      anyPt2 = plot.getWorldCoords(_ptAry[1]);
      dist = VisUtil.computeDistance((WorldPt) anyPt1, (WorldPt) anyPt2);
      world = true;
    } else {
      anyPt1 = _ptAry[0];
      anyPt2 = _ptAry[1];
      dist = VisUtil.computeDistance(anyPt1, anyPt2);
      world = false;
    }

    if (anyPt1 == null || anyPt2 == null) return null;

    ShapeDataObj obj = ShapeDataObj.makeLine(anyPt1, anyPt2);
    obj.setStyle(ShapeDataObj.Style.HANDLED);
    setDistOnShape(obj, dist, ShapeDataObj.TextLocation.LINE_MID_POINT, world);
    obj.setTextOffset(new OffsetScreenPt(-15, 0));
    OffsetScreenPt angleOffPt;

    if (_posAngle) {
      Pt eastPt;
      Pt westPt;

      if (anyPt1.getX() > anyPt2.getX()) {
        eastPt = anyPt1;
        westPt = anyPt2;
      } else {
        eastPt = anyPt2;
        westPt = anyPt1;
      }

      ShapeDataObj adj;
      ShapeDataObj op;
      double adjDist;
      double opDist;
      Pt lonDelta1TextPt;
      if (world) {
        WorldPt lonDelta1 = new WorldPt(eastPt.getX(), eastPt.getY());
        WorldPt lonDelta2 = new WorldPt(westPt.getX(), eastPt.getY());
        adjDist = VisUtil.computeDistance(lonDelta1, lonDelta2);

        WorldPt latDelta1 = new WorldPt(westPt.getX(), eastPt.getY());
        WorldPt latDelta2 = new WorldPt(westPt.getX(), westPt.getY());
        opDist = VisUtil.computeDistance(latDelta1, latDelta2);
        adj = ShapeDataObj.makeLine(lonDelta1, lonDelta2);
        op = ShapeDataObj.makeLine(latDelta1, latDelta2);
        lonDelta1TextPt = lonDelta1;
      } else {
        ImageWorkSpacePt lonDelta1 = new ImageWorkSpacePt(eastPt.getX(), eastPt.getY());
        ImageWorkSpacePt lonDelta2 = new ImageWorkSpacePt(westPt.getX(), eastPt.getY());
        adjDist = VisUtil.computeDistance(lonDelta1, lonDelta2);

        ImageWorkSpacePt latDelta1 = new ImageWorkSpacePt(westPt.getX(), eastPt.getY());
        ImageWorkSpacePt latDelta2 = new ImageWorkSpacePt(westPt.getX(), westPt.getY());
        opDist = VisUtil.computeDistance(latDelta1, latDelta2);
        adj = ShapeDataObj.makeLine(lonDelta1, lonDelta2);
        op = ShapeDataObj.makeLine(latDelta1, latDelta2);
        lonDelta1TextPt = lonDelta1;
      }

      setDistOnShape(adj, adjDist, ShapeDataObj.TextLocation.LINE_MID_POINT_OR_BOTTOM, world);
      setDistOnShape(op, opDist, ShapeDataObj.TextLocation.LINE_MID_POINT_OR_TOP, world);
      op.setTextOffset(new OffsetScreenPt(0, 15));

      double sinX = opDist / dist;
      double angle = Math.toDegrees(Math.asin(sinX));

      String aStr = _nf.format(angle) + HTML_DEG;
      ShapeDataObj angleShape =
          ShapeDataObj.makeText(new OffsetScreenPt(8, -8), lonDelta1TextPt, aStr);

      retval = Arrays.asList((DrawObj) obj, adj, op, angleShape);
    } else {
      retval = Arrays.asList((DrawObj) obj);
    }

    return retval;
  }