Search in sources :

Example 1 with SVGPath

use of javafx.scene.shape.SVGPath in project Board-Instrumentation-Framework by intel.

the class ShapeConverter method shapeToSvgPath.

public static SVGPath shapeToSvgPath(final Shape SHAPE) {
    SVGPath svgPath = new SVGPath();
    svgPath.setContent(shapeToSvgString(SHAPE));
    return svgPath;
}
Also used : SVGPath(javafx.scene.shape.SVGPath)

Example 2 with SVGPath

use of javafx.scene.shape.SVGPath in project TeachingInSimulation by ScOrPiOzzy.

the class SVGGlyph method init.

// public SVGGlyph(String svgPathContent) {
// this(-1, "UNNAMED", svgPathContent, Color.BLACK);
// }
// public SVGGlyph(String svgPathContent, Paint fill) {
// this(-1, "UNNAMED", svgPathContent, fill);
// }
// /**
// * Constructs SVGGlyph node for a specified svg content and color <b>Note:</b> name and glyphId is not needed when creating a single SVG image, they have been used in {@link SVGHelper} to load icomoon svg font.
// * @param glyphId integer represents the glyph id
// * @param name glyph name
// * @param svgPathContent svg content
// * @param fill svg color
// */
// public SVGGlyph(int glyphId, String name, String svgPathContent, Paint fill) {
// this.glyphId = glyphId;
// this.name.set(name);
// init(svgPathContent, fill);
// }
private void init(String svgPathContent, Paint fill) {
    getStyleClass().add(DEFAULT_STYLE_CLASS);
    this.fill.addListener((observable) -> setBackground(new Background(new BackgroundFill(getFill() == null ? Color.BLACK : getFill(), null, null))));
    shapeProperty().addListener(observable -> {
        Shape shape = getShape();
        if (getShape() != null) {
            widthHeightRatio = shape.prefWidth(-1) / shape.prefHeight(-1);
            if (getSize() != Region.USE_COMPUTED_SIZE) {
                setSizeRatio(getSize());
            }
        }
    });
    SVGPath shape = new SVGPath();
    shape.setContent(svgPathContent);
    setShape(shape);
    setFill(fill);
    setPrefSize(DEFAULT_PREF_SIZE, DEFAULT_PREF_SIZE);
    getTransforms().add(new Scale(1, -1));
    Translate height = new Translate();
    height.yProperty().bind(Bindings.createDoubleBinding(() -> -this.getHeight(), this.heightProperty()));
    getTransforms().add(height);
}
Also used : Shape(javafx.scene.shape.Shape) Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) Scale(javafx.scene.transform.Scale) SVGPath(javafx.scene.shape.SVGPath) Translate(javafx.scene.transform.Translate)

Aggregations

SVGPath (javafx.scene.shape.SVGPath)2 Background (javafx.scene.layout.Background)1 BackgroundFill (javafx.scene.layout.BackgroundFill)1 Shape (javafx.scene.shape.Shape)1 Scale (javafx.scene.transform.Scale)1 Translate (javafx.scene.transform.Translate)1