Java Code Examples for javafx.scene.layout.StackPane#setPrefSize()

The following examples show how to use javafx.scene.layout.StackPane#setPrefSize() . 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: ChartViewerSkin.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/** 
 * Creates the node representing this control.
 * 
 * @return The node.
 */
private BorderPane createNode(ChartViewer control) {
    BorderPane borderPane = new BorderPane();
    borderPane.setPrefSize(800, 500);
    StackPane sp = new StackPane();
    sp.setMinSize(10, 10);
    sp.setPrefSize(600, 400);
    this.canvas = new ChartCanvas(getSkinnable().getChart());
    this.canvas.setTooltipEnabled(control.isTooltipEnabled());
    this.canvas.addChartMouseListener(control);
    this.canvas.widthProperty().bind(sp.widthProperty());
    this.canvas.heightProperty().bind(sp.heightProperty());
 
    this.canvas.addMouseHandler(new ZoomHandlerFX("zoom", control));
    sp.getChildren().add(this.canvas);
    
    borderPane.setCenter(sp);
    return borderPane;
}
 
Example 2
Source File: ChartViewerSkin.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/** 
 * Creates the node representing this control.
 * 
 * @return The node.
 */
private BorderPane createNode(ChartViewer control) {
    BorderPane borderPane = new BorderPane();
    borderPane.setPrefSize(800, 500);
    StackPane sp = new StackPane();
    sp.setMinSize(10, 10);
    sp.setPrefSize(600, 400);
    this.canvas = new ChartCanvas(getSkinnable().getChart());
    this.canvas.setTooltipEnabled(control.isTooltipEnabled());
    this.canvas.addChartMouseListener(control);
    this.canvas.widthProperty().bind(sp.widthProperty());
    this.canvas.heightProperty().bind(sp.heightProperty());
 
    this.canvas.addMouseHandler(new ZoomHandlerFX("zoom", control));
    sp.getChildren().add(this.canvas);
    
    borderPane.setCenter(sp);
    return borderPane;
}
 
Example 3
Source File: ChartViewerSkin.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/** 
 * Creates the node representing this control.
 * 
 * @return The node.
 */
private BorderPane createNode(ChartViewer control) {
    BorderPane borderPane = new BorderPane();
    borderPane.setPrefSize(800, 500);
    StackPane sp = new StackPane();
    sp.setMinSize(10, 10);
    sp.setPrefSize(600, 400);
    this.canvas = new ChartCanvas(getSkinnable().getChart());
    this.canvas.setTooltipEnabled(control.isTooltipEnabled());
    this.canvas.addChartMouseListener(control);
    this.canvas.widthProperty().bind(sp.widthProperty());
    this.canvas.heightProperty().bind(sp.heightProperty());
 
    this.canvas.addMouseHandler(new ZoomHandlerFX("zoom", control));
    sp.getChildren().add(this.canvas);
    
    borderPane.setCenter(sp);
    return borderPane;
}
 
Example 4
Source File: MultiplayerTray.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
private void createStage() {
	stage = new Stage();
    // out stage will be translucent, so give it a transparent style.
    stage.initStyle(StageStyle.TRANSPARENT);
   	//stage = multiplayerClient.getMainMenu().getStage();
    // create the layout for the javafx stage.
    StackPane layout = new StackPane(createContent());
    layout.setStyle("-fx-background-color: rgba(255, 255, 255, 0.5);");
    layout.setPrefSize(300, 200);

    layout.setOnMouseClicked(event -> stage.hide());

    Scene scene = new Scene(layout);
    // a scene with a transparent fill is necessary to implement the translucent app window.
    scene.setFill(Color.TRANSPARENT);

    stage.setScene(scene);
    stage.setIconified(true);
}
 
Example 5
Source File: EmojiDisplayer.java    From ChatRoom-JavaFX with Apache License 2.0 6 votes vote down vote up
/**
 * 创建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 6
Source File: ChartViewerSkin.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/** 
 * Creates the node representing this control.
 * 
 * @return The node.
 */
private BorderPane createNode(ChartViewer control) {
    BorderPane borderPane = new BorderPane();
    borderPane.setPrefSize(800, 500);
    StackPane sp = new StackPane();
    sp.setMinSize(10, 10);
    sp.setPrefSize(600, 400);
    this.canvas = new ChartCanvas(getSkinnable().getChart());
    this.canvas.setTooltipEnabled(control.isTooltipEnabled());
    this.canvas.addChartMouseListener(control);
    this.canvas.widthProperty().bind(sp.widthProperty());
    this.canvas.heightProperty().bind(sp.heightProperty());
 
    this.canvas.addMouseHandler(new ZoomHandlerFX("zoom", control));
    sp.getChildren().add(this.canvas);
    
    borderPane.setCenter(sp);
    return borderPane;
}
 
Example 7
Source File: ChartViewerSkin.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/** 
 * Creates the node representing this control.
 * 
 * @return The node.
 */
private BorderPane createNode(ChartViewer control) {
    BorderPane borderPane = new BorderPane();
    borderPane.setPrefSize(800, 500);
    StackPane sp = new StackPane();
    sp.setMinSize(10, 10);
    sp.setPrefSize(600, 400);
    this.canvas = new ChartCanvas(getSkinnable().getChart());
    this.canvas.setTooltipEnabled(control.isTooltipEnabled());
    this.canvas.addChartMouseListener(control);
    this.canvas.widthProperty().bind(sp.widthProperty());
    this.canvas.heightProperty().bind(sp.heightProperty());
 
    this.canvas.addMouseHandler(new ZoomHandlerFX("zoom", control));
    sp.getChildren().add(this.canvas);
    
    borderPane.setCenter(sp);
    return borderPane;
}
 
Example 8
Source File: ChartViewerSkin.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/** 
 * Creates the node representing this control.
 * 
 * @return The node.
 */
private BorderPane createNode(ChartViewer control) {
    BorderPane borderPane = new BorderPane();
    borderPane.setPrefSize(800, 500);
    StackPane sp = new StackPane();
    sp.setMinSize(10, 10);
    sp.setPrefSize(600, 400);
    this.canvas = new ChartCanvas(getSkinnable().getChart());
    this.canvas.setTooltipEnabled(control.isTooltipEnabled());
    this.canvas.addChartMouseListener(control);
    this.canvas.widthProperty().bind(sp.widthProperty());
    this.canvas.heightProperty().bind(sp.heightProperty());
 
    this.canvas.addMouseHandler(new ZoomHandlerFX("zoom", control));
    sp.getChildren().add(this.canvas);
    
    borderPane.setCenter(sp);
    return borderPane;
}
 
Example 9
Source File: WebFrame.java    From oim-fx with MIT License 5 votes vote down vote up
private void init() {
    
    VBox rootVBox = new VBox();
    
    this.setCenter(rootVBox);
   // this.setBackground("Resources/Images/Wallpaper/1.jpg");
    this.setTitle("登录");
    this.setWidth(380);
    this.setHeight(600);
    this.setRadius(10);
    
    StackPane u = new StackPane();
    u.setPrefSize(50, 100);
   // String hString = this.getClass().getResource("/resources/chat/index.html").toString();
    File file = new File("Resources/Images/Head/User/90_100.gif");
    
    String fullPath = file.getAbsolutePath();
    String htmlText = "<html><body> <lable>666</label>"
            + "<img src=\"file:/"+fullPath+"\" />"
            + "</body></html> ";
    System.out.println(htmlText);
    WebView webView = new WebView();
    webView.setContextMenuEnabled(false);
    WebEngine we = webView.getEngine();
    //we.load(hString);
    Image logoIamge = new Image(this.getClass().getResource("/resources/login/logo.png").toExternalForm(), true);
    ImageView logoImageView = new ImageView();
    logoImageView.setImage(logoIamge);
    we.loadContent(htmlText);
   // Document d = we.getDocument();
    // Element root = we.getDocument().getDocumentElement();
    // NodeList nl = root.getElementsByTagName("body");
    // Node node = nl.item(0);

    //node.appendChild(node);
    rootVBox.getChildren().add(u);
    rootVBox.getChildren().add(webView);
}
 
Example 10
Source File: CommitVisualizer.java    From FXTutorials with MIT License 5 votes vote down vote up
private Parent createContent() {
    StackPane root = new StackPane();
    root.setPrefSize(800, 600);

    LineChart<String, Number> chart = new LineChart<>(
            new CategoryAxis(), new NumberAxis()
    );

    chart.getData().add(extract(Paths.get("log1.txt"), "Project 1"));
    chart.getData().add(extract(Paths.get("log2.txt"), "Project 2"));

    root.getChildren().add(chart);

    return root;
}
 
Example 11
Source File: ViewChart.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Node constructContent() {
    areachart = new ChartNode();
    StackPane chart = areachart.getNode();
    chart.setMinSize(40.0, 240.0);
    chart.setPrefSize(40.0, 240.0);
    chart.setPadding(Insets.EMPTY);
    
    legendcontainer = new VBox();
    legendcontainer.getStyleClass().add("unitchartlegend");
    
    chartcontainer = new BorderPane(chart);
    return chartcontainer;
}
 
Example 12
Source File: SmoothedChart.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
public void setSymbolSize(final Series<X, Y> SERIES, final double SIZE) {
    if (!getData().contains(SERIES)) { return; }
    if (SERIES.getData().isEmpty()) { return; }
    double symbolSize = Helper.clamp(0, 30, SIZE);
    for (XYChart.Data<X, Y> data : SERIES.getData()) {
        StackPane stackPane = (StackPane) data.getNode();
        if (null == stackPane) { continue; }
        stackPane.setPrefSize(symbolSize, symbolSize);
    }
}
 
Example 13
Source File: StackPaneSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static Node createIconContent() {
    StackPane sp = new StackPane();

    Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    sp.setPrefSize(rectangle.getWidth(), rectangle.getHeight());

    Rectangle biggerRec = new Rectangle(55, 55, Color.web("#1c89f4"));
    Rectangle smallerRec = new Rectangle(35, 35, Color.web("#349b00"));

    sp.getChildren().addAll(rectangle, biggerRec, smallerRec);
    return new Group(sp);
}
 
Example 14
Source File: StackPaneSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static Node createIconContent() {
    StackPane sp = new StackPane();

    Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    sp.setPrefSize(rectangle.getWidth(), rectangle.getHeight());

    Rectangle biggerRec = new Rectangle(55, 55, Color.web("#1c89f4"));
    Rectangle smallerRec = new Rectangle(35, 35, Color.web("#349b00"));

    sp.getChildren().addAll(rectangle, biggerRec, smallerRec);
    return new Group(sp);
}
 
Example 15
Source File: SmoothedChart.java    From OEE-Designer with MIT License 5 votes vote down vote up
public void setSymbolSize(final Series<X, Y> SERIES, final double SIZE) {
    if (!getData().contains(SERIES)) { return; }
    if (SERIES.getData().isEmpty()) { return; }
    double symbolSize = Helper.clamp(0, 30, SIZE);
    for (XYChart.Data<X, Y> data : SERIES.getData()) {
        StackPane stackPane = (StackPane) data.getNode();
        if (null == stackPane) { continue; }
        stackPane.setPrefSize(symbolSize, symbolSize);
    }
}
 
Example 16
Source File: DefaultUIProvider.java    From fxlauncher with Apache License 2.0 4 votes vote down vote up
public Parent createLoader() {
	StackPane root = new StackPane(new ProgressIndicator());
	root.setPrefSize(200, 80);
	root.setPadding(new Insets(10));
	return root;
}
 
Example 17
Source File: Notification.java    From Enzo with Apache License 2.0 4 votes vote down vote up
/**
 * Creates and shows a popup with the data from the given Notification object
 * @param NOTIFICATION
 */
private void showPopup(final Notification NOTIFICATION) {
    Label title = new Label(NOTIFICATION.TITLE);
    title.getStyleClass().add("title");

    ImageView icon = new ImageView(NOTIFICATION.IMAGE);
    icon.setFitWidth(ICON_WIDTH);
    icon.setFitHeight(ICON_HEIGHT);

    Label message = new Label(NOTIFICATION.MESSAGE, icon);
    message.getStyleClass().add("message");

    VBox popupLayout = new VBox();
    popupLayout.setSpacing(10);
    popupLayout.setPadding(new Insets(10, 10, 10, 10));
    popupLayout.getChildren().addAll(title, message);

    StackPane popupContent = new StackPane();
    popupContent.setPrefSize(width, height);
    popupContent.getStyleClass().add("notification");
    popupContent.getChildren().addAll(popupLayout);

    final Popup POPUP = new Popup();
    POPUP.setX( getX() );
    POPUP.setY( getY() );
    POPUP.getContent().add(popupContent);

    popups.add(POPUP);

    // Add a timeline for popup fade out
    KeyValue fadeOutBegin = new KeyValue(POPUP.opacityProperty(), 1.0);
    KeyValue fadeOutEnd   = new KeyValue(POPUP.opacityProperty(), 0.0);

    KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
    KeyFrame kfEnd   = new KeyFrame(Duration.millis(500), fadeOutEnd);

    Timeline timeline = new Timeline(kfBegin, kfEnd);
    timeline.setDelay(popupLifetime);
    timeline.setOnFinished(actionEvent -> Platform.runLater(() -> {
        POPUP.hide();
        popups.remove(POPUP);
    }));

    // Move popup to the right during fade out
    //POPUP.opacityProperty().addListener((observableValue, oldOpacity, opacity) -> popup.setX(popup.getX() + (1.0 - opacity.doubleValue()) * popup.getWidth()) );

    if (stage.isShowing()) {
        stage.toFront();
    } else {
        stage.show();
    }

    POPUP.show(stage);
    timeline.play();
}
 
Example 18
Source File: CountryTileSkin.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
@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 19
Source File: CountryTileSkin.java    From OEE-Designer with MIT License 4 votes vote down vote up
@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 20
Source File: JFXSpinnerSkin.java    From JFoenix with Apache License 2.0 3 votes vote down vote up
public JFXSpinnerSkin(JFXSpinner control) {
    super(control, new BehaviorBase<JFXSpinner>(control, Collections.emptyList()));

    this.control = control;

    blueColor = Color.valueOf("#4285f4");
    redColor = Color.valueOf("#db4437");
    yellowColor = Color.valueOf("#f4b400");
    greenColor = Color.valueOf("#0F9D58");

    arc = new Arc();
    arc.setManaged(false);
    arc.setStartAngle(0);
    arc.setLength(180);
    arc.getStyleClass().setAll("arc");
    arc.setFill(Color.TRANSPARENT);
    arc.setStrokeWidth(3);

    track = new Arc();
    track.setManaged(false);
    track.setStartAngle(0);
    track.setLength(360);
    track.setStrokeWidth(3);
    track.getStyleClass().setAll("track");
    track.setFill(Color.TRANSPARENT);

    fillRect = new Rectangle();
    fillRect.setFill(Color.TRANSPARENT);
    text = new Text();
    text.getStyleClass().setAll("text", "percentage");
    final Group group = new Group(fillRect, track, arc, text);
    group.setManaged(false);
    arcPane = new StackPane(group);
    arcPane.setPrefSize(50, 50);
    getChildren().setAll(arcPane);

    // register listeners
    registerChangeListener(control.indeterminateProperty(), "INDETERMINATE");
    registerChangeListener(control.progressProperty(), "PROGRESS");
    registerChangeListener(control.visibleProperty(), "VISIBLE");
    registerChangeListener(control.parentProperty(), "PARENT");
    registerChangeListener(control.sceneProperty(), "SCENE");
}