/**
   * Compute the amount of rotation to apply to a label in order to keep it oriented toward its
   * orientation position.
   *
   * @param screenPoint Geographic position of the text, projected onto the screen.
   * @param orientationScreenPoint Orientation position, projected onto the screen.
   * @return The rotation angle to apply when drawing the label.
   */
  protected Angle computeRotation(Vec4 screenPoint, Vec4 orientationScreenPoint) {
    // Determine delta between the orientation position and the label position
    double deltaX = screenPoint.x - orientationScreenPoint.x;
    double deltaY = screenPoint.y - orientationScreenPoint.y;

    if (deltaX != 0) {
      double angle = Math.atan(deltaY / deltaX);
      return Angle.fromRadians(angle);
    } else {
      return Angle.POS90; // Vertical label
    }
  }
  protected Cursor selectResizeCursor(Angle azimuth) {
    while (azimuth.degrees < 0) azimuth = azimuth.addDegrees(360);

    if (azimuth.degrees < 22.5) return Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR);
    else if (azimuth.degrees < 67.5) return Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR);
    else if (azimuth.degrees < 112.5) return Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
    else if (azimuth.degrees < 157.5) return Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR);
    else if (azimuth.degrees < 202.5) return Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
    else if (azimuth.degrees < 247.5) return Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR);
    else if (azimuth.degrees < 292.5) return Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR);
    else if (azimuth.degrees < 337.5) return Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR);
    else // if (azimuth.degrees < 360)
    return Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR);
  }
 protected void setCursor(MeasureTool.ControlPoint controlPoint) {
   // TODO: handle 'rotating' mode cursor is this.isRotating() - when using Alt key on regular
   // shapes
   if (controlPoint == null) {
     setComponentCursor(null);
   } else {
     if (this.measureTool.isRegularShape()) {
       if (this.measureTool.isCornerControl(controlPoint)) {
         Angle azimuth =
             LatLon.greatCircleAzimuth(
                 controlPoint.getPosition(), this.measureTool.getCenterPosition());
         // Account for view heading in cursor selection
         azimuth = azimuth.subtract(this.measureTool.getWwd().getView().getHeading());
         setComponentCursor(selectResizeCursor(azimuth));
       } else if (this.measureTool.isCenterControl(controlPoint)) {
         setComponentCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
       }
     } else {
       // Line, path and polygon
       setComponentCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
     }
   }
 }
    public AppFrame() {
      super(true, true, false);

      IconLayer layer = new IconLayer();
      layer.setPickEnabled(true);
      layer.setAllowBatchPicking(false);
      layer.setRegionCulling(true);

      UserFacingIcon icon =
          new UserFacingIcon(
              "src/images/32x32-icon-nasa.png",
              new Position(Angle.fromRadians(0), Angle.fromRadians(0), 0));
      icon.setSize(new Dimension(24, 24));
      layer.addIcon(icon);

      icon =
          new UserFacingIcon(
              "src/images/32x32-icon-nasa.png",
              new Position(Angle.fromRadians(0.1), Angle.fromRadians(0.0), 0));
      icon.setSize(new Dimension(24, 24));
      layer.addIcon(icon);

      icon =
          new UserFacingIcon(
              "src/images/32x32-icon-nasa.png",
              new Position(Angle.fromRadians(0.0), Angle.fromRadians(0.1), 0));
      icon.setSize(new Dimension(24, 24));
      layer.addIcon(icon);

      icon =
          new UserFacingIcon(
              "src/images/32x32-icon-nasa.png",
              new Position(Angle.fromRadians(0.1), Angle.fromRadians(0.1), 0));
      icon.setSize(new Dimension(24, 24));
      layer.addIcon(icon);

      icon =
          new UserFacingIcon(
              "src/images/32x32-icon-nasa.png",
              new Position(Angle.fromRadians(0), Angle.fromDegrees(180), 0));
      icon.setSize(new Dimension(24, 24));
      layer.addIcon(icon);

      ApplicationTemplate.insertAfterPlacenames(this.getWwd(), layer);

      this.getWwd()
          .addSelectListener(
              new SelectListener() {
                @Override
                public void selected(SelectEvent event) {
                  if (event.getEventAction().equals(SelectEvent.ROLLOVER)) {
                    PickedObjectList pol = event.getObjects();
                    System.out.println(" Picked Objects Size " + pol.size());
                    for (PickedObject po : pol) {
                      System.out.println(
                          " Class "
                              + po.getObject().getClass().getName()
                              + "  isTerrian="
                              + po.isTerrain());
                    }
                  }
                }
              });
      this.getWwd().getSceneController().setDeepPickEnabled(true);
    }