Java Code Examples for javafx.scene.layout.StackPane#setMaxSize()
The following examples show how to use
javafx.scene.layout.StackPane#setMaxSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmojiDisplayer.java From ChatRoom-JavaFX with Apache License 2.0 | 6 votes |
/** * 创建emoji图片节点 * * @param emoji * emoji * @param size * 图片显示大小 * @param pad * 图片间距 * @param isCursor * 是否需要图片光标及鼠标处理事件 * @return */ public static Node createEmojiNode(Emoji emoji, int size, int pad) { // 将表情放到stackpane中 StackPane stackPane = new StackPane(); stackPane.setMaxSize(size, size); stackPane.setPrefSize(size, size); stackPane.setMinSize(size, size); stackPane.setPadding(new Insets(pad)); ImageView imageView = new ImageView(); imageView.setFitWidth(size); imageView.setFitHeight(size); imageView.setImage(ImageCache.getInstance().getImage(getEmojiImagePath(emoji.getHex()))); stackPane.getChildren().add(imageView); return stackPane; }
Example 2
Source File: EditAreaView.java From helloiot with GNU General Public License v3.0 | 6 votes |
@Override public Node constructContent() { StackPane stackpaneroot = new StackPane(); stackpaneroot.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); BorderPane borderpane = new BorderPane(); statusview = new TextArea(); statusview.setEditable(false); statusview.setFocusTraversable(false); statusview.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); statusview.setPrefHeight(100.0); statusview.getStyleClass().add("unitinputview"); BorderPane.setAlignment(statusview, Pos.CENTER); borderpane.setCenter(statusview); stackpaneroot.getChildren().add(borderpane); initialize(); return stackpaneroot; }
Example 3
Source File: LogView.java From helloiot with GNU General Public License v3.0 | 6 votes |
@Override public Node constructContent() { StackPane stackpaneroot = new StackPane(); stackpaneroot.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); BorderPane borderpane = new BorderPane(); statusview = new TextArea(); statusview.setEditable(false); statusview.setFocusTraversable(false); statusview.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); statusview.setPrefHeight(100.0); statusview.getStyleClass().addAll("unitinputview", "unitinputcode"); BorderPane.setAlignment(statusview, Pos.CENTER); borderpane.setCenter(statusview); stackpaneroot.getChildren().add(borderpane); initialize(); return stackpaneroot; }
Example 4
Source File: MainScene.java From mars-sim with GNU General Public License v3.0 | 6 votes |
public void createFXSettlementComboBox() { sBox = new JFXComboBox<>(); sBox.getStyleClass().add("jfx-combo-box"); setQuickToolTip(sBox, Msg.getString("SettlementWindow.tooltip.selectSettlement")); //$NON-NLS-1$ changeSBox(); // sBox.itemsProperty().setValue(FXCollections.observableArrayList(unitManager.getSettlements())); sBox.setPromptText("Select a settlement to view"); sBox.getSelectionModel().selectFirst(); sBox.valueProperty().addListener((observable, oldValue, newValue) -> { if (oldValue != newValue) { SwingUtilities.invokeLater(() -> mapPanel.setSettlement((Settlement) newValue)); } }); settlementBox = new StackPane(sBox); settlementBox.setOpacity(1); settlementBox.setMaxSize(180, 30); settlementBox.setPrefSize(180, 30); settlementBox.setAlignment(Pos.CENTER_RIGHT); }
Example 5
Source File: JFXDialog.java From JFoenix with Apache License 2.0 | 6 votes |
private void initialize() { this.setVisible(false); this.getStyleClass().add(DEFAULT_STYLE_CLASS); this.transitionType.addListener((o, oldVal, newVal) -> { animation = getShowAnimation(transitionType.get()); }); contentHolder = new StackPane(); contentHolder.setBackground(new Background(new BackgroundFill(Color.WHITE, new CornerRadii(2), null))); JFXDepthManager.setDepth(contentHolder, 4); contentHolder.setPickOnBounds(false); // ensure stackpane is never resized beyond it's preferred size contentHolder.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE); this.getChildren().add(contentHolder); this.getStyleClass().add("jfx-dialog-overlay-pane"); StackPane.setAlignment(contentHolder, Pos.CENTER); this.setBackground(new Background(new BackgroundFill(Color.rgb(0, 0, 0, 0.1), null, null))); // close the dialog if clicked on the overlay pane if (overlayClose.get()) { this.addEventHandler(MouseEvent.MOUSE_PRESSED, closeHandler); } // prevent propagating the events to overlay pane contentHolder.addEventHandler(MouseEvent.ANY, e -> e.consume()); }
Example 6
Source File: CountryTileSkin.java From OEE-Designer with MIT License | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); //poiLocations = FXCollections.observableHashMap(); //chartDataLocations = FXCollections.observableHashMap(); //circleHandlerMap = new HashMap<>(); country = tile.getCountry(); if (null == country) { country = Country.DE; } clickHandler = event -> tile.fireTileEvent(new TileEvent(EventType.SELECTED_CHART_DATA, new ChartData(country.getName(), country.getValue(), country.getColor()))); countryPaths = Helper.getHiresCountryPaths().get(country.name()); countryMinX = Helper.MAP_WIDTH; countryMinY = Helper.MAP_HEIGHT; countryMaxX = 0; countryMaxY = 0; countryPaths.forEach(path -> { path.setFill(tile.getBarColor()); countryMinX = Math.min(countryMinX, path.getBoundsInParent().getMinX()); countryMinY = Math.min(countryMinY, path.getBoundsInParent().getMinY()); countryMaxX = Math.max(countryMaxX, path.getBoundsInParent().getMaxX()); countryMaxY = Math.max(countryMaxY, path.getBoundsInParent().getMaxY()); }); /* tile.getPoiList() .forEach(poi -> { String tooltipText = new StringBuilder(poi.getName()).append("\n") .append(poi.getInfo()) .toString(); Circle circle = new Circle(3, poi.getColor()); circle.setOnMousePressed(e -> poi.fireLocationEvent(new LocationEvent(poi))); Tooltip.install(circle, new Tooltip(tooltipText)); poiLocations.put(poi, circle); }); */ titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); text = new Text(tile.getCountry().getDisplayName()); text.setFill(tile.getTextColor()); Helper.enableNode(text, tile.isTextVisible()); countryGroup = new Group(); countryGroup.getChildren().setAll(countryPaths); countryContainer = new StackPane(); countryContainer.setMinSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); countryContainer.setMaxSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); countryContainer.setPrefSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); countryContainer.getChildren().setAll(countryGroup); valueText = new Text(String.format(locale, formatString, ((tile.getValue() - minValue) / range * 100))); valueText.setFill(tile.getValueColor()); valueText.setTextOrigin(VPos.BASELINE); Helper.enableNode(valueText, tile.isValueVisible()); unitText = new Text(" " + tile.getUnit()); unitText.setFill(tile.getUnitColor()); unitText.setTextOrigin(VPos.BASELINE); Helper.enableNode(unitText, !tile.getUnit().isEmpty()); valueUnitFlow = new TextFlow(valueText, unitText); valueUnitFlow.setTextAlignment(TextAlignment.RIGHT); valueUnitFlow.setMouseTransparent(true); getPane().getChildren().addAll(titleText, countryContainer, valueUnitFlow, text); //getPane().getChildren().addAll(poiLocations.values()); }
Example 7
Source File: CountryTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); //poiLocations = FXCollections.observableHashMap(); //chartDataLocations = FXCollections.observableHashMap(); //circleHandlerMap = new HashMap<>(); country = tile.getCountry(); if (null == country) { country = Country.DE; } clickHandler = event -> tile.fireTileEvent(new TileEvent(EventType.SELECTED_CHART_DATA, new ChartData(country.getName(), country.getValue(), country.getColor()))); countryPaths = Helper.getHiresCountryPaths().get(country.name()); countryMinX = Helper.MAP_WIDTH; countryMinY = Helper.MAP_HEIGHT; countryMaxX = 0; countryMaxY = 0; countryPaths.forEach(path -> { path.setFill(tile.getBarColor()); countryMinX = Math.min(countryMinX, path.getBoundsInParent().getMinX()); countryMinY = Math.min(countryMinY, path.getBoundsInParent().getMinY()); countryMaxX = Math.max(countryMaxX, path.getBoundsInParent().getMaxX()); countryMaxY = Math.max(countryMaxY, path.getBoundsInParent().getMaxY()); }); /* tile.getPoiList() .forEach(poi -> { String tooltipText = new StringBuilder(poi.getName()).append("\n") .append(poi.getInfo()) .toString(); Circle circle = new Circle(3, poi.getColor()); circle.setOnMousePressed(e -> poi.fireLocationEvent(new LocationEvent(poi))); Tooltip.install(circle, new Tooltip(tooltipText)); poiLocations.put(poi, circle); }); */ titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); text = new Text(tile.getCountry().getDisplayName()); text.setFill(tile.getTextColor()); Helper.enableNode(text, tile.isTextVisible()); countryGroup = new Group(); countryGroup.getChildren().setAll(countryPaths); countryContainer = new StackPane(); countryContainer.setMinSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); countryContainer.setMaxSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); countryContainer.setPrefSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); countryContainer.getChildren().setAll(countryGroup); valueText = new Text(String.format(locale, formatString, ((tile.getValue() - minValue) / range * 100))); valueText.setFill(tile.getValueColor()); valueText.setTextOrigin(VPos.BASELINE); Helper.enableNode(valueText, tile.isValueVisible()); upperUnitText = new Text(""); upperUnitText.setFill(tile.getUnitColor()); Helper.enableNode(upperUnitText, !tile.getUnit().isEmpty()); fractionLine = new Line(); unitText = new Text(tile.getUnit()); unitText.setFill(tile.getUnitColor()); Helper.enableNode(unitText, !tile.getUnit().isEmpty()); unitFlow = new VBox(upperUnitText, unitText); unitFlow.setAlignment(Pos.CENTER_RIGHT); valueUnitFlow = new HBox(valueText, unitFlow); valueUnitFlow.setAlignment(Pos.BOTTOM_RIGHT); valueUnitFlow.setMouseTransparent(true); valueUnitFlow.setMouseTransparent(true); getPane().getChildren().addAll(titleText, countryContainer, valueUnitFlow, fractionLine, text); //getPane().getChildren().addAll(poiLocations.values()); }
Example 8
Source File: SimpleErrorDialog.java From arma-dialog-creator with MIT License | 4 votes |
/** @param primaryStage the primary stage @param title title of dialog @param error use null if you wish to not show a strack trace to the user @param body body to use, or null to not have a body */ public SimpleErrorDialog(@Nullable Stage primaryStage, @Nullable String title, @Nullable Throwable error, @Nullable B body) { super(primaryStage, new VBox(10), title, false, true, false); this.myBody = body; ResourceBundle bundle = Lang.ApplicationBundle(); final String showStackTraceLblStr = bundle.getString("Popups.SimpleErrorDialog.show_detail"); final String hideStackTraceLblStr = bundle.getString("Popups.SimpleErrorDialog.hide_detail"); myStage.setMinWidth(300d); myStage.setMinHeight(200d); myStage.setMaxWidth(720); if (body != null) { StackPane stackPane = new StackPane(body); stackPane.setAlignment(Pos.TOP_LEFT); stackPane.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); myRootElement.getChildren().add(stackPane); VBox.setVgrow(stackPane, Priority.ALWAYS); body.autosize(); } if (error != null) { Label lblErrMsg = new Label(error.getMessage()); lblErrMsg.setWrapText(true); myRootElement.getChildren().add(lblErrMsg); ToggleButton toggleButton = new ToggleButton(showStackTraceLblStr); myRootElement.getChildren().add(toggleButton); toggleButton.selectedProperty().addListener(new ChangeListener<Boolean>() { final TextArea taErrorMessage = ExceptionHandler.getExceptionTextArea(error); @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean selected) { if (selected) { toggleButton.setText(hideStackTraceLblStr); myRootElement.getChildren().add(taErrorMessage); } else { toggleButton.setText(showStackTraceLblStr); myRootElement.getChildren().remove(taErrorMessage); } SimpleErrorDialog.this.sizeToScene(); } }); } }
Example 9
Source File: DiagramTab.java From JetUML with GNU General Public License v3.0 | 4 votes |
/** * Constructs a diagram tab initialized with pDiagram. * @param pDiagram The initial diagram */ public DiagramTab(Diagram pDiagram) { aDiagram = pDiagram; DiagramTabToolBar sideBar = new DiagramTabToolBar(pDiagram); UserPreferences.instance().addBooleanPreferenceChangeHandler(sideBar); aDiagramCanvas = new DiagramCanvas(pDiagram); UserPreferences.instance().addBooleanPreferenceChangeHandler(aDiagramCanvas); aDiagramCanvasController = new DiagramCanvasController(aDiagramCanvas, sideBar, this); aDiagramCanvas.setController(aDiagramCanvasController); aDiagramCanvas.paintPanel(); BorderPane layout = new BorderPane(); layout.setRight(sideBar); // We put the diagram in a fixed-size StackPane for the sole purpose of being able to // decorate it with CSS. The StackPane needs to have a fixed size so the border fits the // canvas and not the parent container. StackPane pane = new StackPane(aDiagramCanvas); final int buffer = 12; // (border insets + border width + 1)*2 pane.setMaxSize(aDiagramCanvas.getWidth() + buffer, aDiagramCanvas.getHeight() + buffer); final String cssDefault = "-fx-border-color: grey; -fx-border-insets: 4;" + "-fx-border-width: 1; -fx-border-style: solid;"; pane.setStyle(cssDefault); // We wrap pane within an additional, resizable StackPane that can grow to fit the parent // ScrollPane and thus center the decorated canvas. ScrollPane scroll = new ScrollPane(new StackPane(pane)); // The call below is necessary to removes the focus highlight around the Canvas // See issue #250 scroll.setStyle("-fx-focus-color: transparent; -fx-faint-focus-color: transparent;"); scroll.setFitToWidth(true); scroll.setFitToHeight(true); layout.setCenter(scroll); setTitle(); setContent(layout); setOnCloseRequest(pEvent -> { pEvent.consume(); EditorFrame editorFrame = (EditorFrame) getTabPane().getParent(); editorFrame.close(this); }); }