Search in sources :

Example 1 with StyleApplier

use of org.geepawhill.contentment.format.StyleApplier in project contentment by GeePawHill.

the class TypeFace method font.

public static Style font(Font font, Double width, Double opacity) {
    StyleApplier applier = new StyleApplier() {

        @Override
        public void apply(Shape shape) {
            if (shape instanceof Text) {
                Text text = (Text) shape;
                text.setFont(font);
                text.setStrokeWidth(width);
                text.setOpacity(opacity);
            }
        }
    };
    return new Style(FACE, applier, font.getFamily() + " " + font.getSize());
}
Also used : Shape(javafx.scene.shape.Shape) Style(org.geepawhill.contentment.format.Style) Text(javafx.scene.text.Text) StyleApplier(org.geepawhill.contentment.format.StyleApplier)

Example 2 with StyleApplier

use of org.geepawhill.contentment.format.StyleApplier in project contentment by GeePawHill.

the class TypeFace method color.

public static Style color(Paint stroke, Paint fill, Double opacity) {
    StyleApplier applier = new StyleApplier() {

        @Override
        public void apply(Shape shape) {
            shape.setStroke(stroke);
            shape.setFill(fill);
            shape.setOpacity(opacity);
        }
    };
    String value = "Stroke: " + stroke.toString() + " Fill: " + fill.toString() + " Opacity: " + opacity;
    return new Style(COLOR, applier, value);
}
Also used : Shape(javafx.scene.shape.Shape) Style(org.geepawhill.contentment.format.Style) StyleApplier(org.geepawhill.contentment.format.StyleApplier)

Example 3 with StyleApplier

use of org.geepawhill.contentment.format.StyleApplier in project contentment by GeePawHill.

the class Frames method frame.

public static Style frame(Paint stroke, Paint fill, Double width, Double opacity, Dash dash) {
    StyleApplier applier = new StyleApplier() {

        @Override
        public void apply(Shape shape) {
            shape.setStroke(stroke);
            shape.setFill(fill);
            shape.setStrokeWidth(width);
            shape.setOpacity(opacity);
            shape.getStrokeDashArray().clear();
            shape.getStrokeDashArray().addAll(dash.array);
        }
    };
    String value = "Frame: " + stroke.toString() + " Fill: " + fill.toString() + " Width: " + width + " Opacity: " + opacity + " Dash: " + dash;
    return new Style(KEY, applier, value);
}
Also used : Shape(javafx.scene.shape.Shape) Style(org.geepawhill.contentment.format.Style) StyleApplier(org.geepawhill.contentment.format.StyleApplier)

Aggregations

Shape (javafx.scene.shape.Shape)3 Style (org.geepawhill.contentment.format.Style)3 StyleApplier (org.geepawhill.contentment.format.StyleApplier)3 Text (javafx.scene.text.Text)1