javafx.scene.paint.ImagePattern Java Examples

The following examples show how to use javafx.scene.paint.ImagePattern. 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: DefaultRenderColorScheme.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
public static void setFillScheme(final GraphicsContext gc, final String defaultStyle, final int dsIndex) {
    AssertUtils.gtEqThanZero("setFillScheme dsIndex", dsIndex);
    final Map<String, List<String>> map = splitQuery(defaultStyle);

    final Color fillColor = StyleParser.getColorPropertyValue(defaultStyle, XYChartCss.FILL_COLOR);
    if (fillColor != null) {
        final Color rawColor = fillColor;

        final Color color = getColorModifier(map, rawColor);
        if (color == null) {
            return;
        }

        final ImagePattern hatch = FillPatternStyleHelper.getDefaultHatch(color.brighter(),
                dsIndex * hatchShiftByIndexProperty().get());

        gc.setFill(hatch);
    } else {
        final int size = fillStylesProperty().size();
        gc.setFill(fillStylesProperty().get(dsIndex % size));
    }
}
 
Example #2
Source File: Pin.java    From BlockMap with MIT License 6 votes vote down vote up
@Override
protected Node initBottomGui() {
	Polygon shape = new Polygon();
	shape.getPoints().setAll(chunkPositions.stream().flatMap(v -> Stream.of(v.x(), v.y())).map(d -> (d + 1) * 16.0).collect(Collectors.toList()));
	shape.setFill(new ImagePattern(image, 0, 0, 16, 16, false));
	getTopGui().hoverProperty().addListener(e -> {
		if (getTopGui().isHover())
			shape.setOpacity(0.6);
		else
			shape.setOpacity(0.2);
	});
	shape.setOpacity(0.2);
	shape.setMouseTransparent(true);
	shape.setCache(true);
	shape.setCacheHint(CacheHint.SCALE);
	shape.setViewOrder(1);
	return shape;
}
 
Example #3
Source File: PackMan.java    From games_oop_javafx with Apache License 2.0 6 votes vote down vote up
private Rectangle buildFigure(int x, int y, int size, String image) {
    Rectangle rect = new Rectangle();
    rect.setX(x);
    rect.setY(y);
    rect.setHeight(size);
    rect.setWidth(size);
    Image img = new Image(this.getClass().getClassLoader().getResource(image).toString());
    rect.setFill(new ImagePattern(img));
    return rect;
}
 
Example #4
Source File: FillPatternStyleHelper.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
public static ImagePattern getDefaultHatch(final Color color) {
    ImagePattern retVal = FillPatternStyleHelper.defaultHatchCache.get(color);
    if (retVal == null) {
        retVal = FillPatternStyleHelper.getDefaultHatch(color, 0.0);
        FillPatternStyleHelper.defaultHatchCache.put(color, retVal);
    }
    return retVal;
}
 
Example #5
Source File: ViewSingleShape.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
private Paint getHatchingsFillingPaint(final FillingStyle style) {
	final Bounds bounds = border.getBoundsInParent();

	if(bounds.getWidth() <= 0d || bounds.getHeight() <= 0d) {
		return null;
	}

	final Group hatchings = new Group();
	final double hAngle = model.getHatchingsAngle();

	hatchings.getChildren().add(new Rectangle(bounds.getWidth(), bounds.getHeight(), style.isFilled() ? model.getFillingCol().toJFX() : null));

	final double angle = hAngle > 0d ? hAngle - Math.PI / 2d : hAngle + Math.PI / 2d;

	switch(style) {
		case VLINES, VLINES_PLAIN -> computeHatchings(hatchings, hAngle, bounds.getWidth(), bounds.getHeight());
		case HLINES, HLINES_PLAIN -> computeHatchings(hatchings, angle, bounds.getWidth(), bounds.getHeight());
		case CLINES, CLINES_PLAIN -> {
			computeHatchings(hatchings, hAngle, bounds.getWidth(), bounds.getHeight());
			computeHatchings(hatchings, angle, bounds.getWidth(), bounds.getHeight());
		}
	}

	final WritableImage image = new WritableImage((int) bounds.getWidth(), (int) bounds.getHeight());
	hatchings.snapshot(new SnapshotParameters(), image);
	return new ImagePattern(image, 0, 0, 1, 1, true);
}
 
Example #6
Source File: BrushedMetalPaint.java    From Enzo with Apache License 2.0 5 votes vote down vote up
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();
    return new ImagePattern(getImage(width, height), x, y, width, height, false);
}
 
Example #7
Source File: ConicalGradient.java    From Enzo with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #8
Source File: SpecklesView.java    From narjillos with MIT License 5 votes vote down vote up
public SpecklesView(Viewport viewport, long ecosystemSize) {
	this.viewport = viewport;

	createBackgroundTextures();

	background = new Rectangle(0, 0, ecosystemSize, ecosystemSize);
	background.setFill(new ImagePattern(backgroundTexture, 0, 0, viewport.getSizeSC().x, viewport.getSizeSC().y, false));

	infraredBackground = new Rectangle(0, 0, ecosystemSize, ecosystemSize);
	infraredBackground
			.setFill(new ImagePattern(infraredBackgroundTexture, 0, 0, viewport.getSizeSC().x, viewport.getSizeSC().y, false));
}
 
Example #9
Source File: Patterns.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
public Image createPattern(CarbonPatterns cp, boolean save) {
    ImagePattern pattern;
    switch (cp) {
        case DARK_CARBON:
            pattern = createCarbonPattern();
            break;
        case LIGHT_CARBON:
            pattern = createLightCarbonPattern();
            break;
        case CARBON_KEVLAR:
            pattern = createCarbonKevlarPattern();
            break;
        default:
            pattern = createCarbonPattern();
            break;
    }

    Rectangle rectangle = new Rectangle(width, height);
    if (pattern != null) {
        rectangle.setFill(pattern);            
    }
    rectangle.setStrokeWidth(0);
    imgPattern = rectangle.snapshot(new SnapshotParameters(), null);
    if (save) {
        saveImage();
    }
    return imgPattern;
}
 
Example #10
Source File: ConicalGradient.java    From regulators with Apache License 2.0 5 votes vote down vote up
public ImagePattern getImagePattern(final Rectangle BOUNDS) {
    double x      = BOUNDS.getX();
    double y      = BOUNDS.getY();
    double width  = BOUNDS.getWidth();
    double height = BOUNDS.getHeight();
    centerX       = width * 0.5;
    centerY       = height * 0.5;
    return new ImagePattern(getImage(width, height), x, y, width, height, false);
}
 
Example #11
Source File: ConicalGradient.java    From regulators with Apache License 2.0 5 votes vote down vote up
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();
    centerX       = width * 0.5;
    centerY       = height * 0.5;
    return new ImagePattern(getImage(width, height), x, y, width, height, false);
}
 
Example #12
Source File: ConicalGradient.java    From Medusa with Apache License 2.0 5 votes vote down vote up
public ImagePattern getImagePattern(final Rectangle BOUNDS) {
    double x      = BOUNDS.getX();
    double y      = BOUNDS.getY();
    double width  = BOUNDS.getWidth();
    double height = BOUNDS.getHeight();
    centerX       = width * 0.5;
    centerY       = height * 0.5;
    return new ImagePattern(getImage(width, height), x, y, width, height, false);
}
 
Example #13
Source File: ConicalGradient.java    From Medusa with Apache License 2.0 5 votes vote down vote up
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();
    centerX       = width * 0.5;
    centerY       = height * 0.5;
    return new ImagePattern(getImage(width, height), x, y, width, height, false);
}
 
Example #14
Source File: TintedImageHelperRenderer.java    From arma-dialog-creator with MIT License 5 votes vote down vote up
public void updateImageAsTiled(@NotNull Image img, int tileW, int tileH, boolean modifyBoth) {
	ImagePattern pattern = new ImagePattern(img, 0, 0, tileW, tileH, false);
	ColorInput colorInput = new ColorInput(0, 0, w, h, pattern);
	if (modifyBoth || previewMode) {
		imgTrans2.setInput(colorInput);
	}
	if (modifyBoth || !previewMode) {
		imgTrans1.setInput(colorInput);
	}
}
 
Example #15
Source File: ADCCanvasView.java    From arma-dialog-creator with MIT License 5 votes vote down vote up
@Override
public void setCanvasBackgroundToImage(@Nullable String imgPath) {
	if (imgPath == null) {
		uiCanvasEditor.setCanvasBackgroundImage(null);
		return;
	}
	uiCanvasEditor.setCanvasBackgroundImage(new ImagePattern(new Image(imgPath)));
}
 
Example #16
Source File: SideMenuUIController.java    From RentLio with Apache License 2.0 5 votes vote down vote up
private void setUpUI(){
    Image userImage = new Image("/images/chamod.jpg");
    Circle circle = new Circle(75);
    ImagePattern imagePattern = new ImagePattern(userImage);
    circle.setFill(imagePattern);
    imgUser.setImage(userImage);
}
 
Example #17
Source File: Puzzle.java    From games_oop_javafx with Apache License 2.0 5 votes vote down vote up
private Rectangle buildFigure(int x, int y, int size, String image) {
    Rectangle rect = new Rectangle();
    rect.setX(x);
    rect.setY(y);
    rect.setHeight(size);
    rect.setWidth(size);
    Image img = new Image(this.getClass().getClassLoader().getResource(image).toString());
    rect.setFill(new ImagePattern(img));
    final Rectangle momento = new Rectangle(x, y);
    rect.setOnDragDetected(
            event -> {
                momento.setX(event.getX());
                momento.setY(event.getY());
            }
    );
    rect.setOnMouseDragged(
            event -> {
                rect.setX(event.getX() - size / 2);
                rect.setY(event.getY() - size / 2);
            }
    );
    rect.setOnMouseReleased(
            event -> {
                if (logic.move(this.extract(momento.getX(), momento.getY()),
                        this.extract(event.getX(), event.getY()))) {
                    rect.setX(((int) event.getX() / 40) * 40 + 5);
                    rect.setY(((int) event.getY() / 40) * 40 + 5);
                    checkWinner();
                } else {
                    rect.setX(((int) momento.getX() / 40) * 40 + 5);
                    rect.setY(((int) momento.getY() / 40) * 40 + 5);
                }
            }
    );
    return rect;
}
 
Example #18
Source File: ConicalGradient.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
public ImagePattern getImagePattern(final CtxBounds BOUNDS) {
    double x      = BOUNDS.getMinX();
    double y      = BOUNDS.getMinY();
    double width  = BOUNDS.getWidth();
    double height = BOUNDS.getHeight();
    centerX       = BOUNDS.getCenterX();
    centerY       = BOUNDS.getCenterY();
    return new ImagePattern(getImage(width, height), x, y, width, height, false);
}
 
Example #19
Source File: Chess.java    From games_oop_javafx with Apache License 2.0 5 votes vote down vote up
private Rectangle buildFigure(int x, int y, int size, String image) {
    Rectangle rect = new Rectangle();
    rect.setX(x);
    rect.setY(y);
    rect.setHeight(size);
    rect.setWidth(size);
    Image img = new Image(this.getClass().getClassLoader().getResource(image).toString());
    rect.setFill(new ImagePattern(img));
    final Rectangle momento = new Rectangle(x, y);
    rect.setOnDragDetected(
            event -> {
                momento.setX(event.getX());
                momento.setY(event.getY());
            }
    );
    rect.setOnMouseDragged(
            event -> {
                rect.setX(event.getX() - size / 2);
                rect.setY(event.getY() - size / 2);
            }
    );
    rect.setOnMouseReleased(
            event -> {
                try {
                    logic.move(
                            this.findBy(momento.getX(), momento.getY()),
                            this.findBy(event.getX(), event.getY()));
                    rect.setX(((int) event.getX() / 40) * 40 + 5);
                    rect.setY(((int) event.getY() / 40) * 40 + 5);
                } catch (Exception e) {
                    Alert info = new Alert(Alert.AlertType.ERROR);
                    info.setContentText(e.getClass().getName() +  " "  + e.getMessage());
                    info.show();
                    rect.setX(((int) momento.getX() / 40) * 40 + 5);
                    rect.setY(((int) momento.getY() / 40) * 40 + 5);
                }
            }
    );
    return rect;
}
 
Example #20
Source File: ConicalGradient.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
public ImagePattern getImagePattern(final Rectangle BOUNDS) {
    double x      = BOUNDS.getX();
    double y      = BOUNDS.getY();
    double width  = BOUNDS.getWidth();
    double height = BOUNDS.getHeight();
    centerX       = width * 0.5;
    centerY       = height * 0.5;
    return new ImagePattern(getImage(width, height), x, y, width, height, false);
}
 
Example #21
Source File: DashPatternStyle.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
private static ImagePattern createDefaultHatch(final Paint color, final double strokeWidth,
        final boolean isHorizontal, final double[] pattern) {
    final Integer hash = computeHash(color, strokeWidth, isHorizontal, pattern);

    return DashPatternStyle.dashHashMap.computeIfAbsent(hash, t -> {
        // need to recompute hatch pattern image
        final double dashPatternLength = getPatternLength(pattern);
        final double width = isHorizontal ? dashPatternLength : strokeWidth;
        final double height = isHorizontal ? strokeWidth : dashPatternLength;
        final double middle = (int) (strokeWidth / 2.0);

        final Pane pane = new Pane();
        pane.setPrefSize(width, height);
        final Line fw = isHorizontal ? new Line(0, middle, dashPatternLength, middle)
                : new Line(middle, 0, middle, dashPatternLength);

        fw.setSmooth(false);
        fw.setStroke(color);
        if (pattern == null) {
            fw.getStrokeDashArray().setAll(dashPatternLength);
        } else {
            fw.getStrokeDashArray().setAll(DoubleStream.of(pattern).boxed().collect(Collectors.toList()));
        }
        fw.setStrokeWidth(strokeWidth);

        pane.getChildren().addAll(fw);
        pane.setStyle("-fx-background-color: rgba(0, 0, 0, 0.0)");
        final Scene scene = new Scene(pane);
        scene.setFill(Color.TRANSPARENT);

        final Image hatch = pane.snapshot(null, null);

        return new ImagePattern(hatch, width, 0, width, height, false);

    });
}
 
Example #22
Source File: ConicalGradient.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
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();
    centerX       = width * 0.5;
    centerY       = height * 0.5;
    return new ImagePattern(getImage(width, height), x, y, width, height, false);
}
 
Example #23
Source File: AngleConicalGradient.java    From Enzo with Apache License 2.0 4 votes vote down vote up
public ImagePattern apply(final Shape SHAPE) {
    return gradient.apply(SHAPE);
}
 
Example #24
Source File: Patterns.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
public static final ImagePattern createLightCarbonPattern() {
    final double WIDTH = 12;
    final double HEIGHT = 12;
    final Canvas CANVAS = new Canvas(WIDTH, HEIGHT);
    final GraphicsContext CTX = CANVAS.getGraphicsContext2D();

    double offsetY = 0;

    CTX.beginPath();
    CTX.rect(0, 0, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();

    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(108, 108, 108)),
            new Stop(1, Color.rgb(100, 100, 100))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.083333, 0, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(142, 142, 142)),
            new Stop(1, Color.rgb(130, 130, 130))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.5, HEIGHT * 0.5, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(108, 108, 108)),
            new Stop(1, Color.rgb(100, 100, 100))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.583333, HEIGHT * 0.5, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(142, 142, 142)),
            new Stop(1, Color.rgb(130, 130, 130))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.5, 0, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(152, 152, 152)),
            new Stop(1, Color.rgb(146, 146, 146))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.583333, HEIGHT * 0.083333, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.083333;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(160, 160, 160)),
            new Stop(1, Color.rgb(152, 152, 152))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(0, HEIGHT * 0.5, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(152, 152, 152)),
            new Stop(1, Color.rgb(146, 146, 146))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.083333, HEIGHT * 0.583333, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.583333;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(160, 160, 160)),
            new Stop(1, Color.rgb(152, 152, 152))));
    CTX.fill();

    final Image PATTERN_IMAGE = CANVAS.snapshot(new SnapshotParameters(), null);
    final ImagePattern PATTERN = new ImagePattern(PATTERN_IMAGE, 0, 0, WIDTH, HEIGHT, false);

    return PATTERN;
}
 
Example #25
Source File: Patterns.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
public static final ImagePattern createCarbonKevlarPattern() {
    final double WIDTH = 12;
    final double HEIGHT = 12;
    final Canvas CANVAS = new Canvas(WIDTH, HEIGHT);
    final GraphicsContext CTX = CANVAS.getGraphicsContext2D();

    double offsetY = 0;
    /// 1= border=yellow=dark========================================================
    CTX.beginPath();
    CTX.rect(0, 0, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();

    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(105, 105, 0)),
            new Stop(1, Color.rgb(98, 98, 0))));
    CTX.fill();
    //  2=body=yellow==============================
    CTX.beginPath();
    CTX.rect(WIDTH * 0.083333, 0, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(138, 138, 0)),
            new Stop(1, Color.rgb(130, 130, 0))));
    CTX.fill();
    //  3=border=yellow=dark=============================
    CTX.beginPath();
    CTX.rect(WIDTH * 0.5, HEIGHT * 0.5, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(105, 105, 0)),
            new Stop(1, Color.rgb(98, 98, 0))));
    CTX.fill();
    //  4=body=yellow============================================================
    CTX.beginPath();
    CTX.rect(WIDTH * 0.583333, HEIGHT * 0.5, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(138, 138, 0)),
            new Stop(1, Color.rgb(130, 130, 0))));
    CTX.fill();
    //  5= border=gray=dark============================
    CTX.beginPath();
    CTX.rect(WIDTH * 0.5, 0, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(48, 48, 48)),
            new Stop(1, Color.rgb(30, 30, 30))));
    CTX.fill();
    //  6=body=gray=============================
    CTX.beginPath();
    CTX.rect(WIDTH * 0.583333, HEIGHT * 0.083333, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.083333;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(53, 53, 53)),
            new Stop(1, Color.rgb(45, 45, 45))));
    CTX.fill();
    //  7= border=gray=dark=============================
    CTX.beginPath();
    CTX.rect(0, HEIGHT * 0.5, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(48, 48, 48)),
            new Stop(1, Color.rgb(40, 40, 40))));
    CTX.fill();
    //  8= body=gray=light==============================
    CTX.beginPath();
    CTX.rect(WIDTH * 0.083333, HEIGHT * 0.583333, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.583333;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(53, 53, 53)),
            new Stop(1, Color.rgb(45, 45, 45))));
    CTX.fill();

    final Image PATTERN_IMAGE = CANVAS.snapshot(new SnapshotParameters(), null);
    final ImagePattern PATTERN = new ImagePattern(PATTERN_IMAGE, 0, 0, WIDTH, HEIGHT, false);

    return PATTERN;
}
 
Example #26
Source File: RadialBargraphSkin.java    From Enzo with Apache License 2.0 4 votes vote down vote up
private void resize() {
    size = getSkinnable().getWidth() < getSkinnable().getHeight() ? getSkinnable().getWidth() : getSkinnable().getHeight();
    centerX = size * 0.5;
    centerY = 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());

    value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", (angle.get() / angleStep)));
    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),
                                       new Stop(0.76, barColor.deriveColor(-5, 1, 1, 1)), // -5 for on the barColorHue)
                                       new Stop(0.79, barColor),
                                       new Stop(0.97, barColor),
                                       new Stop(1.0, barColor.deriveColor(-5, 1, 1, 1)))); // -5 for on the barColorHue)
    }
    knob.setPrefSize(size * 0.75, size * 0.75);
    knob.setTranslateX((size - knob.getPrefWidth()) * 0.5);
    knob.setTranslateY((size - knob.getPrefHeight()) * 0.5);

    resizeText();
}
 
Example #27
Source File: FillPatternStyleHelper.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
public static ImagePattern getHatch(final FillPattern fillPattern, final Paint color, final double width) {
    final Image hatch = FillPatternStyleHelper.createHatch(fillPattern, color, width);
    return new ImagePattern(hatch, 0, 0, FillPatternStyleHelper.HATCH_WINDOW_SIZE, FillPatternStyleHelper.HATCH_WINDOW_SIZE,
            false);
}
 
Example #28
Source File: ConicalGradient.java    From regulators with Apache License 2.0 4 votes vote down vote up
public ImagePattern getImagePattern(final Bounds BOUNDS) {
    return getImagePattern(new Rectangle(BOUNDS.getMinX(), BOUNDS.getMinY(), BOUNDS.getWidth(), BOUNDS.getHeight()));
}
 
Example #29
Source File: FillPatternStyleHelper.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
public static ImagePattern getHatch(final FillPattern fillPattern, final Paint color) {
    return FillPatternStyleHelper.getHatch(fillPattern, color, 1.0);
}
 
Example #30
Source File: FillPatternStyleHelper.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
public static ImagePattern getDefaultHatch(final Paint color, final double xOffset) {
    return new ImagePattern(FillPatternStyleHelper.createDefaultHatch(color, 1.0), xOffset, xOffset,
            FillPatternStyleHelper.HATCH_WINDOW_SIZE, FillPatternStyleHelper.HATCH_WINDOW_SIZE, false);
}