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

The following examples show how to use javafx.scene.layout.StackPane#setMinSize() . 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: 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 3
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 4
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 5
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 6
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 7
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 8
Source File: ViewNumberChart.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Node constructContent() {
    VBox vboxroot = new VBox();
    vboxroot.setSpacing(10.0);   
    
    boxview = new HBox();
    boxview.setSpacing(6.0);
    
    level = new Label();
    level.setAlignment(Pos.CENTER_RIGHT);
    level.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    level.getStyleClass().add("unitmaintext");
    HBox.setHgrow(level, Priority.SOMETIMES);
    
    boxview.getChildren().add(level);
    
    areachart = new ChartNode();
    StackPane chart = areachart.getNode();
    chart.setMinSize(40.0, 50.0);
    chart.setPrefSize(40.0, 50.0);
    chart.setPadding(Insets.EMPTY);
    
    StackPane stack = new StackPane(chart);
    VBox.setVgrow(stack, Priority.SOMETIMES);   
    stack.setPadding(new Insets(0.0, 0.0, 0.0, 3.0));
    vboxroot.getChildren().addAll(boxview, stack);
    
    initialize();
    return vboxroot;
}
 
Example 9
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 10
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 11
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());
}