Skip to content

Commit a0ecdbc

Browse files
authored
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
1 parent cb3c83e commit a0ecdbc

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/main/java/com/esri/samples/scene/terrain_exaggeration/TerrainExaggerationController.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
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.

src/main/resources/fxml/terrain_exaggeration.fxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@
4848
</background>
4949
<Label text="Exaggeration"/>
5050
<Slider fx:id="exaggerationSlider" max="5" min="1" majorTickUnit="1" minorTickCount="0" showTickMarks="true"
51-
showTickLabels="true" snapToTicks="true"/>
51+
showTickLabels="true" snapToTicks="true" onMouseReleased="#changeElevationExaggeration"/>
5252
</VBox>
5353
</StackPane>

0 commit comments

Comments
 (0)