Line2D (@NotNull Graphics2D g, @NotNull EnumSet<Align> align, double x, double y, double prefLength, boolean vertical, @NotNull StrokeType strokeType, double strokeWidth) { if (align.contains(Align.CENTER_X)) { if (vertical) { x = alignStrokeXY(g, x, strokeType, strokeWidth); } else { double[] p = alignSizeXY(g, x, prefLength, strokeType, strokeWidth, false); x = p[0]; prefLength = p[1]; } } if (align.contains(Align.CENTER_Y)) { if (!vertical) { y = alignStrokeXY(g, y, strokeType, strokeWidth); } else { double[] p = alignSizeXY(g, y, prefLength, strokeType, strokeWidth, false); y = p[0]; prefLength = p[1]; } } double x2 = !vertical ? x + prefLength - 1 : x; double y2 = vertical ? y + prefLength - 1 : y; return new Line2D.Double(x, y, x2, y2); }