From a0ecdbc60d8801210fbac53aba78fead3c846086 Mon Sep 17 00:00:00 2001 From: Rachael Ellen <36415565+Rachael-E@users.noreply.github.com> Date: Fri, 31 May 2019 11:05:23 +0100 Subject: [PATCH 1/2] Allows user to click a value on slider to change exaggeration (#351) * Allows user to click a value on slider to change exaggeration * remove value changed listener, move annotation to correct place, add space before bracket --- .../TerrainExaggerationController.java | 25 +++++++++++-------- .../resources/fxml/terrain_exaggeration.fxml | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/esri/samples/scene/terrain_exaggeration/TerrainExaggerationController.java b/src/main/java/com/esri/samples/scene/terrain_exaggeration/TerrainExaggerationController.java index 64e03fb2cc..a24f745398 100644 --- a/src/main/java/com/esri/samples/scene/terrain_exaggeration/TerrainExaggerationController.java +++ b/src/main/java/com/esri/samples/scene/terrain_exaggeration/TerrainExaggerationController.java @@ -1,12 +1,12 @@ /* * Copyright 2017 Esri. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -31,6 +31,7 @@ public class TerrainExaggerationController { @FXML private SceneView sceneView; @FXML private Slider exaggerationSlider; + private Surface surface; public void initialize() { @@ -44,18 +45,12 @@ public void initialize() { sceneView.setArcGISScene(scene); // add base surface for elevation data - Surface surface = new Surface(); + surface = new Surface(); final String elevationImageService = - "http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"; + "http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"; surface.getElevationSources().add(new ArcGISTiledElevationSource(elevationImageService)); scene.setBaseSurface(surface); - // set exaggeration of surface to the value the user selected - exaggerationSlider.valueChangingProperty().addListener(o -> { - if (!exaggerationSlider.isValueChanging()) { - surface.setElevationExaggeration((float) exaggerationSlider.getValue()); - } - }); // add a camera and initial camera position Point initialLocation = new Point(-119.94891542688772, 46.75792111605992, 0, sceneView.getSpatialReference()); Camera camera = new Camera(initialLocation, 15000.0, 40.0, 60.0, 0.0); @@ -66,6 +61,14 @@ public void initialize() { e.printStackTrace(); } } + + /** + * Sets the elevation exaggeration to the float chosen via the JavaFX slider. + */ + @FXML + private void changeElevationExaggeration() { + surface.setElevationExaggeration((float) exaggerationSlider.getValue()); + } /** * Disposes application resources. diff --git a/src/main/resources/fxml/terrain_exaggeration.fxml b/src/main/resources/fxml/terrain_exaggeration.fxml index 3f60e2373a..578c7d3b7d 100644 --- a/src/main/resources/fxml/terrain_exaggeration.fxml +++ b/src/main/resources/fxml/terrain_exaggeration.fxml @@ -48,6 +48,6 @@