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

The following examples show how to use javafx.scene.layout.VBox#setBackground() . 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: ProcessController.java    From tools-ocr with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ProcessController(){
    VBox vBox = new VBox();
    vBox.setAlignment(Pos.BASELINE_CENTER);
    vBox.setMinWidth(300);
    vBox.setBackground(new Background(new BackgroundFill(Color.rgb(250, 250, 250), CornerRadii.EMPTY, Insets.EMPTY)));
    ProgressIndicator progressIndicator = new ProgressIndicator();
    progressIndicator.setStyle(CommUtils.STYLE_TRANSPARENT);
    int circleSize = 75;
    progressIndicator.setMinWidth(circleSize);
    progressIndicator.setMinHeight(circleSize);
    Label topLab = new Label("正在识别图片,请稍等.....");
    topLab.setFont(Font.font(18));
    vBox.setSpacing(10);
    vBox.setPadding(new Insets(20, 0, 20, 0));
    vBox.getChildren().add(progressIndicator);
    vBox.getChildren().add(topLab);
    Scene scene = new Scene(vBox, Color.TRANSPARENT);
    setScene(scene);
    initStyle(StageStyle.TRANSPARENT);
    CommUtils.initStage(this);
}
 
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: KpiDashboard.java    From medusademo with Apache License 2.0 6 votes vote down vote up
@Override public void init() {
    Label title = new Label("December 2015");
    title.setFont(Font.font(24));

    revenue = getBulletChart("Revenue", "($'000)", 600, 500, new Section(0, 200, RED), new Section(200, 400, YELLOW), new Section(400, 600, GREEN));
    profit  = getBulletChart("Profit", "($'000)", 100, 70, new Section(0, 20, RED), new Section(20, 60, YELLOW), new Section(60, 100, GREEN));
    sales   = getBulletChart("Sales", "(unit)", 1000, 700, new Section(0, 300, RED), new Section(300, 500, YELLOW), new Section(500, 1000, GREEN));

    HBox legend = new HBox(getLegendBox(RED, "Poor", 10),
                           getLegendBox(YELLOW, "Average", 10),
                           getLegendBox(GREEN, "Good", 10),
                           getLegendBox(GRAY, "Target", 5));
    legend.setSpacing(20);
    legend.setAlignment(Pos.CENTER);

    pane = new VBox(title, revenue, profit, sales, legend);
    pane.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
    pane.setPadding(new Insets(20, 20, 20, 20));
    pane.setSpacing(10);
}
 
Example 4
Source File: PollenDashboard.java    From medusademo with Apache License 2.0 5 votes vote down vote up
@Override public void init() {
    GaugeBuilder builder = GaugeBuilder.create()
                                       .skinType(SkinType.INDICATOR)
                                       .prefWidth(150)
                                       .animated(true)
                                       .decimals(0)
                                       .sectionsVisible(true)
                                       .sections(new Section(0, 33, Color.rgb(34, 180, 11)),
                                                 new Section(33, 66, Color.rgb(255, 146, 0)),
                                                 new Section(66, 100, Color.rgb(255, 0, 39)));
    ragweed  = builder.build();
    birch    = builder.build();
    grass    = builder.build();
    olive    = builder.build();
    combined = builder.build();

    HBox ragweedBox  = getHBox("RAGWEED", ragweed);
    HBox birchBox    = getHBox("BIRCH", birch);
    HBox grassBox    = getHBox("GRASS", grass);
    HBox oliveBox    = getHBox("OLIVE", olive);
    HBox combinedBox = getHBox("COMBINED", combined);

    pane = new VBox(ragweedBox, new Separator(Orientation.HORIZONTAL),
                    birchBox, new Separator(Orientation.HORIZONTAL),
                    grassBox, new Separator(Orientation.HORIZONTAL),
                    oliveBox, new Separator(Orientation.HORIZONTAL),
                    combinedBox);
    pane.setPadding(new Insets(20, 20, 0, 20));
    pane.setSpacing(10);
    pane.setBackground(new Background(new BackgroundFill(Color.rgb(242, 242, 242), CornerRadii.EMPTY, Insets.EMPTY)));
}
 
Example 5
Source File: Demo.java    From Enzo with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    VBox pane = new VBox();
    pane.setPadding(new Insets(10, 10, 10, 10));
    pane.setBackground(new Background(new BackgroundFill(Color.web("#34495e"), CornerRadii.EMPTY, Insets.EMPTY)));
    pane.setSpacing(20);
    pane.setAlignment(Pos.CENTER);
    pane.getChildren().addAll(onOffSwitch, iconSwitchSymbol, iconSwitchText, iconSwitchSymbol1);

    Scene scene = new Scene(pane, 100, 150);

    stage.setTitle("OnOffSwitch");
    stage.setScene(scene);
    stage.show();
}
 
Example 6
Source File: PopupDemo.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
BoundsPopup(String buttonText) {
    super();
    button = new Button(buttonText);
    label = new Label();
    vbox = new VBox(button, label);
    vbox.setBackground(new Background(new BackgroundFill(Color.ALICEBLUE, null, null)));
    vbox.setPadding(new Insets(5));
    getContent().add(vbox);
}
 
Example 7
Source File: MainPane.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {
	Label titleLabel = new Label("", logoImageView);
	titleLabel.setStyle("-fx-text-fill: white;");

	titleHBox.setPadding(new Insets(5, 0, 0, 10));
	titleHBox.setPrefHeight(30);
	titleHBox.getChildren().add(titleLabel);

	topVBox.getChildren().add(titleHBox);
	topVBox.getChildren().add(userDataPane);

	listBaseStackPane.getChildren().add(tabPane);
	listBaseStackPane.getChildren().add(findListPane);

	centerBorderPane.setTop(searchBox);
	centerBorderPane.setCenter(listBaseStackPane);

	findTextField.setPromptText("搜索:联系人、多人聊天、群");
	findTextField.getStyleClass().remove("text-field");
	findTextField.setBackground(Background.EMPTY);
	findTextField.setMinHeight(30);
	findTextField.setStyle("-fx-prompt-text-fill:#ffffff;");

	Image image = ImageBox.getImageClassPath("/classics/images/main/search/search_icon.png");
	ImageView searchImageView = new ImageView();
	searchImageView.setImage(image);

	searchBox.getChildren().add(findTextField);
	searchBox.getChildren().add(searchImageView);
	HBox.setHgrow(findTextField, Priority.ALWAYS);

	searchBox.setAlignment(Pos.CENTER_RIGHT);
	searchBox.setStyle("-fx-background-color:rgba(0, 0, 0, 0.3)");

	tabPane.setStyle("-fx-background-color:rgba(230, 230, 230, 0.8)");

	functionBox.setBackground(Background.EMPTY);
	functionBox.setPadding(new Insets(0, 5, 5, 0));

	VBox separator = new VBox();
	separator.setPrefHeight(1);
	separator.setMinHeight(1);
	separator.setBackground(Background.EMPTY);
	// separator.setStyle("-fx-background-color:rgba(230, 230, 230, 1)");

	BorderPane bottomBorderPane = new BorderPane();
	bottomBorderPane.setCenter(functionBox);
	bottomBorderPane.setRight(rightFunctionBox);

	bottomBox.setPadding(new Insets(5, 2, 1, 2));
	bottomBox.setStyle("-fx-background-color:rgba(230, 230, 230, 0.7)");

	bottomBox.getChildren().add(separator);
	bottomBox.getChildren().add(bottomBorderPane);

	borderPane.setTop(topVBox);
	borderPane.setCenter(centerBorderPane);
	borderPane.setBottom(bottomBox);

	this.setCenter(borderPane);
	tabPane.setVisible(true);
	findListPane.setVisible(false);

	functionBox.setOnMouseEntered(m -> {
		functionBox.setCursor(Cursor.DEFAULT);
	});
}
 
Example 8
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 9
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 10
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 11
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 12
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 13
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();
  }
}
 
Example 14
Source File: JFXColorPalette.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
public JFXColorPalette(final JFXColorPicker colorPicker) {
    getStyleClass().add("color-palette-region");
    this.colorPicker = colorPicker;
    colorPickerGrid = new JFXColorGrid();
    colorPickerGrid.getChildren().get(0).requestFocus();
    customColorLabel.setAlignment(Pos.CENTER_LEFT);
    customColorLink.setPrefWidth(colorPickerGrid.prefWidth(-1));
    customColorLink.setAlignment(Pos.CENTER);
    customColorLink.setFocusTraversable(true);
    customColorLink.setOnAction(ev -> {
        if (customColorDialog == null) {
            customColorDialog = new JFXCustomColorPickerDialog(popupControl);
            customColorDialog.customColorProperty().addListener((ov, t1, t2) -> {
                colorPicker.setValue(customColorDialog.customColorProperty().get());
            });
            customColorDialog.setOnSave(() -> {
                Color customColor = customColorDialog.customColorProperty().get();
                buildCustomColors();
                colorPicker.getCustomColors().add(customColor);
                updateSelection(customColor);
                Event.fireEvent(colorPicker, new ActionEvent());
                colorPicker.hide();
            });
        }
        customColorDialog.setCurrentColor(colorPicker.valueProperty().get());
        if (popupControl != null) {
            popupControl.setAutoHide(false);
        }
        customColorDialog.show();
        customColorDialog.setOnHidden(event -> {
            if (popupControl != null) {
                popupControl.setAutoHide(true);
            }
        });
    });

    initNavigation();
    customColorGrid.getStyleClass().add("color-picker-grid");
    customColorGrid.setVisible(false);

    buildCustomColors();

    colorPicker.getCustomColors().addListener((Change<? extends Color> change) -> buildCustomColors());
    VBox paletteBox = new VBox();
    paletteBox.getStyleClass().add("color-palette");
    paletteBox.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
    paletteBox.setBorder(new Border(new BorderStroke(Color.valueOf("#9E9E9E"),
        BorderStrokeStyle.SOLID,
        CornerRadii.EMPTY,
        BorderWidths.DEFAULT)));
    paletteBox.getChildren().addAll(colorPickerGrid);
    if (colorPicker.getPreDefinedColors() == null) {
        paletteBox.getChildren().addAll(customColorLabel, customColorGrid, customColorLink);
    }

    hoverSquare.setMouseTransparent(true);
    hoverSquare.getStyleClass().addAll("hover-square");
    setFocusedSquare(null);

    getChildren().addAll(paletteBox, hoverSquare);
}