/*
 * Copyright 2000-2015 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.vcs.log.ui.render;

import com.intellij.openapi.ui.GraphicsConfig;
import com.intellij.ui.JBColor;
import com.intellij.ui.SimpleColoredComponent;
import com.intellij.util.ui.GraphicsUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;

import java.awt.*;

public class TextLabelPainter {
  protected static final int TEXT_PADDING_X = 5;
  public static final int TOP_TEXT_PADDING = 2;
  public static final int BOTTOM_TEXT_PADDING = 1;

  public static Font getFont() {
    return UIUtil.getLabelFont();
  }

  protected Font getLabelFont() {
    return getFont();
  }

  public void paint(@NotNull Graphics2D g2, @NotNull String text, int paddingX, int paddingY, @NotNull Color color) {
    GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);
    g2.setFont(getLabelFont());
    g2.setStroke(new BasicStroke(1.5f));

    FontMetrics fontMetrics = g2.getFontMetrics();
    int width = fontMetrics.stringWidth(text) + 2 * TEXT_PADDING_X;
    int height = fontMetrics.getHeight() + TOP_TEXT_PADDING + BOTTOM_TEXT_PADDING;

    g2.setColor(color);
    g2.fillRect(paddingX, paddingY, width, height);

    g2.setColor(JBColor.BLACK);
    int x = paddingX + TEXT_PADDING_X;
    int y = paddingY + SimpleColoredComponent.getTextBaseLine(fontMetrics, height);
    g2.drawString(text, x, y);

    config.restore();
  }

  public Dimension calculateSize(@NotNull String text, @NotNull FontMetrics metrics) {
    int width = metrics.stringWidth(text) + 2 * TEXT_PADDING_X;
    int height = metrics.getHeight() + TOP_TEXT_PADDING + BOTTOM_TEXT_PADDING;
    return new Dimension(width, height);
  }
}

@@ -799,24 +799,58 @@
 aphicsUtil;%0A
+import com.intellij.util.ui.JBUI;%0A
 import com.i
@@ -869,24 +869,24 @@
 .ui.UIUtil;%0A
-
 import org.j
@@ -1014,17 +1014,29 @@
 ING_X = 
-5
+JBUI.scale(5)
 ;%0A  publ
@@ -1074,17 +1074,29 @@
 DDING = 
-2
+JBUI.scale(2)
 ;%0A  publ
@@ -1137,17 +1137,29 @@
 DDING = 
-1
+JBUI.scale(1)
 ;%0A%0A  pub

scale padding