Skip to content

Commit b9fff86

Browse files
committed
Stop the animation when the app closes
1 parent 9709cd7 commit b9fff86

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

src/main/java/com/esri/samples/analysis/viewshed_geoelement/ViewshedGeoElementSample.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class ViewshedGeoElementSample extends Application {
5858

5959
private SceneView sceneView;
6060
private Graphic tank;
61+
private Timeline animation;
6162
private Point waypoint;
6263

6364
private static final LinearUnit METERS = new LinearUnit(LinearUnitId.METERS);
@@ -148,7 +149,7 @@ public void start(Stage stage) throws Exception {
148149
sceneView.setCameraController(cameraController);
149150

150151
// create a timeline to animate the tank
151-
Timeline animation = new Timeline();
152+
animation = new Timeline();
152153
animation.setCycleCount(-1);
153154
animation.getKeyFrames().add(new KeyFrame(Duration.millis(100), e -> animate()));
154155
animation.play();
@@ -191,6 +192,9 @@ private void animate() {
191192
@Override
192193
public void stop() {
193194

195+
// stop the animation
196+
animation.stop();
197+
194198
if (sceneView != null) {
195199
sceneView.dispose();
196200
}

src/main/java/com/esri/samples/featurelayers/feature_layer_rendering_mode_map/FeatureLayerRenderingModeMapSample.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class FeatureLayerRenderingModeMapSample extends Application {
4040

4141
private MapView mapViewTop;
4242
private MapView mapViewBottom;
43+
private Timeline timeline;
4344

4445
@Override
4546
public void start(Stage stage) throws Exception {
@@ -100,7 +101,7 @@ public void start(Stage stage) throws Exception {
100101
mapViewBottom.setViewpoint(zoomOutPoint);
101102

102103
//loop an animation into and out from the zoom in point (5 seconds each) with a 2 second gap between zooming
103-
Timeline timeline = new Timeline();
104+
timeline = new Timeline();
104105
timeline.setCycleCount(Animation.INDEFINITE);
105106
timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(7), event -> zoomTo(zoomInPoint, 5)));
106107
timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(14), event -> zoomTo(zoomOutPoint, 5)));
@@ -129,6 +130,9 @@ private void zoomTo(Viewpoint viewpoint, int seconds) {
129130
@Override
130131
public void stop() {
131132

133+
// stop the timer
134+
timeline.stop();
135+
132136
if (mapViewTop != null) {
133137
mapViewTop.dispose();
134138
}

src/main/java/com/esri/samples/scene/calculate_distance_3d/CalculateDistance3dController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ private double convertToRadians(double degrees) {
228228
*/
229229
void terminate() {
230230

231+
// stop the animation
232+
animation.stop();
233+
231234
if (sceneView != null) {
232235
sceneView.dispose();
233236
}

src/main/java/com/esri/samples/scene/feature_layer_rendering_mode_scene/FeatureLayerRenderingModeSceneSample.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class FeatureLayerRenderingModeSceneSample extends Application {
4040

4141
private SceneView sceneViewTop;
4242
private SceneView sceneViewBottom;
43+
private Timeline timeline;
4344

4445
@Override
4546
public void start(Stage stage) throws Exception {
@@ -100,7 +101,7 @@ public void start(Stage stage) throws Exception {
100101
sceneViewBottom.setViewpointCamera(zoomOutCamera);
101102

102103
//loop an animation into and out from the zoom in point (5 seconds each) with a 2 second gap between zooming
103-
Timeline timeline = new Timeline();
104+
timeline = new Timeline();
104105
timeline.setCycleCount(Animation.INDEFINITE);
105106
timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(7), event -> zoomTo(zoomOutCamera, 5)));
106107
timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(14), event -> zoomTo(zoomInCamera, 5)));
@@ -129,6 +130,9 @@ private void zoomTo(Camera camera, int seconds) {
129130
@Override
130131
public void stop() {
131132

133+
// stop the timer
134+
timeline.stop();
135+
132136
if (sceneViewTop != null) {
133137
sceneViewTop.dispose();
134138
}

0 commit comments

Comments
 (0)