Java Code Examples for javafx.stage.Stage#setHeight()

The following examples show how to use javafx.stage.Stage#setHeight() . 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: NaviSelectDemo.java    From tornadofx-controls with Apache License 2.0 6 votes vote down vote up
/**
 * Select value example. Implement whatever technique you want to change value of the NaviSelect
 */
private void selectEmail(NaviSelect<Email> navi) {
	Stage dialog = new Stage(StageStyle.UTILITY);
	dialog.setTitle("Choose person");
	ListView<Email> listview = new ListView<>(FXCollections.observableArrayList(
		new Email("[email protected]", "John Doe"),
		new Email("[email protected]", "Jane Doe"),
		new Email("[email protected]", "Some Dude")
	));
	listview.setOnMouseClicked(event -> {
		Email item = listview.getSelectionModel().getSelectedItem();
		if (item != null) {
			navi.setValue(item);
			dialog.close();
		}
	});
	dialog.setScene(new Scene(listview));
	dialog.setWidth(navi.getWidth());
	dialog.initModality(Modality.APPLICATION_MODAL);
	dialog.setHeight(100);
	dialog.showAndWait();
}
 
Example 2
Source File: LoginController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
public void loadLabAssistant(String username)
{
    Stage stage = new Stage();
    LabAssistantController lab = new LabAssistantController(username);
    lab.loadProfileData(); 
    lab.fillPieChart();
    lab.setAppointments();
    lab.fillLabAppiontments();
    lab.addFocusListener();
    lab.setPaceholders();
    lab.fillTodayAppointments();
    
    stage.setScene(new Scene(lab));
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    stage.initStyle(StageStyle.UNDECORATED);
    stage.show();
}
 
Example 3
Source File: Main.java    From Everest with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    SettingsLoader settingsLoader = new SettingsLoader();
    settingsLoader.settingsLoaderThread.join();

    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/homewindow/HomeWindow.fxml"));
    Parent homeWindow = loader.load();
    Stage dashboardStage = new Stage();
    ThemeManager.setTheme(homeWindow);

    Rectangle2D screenBounds = Screen.getPrimary().getBounds();
    dashboardStage.setWidth(screenBounds.getWidth() * 0.83);
    dashboardStage.setHeight(screenBounds.getHeight() * 0.74);

    dashboardStage.getIcons().add(new Image(getClass().getResource("/assets/Logo.png").toExternalForm()));
    dashboardStage.setScene(new Scene(homeWindow));
    dashboardStage.setTitle(APP_NAME);
    dashboardStage.show();
}
 
Example 4
Source File: JavaFXTableViewElementScrollTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void scrollToCell() throws Throwable {
    Stage primaryStage = getPrimaryStage();
    primaryStage.setWidth(250);
    primaryStage.setHeight(250);
    TableView<?> tableViewNode = (TableView<?>) primaryStage.getScene().getRoot().lookup(".table-view");
    Platform.runLater(() -> {
        tableViewNode.getSelectionModel().setCellSelectionEnabled(true);
        tableView.marathon_select("{\"cells\":[[\"10\",\"Email\"]]}");
    });
    new Wait("Waiting for the point to be in viewport") {
        @Override
        public boolean until() {
            return getPoint(tableViewNode, 2, 10) != null;
        }
    };
    Point2D point = getPoint(tableViewNode, 2, 10);
    AssertJUnit.assertTrue(tableViewNode.getBoundsInLocal().contains(point));
}
 
Example 5
Source File: SysUserController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
public void showSuccessIndicator()
{
    Stage stage= new Stage();
    SuccessIndicatorController success = new SuccessIndicatorController();
    Scene scene = new Scene(success);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show();
}
 
Example 6
Source File: MapperGenApplication.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
@Override
    public void start(Stage primaryStage) throws Exception {
        applicationContext.getBeanFactory().registerSingleton("primaryStage", primaryStage);

        fxmlLoader.setLocation(getClass().getResource("/fxml/main.fxml"));
        Parent root = fxmlLoader.load();

//        primaryStage.initStyle(StageStyle.UNDECORATED);
        primaryStage.setScene(new Scene(root));
        //图标
        primaryStage.getIcons().add(new Image("/image/icon.png"));
        primaryStage.setWidth(1200);
        primaryStage.setHeight(700);
        primaryStage.setTitle("mapper 生成小工具");
//        primaryStage.setOnCloseRequest(event -> {
//            closeDialog(primaryStage);
//        });
        primaryStage.show();
    }
 
Example 7
Source File: CashierController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
@FXML
public void showRefundTable()
{
    Stage stage= new Stage();
    RefundController refundTable = new RefundController(this);
  
    refundTable.fillRefundTable();
    
    Scene scene = new Scene(refundTable);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show();

}
 
Example 8
Source File: ACEEditorSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage stage) throws IOException {
    INITIAL_TEXT = new String(IOUtils.toByteArray(ACEEditorSample.class.getResourceAsStream("/aceeditor.js")));
    stage.setTitle("HTMLEditor Sample");
    stage.setWidth(650);
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox root = new VBox();
    root.setPadding(new Insets(8, 8, 8, 8));
    root.setSpacing(5);
    root.setAlignment(Pos.BOTTOM_LEFT);

    final ACEEditor htmlEditor = new ACEEditor(true, 1, true);
    htmlEditor.setText(INITIAL_TEXT);
    htmlEditor.setMode("javascript");

    root.getChildren().addAll(htmlEditor.getNode());
    scene.setRoot(root);

    stage.setScene(scene);
    stage.show();
}
 
Example 9
Source File: ScaleBarSample.java    From arcgis-runtime-samples-java with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) {

  // create stack pane and application scene
  StackPane stackPane = new StackPane();
  Scene scene = new Scene(stackPane);

  // set title, size and scene to stage
  stage.setTitle("Scale Bar Sample");
  stage.setWidth(800);
  stage.setHeight(700);
  stage.setScene(scene);
  stage.show();

  // create a map view
  mapView = new MapView();
  ArcGISMap map = new ArcGISMap(Basemap.Type.IMAGERY, 64.1405, -16.2426, 16);
  mapView.setMap(map);

  // create a scale bar for the map view
  Scalebar scaleBar = new Scalebar(mapView);

  // specify skin style for the scale bar
  scaleBar.setSkinStyle(Scalebar.SkinStyle.GRADUATED_LINE);

  // set the unit system (default is METRIC)
  scaleBar.setUnitSystem(UnitSystem.IMPERIAL);

  // to enhance visibility of the scale bar, by making background transparent
  Color transparentWhite = new Color(1, 1, 1, 0.7);
  scaleBar.setBackground(new Background(new BackgroundFill(transparentWhite, new CornerRadii(5), Insets.EMPTY)));

  // add the map view and scale bar to stack pane
  stackPane.getChildren().addAll(mapView, scaleBar);

  // set position of scale bar
  StackPane.setAlignment(scaleBar, Pos.BOTTOM_CENTER);
  // give padding to scale bar
  StackPane.setMargin(scaleBar, new Insets(0, 0, 50, 0));
}
 
Example 10
Source File: DisplayMapSample.java    From arcgis-runtime-samples-java with Apache License 2.0 5 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);

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

    // create a map with the imagery basemap
    ArcGISMap map = new ArcGISMap(Basemap.createImagery());

    // create a map view and set its map
    mapView = new MapView();
    mapView.setMap(map);

    // add the map view to stack pane
    stackPane.getChildren().addAll(mapView);
  } catch (Exception e) {
    // on any error, display the stack trace.
    e.printStackTrace();
  }
}
 
Example 11
Source File: BoundsTests.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    super.start(stage);
    stage.setHeight(50);

    // insure caret is always visible
    area.setShowCaret(Caret.CaretVisibility.ON);
    area.replaceText(MANY_PARS_OF_TEXT);
    area.moveTo(0);
    area.showParagraphAtTop(0);
}
 
Example 12
Source File: ChoiceBoxDemo.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {

	VBox vbox = new VBox();
	vbox.setPadding(new Insets(10));
	vbox.setAlignment(Pos.CENTER);
	vbox.setSpacing(10);
	
	Label label = new Label("Make Yes/No Selection");
	
	ChoiceBox<Pair<String, String>> cb = new ChoiceBox<>();
	cb.setItems( Constants.LIST_YES_NO );
	cb.setConverter( new PairStringConverter() );
	cb.setValue( Constants.PAIR_NO );
	
	Label labelOpt = new Label("Make Yes/No Selection (Optional)");

	ChoiceBox<Pair<String, String>> cbOpt = new ChoiceBox<>();
	cbOpt.setItems( Constants.LIST_YES_NO_OPT );
	cbOpt.setConverter(new PairStringConverter(true) );
	cbOpt.setValue( Constants.PAIR_NULL );
	
	Button b = new Button("Save");
	b.setOnAction( (evt) -> 
		System.out.println("Selections - yes/no was '" + cb.getValue() + "' and yes/no/opt was '" + cbOpt.getValue() + "'")
	);
	
	vbox.getChildren().addAll(label, cb, labelOpt, cbOpt, b);
	
	Scene scene = new Scene(vbox);
	
	primaryStage.setTitle("Choice Box Demo");
	primaryStage.setHeight(200);
	primaryStage.setWidth(300);
	primaryStage.setScene( scene );
	primaryStage.show();
}
 
Example 13
Source File: OpenStreetMapLayerSample.java    From arcgis-runtime-samples-java with Apache License 2.0 5 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);

    // set title, size, and add scene to stage
    stage.setTitle("Open Street Map Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(scene);
    stage.show();

    // create map with an OpenStreetMap basemap
    ArcGISMap map = new ArcGISMap(Basemap.Type.OPEN_STREET_MAP, 34.056295, -117.195800, 10);
    
    // set the map to a map view
    mapView = new MapView();
    mapView.setMap(map);

    // add the map view to stack pane
    stackPane.getChildren().add(mapView);
  } catch (Exception e) {
    // on any error, display the stack trace.
    e.printStackTrace();
  }
}
 
Example 14
Source File: UndecoratorScene.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * UndecoratorScene constructor
 *
 * @param stage The main stage
 * @param stageStyle could be StageStyle.UTILITY or StageStyle.TRANSPARENT
 * @param root your UI to be displayed in the Stage
 * @param stageDecorationFxml Your own Stage decoration or null to use the
 * built-in one
 */
public UndecoratorScene(Stage stage, StageStyle stageStyle, Region root, String stageDecorationFxml) {
    super(root);
    myRoot = root;
    /*
     * Fxml
     */
    if (stageDecorationFxml == null) {
        if (stageStyle == StageStyle.UTILITY) {
            stageDecorationFxml = STAGEDECORATION_UTILITY;
        } else {
            stageDecorationFxml = STAGEDECORATION;
        }
    }
    undecorator = new Undecorator(stage, root, stageDecorationFxml, stageStyle);
    super.setRoot(undecorator);

    // Customize it by CSS if needed:
    if (stageStyle == StageStyle.UTILITY) {
        undecorator.getStylesheets().add(STYLESHEET_UTILITY);
    } else {
        undecorator.getStylesheets().add(STYLESHEET);
    }

    // Transparent scene and stage
    if (stage.getStyle() != StageStyle.TRANSPARENT) {
        stage.initStyle(StageStyle.TRANSPARENT);
    }
    super.setFill(Color.TRANSPARENT);

    // Default Accelerators
    undecorator.installAccelerators(this);

    // Forward pref and max size to main stage
    stage.setMinWidth(undecorator.getMinWidth());
    stage.setMinHeight(undecorator.getMinHeight());
    stage.setWidth(undecorator.getPrefWidth());
    stage.setHeight(undecorator.getPrefHeight());
}
 
Example 15
Source File: GroupLayersSample.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

  try {

    // set the title and size of the stage and show it
    StackPane stackPane = new StackPane();
    Scene fxScene = new Scene(stackPane);
    stage.setTitle("Group Layers Sample");
    stage.setWidth(800);
    stage.setHeight(700);

    // create a JavaFX scene with a stackpane and set it to the stage
    stage.setScene(fxScene);
    stage.show();

    // create a scene view and add it to the stack pane
    sceneView = new SceneView();
    stackPane.getChildren().add(sceneView);

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

    // set the base surface with world elevation
    Surface surface = new Surface();
    surface.getElevationSources().add(new ArcGISTiledElevationSource("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"));
    scene.setBaseSurface(surface);

    // create different types of layers
    ArcGISSceneLayer devABuildings = new ArcGISSceneLayer("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_BuildingShells/SceneServer");
    ArcGISSceneLayer devBBuildings = new ArcGISSceneLayer("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevB_BuildingShells/SceneServer");
    ArcGISSceneLayer devATrees = new ArcGISSceneLayer("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_Trees/SceneServer");
    FeatureLayer devAPathways = new FeatureLayer(new ServiceFeatureTable(" https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_Pathways/FeatureServer/1"));
    FeatureLayer devProjectArea = new FeatureLayer(new ServiceFeatureTable("https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/DevelopmentProjectArea/FeatureServer/0"));

    // create a group layer from scratch by adding the layers as children
    groupLayer = new GroupLayer();
    groupLayer.setName("Group: Dev A");
    groupLayer.getLayers().addAll(Arrays.asList(devATrees, devAPathways, devABuildings));

    // add the group layer and other layers to the scene as operational layers
    scene.getOperationalLayers().addAll(Arrays.asList(groupLayer, devBBuildings, devProjectArea));

    // zoom to the extent of the group layer when the child layers are loaded
    groupLayer.getLayers().forEach(childLayer ->
      childLayer.addDoneLoadingListener(() -> {
        if (childLayer.getLoadStatus() == LoadStatus.LOADED) {
          sceneView.setViewpointCamera(new Camera(groupLayer.getFullExtent().getCenter(), 700, 0, 60, 0));
        }
      })
    );

    // create a JavaFX tree view to show the layers in the scene
    TreeView<Layer> layerTreeView = new TreeView<>();
    layerTreeView.setMaxSize(250, 200);
    TreeItem<Layer> rootTreeItem = new TreeItem<>();
    layerTreeView.setRoot(rootTreeItem);
    layerTreeView.setShowRoot(false);
    StackPane.setAlignment(layerTreeView, Pos.TOP_RIGHT);
    StackPane.setMargin(layerTreeView, new Insets(10));
    stackPane.getChildren().add(layerTreeView);

    // display each layer with a custom tree cell
    layerTreeView.setCellFactory(p -> new LayerTreeCell());

    // recursively build the table of contents from the scene's operational layers
    buildLayersView(rootTreeItem, scene.getOperationalLayers());

  } catch (Exception e) {
    // on any error, display the stack trace.
    e.printStackTrace();
  }
}
 
Example 16
Source File: DisplayAnnotationSample.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);

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

        // create a map
        ArcGISMap map = new ArcGISMap(Basemap.Type.LIGHT_GRAY_CANVAS_VECTOR, 55.882436, -2.725610, 13);

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

        // create a feature layer from a feature service
        FeatureLayer riverFeatureLayer = new FeatureLayer(new ServiceFeatureTable("https://services1.arcgis.com/6677msI40mnLuuLr/arcgis/rest/services/East_Lothian_Rivers/FeatureServer/0"));

        // add the feature layer to the map
        map.getOperationalLayers().add(riverFeatureLayer);

        // create an annotation layer from a feature service
        AnnotationLayer annotationLayer = new AnnotationLayer("https://sampleserver6.arcgisonline.com/arcgis/rest/services/RiversAnnotation/FeatureServer/0");

        // add the annotation layer to the map
        map.getOperationalLayers().add(annotationLayer);

        // show alert if layer fails to load
        riverFeatureLayer.addDoneLoadingListener(() -> {
            if (riverFeatureLayer.getLoadStatus() != LoadStatus.LOADED) {
                new Alert(Alert.AlertType.ERROR, "Error loading Feature Layer.").show();
            }
        });

        // add a done loading listener, with a runnable that gets triggered asynchronously when the feature layer has loaded
        // check for the load status of the layer and if it hasn't loaded, report an error
        annotationLayer.addDoneLoadingListener(() -> {
            if (annotationLayer.getLoadStatus() != LoadStatus.LOADED) {
                new Alert(Alert.AlertType.ERROR, "Error loading Annotation Layer.").show();
            }
        });

        // add the map view to stack pane
        stackPane.getChildren().add(mapView);

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 17
Source File: HangmanMain.java    From FXTutorials with MIT License 4 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    Scene scene = new Scene(createContent());
    scene.setOnKeyPressed((KeyEvent event) -> {
        if (event.getText().isEmpty())
            return;

        char pressed = event.getText().toUpperCase().charAt(0);
        if ((pressed < 'A' || pressed > 'Z') && pressed != '-')
            return;

        if (playable.get()) {
            Text t = alphabet.get(pressed);
            if (t.isStrikethrough())
                return;

            // mark the letter 'used'
            t.setFill(Color.BLUE);
            t.setStrikethrough(true);

            boolean found = false;

            for (Node n : letters) {
                Letter letter = (Letter) n;
                if (letter.isEqualTo(pressed)) {
                    found = true;
                    score.set(score.get() + (int)(scoreModifier * POINTS_PER_LETTER));
                    lettersToGuess.set(lettersToGuess.get() - 1);
                    letter.show();
                }
            }

            if (!found) {
                hangman.takeAwayLife();
                scoreModifier = 1.0f;
            }
            else {
                scoreModifier += BONUS_MODIFIER;
            }
        }
    });

    primaryStage.setResizable(false);
    primaryStage.setWidth(APP_W);
    primaryStage.setHeight(APP_H);
    primaryStage.setTitle("Hangman");
    primaryStage.setScene(scene);
    primaryStage.show();
    startGame();
}
 
Example 18
Source File: CreateTerrainSurfaceFromLocalTilePackageSample.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);

    // set title, size, and add JavaFX scene to stage
    stage.setTitle("Create Terrain Surface from Local Tile Package 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());

    // add the SceneView to the stack pane
    sceneView = new SceneView();
    sceneView.setArcGISScene(scene);
    stackPane.getChildren().add(sceneView);

    // create an elevation source from the local LERC encoded tile package
    ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(
        new File(System.getProperty("data.dir"), "./samples-data/monterey_elevation/MontereyElevation.tpk"
    ).getAbsolutePath());

    // create a surface, adding the elevation source
    Surface surface = new Surface();
    surface.getElevationSources().add(elevationSource);
    // set the surface to the scene
    scene.setBaseSurface(surface);

    // specify the initial camera position
    Camera camera = new Camera(36.525, -121.80 , 300.0, 180, 80.0, 0.0);
    sceneView.setViewpointCamera(camera);
  } catch (Exception e) {
    // on any error, display the stack trace.
    e.printStackTrace();
  }
}
 
Example 19
Source File: WindowSettingsParameter.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set window size and position according to the values in this instance
 */
public void applySettingsToWindow(@Nonnull final Stage stage) {

  logger.finest("Setting window " + stage.getTitle() + " position " + posX + ":" + posY
      + " and size " + width + "x" + height);
  if (posX != null)
    stage.setX(posX);
  if (posY != null)
    stage.setX(posY);
  if (width != null)
    stage.setWidth(width);
  if (height != null)
    stage.setHeight(height);

  if ((isMaximized != null) && isMaximized) {
    logger.finest("Setting window " + stage.getTitle() + " to maximized");
    stage.setMaximized(true);
  }

  // when still outside of screen
  // e.g. changing from 2 screens to one
  if (stage.isShowing() && !isOnScreen(stage)) {
    // Maximize on screen 1
    logger.finest(
        "Window " + stage.getTitle() + " is not on screen, setting to maximized on screen 1");
    stage.setX(0.0);
    stage.setY(0.0);
    stage.sizeToScene();
    stage.setMaximized(true);
  }

  ChangeListener<Number> stageListener = (observable, oldValue, newValue) -> {
    posX = stage.getX();
    posY = stage.getY();
    width = stage.getWidth();
    height = stage.getHeight();
  };
  stage.widthProperty().addListener(stageListener);
  stage.heightProperty().addListener(stageListener);
  stage.xProperty().addListener(stageListener);
  stage.yProperty().addListener(stageListener);

}
 
Example 20
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();
  }
}