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);
}
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();
}
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);
}
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));
}
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();
}
Aggregations