Java Code Examples for javafx.scene.layout.StackPane#setMargin()
The following examples show how to use
javafx.scene.layout.StackPane#setMargin() .
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: BillBoardBehaviorTest.java From FXyzLib with GNU General Public License v3.0 | 6 votes |
private void createCameraView(){ cameraView = new CameraView(subScene); cameraView.setFitWidth(400); cameraView.setFitHeight(300); cameraView.setFirstPersonNavigationEabled(true); cameraView.setFocusTraversable(true); cameraView.getCamera().setTranslateZ(-2500); cameraView.getCamera().setTranslateX(500); StackPane.setAlignment(cameraView, Pos.BOTTOM_RIGHT); StackPane.setMargin(cameraView, new Insets(10)); rootPane.getChildren().add(cameraView); cameraView.startViewing(); }
Example 2
Source File: ChipViewDemo.java From JFoenix with Apache License 2.0 | 6 votes |
@Override public void start(Stage stage) { JFXChipView<String> chipView = new JFXChipView<>(); chipView.getChips().addAll("WEF", "WWW", "JD"); chipView.getSuggestions().addAll("HELLO", "TROLL", "WFEWEF", "WEF"); chipView.setStyle("-fx-background-color: WHITE;"); StackPane pane = new StackPane(); pane.getChildren().add(chipView); StackPane.setMargin(chipView, new Insets(100)); pane.setStyle("-fx-background-color:GRAY;"); final Scene scene = new Scene(pane, 500, 500); // scene.getStylesheets().add(TagAreaDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); stage.setTitle("JFX Button Demo"); stage.setScene(scene); stage.show(); // ScenicView.show(scene); }
Example 3
Source File: ProgressIndicatorTest.java From mars-sim with GNU General Public License v3.0 | 6 votes |
private Parent createRoot() { StackPane stackPane = new StackPane(); BorderPane controlsPane = new BorderPane(); controlsPane.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); stackPane.getChildren().add(controlsPane); controlsPane.setCenter(new TableView<Void>()); ProgressIndicator indicator = new ProgressIndicator(); indicator.setMaxSize(120, 120); stackPane.getChildren().add(indicator); StackPane.setAlignment(indicator, Pos.BOTTOM_RIGHT); StackPane.setMargin(indicator, new Insets(20)); return stackPane; }
Example 4
Source File: ButtonDemo.java From JFoenix with Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) { FlowPane main = new FlowPane(); main.setVgap(20); main.setHgap(20); main.getChildren().add(new Button("Java Button")); JFXButton jfoenixButton = new JFXButton("JFoenix Button"); main.getChildren().add(jfoenixButton); JFXButton button = new JFXButton("RAISED BUTTON"); button.getStyleClass().add("button-raised"); main.getChildren().add(button); JFXButton button1 = new JFXButton("DISABLED"); button1.setDisable(true); main.getChildren().add(button1); StackPane pane = new StackPane(); pane.getChildren().add(main); StackPane.setMargin(main, new Insets(100)); pane.setStyle("-fx-background-color:WHITE"); final Scene scene = new Scene(pane, 800, 200); scene.getStylesheets().add(ButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); stage.setTitle("JFX Button Demo"); stage.setScene(scene); stage.show(); }
Example 5
Source File: DatePickerDemo.java From JFoenix with Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) { FlowPane main = new FlowPane(); main.setVgap(20); main.setHgap(20); DatePicker datePicker = new DatePicker(); main.getChildren().add(datePicker); JFXDatePicker datePickerFX = new JFXDatePicker(); main.getChildren().add(datePickerFX); datePickerFX.setPromptText("pick a date"); JFXTimePicker blueDatePicker = new JFXTimePicker(); blueDatePicker.setDefaultColor(Color.valueOf("#3f51b5")); blueDatePicker.setOverLay(true); main.getChildren().add(blueDatePicker); StackPane pane = new StackPane(); pane.getChildren().add(main); StackPane.setMargin(main, new Insets(100)); pane.setStyle("-fx-background-color:WHITE"); final Scene scene = new Scene(pane, 400, 700); final ObservableList<String> stylesheets = scene.getStylesheets(); stylesheets.addAll(MainDemo.class.getResource("/css/jfoenix-fonts.css").toExternalForm(), MainDemo.class.getResource("/css/jfoenix-design.css").toExternalForm()); stage.setTitle("JFX Date Picker Demo"); stage.setScene(scene); stage.show(); }
Example 6
Source File: SwitchBibleVersionDialog.java From Quelea with GNU General Public License v3.0 | 5 votes |
/** * Create the dialog to switch bible versions. */ public SwitchBibleVersionDialog() { Utils.addIconsToStage(this); setOnShowing(event -> { selectedVersion = null; }); VBox root = new VBox(5); Label switchToLabel = new Label(LabelGrabber.INSTANCE.getLabel("switch.to.text") + "..."); root.getChildren().add(switchToLabel); root.getChildren().add(comboBox); okButton = new Button(LabelGrabber.INSTANCE.getLabel("ok.button"), new ImageView(new Image("file:icons/tick.png"))); okButton.setDefaultButton(true); okButton.setOnAction(t -> { selectedVersion = comboBox.getValue(); hide(); }); cancelButton = new Button(LabelGrabber.INSTANCE.getLabel("cancel.button"), new ImageView(new Image("file:icons/cross.png"))); cancelButton.setOnAction(t -> { hide(); }); HBox buttonPanel = new HBox(5); buttonPanel.setAlignment(Pos.CENTER); buttonPanel.getChildren().addAll(okButton, cancelButton); root.getChildren().add(buttonPanel); StackPane containerPane = new StackPane(); StackPane.setMargin(root, new Insets(10)); containerPane.getChildren().add(root); Scene scene = new Scene(containerPane); if (QueleaProperties.get().getUseDarkTheme()) { scene.getStylesheets().add("org/modena_dark.css"); } setScene(scene); setResizable(false); }
Example 7
Source File: AddSongPromptOverlay.java From Quelea with GNU General Public License v3.0 | 5 votes |
/** * Create the overlay. */ public AddSongPromptOverlay() { setAlignment(Pos.CENTER); VBox content = new VBox(); content.setAlignment(Pos.TOP_LEFT); StackPane.setMargin(content, new Insets(10,0,0,15)); ImageView iv = new ImageView(new Image("file:icons/whitearrow.png")); content.getChildren().add(iv); text = new Label(LabelGrabber.INSTANCE.getLabel("add.song.hint.text")); Platform.runLater(new Runnable() { @Override public void run() { QueleaApp.get().getMainWindow().getMainPanel().getLibraryPanel().getLibrarySongPanel().getSearchBox().textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> ov, String t, String t1) { if(t1.isEmpty()) { text.setText(LabelGrabber.INSTANCE.getLabel("add.song.hint.text")); } else { text.setText(LabelGrabber.INSTANCE.getLabel("add.song.hint.search.text")); } } }); } }); text.setWrapText(true); text.setTextFill(Color.WHITESMOKE); text.setStyle("-fx-font-size:16pt; -fx-font-family:Calibri;"); content.getChildren().add(text); getChildren().add(content); setOpacity(0); setStyle("-fx-background-color: #555555;"); setVisible(false); }
Example 8
Source File: BillBoardBehaviorTest.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
private void createOverlay(){ Button b = new Button("Activate"); b.setPrefSize(150, 40); b.setFocusTraversable(false); b.setOnAction(e->{ if(!active){ bill.startBillboardBehavior(); active = true; b.setText("Disable"); }else{ bill.stopBillboardBehavior(); active = false; b.setText("Enable"); } }); CheckBox c = new CheckBox("Toggle Cylindrical Mode"); c.setFont(Font.font(24)); c.setFocusTraversable(false); c.setOnAction(e->{ if(c.isSelected()){ bill.setBillboardMode(BillboardBehavior.BillboardMode.CYLINDRICAL); }else{ bill.setBillboardMode(BillboardBehavior.BillboardMode.SPHERICAL); } }); StackPane.setAlignment(b, Pos.TOP_LEFT); StackPane.setMargin(b, new Insets(10)); StackPane.setAlignment(c, Pos.CENTER_LEFT); StackPane.setMargin(c, new Insets(10)); rootPane.getChildren().addAll(b, c); }
Example 9
Source File: MainMenu.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public static StackPane getExitDialogPane(JFXButton b1, JFXButton b2, JFXButton b3) { Label l = new Label("Do you really want to exit ?");// mainScene.createBlendLabel(Msg.getString("MainScene.exit.header")); // l.setPadding(new Insets(10, 10, 10, 10)); l.setFont(Font.font(null, FontWeight.BOLD, 14)); l.setStyle("-fx-text-fill: white;"); b1.setStyle("-fx-background-color: grey;-fx-text-fill: white;"); b2.setStyle("-fx-background-color: grey;-fx-text-fill: white;"); if (b3 != null) b3.setStyle("-fx-background-color: grey;-fx-text-fill: white;"); HBox hb = new HBox(); hb.setAlignment(Pos.CENTER); if (b3 != null) hb.getChildren().addAll(b1, b2, b3); else hb.getChildren().addAll(b1, b2); HBox.setMargin(b1, new Insets(3, 3, 3, 3)); HBox.setMargin(b2, new Insets(3, 3, 3, 3)); if (b3 != null) HBox.setMargin(b3, new Insets(3, 3, 3, 3)); VBox vb = new VBox(); vb.setAlignment(Pos.CENTER); vb.setPadding(new Insets(5, 5, 5, 5)); vb.getChildren().addAll(l, hb); StackPane sp = new StackPane(vb); sp.setStyle("-fx-background-color: black;"); StackPane.setMargin(vb, new Insets(10, 10, 10, 10)); return sp; }
Example 10
Source File: TextAreaDemo.java From JFoenix with Apache License 2.0 | 4 votes |
@Override public void start(Stage stage) { VBox main = new VBox(); main.setSpacing(50); TextArea javafxTextArea = new TextArea(); javafxTextArea.setPromptText("JavaFX Text Area"); main.getChildren().add(javafxTextArea); JFXTextArea jfxTextArea = new JFXTextArea(); jfxTextArea.setPromptText("JFoenix Text Area :D"); jfxTextArea.setLabelFloat(true); RequiredFieldValidator validator = new RequiredFieldValidator(); // NOTE adding error class to text area is causing the cursor to disapper validator.setMessage("Please type something!"); FontIcon warnIcon = new FontIcon(FontAwesomeSolid.EXCLAMATION_TRIANGLE); warnIcon.getStyleClass().add("error"); validator.setIcon(warnIcon); jfxTextArea.getValidators().add(validator); jfxTextArea.focusedProperty().addListener((o, oldVal, newVal) -> { if (!newVal) { jfxTextArea.validate(); } }); main.getChildren().add(jfxTextArea); StackPane pane = new StackPane(); pane.getChildren().add(main); StackPane.setMargin(main, new Insets(100)); pane.setStyle("-fx-background-color:WHITE"); final Scene scene = new Scene(pane, 800, 600); scene.getStylesheets() .add(ButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); stage.setTitle("JFX Button Demo"); stage.setScene(scene); stage.show(); }
Example 11
Source File: ListKMLContentsSample.java From arcgis-runtime-samples-java with Apache License 2.0 | 4 votes |
@Override public void start(Stage stage) { try { // create stack pane and application scene StackPane stackPane = new StackPane(); Scene fxScene = new Scene(stackPane); // set title, size, and add scene to stage stage.setTitle("List KML Contents Sample"); stage.setWidth(800); stage.setHeight(700); stage.setScene(fxScene); stage.show(); // create a map and add it to the map view ArcGISScene scene = new ArcGISScene(Basemap.createImageryWithLabels()); sceneView = new SceneView(); sceneView.setArcGISScene(scene); // load a KML dataset from a local KMZ file and show it as an operational layer File kmzFile = new File(System.getProperty("data.dir"), "./samples-data/kml/esri_test_data.kmz"); KmlDataset kmlDataset = new KmlDataset(kmzFile.getAbsolutePath()); KmlLayer kmlLayer = new KmlLayer(kmlDataset); scene.getOperationalLayers().add(kmlLayer); // create a tree view to list the contents of the KML dataset TreeView<KmlNode> kmlTree = new TreeView<>(); kmlTree.setMaxSize(300, 400); TreeItem<KmlNode> root = new TreeItem<>(null); kmlTree.setRoot(root); kmlTree.setShowRoot(false); // when the dataset is loaded, recursively build the tree view with KML nodes starting with the root node(s) kmlDataset.addDoneLoadingListener(() -> kmlDataset.getRootNodes().forEach(kmlNode -> { TreeItem<KmlNode> kmlNodeTreeItem = buildTree(new TreeItem<>(kmlNode)); root.getChildren().add(kmlNodeTreeItem); })); // show the KML node in the tree view with its name and type kmlTree.setCellFactory(param -> new TextFieldTreeCell<>(new StringConverter<KmlNode>() { @Override public String toString(KmlNode node) { String type = null; if (node instanceof KmlDocument) { type = "KmlDocument"; } else if (node instanceof KmlFolder) { type = "KmlFolder"; } else if (node instanceof KmlGroundOverlay) { type = "KmlGroundOverlay"; } else if (node instanceof KmlScreenOverlay) { type = "KmlScreenOverlay"; } else if (node instanceof KmlPlacemark) { type = "KmlPlacemark"; } return node.getName() + " - " + type; } @Override public KmlNode fromString(String string) { return null; //not needed } })); // when a tree item is selected, zoom to its node's extent (if it has one) kmlTree.getSelectionModel().selectedItemProperty().addListener(o -> { TreeItem<KmlNode> selectedTreeItem = kmlTree.getSelectionModel().getSelectedItem(); KmlNode selectedNode = selectedTreeItem.getValue(); Envelope nodeExtent = selectedNode.getExtent(); if (nodeExtent != null && !nodeExtent.isEmpty()) { sceneView.setViewpointAsync(new Viewpoint(nodeExtent)); } }); // add the map view to stack pane stackPane.getChildren().addAll(sceneView, kmlTree); StackPane.setAlignment(kmlTree, Pos.TOP_LEFT); StackPane.setMargin(kmlTree, new Insets(10)); } catch (Exception e) { // on any error, display the stack trace. e.printStackTrace(); } }
Example 12
Source File: FindAddressSample.java From arcgis-runtime-samples-java with Apache License 2.0 | 4 votes |
@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("Find Address Sample"); stage.setWidth(800); stage.setHeight(700); stage.setScene(scene); stage.show(); // create search box searchBox = new ComboBox<>(); searchBox.setPromptText("Search"); searchBox.setEditable(true); searchBox.setMaxWidth(260.0); // add example locations String[] examples = { "277 N Avenida Caballeros, Palm Springs, CA", "380 New York St, Redlands, CA 92373", "Београд", "Москва", "北京" }; searchBox.getItems().addAll(examples); // create ArcGISMap with imagery basemap ArcGISMap map = new ArcGISMap(Basemap.Type.IMAGERY, 48.354406, -99.998267, 2); // create a view and set ArcGISMap to it mapView = new MapView(); mapView.setMap(map); // add a graphics overlay graphicsOverlay = new GraphicsOverlay(); mapView.getGraphicsOverlays().add(graphicsOverlay); // set the callout's default style Callout callout = mapView.getCallout(); callout.setLeaderPosition(LeaderPosition.BOTTOM); // create a locatorTask locatorTask = new LocatorTask("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"); // create geocode task parameters GeocodeParameters geocodeParameters = new GeocodeParameters(); // return all attributes geocodeParameters.getResultAttributeNames().add("*"); geocodeParameters.setMaxResults(1); // get closest match geocodeParameters.setOutputSpatialReference(mapView.getSpatialReference()); // create a pin graphic Image img = new Image(getClass().getResourceAsStream("/pin.png"), 0, 80, true, true); pinSymbol = new PictureMarkerSymbol(img); pinSymbol.loadAsync(); // event to get geocode when query is submitted searchBox.setOnAction((ActionEvent evt) -> { // get the user's query String query; if (searchBox.getSelectionModel().getSelectedIndex() == -1) { // user supplied their own query query = searchBox.getEditor().getText(); } else { // user chose a suggested query query = searchBox.getSelectionModel().getSelectedItem(); } if (!query.equals("")) { // hide callout if showing mapView.getCallout().dismiss(); // run the locatorTask geocode task ListenableFuture<List<GeocodeResult>> results = locatorTask.geocodeAsync(query, geocodeParameters); // add a listener to display the result when loaded results.addDoneListener(new ResultsLoadedListener(results)); } }); // add map view and control panel to stack pane stackPane.getChildren().addAll(mapView, searchBox); StackPane.setAlignment(searchBox, Pos.TOP_LEFT); StackPane.setMargin(searchBox, new Insets(10, 0, 0, 10)); } catch (Exception e) { // on any error, print the stack trace e.printStackTrace(); } }
Example 13
Source File: ChangeAtmosphereEffectSample.java From arcgis-runtime-samples-java with Apache License 2.0 | 4 votes |
@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 14
Source File: ChangeBasemapSample.java From arcgis-runtime-samples-java with Apache License 2.0 | 4 votes |
@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("Change Basemap Sample"); stage.setWidth(800); stage.setHeight(700); stage.setScene(scene); stage.show(); // creates a map view mapView = new MapView(); // setup listview of basemaps ListView<Basemap.Type> basemapList = new ListView<>(FXCollections.observableArrayList(Basemap.Type.values())); basemapList.setMaxSize(250, 150); // change the basemap when list option is selected basemapList.getSelectionModel().selectedItemProperty().addListener(o -> { String basemapString = basemapList.getSelectionModel().getSelectedItem().toString(); map = new ArcGISMap(Basemap.Type.valueOf(basemapString), LATITUDE, LONGITUDE, LOD); mapView.setMap(map); }); // select the first basemap basemapList.getSelectionModel().selectFirst(); // add the map view and control panel to stack pane stackPane.getChildren().addAll(mapView, basemapList); StackPane.setAlignment(basemapList, Pos.TOP_LEFT); StackPane.setMargin(basemapList, new Insets(10, 0, 0, 10)); } catch (Exception e) { // on any error, display the stack trace. e.printStackTrace(); } }
Example 15
Source File: MapImageLayerTablesSample.java From arcgis-runtime-samples-java with Apache License 2.0 | 4 votes |
@Override public void start(Stage stage) { try { // create a stack pane and application scene StackPane stackPane = new StackPane(); Scene scene = new Scene(stackPane); scene.getStylesheets().add(getClass().getResource("/map_image_layer_tables/style.css").toExternalForm()); // size the stage and add a title stage.setTitle("Map Image Layer Tables Sample"); stage.setWidth(800); stage.setHeight(700); stage.setScene(scene); stage.show(); // create a map with a basemap ArcGISMap map = new ArcGISMap(Basemap.createStreetsVector()); // create and add a map image layer to the map // the map image layer contains a feature table with related spatial and non-spatial comment features ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer( "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/MapServer"); map.getOperationalLayers().add(imageLayer); // create a map view and set the map to it mapView = new MapView(); mapView.setMap(map); // create a graphics overlay to show the related spatial features in graphicsOverlay = new GraphicsOverlay(); mapView.getGraphicsOverlays().add(graphicsOverlay); // show the related graphics as cyan circles SimpleRenderer renderer = new SimpleRenderer(); renderer.setSymbol(new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, 0xFF00FFFF, 14)); graphicsOverlay.setRenderer(renderer); // create a list view to show the non-spatial comment features commentsListView = new ListView<>(); commentsListView.setMaxSize(200.0, 150.0); // show the comments attribute of the feature in the list commentsListView.setCellFactory(listView -> new ListCell<Feature>() { @Override protected void updateItem(Feature item, boolean empty) { super.updateItem(item, empty); if (item != null) { ArcGISFeature feature = (ArcGISFeature) item; setText((String) feature.getAttributes().get("comments")); } } }); // when a comment is selected, query its related spatial features and show the first result on the map commentsListView.getSelectionModel().selectedItemProperty().addListener(observable -> showRelatedRequests()); // when the layer is loaded, get the comment features imageLayer.addDoneLoadingListener(() -> { if (imageLayer.getLoadStatus() == LoadStatus.LOADED) { // zoom to the layer's extent mapView.setViewpoint(new Viewpoint(imageLayer.getFullExtent())); // get the comments feature table commentsTable = imageLayer.getTables().get(0); // create query parameters to get features that have non-empty comments QueryParameters queryParameters = new QueryParameters(); queryParameters.setWhereClause("requestid <> '' AND comments <> ''"); // query the comments table for features ListenableFuture<FeatureQueryResult> featureQuery = commentsTable.queryFeaturesAsync(queryParameters); featureQuery.addDoneListener(() -> { try { // add the returned features to the list view FeatureQueryResult results = featureQuery.get(); for (Feature f : results) { commentsListView.getItems().addAll(f); } } catch (InterruptedException | ExecutionException ex) { new Alert(Alert.AlertType.ERROR, "Error querying comment features"); } }); } else { new Alert(Alert.AlertType.ERROR, imageLayer.getLoadError().getMessage()).show(); } }); // add the mapview and controls to the stack pane stackPane.getChildren().addAll(mapView, commentsListView); StackPane.setAlignment(commentsListView, Pos.TOP_LEFT); StackPane.setMargin(commentsListView, new Insets(10, 0, 0, 10)); } catch (Exception e) { // on any error, display the stack trace. e.printStackTrace(); } }
Example 16
Source File: MasonryPaneController.java From JFoenix with Apache License 2.0 | 4 votes |
/** * init fxml when loaded. */ @PostConstruct public void init() { ArrayList<Node> children = new ArrayList<>(); for (int i = 0; i < 20; i++) { StackPane child = new StackPane(); double width = Math.random() * 100 + 100; child.setPrefWidth(width); double height = Math.random() * 100 + 100; child.setPrefHeight(height); JFXDepthManager.setDepth(child, 1); children.add(child); // create content StackPane header = new StackPane(); String headerColor = getDefaultColor(i % 12); header.setStyle("-fx-background-radius: 5 5 0 0; -fx-background-color: " + headerColor); VBox.setVgrow(header, Priority.ALWAYS); StackPane body = new StackPane(); body.setMinHeight(Math.random() * 20 + 50); VBox content = new VBox(); content.getChildren().addAll(header, body); body.setStyle("-fx-background-radius: 0 0 5 5; -fx-background-color: rgb(255,255,255,0.87);"); // create button JFXButton button = new JFXButton(""); button.setButtonType(ButtonType.RAISED); button.setStyle("-fx-background-radius: 40;-fx-background-color: " + getDefaultColor((int) ((Math.random() * 12) % 12))); button.setPrefSize(40, 40); button.setRipplerFill(Color.valueOf(headerColor)); button.setScaleX(0); button.setScaleY(0); SVGGlyph glyph = new SVGGlyph(-1, "test", "M1008 6.286q18.857 13.714 15.429 36.571l-146.286 877.714q-2.857 16.571-18.286 25.714-8 4.571-17.714 4.571-6.286 " + "0-13.714-2.857l-258.857-105.714-138.286 168.571q-10.286 13.143-28 13.143-7.429 " + "0-12.571-2.286-10.857-4-17.429-13.429t-6.571-20.857v-199.429l493.714-605.143-610.857 " + "528.571-225.714-92.571q-21.143-8-22.857-31.429-1.143-22.857 18.286-33.714l950.857-548.571q8.571-5.143 18.286-5.143" + " 11.429 0 20.571 6.286z", Color.WHITE); glyph.setSize(20, 20); button.setGraphic(glyph); button.translateYProperty().bind(Bindings.createDoubleBinding(() -> { return header.getBoundsInParent().getHeight() - button.getHeight() / 2; }, header.boundsInParentProperty(), button.heightProperty())); StackPane.setMargin(button, new Insets(0, 12, 0, 0)); StackPane.setAlignment(button, Pos.TOP_RIGHT); Timeline animation = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(button.scaleXProperty(), 1, EASE_BOTH), new KeyValue(button.scaleYProperty(), 1, EASE_BOTH))); animation.setDelay(Duration.millis(100 * i + 1000)); animation.play(); child.getChildren().addAll(content, button); } masonryPane.getChildren().addAll(children); Platform.runLater(() -> scrollPane.requestLayout()); JFXScrollPane.smoothScrolling(scrollPane); }
Example 17
Source File: BrowseWfsLayersSample.java From arcgis-runtime-samples-java with Apache License 2.0 | 4 votes |
@Override public void start(Stage stage) throws Exception { // create stack pane and JavaFX app scene StackPane stackPane = new StackPane(); Scene scene = new Scene(stackPane); scene.getStylesheets().add(getClass().getResource("/browse_wfs_layers/style.css").toExternalForm()); // set title, size, and add JavaFX scene to stage stage.setTitle("Browse WFS Layers"); stage.setWidth(800); stage.setHeight(700); stage.setScene(scene); stage.show(); // create a list view to show all of the layers in a WFS service ListView<WfsLayerInfo> wfsLayerNamesListView = new ListView<>(); wfsLayerNamesListView.setMaxSize(200, 160); // create a progress indicator progressIndicator = new ProgressIndicator(); progressIndicator.setVisible(true); // create an ArcGISMap with topographic basemap and set it to the map view map = new ArcGISMap(Basemap.createImagery()); mapView = new MapView(); mapView.setMap(map); // create a WFS service with a URL and load it wfsService = new WfsService("https://dservices2.arcgis.com/ZQgQTuoyBrtmoGdP/arcgis/services/Seattle_Downtown_Features/WFSServer?service=wfs&request=getcapabilities"); wfsService.loadAsync(); // when the WFS service has loaded, add its layer information to the list view for browsing wfsService.addDoneLoadingListener(() -> { progressIndicator.setVisible(false); if (wfsService.getLoadStatus() == LoadStatus.LOADED) { // add the list of WFS layers to the list view List<WfsLayerInfo> wfsLayerInfos = wfsService.getServiceInfo().getLayerInfos(); wfsLayerNamesListView.getItems().addAll(wfsLayerInfos); } else { Alert alert = new Alert(Alert.AlertType.ERROR, "WFS Service Failed to Load!"); alert.show(); } }); // populate the list view with layer names wfsLayerNamesListView.setCellFactory(list -> new ListCell<>() { @Override protected void updateItem(WfsLayerInfo wfsLayerInfo, boolean bln) { super.updateItem(wfsLayerInfo, bln); if (wfsLayerInfo != null) { String fullNameOfWfsLayer = wfsLayerInfo.getName(); String[] split = fullNameOfWfsLayer.split(":"); String smallName = split[1]; setText(smallName); } } }); // load the selected layer from the list view when the layer is selected wfsLayerNamesListView.getSelectionModel().selectedItemProperty().addListener(observable -> updateMap(wfsLayerNamesListView.getSelectionModel().getSelectedItem()) ); // add the controls to the stack pane stackPane.getChildren().addAll(mapView, wfsLayerNamesListView, progressIndicator); StackPane.setAlignment(wfsLayerNamesListView, Pos.TOP_LEFT); StackPane.setMargin(wfsLayerNamesListView, new Insets(10)); }
Example 18
Source File: HamburgerDemo.java From JFoenix with Apache License 2.0 | 4 votes |
@Override public void start(Stage stage) { FlowPane main = new FlowPane(); main.setVgap(20); main.setHgap(20); JFXHamburger h1 = new JFXHamburger(); HamburgerSlideCloseTransition burgerTask = new HamburgerSlideCloseTransition(h1); burgerTask.setRate(-1); h1.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> { burgerTask.setRate(burgerTask.getRate() * -1); burgerTask.play(); }); JFXHamburger h2 = new JFXHamburger(); HamburgerBasicCloseTransition burgerTask1 = new HamburgerBasicCloseTransition(h2); burgerTask1.setRate(-1); h2.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> { burgerTask1.setRate(burgerTask1.getRate() * -1); burgerTask1.play(); }); JFXHamburger h3 = new JFXHamburger(); HamburgerBackArrowBasicTransition burgerTask2 = new HamburgerBackArrowBasicTransition(h3); burgerTask2.setRate(-1); h3.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> { burgerTask2.setRate(burgerTask2.getRate() * -1); burgerTask2.play(); }); JFXHamburger h4 = new JFXHamburger(); HamburgerNextArrowBasicTransition burgerTask3 = new HamburgerNextArrowBasicTransition(h4); burgerTask3.setRate(-1); h4.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> { burgerTask3.setRate(burgerTask3.getRate() * -1); burgerTask3.play(); }); main.getChildren().add(h1); main.getChildren().add(h2); main.getChildren().add(h3); main.getChildren().add(h4); StackPane pane = new StackPane(); pane.getChildren().add(main); StackPane.setMargin(main, new Insets(60)); pane.setStyle("-fx-background-color:WHITE"); final Scene scene = new Scene(pane, 400, 200); scene.getStylesheets().add(HamburgerDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); stage.setTitle("JFX Burgers Demo :) "); stage.setScene(scene); stage.setResizable(false); stage.show(); }
Example 19
Source File: AnimationDemo.java From JFoenix with Apache License 2.0 | 4 votes |
@Override public void start(Stage stage) { FlowPane main = new FlowPane(); main.setVgap(20); main.setHgap(20); StackPane colorPane = new StackPane(); colorPane.setStyle(STYLE); colorPane.getStyleClass().add("red-500"); main.getChildren().add(colorPane); StackPane colorPane1 = new StackPane(); colorPane1.setStyle(STYLE); colorPane1.getStyleClass().add("blue-500"); StackPane placeHolder = new StackPane(colorPane1); placeHolder.setStyle(STYLE); main.getChildren().add(placeHolder); StackPane colorPane2 = new StackPane(); colorPane2.setStyle(STYLE); colorPane2.getStyleClass().add("green-500"); main.getChildren().add(colorPane2); StackPane colorPane3 = new StackPane(); colorPane3.setStyle(STYLE); colorPane3.getStyleClass().add("yellow-500"); main.getChildren().add(colorPane3); StackPane colorPane4 = new StackPane(); colorPane4.setStyle(STYLE); colorPane4.getStyleClass().add("purple-500"); main.getChildren().add(colorPane4); StackPane wizard = new StackPane(); wizard.getChildren().add(main); StackPane.setMargin(main, new Insets(100)); wizard.setStyle("-fx-background-color:WHITE"); StackPane nextPage = new StackPane(); StackPane newPlaceHolder = new StackPane(); newPlaceHolder.setStyle("-fx-background-radius:50; -fx-max-width:50; -fx-max-height:50;"); nextPage.getChildren().add(newPlaceHolder); StackPane.setAlignment(newPlaceHolder, Pos.TOP_LEFT); JFXHamburger h4 = new JFXHamburger(); h4.setMaxSize(40, 40); HamburgerBackArrowBasicTransition burgerTask3 = new HamburgerBackArrowBasicTransition(h4); burgerTask3.setRate(-1); h4.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> { burgerTask3.setRate(burgerTask3.getRate() * -1); burgerTask3.play(); }); nextPage.getChildren().add(h4); StackPane.setAlignment(h4, Pos.TOP_LEFT); StackPane.setMargin(h4, new Insets(10)); JFXNodesAnimation<FlowPane, StackPane> animation = new FlowPaneStackPaneJFXNodesAnimation(main, nextPage, wizard, colorPane1); colorPane1.setOnMouseClicked((click) -> animation.animate()); final Scene scene = new Scene(wizard, 800, 200); final ObservableList<String> stylesheets = scene.getStylesheets(); stylesheets.addAll(ButtonDemo.class.getResource("/css/jfoenix-design.css").toExternalForm(), ButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); stage.setTitle("JFX Button Demo"); stage.setScene(scene); stage.show(); }
Example 20
Source File: ScrollPaneDemo.java From JFoenix with Apache License 2.0 | 4 votes |
@Override public void start(Stage stage) { JFXListView<Label> list = new JFXListView<>(); for (int i = 0; i < 100; i++) { list.getItems().add(new Label("Item " + i)); } list.getStyleClass().add("mylistview"); list.setMaxHeight(3400); StackPane container = new StackPane(list); container.setPadding(new Insets(24)); JFXScrollPane pane = new JFXScrollPane(); pane.setContent(container); JFXButton button = new JFXButton(""); SVGGlyph arrow = new SVGGlyph(0, "FULLSCREEN", "M402.746 877.254l-320-320c-24.994-24.992-24.994-65.516 0-90.51l320-320c24.994-24.992 65.516-24.992 90.51 0 24.994 24.994 " + "24.994 65.516 0 90.51l-210.746 210.746h613.49c35.346 0 64 28.654 64 64s-28.654 64-64 64h-613.49l210.746 210.746c12.496 " + "12.496 18.744 28.876 18.744 45.254s-6.248 32.758-18.744 45.254c-24.994 24.994-65.516 24.994-90.51 0z", Color.WHITE); arrow.setSize(20, 16); button.setGraphic(arrow); button.setRipplerFill(Color.WHITE); pane.getTopBar().getChildren().add(button); Label title = new Label("Title"); pane.getBottomBar().getChildren().add(title); title.setStyle("-fx-text-fill:WHITE; -fx-font-size: 40;"); JFXScrollPane.smoothScrolling((ScrollPane) pane.getChildren().get(0)); StackPane.setMargin(title, new Insets(0, 0, 0, 80)); StackPane.setAlignment(title, Pos.CENTER_LEFT); StackPane.setAlignment(button, Pos.CENTER_LEFT); StackPane.setMargin(button, new Insets(0, 0, 0, 20)); final Scene scene = new Scene(new StackPane(pane), 600, 600, Color.WHITE); stage.setTitle("JFX ListView Demo "); stage.setScene(scene); stage.show(); }