Example usage for javafx.scene.shape StrokeLineJoin ROUND

List of usage examples for javafx.scene.shape StrokeLineJoin ROUND

Introduction

In this page you can find the example usage for javafx.scene.shape StrokeLineJoin ROUND.

Prototype

StrokeLineJoin ROUND

To view the source code for javafx.scene.shape StrokeLineJoin ROUND.

Click Source Link

Document

Joins path segments by rounding off the corner at a radius of half the line width.

Usage

From source file:net.rptools.image.listeners.DrawHandler.java

/**
 * Main work method./*  w  ww .  jav  a2  s  . c om*/
 * @param phase phase of drawing we are in
 * @param newEnd new end of current draw
 * @param pen pen color
 * @param fill fill color
 * @param radius pen radius
 */
@ThreadPolicy(ThreadPolicy.ThreadId.JFX)
private void draw(final String phase, final Point2D newEnd, final String pen, final String fill,
        final int radius) {
    LOGGER.debug("phase={}; draw={}; pen={}; fill={}; radius={}", phase, newEnd, pen, fill, radius);

    if (phase.equals(START)) {
        currentShape = new Polygon();
        getLayer().getDrawable().getChildren().add(currentShape);
    }

    if (currentShape == null) {
        return;
    }

    currentShape.getPoints().addAll(newEnd.getX(), newEnd.getY());

    switch (fill.charAt(0)) {
    case '#':
        currentShape.setFill(Color.web(fill));
        break;
    case '-':
        currentShape.setFill(null);
        break;
    default:
        if (currentFill == null) {
            currentFill = getLayer().loadImage(fill);
        }
        currentShape.setFill(
                new ImagePattern(currentFill, 0, 0, currentFill.getWidth(), currentFill.getHeight(), false));
    }
    switch (pen.charAt(0)) {
    case '#':
        currentShape.setStroke(Color.web(pen));
        break;
    case '-':
        currentShape.setStroke(null);
        break;
    default:
        if (currentPen == null) {
            currentPen = getLayer().loadImage(pen);
        }
        currentShape.setStroke(
                new ImagePattern(currentPen, 0, 0, currentPen.getWidth(), currentPen.getHeight(), false));
    }
    currentShape.setStrokeLineCap(StrokeLineCap.ROUND);
    currentShape.setStrokeLineJoin(StrokeLineJoin.ROUND);
    currentShape.setStrokeWidth(radius);

    if (phase.equals(END)) {
        finalizeDrawing();
        currentShape = null;
        currentPen = null;
        currentFill = null;
    }
    LOGGER.debug("draw polygon completed={}", currentShape == null);
}