private static void paintUnderline(Graphics2D g, double x, double y, double width, double height, Font font, double thickness, EffectPainter2D painter) {
    if (width > 0 && height > 0) {
      if (Registry.is("ide.text.effect.new.metrics")) {
        if (font == null) font = g.getFont();
        RoundingMode roundingMode = !JreHiDpiUtil.isJreHiDPIEnabled() || painter != WAVE_UNDERSCORE || font.getSize2D() / UISettings.getDefFontSize() > 1 ?
                                    RoundingMode.FLOOR : RoundingMode.CEIL;
        LineMetrics metrics = font.getLineMetrics("", g.getFontRenderContext());
        double devPixel = PaintUtil.devPixel(g);
        double underlineThickness = maybeScaleFontMetricsThickness(metrics.getUnderlineThickness(), font);
        double underlineOffset = Math.max(devPixel, metrics.getUnderlineOffset());

        boolean positive = thickness * underlineThickness > 0;
        thickness = PaintUtil.alignToInt(thickness * underlineThickness, g, roundingMode);
        if (positive && thickness <= 0) {
          thickness = devPixel;
        }
        double offset = Math.min(height - thickness, underlineOffset);

        if (offset < devPixel) {
          offset = height > 3 * devPixel ? devPixel : 0;
          thickness = PaintUtil.alignToInt(Math.min(thickness, height - offset), g, roundingMode);
        }
        else {
          offset = PaintUtil.alignToInt(offset, g, roundingMode);
        }
        drawLine(g, x, y + offset, width, thickness, painter);
      }
      else {
        if (height > 3) {
          double max = getMaxHeight(height);
          y += height - max;
          height = max;
          if (thickness > 1 && height > 3) {
            thickness = JBUIScale.scale((float)thickness);
          }
        }
        drawLineCentered(g, x, y, width, height, thickness, painter);
      }
    }
  }
private static void paintUnderline(Graphics2D g, double x, double y, double width, double height, Font font, double thickness, EffectPainter2D painter)