void (final @NotNull Graphics2D g, double x, double y, double width, double height, final @Nullable Double arc, @NotNull StrokeType strokeType, double strokeWidth, @NotNull Object valueAA) { if (width < 0 || height < 0) return; double sw = alignToInt(strokeWidth, g); double dsw = sw * 2; if (width > dsw && height > dsw) { // align conforms to LinePainter2D x = alignToInt(x, g); y = alignToInt(y, g); double[] strokeSplit = LinePainter2D.getStrokeSplit(ScaleContext.create(g), strokeType, sw, false); double sw_1 = strokeSplit[0]; double sw_2 = strokeSplit[1]; double a_out = strokeType == StrokeType.CENTERED ? sw : strokeType == StrokeType.OUTSIDE ? dsw : 0; double x_out = x - sw_1; double y_out = y - sw_1; double w_out = sw_1 + width + sw_2; double h_out = sw_1 + height + sw_2; final Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD); if (arc != null) { path.append(new RoundRectangle2D.Double(x_out, y_out, w_out, h_out, arc + a_out, arc + a_out), false); path.append(new RoundRectangle2D.Double(x_out + sw, y_out + sw, w_out - dsw, h_out - dsw, arc - dsw, arc - dsw), false); } else { path.append(new Rectangle2D.Double(x_out, y_out, w_out, h_out), false); path.append(new Rectangle2D.Double(x_out + sw, y_out + sw, w_out - dsw, h_out - dsw), false); } PaintUtil.paintWithAA(g, arc != null ? valueAA : RenderingHints.VALUE_ANTIALIAS_DEFAULT, () -> g.fill(path)); } else { FILL.paint(g, x, y, width, height, arc, strokeType, strokeWidth, valueAA); } }