0

I just did some tests with Path of JavaFX, and I observed a bug when I work with the LineTo :

Path border = GraphUtil.buildBorder(w, h, ARC_BORDER);
border.setStroke(Color.BLACK);
border.setStrokeWidth(0.3);
border.setOpacity(0.8);

With my utility method :

public class GraphUtil {

    public static Path buildBorder(double w, double h, double arcBorder) {
        //FIXME apply arcborder
        Path border = new Path();
        MoveTo mTo = new MoveTo();
        mTo.setX(0);
        mTo.setY(0);
        LineTo lTop = new LineTo();
        lTop.setX(w);
        lTop.setY(0);
        LineTo lRight = new LineTo();
        lRight.setX(w);
        lRight.setY(h);
        LineTo lBottom = new LineTo();
        lBottom.setX(0);
        lBottom.setY(h);
        LineTo lLeft = new LineTo();
        lLeft.setX(0);
        lLeft.setY(0);
        border.getElements().addAll(mTo, lTop, lRight, lBottom, lLeft);

        return border;
    }
}

When I do that, it's ok. But when I want the strokewidth to be smaller (0.2 or 0.1), the left border is invisible, the other ones are visible.. Does someone know why? Thanks.

PacDroid
  • 541
  • 1
  • 7
  • 22

1 Answers1

0

Maybe same reason as this?

So your options for clean lines when you have an odd stroke width are:

Use a StrokeType.INSIDE or StrokeType.OUTSIDE stroke style. Offset the co-ordinates of shapes by 0.5 of a pixel so that the strokes line up on the lines rather than the cracks between lines. Just use the next even number up as the stroke width, e.g. 1 => 2, 3 => 4, etc.

JavaFX graphics "blurred" or anti-aliased? (No effects used)

Community
  • 1
  • 1
taskman
  • 53
  • 9