Java Code Examples for javafx.scene.layout.VBox#setMaxSize()

The following examples show how to use javafx.scene.layout.VBox#setMaxSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColorPickerApp.java    From oim-fx with MIT License 6 votes vote down vote up
public Parent createContent() {
    final ColorPicker colorPicker = new ColorPicker(Color.GREEN);
    final Label coloredText = new Label("Colors");
    Font font = new Font(53);
    coloredText.setFont(font);
    final Button coloredButton = new Button("Colored Control");
    Color c = colorPicker.getValue();
    coloredText.setTextFill(c);
    coloredButton.setStyle(createRGBString(c));
    
    colorPicker.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent t) {
            Color newColor = colorPicker.getValue();
            coloredText.setTextFill(newColor);
            coloredButton.setStyle(createRGBString(newColor));
        }
    });
    
    VBox outerVBox = new VBox(coloredText, coloredButton, colorPicker);
    outerVBox.setAlignment(Pos.CENTER);
    outerVBox.setSpacing(20);
    outerVBox.setMaxSize(VBox.USE_PREF_SIZE, VBox.USE_PREF_SIZE);
    
    return outerVBox;
}
 
Example 2
Source File: FxDisplay.java    From testing-video with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    Parent pane = root.get();

    double width = size.width;
    double height = size.height;

    VBox box = new VBox(pane);
    VBox.setVgrow(pane, ALWAYS);
    box.setMinSize(width, height);
    box.setPrefSize(width, height);
    box.setMaxSize(width, height);

    box.setBackground(new Background(new BackgroundFill(fill, null, null)));

    var scroll = new ScrollPane(box);
    var scene = new Scene(scroll);

    stage.setScene(scene);
    stage.show();
}
 
Example 3
Source File: ScreenShotFrameTest.java    From oim-fx with MIT License 5 votes vote down vote up
public Parent createContent() {
	Button button = new Button("Screen Shot");
	button.setOnAction(a->{
		frame.setVisible(true);
	});
	
	VBox outerVBox = new VBox(button);
	outerVBox.setAlignment(Pos.CENTER);
	outerVBox.setSpacing(20);
	outerVBox.setMaxSize(VBox.USE_PREF_SIZE, VBox.USE_PREF_SIZE);
	return outerVBox;
}
 
Example 4
Source File: UnitsContainerClassic.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
public UnitsContainerClassic(double maxwidth, double maxheight) {
    container = new VBox();
    container.getStyleClass().add("unitscontainer");
    container.setMaxSize(maxwidth, maxheight);
    scrollcontainer = new ScrollPane(container);
    scrollcontainer.setFitToWidth(true);
    scrollcontainer.setFocusTraversable(false);

    BorderPane.setAlignment(scrollcontainer, Pos.CENTER);            
}
 
Example 5
Source File: ButtonPair.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
@Override
    public Node constructContent() {

        goup = new Button();
        goup.setGraphic(IconBuilder.create(IconFontGlyph.FA_SOLID_CHEVRON_UP, 22.0).styleClass("icon-fill").build());
        goup.setContentDisplay(ContentDisplay.TOP);
        goup.getStyleClass().add("buttonbase");
        goup.getStyleClass().add("buttonup");
        VBox.setVgrow(goup, Priority.SOMETIMES);
        goup.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
        goup.setFocusTraversable(false);
        goup.setOnAction(event -> {
            device.sendStatus(roll ? device.rollNextStatus() : device.nextStatus());
        });

        godown = new Button();
        godown.setGraphic(IconBuilder.create(IconFontGlyph.FA_SOLID_CHEVRON_DOWN, 22.0).styleClass("icon-fill").build());
        godown.setContentDisplay(ContentDisplay.TOP);
        godown.getStyleClass().add("buttonbase");
        godown.getStyleClass().add("buttondown");
        VBox.setVgrow(godown, Priority.SOMETIMES);
        godown.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
        godown.setFocusTraversable(false);
        godown.setOnAction(event -> {
            device.sendStatus(roll ? device.rollPrevStatus() : device.prevStatus());
        });

//        setIconStatus(IconStatus.valueOf("TEXT/ON/OFF"));
        VBox content = new VBox(goup, godown);
        content.setSpacing(4);
        VBox.setVgrow(content, Priority.SOMETIMES);
        content.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
        return content;
    }
 
Example 6
Source File: UnitsContainerFull.java    From helloiot with GNU General Public License v3.0 4 votes vote down vote up
public UnitsContainerFull(double maxwidth, double maxheight) {
    container = new VBox();
    container.setMaxSize(maxwidth, maxheight);
    BorderPane.setAlignment(container, Pos.CENTER);
}
 
Example 7
Source File: HonorMobileMapPackageExpirationDateSample.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

  try {
    // create stack pane and application scene
    StackPane stackPane = new StackPane();
    Scene scene = new Scene(stackPane);
    scene.getStylesheets().add(getClass().getResource("/honor_mobile_map_package_expiration_date/style.css").toExternalForm());

    // set title, size, and add scene to stage
    stage.setTitle("Honor Mobile Map Package Expiration Date Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(scene);
    stage.show();

    // create an overlay to display the expiration information
    VBox expirationMessageVbox = new VBox(6);
    expirationMessageVbox.setBackground(new Background(new BackgroundFill(Paint.valueOf("rgba(0,0,0,0.3)"), CornerRadii.EMPTY,
            Insets.EMPTY)));
    expirationMessageVbox.setPadding(new Insets(10.0));
    expirationMessageVbox.setMaxSize(800, 150);
    expirationMessageVbox.setAlignment(Pos.CENTER);
    expirationMessageVbox.getStyleClass().add("panel-region");

    // create a label to display the expiration message and expiration date
    Label expirationDetailsLabel = new Label();
    expirationMessageVbox.getStyleClass().add("label");

    // add the labels to the overlay
    expirationMessageVbox.getChildren().add(expirationDetailsLabel);

    // create a map view
    mapView = new MapView();

    // load the mobile map package
    File mmpkFile = new File(System.getProperty("data.dir"), "./samples-data/mmpk/LothianRiversAnno.mmpk");
    mobileMapPackage = new MobileMapPackage(mmpkFile.getAbsolutePath());
    mobileMapPackage.loadAsync();
    mobileMapPackage.addDoneLoadingListener(() -> {
      // check if the map package has expiration information and if so, has it expired yet
      if (mobileMapPackage.getExpiration() != null && mobileMapPackage.getExpiration().isExpired()) {

        // get the expiration of the mobile map package
        Expiration expiration = mobileMapPackage.getExpiration();

        // get the expiration message
        String expirationMessage = expiration.getMessage();

        // get the expiration date
        SimpleDateFormat daysHoursFormat = new SimpleDateFormat("EEE',' d MMM yyyy 'at' hh:mm:ss a", Locale.US);
        String expirationDate = daysHoursFormat.format(expiration.getDateTime().getTimeInMillis());

        // set the expiration message to the label
        expirationDetailsLabel.setText(expirationMessage + "\n Mobile map package expired on: " + expirationDate + ".");

        // load the expired map if it is still accessible after expiration
        if (mobileMapPackage.getExpiration().getType() == ExpirationType.ALLOW_EXPIRED_ACCESS && mobileMapPackage.getLoadStatus() == LoadStatus.LOADED && !mobileMapPackage.getMaps().isEmpty()) {
          // add the map from the mobile map package to the map view
          mapView.setMap(mobileMapPackage.getMaps().get(0));

          // show an alert if the mobile map package is not accessible after expiration
        } else if (mobileMapPackage.getExpiration().getType() == ExpirationType.PREVENT_EXPIRED_ACCESS) {
          new Alert(Alert.AlertType.ERROR, "The author of this mobile map package has disallowed access after the expiration date.").show();
        }

        // show the map if it is not expired
      } else if (mobileMapPackage.getLoadStatus() == LoadStatus.LOADED && !mobileMapPackage.getMaps().isEmpty()) {
        // add the map from the mobile map package to the map view
        mapView.setMap(mobileMapPackage.getMaps().get(0));

      } else {
        new Alert(Alert.AlertType.ERROR, "Failed to load the mobile map package.").show();
      }
    });

    // add the map view and overlay to the stack pane
    stackPane.getChildren().addAll(mapView, expirationMessageVbox);
    StackPane.setAlignment(expirationMessageVbox, Pos.CENTER);

  } catch (Exception e) {
    // on any error, display the stack trace
    e.printStackTrace();
  }
}
 
Example 8
Source File: ChangeAtmosphereEffectSample.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

  try {
    // create stack pane and JavaFX app scene
    StackPane stackPane = new StackPane();
    Scene fxScene = new Scene(stackPane);
    fxScene.getStylesheets().add(getClass().getResource("/change_atmosphere_effect/style.css").toExternalForm());

    // set title, size, and add JavaFX scene to stage
    stage.setTitle("Change Atmosphere Effect Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(fxScene);
    stage.show();

    // create a scene and add a basemap to it
    ArcGISScene scene = new ArcGISScene();
    scene.setBasemap(Basemap.createImagery());

    // set the scene to a scene view
    sceneView = new SceneView();
    sceneView.setArcGISScene(scene);

    // add base surface for elevation data
    Surface surface = new Surface();
    ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(
            "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");
    surface.getElevationSources().add(elevationSource);
    scene.setBaseSurface(surface);

    // add a camera and initial camera position
    Camera camera = new Camera(64.416919, -14.483728, 100, 318, 105, 0);
    sceneView.setViewpointCamera(camera);

    // create a control panel
    VBox controlsVBox = new VBox(6);
    controlsVBox.setBackground(new Background(new BackgroundFill(Paint.valueOf("rgba(0, 0, 0, 0.3)"),
        CornerRadii.EMPTY, Insets.EMPTY)));
    controlsVBox.setPadding(new Insets(10.0));
    controlsVBox.setMaxSize(260, 110);
    controlsVBox.getStyleClass().add("panel-region");

    // create buttons to set each atmosphere effect
    Button noAtmosphereButton = new Button("No Atmosphere Effect");
    Button realisticAtmosphereButton = new Button ("Realistic Atmosphere Effect");
    Button horizonAtmosphereButton = new Button ("Horizon Only Atmosphere Effect");
    noAtmosphereButton.setMaxWidth(Double.MAX_VALUE);
    realisticAtmosphereButton.setMaxWidth(Double.MAX_VALUE);
    horizonAtmosphereButton.setMaxWidth(Double.MAX_VALUE);

    noAtmosphereButton.setOnAction(event -> sceneView.setAtmosphereEffect(AtmosphereEffect.NONE));
    realisticAtmosphereButton.setOnAction(event -> sceneView.setAtmosphereEffect(AtmosphereEffect.REALISTIC));
    horizonAtmosphereButton.setOnAction(event -> sceneView.setAtmosphereEffect(AtmosphereEffect.HORIZON_ONLY));

    // add buttons to the control panel
    controlsVBox.getChildren().addAll(noAtmosphereButton, realisticAtmosphereButton, horizonAtmosphereButton);

    // add scene view and control panel to the stack pane
    stackPane.getChildren().addAll(sceneView, controlsVBox);
    StackPane.setAlignment(controlsVBox, Pos.TOP_RIGHT);
    StackPane.setMargin(controlsVBox, new Insets(10, 0, 0, 10));
  } catch (Exception e) {
    // on any error, display the stack trace.
    e.printStackTrace();
  }
}
 
Example 9
Source File: ChooseCameraControllerSample.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage){

  try {

    // create stack pane and JavaFX app scene
    StackPane stackPane = new StackPane();
    Scene fxScene = new Scene(stackPane);
    fxScene.getStylesheets().add(getClass().getResource("/choose_camera_controller/style.css").toExternalForm());

    // set title, size, and add JavaFX scene to stage
    stage.setTitle("Choose Camera Controller Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(fxScene);
    stage.show();

    // create a scene and add a basemap to it
    ArcGISScene scene = new ArcGISScene();
    scene.setBasemap(Basemap.createImagery());

    // set the scene to a scene view
    sceneView = new SceneView();
    sceneView.setArcGISScene(scene);

    // add base surface for elevation data
    Surface surface = new Surface();
    ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource("https://elevation3d.arcgis" +
            ".com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");
    surface.getElevationSources().add(elevationSource);
    scene.setBaseSurface(surface);

    // create a graphics overlay for the scene
    GraphicsOverlay sceneGraphicsOverlay = new GraphicsOverlay();
    sceneView.getGraphicsOverlays().add(sceneGraphicsOverlay);

    // create a graphic with a ModelSceneSymbol of a plane to add to the scene
    String modelURI = new File(System.getProperty("data.dir"), "./samples-data/bristol/Collada/Bristol.dae").getAbsolutePath();
    ModelSceneSymbol plane3DSymbol = new ModelSceneSymbol(modelURI, 1.0);
    plane3DSymbol.loadAsync();
    plane3DSymbol.setHeading(45);
    Graphic plane3D = new Graphic(new Point(-109.937516, 38.456714, 5000, SpatialReferences.getWgs84()), plane3DSymbol);
    sceneGraphicsOverlay.getSceneProperties().setSurfacePlacement(LayerSceneProperties.SurfacePlacement.ABSOLUTE);
    sceneGraphicsOverlay.getGraphics().add(plane3D);

    // create a camera and set it as the viewpoint for when the scene loads
    Camera camera = new Camera(38.459291, -109.937576, 5500, 150.0, 20.0, 0.0);
    sceneView.setViewpointCamera(camera);

    // instantiate a new camera controller which orbits the plane at a set distance
    OrbitGeoElementCameraController orbitPlaneCameraController = new OrbitGeoElementCameraController(plane3D, 100.0);
    orbitPlaneCameraController.setCameraPitchOffset(30);
    orbitPlaneCameraController.setCameraHeadingOffset(150);

    // instantiate a new camera controller which orbits a target location
    Point locationPoint = new Point(-109.929589, 38.437304, 1700, SpatialReferences.getWgs84());
    OrbitLocationCameraController orbitLocationCameraController = new OrbitLocationCameraController(locationPoint, 5000);
    orbitLocationCameraController.setCameraPitchOffset(3);
    orbitLocationCameraController.setCameraHeadingOffset(150);

    // create radio buttons for choosing camera controller
    RadioButton orbitPlane = new RadioButton("ORBIT CAMERA AROUND PLANE");
    RadioButton orbitLocation = new RadioButton("ORBIT CAMERA AROUND CRATER");
    RadioButton globeCamera = new RadioButton("FREE PAN ROUND THE GLOBE");
    globeCamera.setSelected(true);

    // set the buttons to a toggle group
    ToggleGroup toggleGroup = new ToggleGroup();
    orbitPlane.setToggleGroup(toggleGroup);
    orbitLocation.setToggleGroup(toggleGroup);
    globeCamera.setToggleGroup(toggleGroup);

    // set the radio buttons to choose which camera controller is active
    orbitPlane.setOnAction(event -> sceneView.setCameraController(orbitPlaneCameraController));

    orbitLocation.setOnAction(event -> sceneView.setCameraController(orbitLocationCameraController));

    globeCamera.setOnAction(event -> sceneView.setCameraController(new GlobeCameraController()));

    // create a control panel
    VBox controlsVBox = new VBox(10);
    controlsVBox.setBackground(new Background(new BackgroundFill(Paint.valueOf("rgba(0, 0, 0, 0.3)"), CornerRadii.EMPTY, Insets.EMPTY)));
    controlsVBox.setPadding(new Insets(10.0));
    controlsVBox.setMaxSize(300, 80);
    controlsVBox.getStyleClass().add("panel-region");
    // add radio buttons to the control panel
    controlsVBox.getChildren().addAll(orbitPlane, orbitLocation, globeCamera);

    // add scene view, label and control panel to the stack pane
    stackPane.getChildren().addAll(sceneView, controlsVBox);
    StackPane.setAlignment(controlsVBox, Pos.TOP_LEFT);
    StackPane.setMargin(controlsVBox, new Insets(60, 0, 0, 20));

  } catch (Exception e) {
    // on any exception, print the stack trace
    e.printStackTrace();
  }
}
 
Example 10
Source File: SimpleLineSymbolSample.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

  try {
    // create stack pane and application scene
    StackPane stackPane = new StackPane();
    Scene scene = new Scene(stackPane);
    scene.getStylesheets().add(getClass().getResource("/simple_line_symbol/style.css").toExternalForm());

    // set title, size, and add scene to stage
    stage.setTitle("Simple Line Symbol Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(scene);
    stage.show();

    // create a control panel
    VBox controlsVBox = new VBox(6);
    controlsVBox.setBackground(new Background(new BackgroundFill(Paint.valueOf("rgba(0,0,0,0.3)"), CornerRadii.EMPTY,
        Insets.EMPTY)));
    controlsVBox.setPadding(new Insets(10.0));
    controlsVBox.setMaxSize(180, 200);
    controlsVBox.getStyleClass().add("panel-region");

    createSymbolFunctionality(controlsVBox);

    final ArcGISMap map = new ArcGISMap(Basemap.createImagery());

    // set initial map view point
    Point point = new Point(-226773, 6550477, SpatialReferences.getWebMercator());
    Viewpoint viewpoint = new Viewpoint(point, 7200); // point, scale
    map.setInitialViewpoint(viewpoint);

    // create a view for this ArcGISMap and set ArcGISMap to it
    mapView = new MapView();
    mapView.setMap(map);

    // creates a line from two points
    PointCollection points = new PointCollection(SpatialReferences.getWebMercator());
    points.add(-226913, 6550477);
    points.add(-226643, 6550477);
    Polyline line = new Polyline(points);

    // creates a solid red (0xFFFF0000) simple line symbol
    lineSymbol = new SimpleLineSymbol(Style.SOLID, 0xFFFF0000, 3);

    // add line with symbol to graphics overlay and add overlay to map view
    GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
    mapView.getGraphicsOverlays().add(graphicsOverlay);
    graphicsOverlay.getGraphics().add(new Graphic(line, lineSymbol));

    // add the map view and control panel to stack pane
    stackPane.getChildren().addAll(mapView, controlsVBox);
    StackPane.setAlignment(controlsVBox, Pos.TOP_LEFT);
    StackPane.setMargin(controlsVBox, new Insets(10, 0, 0, 10));
  } catch (Exception e) {
    // on any error, display the stack trace
    e.printStackTrace();
  }
}
 
Example 11
Source File: SimpleFillSymbolSample.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

  try {
    // create stack pane and application scene
    StackPane stackPane = new StackPane();
    Scene scene = new Scene(stackPane);
    scene.getStylesheets().add(getClass().getResource("/simple_fill_symbol/style.css").toExternalForm());

    // set title, size, and add scene to stage
    stage.setTitle("Simple Fill Symbol Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(scene);
    stage.show();

    // create a control panel
    controlsVBox = new VBox(6);
    controlsVBox.setBackground(new Background(new BackgroundFill(Paint.valueOf("rgba(0,0,0,0.3)"), CornerRadii.EMPTY,
        Insets.EMPTY)));
    controlsVBox.setPadding(new Insets(10.0));
    controlsVBox.setMaxSize(180, 200);
    controlsVBox.getStyleClass().add("panel-region");

    createSymbolFunctionality();

    final ArcGISMap map = new ArcGISMap(Basemap.createTopographic());

    // set initial map view point
    Point initialPoint = new Point(-12000000, 5400000, SpatialReferences.getWebMercator());
    Viewpoint viewpoint = new Viewpoint(initialPoint, 10000000); // point, scale
    map.setInitialViewpoint(viewpoint);

    // create a view for this ArcGISMap and set ArcGISMap to it
    mapView = new MapView();
    mapView.setMap(map);

    // creates a square from four points
    PointCollection points = new PointCollection(SpatialReferences.getWebMercator());
    points.add(-1.1579397849033352E7, 5618494.623878779);
    points.add(-1.158486021463032E7, 5020365.591010623);
    points.add(-1.236324731219847E7, 5009440.859816683);
    points.add(-1.2360516129399985E7, 5621225.806677263);
    Polygon square = new Polygon(points);

    // transparent red (0x88FF0000) color symbol
    fillSymbol = new SimpleFillSymbol(Style.SOLID, 0x88FF0000, null);

    // renders graphics to the GeoView
    GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
    mapView.getGraphicsOverlays().add(graphicsOverlay);
    graphicsOverlay.getGraphics().add(new Graphic(square, fillSymbol));

    createLineSymbols();

    // add the map view and control panel to stack pane
    stackPane.getChildren().addAll(mapView, controlsVBox);
    StackPane.setAlignment(controlsVBox, Pos.TOP_LEFT);
    StackPane.setMargin(controlsVBox, new Insets(10, 0, 0, 10));

  } catch (Exception e) {
    // on any error, display the stack trace
    e.printStackTrace();
  }
}
 
Example 12
Source File: EditKMLGroundOverlaySample.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

  try {
    // create stack pane and application scene
    StackPane stackPane = new StackPane();
    Scene fxScene = new Scene(stackPane);
    fxScene.getStylesheets().add(getClass().getResource("/edit_kml_ground_overlay/style.css").toExternalForm());

    // set title, size and add application scene to stage
    stage.setTitle("Edit KML Ground Overlay Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(fxScene);
    stage.show();

    // create a scene and add it to the scene view
    ArcGISScene scene = new ArcGISScene(Basemap.createImagery());
    sceneView = new SceneView();
    sceneView.setArcGISScene(scene);

    // create a geometry for the ground overlay
    Envelope overlayGeometry = new Envelope(-123.066227926904, 44.04736963555683, -123.0796942287304, 44.03878298600624, SpatialReferences.getWgs84());

    // create a KML icon for the overlay image
    String overlayImageURI = new File(System.getProperty("data.dir"), "./samples-data/images/1944.jpg").getAbsolutePath();
    KmlIcon overlayImage = new KmlIcon(overlayImageURI);

    // create the KML ground overlay
    KmlGroundOverlay kmlGroundOverlay = new KmlGroundOverlay(overlayGeometry, overlayImage);

    // set the rotation of the ground overlay to correct the overlay's rotation with respect to the basemap
    kmlGroundOverlay.setRotation(-3.046024799346924);

    // create a KML dataset with the ground overlay as the root node
    KmlDataset kmlDataset = new KmlDataset(kmlGroundOverlay);

    // create a KML layer using the KML dataset
    KmlLayer kmlLayer = new KmlLayer(kmlDataset);

    // add the KML layer to the scene view
    sceneView.getArcGISScene().getOperationalLayers().add(kmlLayer);

    // set the viewpoint to the ground overlay
    sceneView.setViewpoint(new Viewpoint(overlayGeometry, new Camera(overlayGeometry.getCenter(), 1250, 45, 60, 0)));

    // create a slider for adjusting the overlay opacity
    Slider slider = new Slider(0, 1, 1);
    slider.setMaxWidth(300);

    // add a listener to the slider's value property to set the opacity of the KML ground overlay
    slider.valueProperty().addListener(o ->
            kmlGroundOverlay.setColor(ColorUtil.colorToArgb(new Color(0, 0, 0, slider.getValue())))
    );

    // create a controls box
    VBox controlsVBox = new VBox();
    controlsVBox.setBackground(new Background(new BackgroundFill(Paint.valueOf("rgba(0,0,0,0.5)"), CornerRadii.EMPTY,
            Insets.EMPTY)));
    controlsVBox.setPadding(new Insets(10.0));
    controlsVBox.setSpacing(5);
    controlsVBox.setMaxSize(250, 20);
    controlsVBox.setAlignment(Pos.CENTER);
    controlsVBox.getStyleClass().add("panel-region");

    // create a label for the slider
    Label label = new Label("Overlay Opacity");
    // add the slider and label to the controls box
    controlsVBox.getChildren().addAll(label, slider);

    // add the scene view and controls to the stack pane
    stackPane.getChildren().addAll(sceneView, controlsVBox);
    StackPane.setAlignment(controlsVBox, Pos.TOP_LEFT);
    StackPane.setMargin(controlsVBox, new Insets(10, 0, 0, 10));

  } catch (Exception e) {
    // on any error, display the stack trace.
    e.printStackTrace();
  }
}