Skip to content

Commit 74c2be1

Browse files
committed
add background so you can see slider labels
1 parent a8737f3 commit 74c2be1

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/main/java/com/esri/samples/analysis/line_of_sight_geoelement/LineOfSightGeoElementSample.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@
2828
import javafx.geometry.Pos;
2929
import javafx.scene.Scene;
3030
import javafx.scene.control.Slider;
31+
import javafx.scene.layout.Background;
32+
import javafx.scene.layout.BackgroundFill;
33+
import javafx.scene.layout.CornerRadii;
3134
import javafx.scene.layout.StackPane;
35+
import javafx.scene.layout.VBox;
36+
import javafx.scene.paint.Paint;
3237
import javafx.stage.Stage;
3338
import javafx.util.Duration;
3439

@@ -80,6 +85,7 @@ public void start(Stage stage) {
8085
// create stack pane and JavaFX app scene
8186
StackPane stackPane = new StackPane();
8287
Scene fxScene = new Scene(stackPane);
88+
fxScene.getStylesheets().add(getClass().getResource("/css/style.css").toExternalForm());
8389

8490
// set title, size, and add JavaFX scene to stage
8591
stage.setTitle("Line of Sight GeoElement Sample");
@@ -129,15 +135,24 @@ public void start(Stage stage) {
129135
heightSlider.setMaxSize(30, 150);
130136
heightSlider.setShowTickLabels(true);
131137
heightSlider.setOrientation(Orientation.VERTICAL);
132-
stackPane.getChildren().add(heightSlider);
133-
StackPane.setAlignment(heightSlider, Pos.TOP_LEFT);
134-
StackPane.setMargin(heightSlider, new Insets(10, 0, 0, 10));
135138
heightSlider.valueProperty().addListener(e -> {
136139
PointBuilder pointBuilder = new PointBuilder((Point) observer.getGeometry());
137140
pointBuilder.setZ(heightSlider.getValue());
138141
observer.setGeometry(pointBuilder.toGeometry());
139142
});
140143

144+
// show a background behind the slider
145+
VBox controlsVBox = new VBox(6);
146+
controlsVBox.setBackground(new Background(new BackgroundFill(Paint.valueOf("rgba(0,0,0,0.3)"), CornerRadii.EMPTY,
147+
Insets.EMPTY)));
148+
controlsVBox.setPadding(new Insets(10.0));
149+
controlsVBox.setMaxSize(50, 160);
150+
controlsVBox.getStyleClass().add("panel-region");
151+
controlsVBox.getChildren().add(heightSlider);
152+
stackPane.getChildren().add(controlsVBox);
153+
StackPane.setAlignment(controlsVBox, Pos.TOP_LEFT);
154+
StackPane.setMargin(controlsVBox, new Insets(10, 0, 0, 10));
155+
141156
// create waypoints around a block for the taxi to drive to
142157
waypoints = Arrays.asList(
143158
new Point(-73.984513, 40.748469, SpatialReferences.getWgs84()),

0 commit comments

Comments
 (0)