arcgissamples\globe\AnimationUtil.java
/* Copyright 2010 ESRI * * All rights reserved under the copyright laws of the United States * and applicable international laws, treaties, and conventions. * * You may freely redistribute and use this sample code, with or * without modification, provided you include the original copyright * notice and use restrictions. * * See the use restrictions. * */ package arcgissamples.globe; import com.esri.arcgis.analyst3d.IBasicScene2; import com.esri.arcgis.analyst3d.IScene; import com.esri.arcgis.animation.AGAnimationUtils; import com.esri.arcgis.animation.IAGAnimationContainer; import com.esri.arcgis.animation.IAGAnimationEnvironment; import com.esri.arcgis.animation.IAGAnimationPlayer; import com.esri.arcgis.animation.IAGAnimationTrack; import com.esri.arcgis.animation.IAGAnimationTracks; import com.esri.arcgis.animation.IAGAnimationUtils; import com.esri.arcgis.animation.IAnimationExtension; import com.esri.arcgis.globecore.IGlobe; import com.esri.arcgis.globecore.IGlobeDisplay; public class AnimationUtil { public static void captureCurrentView(IGlobe globe) throws Exception { IBasicScene2 basicScene = (IBasicScene2) globe.getGlobeDisplay().getScene(); IAGAnimationTracks tracks = (IAGAnimationTracks) globe; IAnimationExtension animExt = basicScene.getAnimationExtension(); IAGAnimationEnvironment env = animExt.getAnimationEnvironment(); IAGAnimationUtils animUtils = new AGAnimationUtils(); //add the current view to the animation tracks animUtils.captureCurrentView(tracks, env); } public static void loadAnimation(IGlobe globe, String filePath) throws Exception { IBasicScene2 basicScene = (IBasicScene2) globe.getGlobeDisplay().getScene(); IAnimationExtension animExt = basicScene.getAnimationExtension(); IAGAnimationContainer container = animExt.getAnimationTracks() .getAnimationObjectContainer(); IAGAnimationUtils animUtils = new AGAnimationUtils(); //load the animation animUtils.loadAnimationFile(container, filePath); } public static void playAnimation(IGlobe globe, IAGAnimationEnvironment env) throws Exception { IBasicScene2 basicScene = (IBasicScene2) globe.getGlobeDisplay().getScene(); IAnimationExtension animExt = basicScene.getAnimationExtension(); IAGAnimationTracks tracks = animExt.getAnimationTracks(); IAGAnimationPlayer animPlayer = new AGAnimationUtils(); //play the animation animPlayer.playAnimation(tracks, env, null); } public static void stopAnimation(IGlobe globe) throws Exception { IAGAnimationPlayer animPlayer = new AGAnimationUtils(); //stop the animation animPlayer.stopAnimation(); } public static void pauseAnimation(IGlobe globe) throws Exception { IAGAnimationPlayer animPlayer = new AGAnimationUtils(); //pause the animation animPlayer.pauseAnimation(); } public static void clearAnimation(IGlobe globe) throws Exception { IGlobeDisplay globeDisplay = globe.getGlobeDisplay(); IBasicScene2 basicScene = (IBasicScene2) globeDisplay.getScene(); IAnimationExtension animExt = basicScene.getAnimationExtension(); IAGAnimationTracks tracks = animExt.getAnimationTracks(); //remove all tracks, and refresh the viewers tracks.removeAllTracks(); globeDisplay.refreshViewers(); } public static void saveAnimation(IGlobe globe, String filePath, int version) throws Exception { IBasicScene2 basicScene = (IBasicScene2) globe.getGlobeDisplay().getScene(); IAnimationExtension animExt = basicScene.getAnimationExtension(); IAGAnimationContainer container = animExt.getAnimationTracks() .getAnimationObjectContainer(); IAGAnimationUtils animUtils = new AGAnimationUtils(); //save the animation out to a file animUtils.saveAnimationFile(container, filePath, version); } public static void addAnimationTrack(IGlobe globe, IAGAnimationTrack track) throws Exception { IScene scene = (IScene) globe.getGlobeDisplay().getScene(); IBasicScene2 basicScene = (IBasicScene2) scene; IAnimationExtension animExt = basicScene.getAnimationExtension(); IAGAnimationTracks animTracks = animExt.getAnimationTracks(); //add an animation track to the existing list of tracks animTracks.addTrack(track); } }