diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java index 29c9637b2647..e581323fa28b 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java @@ -215,7 +215,7 @@ public class GraphCommitCellRenderer extends TypeSafeTableCellRenderer refGroups = manager == null ? ContainerUtil.emptyList() : manager.groupForTable(references, myCompact, myShowTagNames); @@ -141,7 +144,7 @@ public class LabelPainter { @NotNull Color background, int availableWidth, boolean compact) { - int width = LEFT_PADDING + RIGHT_PADDING; + int width = LEFT_PADDING.get() + RIGHT_PADDING.get(); List> labels = ContainerUtil.newArrayList(); if (refGroups.isEmpty()) return Pair.create(labels, width); @@ -156,7 +159,7 @@ public class LabelPainter { @NotNull FontMetrics fontMetrics, @NotNull Color background, int availableWidth) { - int width = LEFT_PADDING + RIGHT_PADDING; + int width = LEFT_PADDING.get() + RIGHT_PADDING.get(); List> labels = ContainerUtil.newArrayList(); if (refGroups.isEmpty()) return Pair.create(labels, width); @@ -164,7 +167,7 @@ public class LabelPainter { for (RefGroup group : refGroups) { List colors = group.getColors(); LabelIcon labelIcon = getIcon(fontMetrics.getHeight(), background, colors); - int newWidth = width + labelIcon.getIconWidth() + (group != ContainerUtil.getLastItem(refGroups) ? COMPACT_MIDDLE_PADDING : 0); + int newWidth = width + labelIcon.getIconWidth() + (group != ContainerUtil.getLastItem(refGroups) ? COMPACT_MIDDLE_PADDING.get() : 0); String text = shortenRefName(group.getName(), fontMetrics, availableWidth - newWidth); newWidth += fontMetrics.stringWidth(text); @@ -181,7 +184,7 @@ public class LabelPainter { @NotNull FontMetrics fontMetrics, @NotNull Color background, int availableWidth) { - int width = LEFT_PADDING + RIGHT_PADDING; + int width = LEFT_PADDING.get() + RIGHT_PADDING.get(); List> labels = ContainerUtil.newArrayList(); if (refGroups.isEmpty()) return Pair.create(labels, width); @@ -198,7 +201,7 @@ public class LabelPainter { List colors = group.getColors(); LabelIcon labelIcon = getIcon(height, background, colors); - int newWidth = width + labelIcon.getIconWidth() + (i != refGroups.size() - 1 ? MIDDLE_PADDING : 0); + int newWidth = width + labelIcon.getIconWidth() + (i != refGroups.size() - 1 ? MIDDLE_PADDING.get() : 0); String text = getGroupText(group, fontMetrics, availableWidth - newWidth - doNotFitWidth); newWidth += fontMetrics.stringWidth(text); @@ -338,12 +341,12 @@ public class LabelPainter { if (myGreyBackground != null && myCompact) { g2.setColor(myGreyBackground); - g2.fillRect(x, y + baseLine - fontMetrics.getAscent() - TOP_TEXT_PADDING, + g2.fillRect(x, y + baseLine - fontMetrics.getAscent() - TOP_TEXT_PADDING.get(), myWidth, - fontMetrics.getHeight() + TOP_TEXT_PADDING + BOTTOM_TEXT_PADDING); + fontMetrics.getHeight() + TOP_TEXT_PADDING.get() + BOTTOM_TEXT_PADDING.get()); } - x += LEFT_PADDING; + x += LEFT_PADDING.get(); for (Pair label : myLabels) { LabelIcon icon = label.second; @@ -351,9 +354,9 @@ public class LabelPainter { if (myGreyBackground != null && !myCompact) { g2.setColor(myGreyBackground); - g2.fill(new RoundRectangle2D.Double(x - MIDDLE_PADDING / 3, y + baseLine - fontMetrics.getAscent() - TOP_TEXT_PADDING, - icon.getIconWidth() + fontMetrics.stringWidth(text) + 2 * MIDDLE_PADDING / 3, - fontMetrics.getHeight() + TOP_TEXT_PADDING + BOTTOM_TEXT_PADDING, LABEL_ARC, LABEL_ARC)); + g2.fill(new RoundRectangle2D.Double(x - MIDDLE_PADDING.get() / 3, y + baseLine - fontMetrics.getAscent() - TOP_TEXT_PADDING.get(), + icon.getIconWidth() + fontMetrics.stringWidth(text) + 2 * MIDDLE_PADDING.get() / 3, + fontMetrics.getHeight() + TOP_TEXT_PADDING.get() + BOTTOM_TEXT_PADDING.get(), LABEL_ARC.get(), LABEL_ARC.get())); } icon.paintIcon(null, g2, x, y + (height - icon.getIconHeight()) / 2); @@ -361,7 +364,7 @@ public class LabelPainter { g2.setColor(myForeground); g2.drawString(text, x, y + baseLine); - x += fontMetrics.stringWidth(text) + (myCompact ? COMPACT_MIDDLE_PADDING : MIDDLE_PADDING); + x += fontMetrics.stringWidth(text) + (myCompact ? COMPACT_MIDDLE_PADDING.get() : MIDDLE_PADDING.get()); } config.restore(); diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/RectanglePainter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/RectanglePainter.java index 645fecce7874..90adc9ebe9e8 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/RectanglePainter.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/RectanglePainter.java @@ -19,7 +19,8 @@ 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.JBUI; +import com.intellij.util.ui.JBValue; +import com.intellij.util.ui.JBValue.JBValueGroup; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -27,10 +28,11 @@ import java.awt.*; import java.awt.geom.RoundRectangle2D; public class RectanglePainter { - protected static final int TEXT_PADDING_X = JBUI.scale(5); - public static final int TOP_TEXT_PADDING = JBUI.scale(2); - public static final int BOTTOM_TEXT_PADDING = JBUI.scale(1); - public static final int LABEL_ARC = JBUI.scale(6); + private static final JBValueGroup JBVG = new JBValueGroup(); + protected static final JBValue TEXT_PADDING_X = JBVG.value(5); + public static final JBValue TOP_TEXT_PADDING = JBVG.value(2); + public static final JBValue BOTTOM_TEXT_PADDING = JBVG.value(1); + public static final JBValue LABEL_ARC = JBVG.value(6); private final boolean mySquare; @@ -52,19 +54,19 @@ public class RectanglePainter { 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; + int width = fontMetrics.stringWidth(text) + 2 * TEXT_PADDING_X.get(); + int height = fontMetrics.getHeight() + TOP_TEXT_PADDING.get() + BOTTOM_TEXT_PADDING.get(); g2.setColor(color); if (mySquare) { g2.fillRect(paddingX, paddingY, width, height); } else { - g2.fill(new RoundRectangle2D.Double(paddingX, paddingY, width, height, LABEL_ARC, LABEL_ARC)); + g2.fill(new RoundRectangle2D.Double(paddingX, paddingY, width, height, LABEL_ARC.get(), LABEL_ARC.get())); } g2.setColor(JBColor.BLACK); - int x = paddingX + TEXT_PADDING_X; + int x = paddingX + TEXT_PADDING_X.get(); int y = paddingY + SimpleColoredComponent.getTextBaseLine(fontMetrics, height); g2.drawString(text, x, y); @@ -72,8 +74,8 @@ public class RectanglePainter { } 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; + int width = metrics.stringWidth(text) + 2 * TEXT_PADDING_X.get(); + int height = metrics.getHeight() + TOP_TEXT_PADDING.get() + BOTTOM_TEXT_PADDING.get(); return new Dimension(width, height); } }