public void goTo ( Sector sector , boolean animate ) { View view = getWwd ( ) . getView ( ) ; view . stopAnimations ( ) ; view . stopMovement ( ) ; if ( sector == null ) { return ; } // Create a bounding box for the specified sector in order to estimate // its size in model coordinates. Box extent = Sector . computeBoundingBox ( getWwd ( ) . getModel ( ) . getGlobe ( ) , getWwd ( ) . getSceneController ( ) . getVerticalExaggeration ( ) , sector ) ; // Estimate the distance between the center position and the eye // position that is necessary to cause the sector to // fill a viewport with the specified field of view. Note that we change // the distance between the center and eye // position here, and leave the field of view constant. Angle fov = view . getFieldOfView ( ) ; double zoom = extent . getRadius ( ) / fov . cosHalfAngle ( ) / fov . tanHalfAngle ( ) ; // Configure OrbitView to look at the center of the sector from our // estimated distance. This causes OrbitView to // animate to the specified position over several seconds. To affect // this change immediately use the following: if ( animate ) { view . goTo ( new Position ( sector . getCentroid ( ) , 0d ) , zoom ) ; } else { ( ( OrbitView ) wwd . getView ( ) ) . setCenterPosition ( new Position ( sector . getCentroid ( ) , 0d ) ) ; ( ( OrbitView ) wwd . getView ( ) ) . setZoom ( zoom ) ; } }
Move to see a given sector .