List of usage examples for javafx.geometry Insets Insets
public Insets(@NamedArg("top") double top, @NamedArg("right") double right, @NamedArg("bottom") double bottom, @NamedArg("left") double left)
From source file:qupath.lib.gui.panels.classify.RandomTrainingRegionSelector.java
private void createDialog() { dialog = new Stage(); dialog.initOwner(qupath.getStage()); dialog.setTitle("Training sample selector"); pointCreator = new RandomPointCreator(); for (PathClass pathClass : pathClassListModel) { if (pathClass != null && pathClass.getName() != null) pointCreator.addPathClass(pathClass, KeyCode.getKeyCode(pathClass.getName().toUpperCase().substring(0, 1))); // pointCreator.addPathClass(pathClass, KeyStroke.getKeyStroke(new pathClass.getName().toLowerCase().charAt(0), 0).getKeyCode()); }/*w w w.j a v a 2 s .c o m*/ // PathClass tumourClass = PathClassFactory.getDefaultPathClass(PathClasses.TUMOR); // PathClass stromaClass = PathClassFactory.getDefaultPathClass(PathClasses.STROMA); // pointCreator.addPathClass(tumourClass, KeyCode.T); // pointCreator.addPathClass(stromaClass, KeyCode.S); QuPathViewer viewer = qupath.getViewer(); pointCreator.registerViewer(viewer); // Adapt to changing active viewers ImageDataChangeListener<BufferedImage> listener = new ImageDataChangeListener<BufferedImage>() { @Override public void imageDataChanged(ImageDataWrapper<BufferedImage> source, ImageData<BufferedImage> imageDataOld, ImageData<BufferedImage> imageDataNew) { if (pointCreator != null) { QuPathViewer viewer = qupath.getViewer(); pointCreator.registerViewer(viewer); updateObjectCache(viewer); } refreshList(); updateLabel(); } }; qupath.addImageDataChangeListener(listener); // Remove listeners for cleanup dialog.setOnCloseRequest(e -> { pointCreator.deregisterViewer(); qupath.removeImageDataChangeListener(listener); dialog.setOnCloseRequest(null); dialog = null; // Re-enable mode switching qupath.setModeSwitchingEnabled(true); }); ParameterPanelFX paramPanel = new ParameterPanelFX(params); paramPanel.getPane().setPadding(new Insets(2, 5, 5, 5)); list = new ListView<PathClass>(pathClassListModel); list.setPrefSize(400, 200); // TODO: ADD A SENSIBLE RENDERER! // For now, this is simply duplicated from PathAnnotationPanel list.setCellFactory(new Callback<ListView<PathClass>, ListCell<PathClass>>() { @Override public ListCell<PathClass> call(ListView<PathClass> p) { ListCell<PathClass> cell = new ListCell<PathClass>() { @Override protected void updateItem(PathClass value, boolean bln) { super.updateItem(value, bln); int size = 10; if (value == null) { setText(null); setGraphic(null); } else if (value.getName() == null) { setText("None"); setGraphic(new Rectangle(size, size, ColorToolsFX.getCachedColor(0, 0, 0, 0))); } else { setText(value.getName()); setGraphic(new Rectangle(size, size, ColorToolsFX.getPathClassColor(value))); } } }; return cell; } }); // list.setCellRenderer(new PathClassListCellRendererPoints()); list.setTooltip(new Tooltip("Available classes")); labelCount = new Label(); labelCount.setTextAlignment(TextAlignment.CENTER); labelCount.setPadding(new Insets(5, 0, 5, 0)); BorderPane panelTop = new BorderPane(); panelTop.setTop(paramPanel.getPane()); panelTop.setCenter(list); panelTop.setBottom(labelCount); labelCount.prefWidthProperty().bind(panelTop.widthProperty()); updateLabel(); // panelButtons.add(new JButton(new UndoAction("Undo"))); Action actionAdd = new Action("Add to class", e -> { if (list == null || pointCreator == null) return; PathClass pathClass = list.getSelectionModel().getSelectedItem(); pointCreator.addPoint(pathClass); }); Action actionSkip = new Action("Skip", e -> { if (pointCreator != null) pointCreator.addPoint(null); }); GridPane panelButtons = PanelToolsFX.createColumnGridControls(ActionUtils.createButton(actionAdd), ActionUtils.createButton(actionSkip)); BorderPane pane = new BorderPane(); pane.setCenter(panelTop); pane.setBottom(panelButtons); pane.setPadding(new Insets(10, 10, 10, 10)); Scene scene = new Scene(pane); dialog.setScene(scene); }
From source file:boundary.GraphPane.java
private Node addThresholdSlider(float min, float max) { HBox hBox = new HBox(); hBox.setPadding(new Insets(15, 12, 15, 12)); hBox.setStyle("-fx-background-color: #66FFFF;"); Label lblThreshold = new Label("Threshold: "); lblThreshold.setPrefSize(100, 20);// w w w.j a va 2 s.co m Label lblValue = new Label("Value: "); lblValue.setPrefSize(50, 20); TextField tfValue = new TextField(String.valueOf(min)); Slider thresholdSlider = new Slider(); thresholdSlider.setMin(Math.floor(min)); thresholdSlider.setMax(Math.ceil(max)); thresholdSlider.setMajorTickUnit(Math.ceil((max - min) / 5)); thresholdSlider.setMinorTickCount(1); thresholdSlider.setBlockIncrement(1); thresholdSlider.setSnapToTicks(true); thresholdSlider.setShowTickMarks(true); thresholdSlider.valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { edgePredicate.setThreshold(newValue.floatValue()); vertexPredicate.setThreshold(newValue.floatValue()); vv.repaint(); tfValue.setText(String.format(Locale.US, "%.2f", newValue.floatValue())); } }); tfValue.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { float value; try { value = Float.parseFloat(tfValue.getText()); } catch (Exception ex) { value = 0; } edgePredicate.setThreshold(value); vertexPredicate.setThreshold(value); vv.repaint(); thresholdSlider.setValue(value); } }); Label lblSearch = new Label("Search: "); lblSearch.setPrefSize(70, 20); TextField tf = new TextField(); tf.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { String toFind = tf.getText().toLowerCase(); for (NodeInfo nodeInfo : nodesHighlighted) nodeInfo.setHighlighted(false); if (nodesHighlighted.size() > 0) { nodesHighlighted.clear(); vv.repaint(); } if (toFind.length() > 2) { for (NodeInfo nodeInfo : nodes.values()) { if (nodeInfo.getUserData().toLowerCase().contains((toFind))) { nodeInfo.setHighlighted(true); nodesHighlighted.add(nodeInfo); } } if (nodesHighlighted.size() == 1) { Layout<String, String> layout = vv.getGraphLayout(); Point2D q = layout.transform(nodesHighlighted.get(0).id); Point2D lvc = vv.getRenderContext().getMultiLayerTransformer() .inverseTransform(vv.getCenter()); final double dx = (lvc.getX() - q.getX()) / 10; final double dy = (lvc.getY() - q.getY()) / 10; Runnable animator = new Runnable() { public void run() { for (int i = 0; i < 10; i++) { vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT) .translate(dx, dy); try { Thread.sleep(100); } catch (InterruptedException ex) { } } } }; Thread thread = new Thread(animator); thread.start(); } vv.repaint(); } } }); hBox.getChildren().addAll(lblThreshold, thresholdSlider, lblValue, tfValue, lblSearch, tf); return hBox; }
From source file:se.trixon.filebydate.ui.ProfilePanel.java
private void createUI() { //setGridLinesVisible(true); Label nameLabel = new Label(Dict.NAME.toString()); Label descLabel = new Label(Dict.DESCRIPTION.toString()); Label filePatternLabel = new Label(Dict.FILE_PATTERN.toString()); Label dateSourceLabel = new Label(Dict.DATE_SOURCE.toString()); mDatePatternLabel = new Label(Dict.DATE_PATTERN.toString()); Label operationLabel = new Label(Dict.OPERATION.toString()); Label caseBaseLabel = new Label(Dict.BASENAME.toString()); Label caseExtLabel = new Label(Dict.EXTENSION.toString()); mLinksCheckBox = new CheckBox(Dict.FOLLOW_LINKS.toString()); mRecursiveCheckBox = new CheckBox(Dict.RECURSIVE.toString()); mReplaceCheckBox = new CheckBox(Dict.REPLACE.toString()); mCaseBaseComboBox = new ComboBox<>(); mDatePatternComboBox = new ComboBox<>(); mDateSourceComboBox = new ComboBox<>(); mFilePatternComboBox = new ComboBox<>(); mOperationComboBox = new ComboBox<>(); mCaseExtComboBox = new ComboBox<>(); mNameTextField = new TextField(); mDescTextField = new TextField(); mSourceChooserPane = new FileChooserPane(Dict.OPEN.toString(), Dict.SOURCE.toString(), ObjectMode.DIRECTORY, SelectionMode.SINGLE);//from w w w . j ava 2 s .c o m mDestChooserPane = new FileChooserPane(Dict.OPEN.toString(), Dict.DESTINATION.toString(), ObjectMode.DIRECTORY, SelectionMode.SINGLE); mFilePatternComboBox.setEditable(true); mDatePatternComboBox.setEditable(true); //mDatePatternLabel.setPrefWidth(300); int col = 0; int row = 0; add(nameLabel, col, row, REMAINING, 1); add(mNameTextField, col, ++row, REMAINING, 1); add(descLabel, col, ++row, REMAINING, 1); add(mDescTextField, col, ++row, REMAINING, 1); add(mSourceChooserPane, col, ++row, REMAINING, 1); add(mDestChooserPane, col, ++row, REMAINING, 1); GridPane patternPane = new GridPane(); patternPane.addRow(0, filePatternLabel, dateSourceLabel, mDatePatternLabel); patternPane.addRow(1, mFilePatternComboBox, mDateSourceComboBox, mDatePatternComboBox); patternPane.setHgap(8); addRow(++row, patternPane); GridPane.setHgrow(mFilePatternComboBox, Priority.ALWAYS); GridPane.setHgrow(mDateSourceComboBox, Priority.ALWAYS); GridPane.setHgrow(mDatePatternComboBox, Priority.ALWAYS); GridPane.setFillWidth(mFilePatternComboBox, true); GridPane.setFillWidth(mDateSourceComboBox, true); GridPane.setFillWidth(mDatePatternComboBox, true); double width = 100.0 / 3.0; ColumnConstraints col1 = new ColumnConstraints(); col1.setPercentWidth(width); ColumnConstraints col2 = new ColumnConstraints(); col2.setPercentWidth(width); ColumnConstraints col3 = new ColumnConstraints(); col3.setPercentWidth(width); patternPane.getColumnConstraints().addAll(col1, col2, col3); mFilePatternComboBox.setMaxWidth(Double.MAX_VALUE); mDateSourceComboBox.setMaxWidth(Double.MAX_VALUE); mDatePatternComboBox.setMaxWidth(Double.MAX_VALUE); GridPane subPane = new GridPane(); //subPane.setGridLinesVisible(true); subPane.addRow(0, operationLabel, new Label(), new Label(), new Label(), caseBaseLabel, caseExtLabel); subPane.addRow(1, mOperationComboBox, mLinksCheckBox, mRecursiveCheckBox, mReplaceCheckBox, mCaseBaseComboBox, mCaseExtComboBox); subPane.setHgap(8); add(subPane, col, ++row, REMAINING, 1); final Insets rowInsets = new Insets(0, 0, 8, 0); GridPane.setMargin(mNameTextField, rowInsets); GridPane.setMargin(mDescTextField, rowInsets); GridPane.setMargin(mSourceChooserPane, rowInsets); GridPane.setMargin(mDestChooserPane, rowInsets); GridPane.setMargin(patternPane, rowInsets); mFilePatternComboBox.setItems(FXCollections.observableArrayList("*", "{*.jpg,*.JPG}", "{*.mp4,*.MP4}")); mDatePatternComboBox.setItems(FXCollections.observableArrayList("yyyy/MM/yyyy-MM-dd", "yyyy/MM/yyyy-MM-dd/HH", "yyyy/MM/dd", "yyyy/ww", "yyyy/ww/u")); mCaseBaseComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(NameCase.values()))); mCaseExtComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(NameCase.values()))); mDateSourceComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(DateSource.values()))); mOperationComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(Command.COPY, Command.MOVE))); }
From source file:Main.java
private FlowPane addFlowPane() { FlowPane flow = new FlowPane(); flow.setPadding(new Insets(5, 0, 5, 0)); flow.setVgap(4);/* ww w.jav a 2 s . c o m*/ flow.setHgap(4); flow.setPrefWrapLength(170); // preferred width allows for two columns flow.setStyle("-fx-background-color: DAE6F3;"); ImageView pages[] = new ImageView[8]; for (int i = 0; i < 8; i++) { pages[i] = new ImageView( new Image(Main.class.getResourceAsStream("graphics/chart_" + (i + 1) + ".png"))); flow.getChildren().add(pages[i]); } return flow; }
From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java
private void createAccount(ListView<String> to_update) { Stage createAccountStage = new Stage(); createAccountStage.initModality(Modality.APPLICATION_MODAL); //Set the stage info createAccountStage.setTitle("Add Server Account"); //Create a layout GridPane gp = new GridPane(); gp.setAlignment(Pos.CENTER);// ww w .ja va 2s. c om gp.setVgap(10); gp.setHgap(10); gp.setPadding(new Insets(25, 25, 25, 25)); //Ads the important things Text welcome = new Text("Create Server Account"); welcome.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20)); gp.add(welcome, 0, 0, 2, 1); Label username = new Label("Username"); Label password = new Label("Password"); Label r_password = new Label("Repeat Password"); TextField usernamefield = new TextField(); PasswordField passwordfield = new PasswordField(); PasswordField r_passwordfield = new PasswordField(); gp.add(username, 0, 1); gp.add(password, 0, 2); gp.add(r_password, 0, 3); gp.add(usernamefield, 1, 1); gp.add(passwordfield, 1, 2); gp.add(r_passwordfield, 1, 3); Text error = new Text(""); HBox error_box = new HBox(10); error_box.setAlignment(Pos.CENTER); error_box.getChildren().add(error); gp.add(error_box, 0, 4, 2, 1); Button finish = new Button("Finish"); finish.setDisable(true); HBox center_button = new HBox(10); center_button.setAlignment(Pos.CENTER); center_button.getChildren().add(finish); gp.add(center_button, 0, 5, 2, 1); ChangeListener name = new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { finish.setDisable(true); if (usernamefield.getText().equals("")) { error.setFill(Color.RED); error.setText("Username can not be blank!"); } if (!passwordfield.getText().equals(r_passwordfield.getText())) { error.setFill(Color.RED); error.setText("Passwords do not match!"); } if (passwordfield.getText().equals("") && r_passwordfield.getText().equals("")) { error.setFill(Color.RED); error.setText("Passwords can not be blank!"); } if (passwordfield.getText().equals(r_passwordfield.getText()) && !usernamefield.getText().equals("") && !passwordfield.getText().equals("")) { error.setFill(Color.GREEN); error.setText("No issues."); finish.setDisable(false); } } }; usernamefield.textProperty().addListener(name); passwordfield.textProperty().addListener(name); r_passwordfield.textProperty().addListener(name); finish.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { users.remove(usernamefield.getText()); users.add(usernamefield.getText()); userpasswords.put(usernamefield.getText(), passwordfield.getText()); to_update.setItems(FXCollections.observableArrayList(users)); createAccountStage.close(); } }); //Creates the scene Scene scene = new Scene(gp, 300, 275); scene.getStylesheets().add(this.getClass().getResource("login_css.css").toExternalForm()); createAccountStage.setScene(scene); createAccountStage.show(); }
From source file:Main.java
private TilePane addTilePane() { TilePane tile = new TilePane(); tile.setPadding(new Insets(5, 0, 5, 0)); tile.setVgap(4);/*from w ww . jav a 2s .c o m*/ tile.setHgap(4); tile.setPrefColumns(2); tile.setStyle("-fx-background-color: DAE6F3;"); ImageView pages[] = new ImageView[8]; for (int i = 0; i < 8; i++) { pages[i] = new ImageView( new Image(Main.class.getResourceAsStream("graphics/chart_" + (i + 1) + ".png"))); tile.getChildren().add(pages[i]); } return tile; }
From source file:io.bitsquare.gui.components.paymentmethods.SepaForm.java
private void addCountriesGrid(boolean isEditable, String title, List<CheckBox> checkBoxList, List<Country> dataProvider) { Label label = addLabel(gridPane, ++gridRow, title, 0); label.setWrapText(true);/* www . ja va 2s . co m*/ label.setMaxWidth(180); label.setTextAlignment(TextAlignment.RIGHT); GridPane.setHalignment(label, HPos.RIGHT); GridPane.setValignment(label, VPos.TOP); FlowPane flowPane = new FlowPane(); flowPane.setPadding(new Insets(10, 10, 10, 10)); flowPane.setVgap(10); flowPane.setHgap(10); flowPane.setMinHeight(55); if (isEditable) flowPane.setId("flow-pane-checkboxes-bg"); else flowPane.setId("flow-pane-checkboxes-non-editable-bg"); dataProvider.stream().forEach(country -> { final String countryCode = country.code; CheckBox checkBox = new CheckBox(countryCode); checkBox.setUserData(countryCode); checkBoxList.add(checkBox); checkBox.setMouseTransparent(!isEditable); checkBox.setMinWidth(45); checkBox.setMaxWidth(45); checkBox.setTooltip(new Tooltip(country.name)); checkBox.setOnAction(event -> { if (checkBox.isSelected()) sepaAccount.addAcceptedCountry(countryCode); else sepaAccount.removeAcceptedCountry(countryCode); updateAllInputsValid(); }); flowPane.getChildren().add(checkBox); }); updateCountriesSelection(isEditable, checkBoxList); GridPane.setRowIndex(flowPane, gridRow); GridPane.setColumnIndex(flowPane, 1); gridPane.getChildren().add(flowPane); }
From source file:ca.wumbo.doommanager.client.controller.file.entry.PlaypalController.java
/** * Resizes the canvas using the minimium expected widths of the borders, * and then calls for repainting.//w ww. ja v a 2 s . c o m */ private void resizeAndRepaintCanvas() { // We have to resize such that the width = height, going with the smaller side. int w = (int) (borderPane.getWidth() - rightVBox.getMinWidth()); int h = (int) (borderPane.getHeight() - topHBox.getMinHeight() - bottomHBox.getMinHeight()); int dimension = Math.max(256, Math.min(w, h)); // The palette should be a square, clamp it from [0, inf). paletteCanvas.setWidth(dimension); paletteCanvas.setHeight(dimension); // Position the bottom buttons on the next pass. // We have to check for 'PALETTE_INDEX_PADDING_PIXELS' because it might not properly be refreshed. int nodeSizes = PALETTE_INDEX_PADDING_PIXELS; nodeSizes += (int) paletteIndexLeftButton.getWidth(); nodeSizes += (int) paletteIndexRightButton.getWidth(); nodeSizes += (int) paletteIndexLabel.getWidth(); nodeSizes += (int) paletteIndexSlashLabel.getWidth(); nodeSizes += (int) totalPaletteIndexes.getWidth(); if (nodeSizes != PALETTE_INDEX_PADDING_PIXELS) { HBox.setMargin(paletteIndexLeftButton, new Insets(8, 0, 0, Math.max(8, (dimension / 2) - (nodeSizes) / 2))); } else { HBox.setMargin(paletteIndexLeftButton, new Insets(8, 0, 0, (dimension / 2) - 56)); // Else, make an educated guess. } // After resizing, call for a repaint. repaintPlaypalCanvas(); }
From source file:Main.java
private AnchorPane addAnchorPane(GridPane grid) { AnchorPane anchorpane = new AnchorPane(); Button buttonSave = new Button("Save"); Button buttonCancel = new Button("Cancel"); HBox hb = new HBox(); hb.setPadding(new Insets(0, 10, 10, 10)); hb.setSpacing(10);//from ww w. j a v a 2 s .c om hb.getChildren().addAll(buttonSave, buttonCancel); anchorpane.getChildren().addAll(grid, hb); // Anchor buttons to bottom right, anchor grid to top AnchorPane.setBottomAnchor(hb, 8.0); AnchorPane.setRightAnchor(hb, 5.0); AnchorPane.setTopAnchor(grid, 10.0); return anchorpane; }
From source file:fruitproject.FruitProject.java
public void third(final String pfname) { final Stage st = new Stage(); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER);/*from ww w .java 2s . c o m*/ grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); Label label1 = new Label("New Fruit"); grid.add(label1, 1, 0); final TextField txtName = new TextField(); grid.add(txtName, 1, 1); final TextField txtAmount = new TextField(); grid.add(txtAmount, 1, 2); Button btn = new Button(); btn.setText("OK"); grid.add(btn, 1, 3); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); addPairs.add(txtName.getText()); addPairs.add(txtAmount.getText()); st.close(); second(pfname); } }); Scene scene = new Scene(grid, 500, 500); st.setScene(scene); st.show(); }