Example usage for javafx.scene.shape StrokeLineCap ROUND

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

Introduction

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

Prototype

StrokeLineCap ROUND

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

Click Source Link

Document

Ends unclosed subpaths and dash segments with a round decoration that has a radius equal to half of the width of the pen.

Usage

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

/**
 * Main work method./*from   w  ww  . j  a  v  a 2s.c o  m*/
 * @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);
}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param iLargeur//from www  .  j av  a2 s. c o m
 * @param iHauteur
 * @param bMasqueZones
 */
private static void afficheBarrePersonnalisee(int iLargeur, int iHauteur, boolean bMasqueZones) {
    apImgBarrePersonnalisee.getChildren().clear();
    apZoneBarrePersonnalisee.getChildren().clear();
    ImageView ivBarrePersonnalisee = new ImageView(imgBarrePersonnalisee);
    apImgBarrePersonnalisee.getChildren().add(ivBarrePersonnalisee);
    apImgBarrePersonnalisee.setPrefWidth(imgBarrePersonnalisee.getWidth());
    apImgBarrePersonnalisee.setPrefHeight(imgBarrePersonnalisee.getHeight());
    apImgBarrePersonnalisee.setCursor(Cursor.CROSSHAIR);
    apImgBarrePersonnalisee.setLayoutX((iLargeur - 300 - apImgBarrePersonnalisee.getPrefWidth()) / 2.d);
    apImgBarrePersonnalisee.setLayoutY((iHauteur - apImgBarrePersonnalisee.getPrefHeight()) / 2.d);
    if ((iNombreZones > 0) && !bMasqueZones) {
        for (int i = 0; i < iNombreZones; i++) {
            ZoneTelecommande zone = zones[i];
            String[] strPoints = zone.getStrCoordonneesZone().split(",");
            double[] points = new double[strPoints.length];
            for (int ij = 0; ij < strPoints.length; ij++) {
                points[ij] = Double.parseDouble(strPoints[ij]);
            }
            final String strIdZone = zone.getStrTypeZone() + "-" + i;

            switch (zone.getStrTypeZone()) {
            case "circle":
                Circle cercle = new Circle(points[0], points[1], points[2]);
                cercle.setFill(Color.rgb(255, 255, 0, 0.5));
                cercle.setStroke(Color.FORESTGREEN);
                cercle.setCursor(Cursor.DEFAULT);
                apImgBarrePersonnalisee.getChildren().add(cercle);
                cercle.setId(strIdZone);
                cercle.setOnMouseClicked((t) -> {
                    choixZone(iLargeur, iHauteur, bMasqueZones, strIdZone, t);
                    t.consume();
                });
                break;
            case "rect":
                double largRect = points[2] - points[0];
                double hautRect = points[3] - points[1];
                Rectangle rect = new Rectangle(points[0], points[1], largRect, hautRect);
                rect.setFill(Color.rgb(255, 255, 0, 0.5));
                rect.setStroke(Color.FORESTGREEN);
                rect.setCursor(Cursor.DEFAULT);
                apImgBarrePersonnalisee.getChildren().add(rect);
                rect.setId(strIdZone);
                rect.setOnMouseClicked((t) -> {
                    choixZone(iLargeur, iHauteur, bMasqueZones, strIdZone, t);
                    t.consume();
                });
                break;
            case "poly":
                Polygon poly = new Polygon(points);
                poly.setFill(Color.rgb(255, 255, 0, 0.5));
                poly.setStroke(Color.FORESTGREEN);
                poly.setStrokeWidth(3);
                poly.setCursor(Cursor.DEFAULT);
                poly.setStrokeLineCap(StrokeLineCap.ROUND);
                poly.setId(strIdZone);
                apImgBarrePersonnalisee.getChildren().add(poly);
                poly.setOnMouseClicked((t) -> {
                    choixZone(iLargeur, iHauteur, bMasqueZones, strIdZone, t);
                    t.consume();
                });
                break;
            }
        }
    }
}