11/*
22 * Copyright 2017 Esri.
3- *
3+ *
44 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
55 * use this file except in compliance with the License. You may obtain a copy of
66 * the License at
7- *
7+ *
88 * http://www.apache.org/licenses/LICENSE-2.0
9- *
9+ *
1010 * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
1212 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -31,6 +31,7 @@ public class TerrainExaggerationController {
3131
3232 @ FXML private SceneView sceneView ;
3333 @ FXML private Slider exaggerationSlider ;
34+ private Surface surface ;
3435
3536 public void initialize () {
3637
@@ -44,18 +45,12 @@ public void initialize() {
4445 sceneView .setArcGISScene (scene );
4546
4647 // add base surface for elevation data
47- Surface surface = new Surface ();
48+ surface = new Surface ();
4849 final String elevationImageService =
49- "http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" ;
50+ "http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" ;
5051 surface .getElevationSources ().add (new ArcGISTiledElevationSource (elevationImageService ));
5152 scene .setBaseSurface (surface );
5253
53- // set exaggeration of surface to the value the user selected
54- exaggerationSlider .valueChangingProperty ().addListener (o -> {
55- if (!exaggerationSlider .isValueChanging ()) {
56- surface .setElevationExaggeration ((float ) exaggerationSlider .getValue ());
57- }
58- });
5954 // add a camera and initial camera position
6055 Point initialLocation = new Point (-119.94891542688772 , 46.75792111605992 , 0 , sceneView .getSpatialReference ());
6156 Camera camera = new Camera (initialLocation , 15000.0 , 40.0 , 60.0 , 0.0 );
@@ -66,6 +61,14 @@ public void initialize() {
6661 e .printStackTrace ();
6762 }
6863 }
64+
65+ /**
66+ * Sets the elevation exaggeration to the float chosen via the JavaFX slider.
67+ */
68+ @ FXML
69+ private void changeElevationExaggeration () {
70+ surface .setElevationExaggeration ((float ) exaggerationSlider .getValue ());
71+ }
6972
7073 /**
7174 * Disposes application resources.
0 commit comments