Search in sources :

Example 26 with Background

use of javafx.scene.layout.Background in project tilesfx by HanSolo.

the class RadarChart method initGraphics.

private void initGraphics() {
    stops = new ArrayList<>(16);
    for (Stop stop : getGradientStops()) {
        if (Double.compare(stop.getOffset(), 0.0) == 0)
            stops.add(new Stop(0, stop.getColor()));
        stops.add(new Stop(stop.getOffset() * 0.69924 + 0.285, stop.getColor()));
    }
    chartCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    chartCtx = chartCanvas.getGraphicsContext2D();
    overlayCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    overlayCtx = overlayCanvas.getGraphicsContext2D();
    unitText = new Text(getUnit());
    unitText.setTextAlignment(TextAlignment.CENTER);
    unitText.setTextOrigin(VPos.CENTER);
    unitText.setFont(Fonts.latoLight(0.045 * PREFERRED_WIDTH));
    legendStep = (getMaxValue() - getMinValue()) / 5d;
    dropShadow = new DropShadow(BlurType.TWO_PASS_BOX, Color.BLACK, 5, 0, 0, 0);
    minValueText = new Text(String.format(Locale.US, formatString, getMinValue()));
    minValueText.setTextAlignment(TextAlignment.CENTER);
    minValueText.setTextOrigin(VPos.CENTER);
    minValueText.setVisible(isLegendVisible());
    minValueText.setEffect(dropShadow);
    legend1Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep));
    legend1Text.setTextAlignment(TextAlignment.CENTER);
    legend1Text.setTextOrigin(VPos.CENTER);
    legend1Text.setVisible(isLegendVisible());
    legend1Text.setEffect(dropShadow);
    legend2Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep * 2));
    legend2Text.setTextAlignment(TextAlignment.CENTER);
    legend2Text.setTextOrigin(VPos.CENTER);
    legend2Text.setVisible(isLegendVisible());
    legend2Text.setEffect(dropShadow);
    legend3Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep * 3));
    legend3Text.setTextAlignment(TextAlignment.CENTER);
    legend3Text.setTextOrigin(VPos.CENTER);
    legend3Text.setVisible(isLegendVisible());
    legend3Text.setEffect(dropShadow);
    legend4Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep * 3));
    legend4Text.setTextAlignment(TextAlignment.CENTER);
    legend4Text.setTextOrigin(VPos.CENTER);
    legend4Text.setVisible(isLegendVisible());
    legend4Text.setEffect(dropShadow);
    maxValueText = new Text(String.format(Locale.US, formatString, getMaxValue()));
    maxValueText.setTextAlignment(TextAlignment.CENTER);
    maxValueText.setTextOrigin(VPos.CENTER);
    maxValueText.setVisible(isLegendVisible());
    maxValueText.setEffect(dropShadow);
    // Add all nodes
    pane = new Pane(chartCanvas, overlayCanvas, unitText, minValueText, legend1Text, legend2Text, legend3Text, legend4Text, maxValueText);
    pane.setBackground(new Background(new BackgroundFill(getChartBackgroundColor(), new CornerRadii(1024), Insets.EMPTY)));
    getChildren().setAll(pane);
}
Also used : Background(javafx.scene.layout.Background) Stop(javafx.scene.paint.Stop) Canvas(javafx.scene.canvas.Canvas) BackgroundFill(javafx.scene.layout.BackgroundFill) Text(javafx.scene.text.Text) CornerRadii(javafx.scene.layout.CornerRadii) Pane(javafx.scene.layout.Pane) DropShadow(javafx.scene.effect.DropShadow)

Example 27 with Background

use of javafx.scene.layout.Background in project tilesfx by HanSolo.

the class SunburstChart method initGraphics.

// ******************** Initialization ************************************
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 || Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }
    segmentPane = new Pane();
    chartCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    chartCanvas.setMouseTransparent(true);
    chartCtx = chartCanvas.getGraphicsContext2D();
    pane = new Pane(segmentPane, chartCanvas);
    pane.setBackground(new Background(new BackgroundFill(backgroundPaint, CornerRadii.EMPTY, Insets.EMPTY)));
    pane.setBorder(new Border(new BorderStroke(borderPaint, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(borderWidth))));
    getChildren().setAll(pane);
    prepareData();
}
Also used : Background(javafx.scene.layout.Background) BorderWidths(javafx.scene.layout.BorderWidths) Canvas(javafx.scene.canvas.Canvas) BackgroundFill(javafx.scene.layout.BackgroundFill) BorderStroke(javafx.scene.layout.BorderStroke) Pane(javafx.scene.layout.Pane) Border(javafx.scene.layout.Border)

Example 28 with Background

use of javafx.scene.layout.Background in project tilesfx by HanSolo.

the class LeaderBoardItem method initGraphics.

// ******************** Initialization ************************************
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 || Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            // 11x7
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }
    state = State.CONSTANT;
    triangle = new Path();
    triangle.setStroke(null);
    triangle.setFill(state.color);
    triangle.setRotate(state.angle);
    nameText = new Text(getName());
    nameText.setTextOrigin(VPos.TOP);
    valueText = new Text(String.format(locale, formatString, getValue()));
    valueText.setTextOrigin(VPos.TOP);
    separator = new Line();
    pane = new Pane(triangle, nameText, valueText, separator);
    pane.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
    getChildren().setAll(pane);
}
Also used : Path(javafx.scene.shape.Path) ClosePath(javafx.scene.shape.ClosePath) Line(javafx.scene.shape.Line) Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) Text(javafx.scene.text.Text) Pane(javafx.scene.layout.Pane)

Example 29 with Background

use of javafx.scene.layout.Background in project TestFX by TestFX.

the class BoundsQueryUtilsTest method setupRegion.

private static void setupRegion() {
    region = new Region();
    region.setMaxSize(0, 0);
    region.setBackground(new Background(new BackgroundFill(Color.RED, null, null)));
    // nodeBounds(), nodeBoundsInLocal()
    region.setPadding(new Insets(0, 0, 0, PADDING_LEFT));
    region.setBorder(new Border(new BorderStroke(Color.BLUE, BorderStrokeStyle.SOLID, null, // nodeBounds(), nodeBoundsInLocal()
    new BorderWidths(0, 0, 0, BORDER_LEFT))));
    // nodeBoundsInParent()
    StackPane.setMargin(region, new Insets(0, 0, 0, MARGIN_LEFT));
}
Also used : Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) BorderWidths(javafx.scene.layout.BorderWidths) BackgroundFill(javafx.scene.layout.BackgroundFill) Region(javafx.scene.layout.Region) BorderStroke(javafx.scene.layout.BorderStroke) Border(javafx.scene.layout.Border)

Example 30 with Background

use of javafx.scene.layout.Background in project testing-video by testing-av.

the class FxDisplay method start.

@Override
public void start(Stage stage) throws Exception {
    Parent pane = root.get();
    double width = size.width;
    double height = size.height;
    VBox box = new VBox(pane);
    VBox.setVgrow(pane, ALWAYS);
    box.setMinSize(width, height);
    box.setPrefSize(width, height);
    box.setMaxSize(width, height);
    box.setBackground(new Background(new BackgroundFill(fill, null, null)));
    var scroll = new ScrollPane(box);
    var scene = new Scene(scroll);
    stage.setScene(scene);
    stage.show();
}
Also used : Background(javafx.scene.layout.Background) Parent(javafx.scene.Parent) ScrollPane(javafx.scene.control.ScrollPane) BackgroundFill(javafx.scene.layout.BackgroundFill) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox)

Aggregations

Background (javafx.scene.layout.Background)86 BackgroundFill (javafx.scene.layout.BackgroundFill)82 Insets (javafx.geometry.Insets)30 CornerRadii (javafx.scene.layout.CornerRadii)24 Scene (javafx.scene.Scene)18 StackPane (javafx.scene.layout.StackPane)15 Color (javafx.scene.paint.Color)15 Label (javafx.scene.control.Label)14 Border (javafx.scene.layout.Border)14 BorderStroke (javafx.scene.layout.BorderStroke)14 BorderWidths (javafx.scene.layout.BorderWidths)12 Pane (javafx.scene.layout.Pane)12 Text (javafx.scene.text.Text)9 BorderPane (javafx.scene.layout.BorderPane)8 Region (javafx.scene.layout.Region)8 HBox (javafx.scene.layout.HBox)7 ArrayList (java.util.ArrayList)6 MouseEvent (javafx.scene.input.MouseEvent)6 VBox (javafx.scene.layout.VBox)6 Rectangle (javafx.scene.shape.Rectangle)5