Java Code Examples for javafx.scene.layout.BackgroundFill#getRadii()

The following examples show how to use javafx.scene.layout.BackgroundFill#getRadii() . 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: GlowBackground.java    From AnimateFX with Apache License 2.0 5 votes vote down vote up
/**
     * Constructs the animation
     *
     * @param node       the node to animate
     * @param colorA     the color to start with
     * @param colorB     the other color
     * @param colorSteps how many interpolations between the two colors
     */
    public GlowBackground(Region node, Color colorA, Color colorB, int colorSteps) {
        super(node);
        this.originalBackground = getNode().backgroundProperty().get();
        if (originalBackground != null && !originalBackground.getFills().isEmpty()) {
            BackgroundFill lastFill = originalBackground.getFills().get(originalBackground.getFills().size() - 1);
            originalRadii = lastFill.getRadii();
            originalInsets = lastFill.getInsets();
        } else {
            originalRadii = CornerRadii.EMPTY;
            originalInsets = Insets.EMPTY;
        }

        int totalFrames = colorSteps * 2;
        double millisPerFrame = 1000 / totalFrames;
        for (int i = 0; i < totalFrames; i++) {
            Color color;
            double frac = i * 2.0 / totalFrames;
            Duration dur = Duration.millis(i * millisPerFrame);
            if (i <= colorSteps) {
                color = colorA.interpolate(colorB, frac);
            } else {
                color = colorB.interpolate(colorA, frac - 1);
            }
            getTimeline().getKeyFrames().add(
                    new KeyFrame(dur,
                            new KeyValue(getNode().backgroundProperty(),
//                                    new Background(new BackgroundFill(color, CornerRadii.EMPTY, Insets.EMPTY)))));
                                    new Background(new BackgroundFill(color, originalRadii, originalInsets)))));
        }

    }
 
Example 2
Source File: JFXNodeUtils.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
public static void updateBackground(Background newBackground, Region nodeToUpdate, Paint fill) {
    if (newBackground != null && !newBackground.getFills().isEmpty()) {
        final BackgroundFill[] fills = new BackgroundFill[newBackground.getFills().size()];
        for (int i = 0; i < newBackground.getFills().size(); i++) {
            BackgroundFill bf = newBackground.getFills().get(i);
            fills[i] = new BackgroundFill(fill, bf.getRadii(), bf.getInsets());
        }
        nodeToUpdate.setBackground(new Background(fills));
    }
}
 
Example 3
Source File: FullPropertiesDetailPaneInfo.java    From scenic-view with GNU General Public License v3.0 4 votes vote down vote up
private static String backgroundFillToString(BackgroundFill backgroundFill) {
    return "paint=" + backgroundFill.getFill() 
        + " insets=" + backgroundFill.getInsets()
        + " radii=" + backgroundFill.getRadii();
}