/** * 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 } }
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); }