void (final @NotNull Graphics2D g, final int startX, final int endX, final int lineY, final Color bgColor, final Color fgColor, final boolean opaque) { final Color oldColor = g.getColor(); // Fill 2 lines with background color if (opaque && bgColor != null) { g.setColor(bgColor); LinePainter2D.paint(g, startX, lineY, endX, lineY); LinePainter2D.paint(g, startX, lineY + 1, endX, lineY + 1); } // Draw dotted line: // // CCC CCC CCC ... // CCC CCC CCC ... // // (where "C" - colored pixel, " " - white pixel) final int step = 4; final int startPosCorrection = startX % step < 3 ? 0 : 1; g.setColor(fgColor != null ? fgColor : oldColor); // Now draw bold line segments for (int dotXi = (startX / step + startPosCorrection) * step; dotXi < endX; dotXi += step) { LinePainter2D.paint(g, dotXi, lineY, dotXi + 1, lineY); LinePainter2D.paint(g, dotXi, lineY + 1, dotXi + 1, lineY + 1); } // restore color g.setColor(oldColor); }