Search in sources :

Example 11 with ImagePattern

use of javafx.scene.paint.ImagePattern in project Board-Instrumentation-Framework by intel.

the class ConicalGradient method apply.

public ImagePattern apply(final Shape SHAPE) {
    double x = SHAPE.getLayoutBounds().getMinX();
    double y = SHAPE.getLayoutBounds().getMinY();
    double width = SHAPE.getLayoutBounds().getWidth();
    double height = SHAPE.getLayoutBounds().getHeight();
    center = new Point2D(width * 0.5, height * 0.5);
    return new ImagePattern(getImage(width, height), x, y, width, height, false);
}
Also used : Point2D(javafx.geometry.Point2D) ImagePattern(javafx.scene.paint.ImagePattern)

Example 12 with ImagePattern

use of javafx.scene.paint.ImagePattern in project Board-Instrumentation-Framework by intel.

the class RadialBargraphSkin method resize.

private void resize() {
    size = getSkinnable().getWidth() < getSkinnable().getHeight() ? getSkinnable().getWidth() : getSkinnable().getHeight();
    centerX = size * 0.5;
    centerY = size * 0.5;
    if (size > 0) {
        pane.setMaxSize(size, size);
        pane.relocate((getSkinnable().getWidth() - size) * 0.5, (getSkinnable().getHeight() - size) * 0.5);
        final double RADIUS = size * 0.5 - 2;
        valueBlendBottomShadow.setOffsetY(0.005 * size);
        valueBlendTopShadow.setOffsetY(0.005 * size);
        valueBlendTopShadow.setRadius(0.005 * size);
        dropShadow.setRadius(0.015 * size);
        dropShadow.setOffsetY(0.015 * size);
        background.setPrefSize(size, size);
        ticksAndSectionsCanvas.setWidth(size);
        ticksAndSectionsCanvas.setHeight(size);
        ticksAndSections.clearRect(0, 0, size, size);
        drawSections(ticksAndSections);
        drawTickMarks(ticksAndSections);
        ticksAndSectionsCanvas.setCache(true);
        ticksAndSectionsCanvas.setCacheHint(CacheHint.QUALITY);
        drawMarkers();
        minMeasuredValue.setPrefSize(0.03 * size, 0.03 * size);
        minMeasuredValue.relocate((size - minMeasuredValue.getPrefWidth()) * 0.5, size * 0.11);
        minMeasuredValueRotate.setPivotX(minMeasuredValue.getPrefWidth() * 0.5);
        minMeasuredValueRotate.setPivotY(size * 0.39);
        minMeasuredValueRotate.setAngle(getSkinnable().getMinMeasuredValue() * angleStep - 180 - getSkinnable().getStartAngle());
        maxMeasuredValue.setPrefSize(0.03 * size, 0.03 * size);
        maxMeasuredValue.relocate((size - maxMeasuredValue.getPrefWidth()) * 0.5, size * 0.11);
        maxMeasuredValueRotate.setPivotX(maxMeasuredValue.getPrefWidth() * 0.5);
        maxMeasuredValueRotate.setPivotY(size * 0.39);
        maxMeasuredValueRotate.setAngle(getSkinnable().getMaxMeasuredValue() * angleStep - 180 - getSkinnable().getStartAngle());
        threshold.setPrefSize(0.06 * size, 0.055 * size);
        threshold.relocate((size - threshold.getPrefWidth()) * 0.5, size * 0.08);
        thresholdRotate.setPivotX(threshold.getPrefWidth() * 0.5);
        thresholdRotate.setPivotY(size * 0.42);
        thresholdRotate.setAngle(getSkinnable().getThreshold() * angleStep - 180 - getSkinnable().getStartAngle());
        bar.setCenterX(centerX);
        bar.setCenterY(centerY);
        bar.setRadiusX(RADIUS);
        bar.setRadiusY(RADIUS);
        if (getSkinnable().isBarGradientEnabled()) {
            recalculateBarGradient();
            Image image = barGradient.getImage(size, size);
            bar.setFill(new ImagePattern(image, 0, 0, size, size, false));
        } else {
            bar.setFill(new RadialGradient(0, 0, centerX, centerY, RADIUS, false, CycleMethod.NO_CYCLE, new Stop(0.0, barColor), // -5 for on the barColorHue)
            new Stop(0.76, barColor.deriveColor(-5, 1, 1, 1)), new Stop(0.79, barColor), new Stop(0.97, barColor), // -5 for on the barColorHue)
            new Stop(1.0, barColor.deriveColor(-5, 1, 1, 1))));
        }
        knob.setPrefSize(size * 0.75, size * 0.75);
        knob.setTranslateX((size - knob.getPrefWidth()) * 0.5);
        knob.setTranslateY((size - knob.getPrefHeight()) * 0.5);
        resizeText();
    }
}
Also used : Stop(javafx.scene.paint.Stop) ImagePattern(javafx.scene.paint.ImagePattern) RadialGradient(javafx.scene.paint.RadialGradient) Image(javafx.scene.image.Image)

Aggregations

ImagePattern (javafx.scene.paint.ImagePattern)12 Image (javafx.scene.image.Image)6 SnapshotParameters (javafx.scene.SnapshotParameters)5 Stop (javafx.scene.paint.Stop)4 Canvas (javafx.scene.canvas.Canvas)3 GraphicsContext (javafx.scene.canvas.GraphicsContext)3 LinearGradient (javafx.scene.paint.LinearGradient)3 Rectangle (javafx.scene.shape.Rectangle)3 Group (javafx.scene.Group)2 TextFieldTableCell (javafx.scene.control.cell.TextFieldTableCell)2 WritableImage (javafx.scene.image.WritableImage)2 BasicStroke (java.awt.BasicStroke)1 Color (java.awt.Color)1 Graphics2D (java.awt.Graphics2D)1 BufferedImage (java.awt.image.BufferedImage)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 java.util (java.util)1