mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 06:51:17 +07:00
[vcs-log] rename TagIcon -> LabelIcon, TagLabelPainter -> LabelPainter, TextLabelPainter -> RectanglePainter IDEA-CR-13391
This commit is contained in:
@@ -40,8 +40,8 @@ import com.intellij.vcs.log.data.VcsLogData;
|
||||
import com.intellij.vcs.log.ui.VcsLogColorManager;
|
||||
import com.intellij.vcs.log.ui.render.GraphCommitCellRenderer;
|
||||
import com.intellij.vcs.log.ui.render.RectangleReferencePainter;
|
||||
import com.intellij.vcs.log.ui.render.TagIcon;
|
||||
import com.intellij.vcs.log.ui.render.TextLabelPainter;
|
||||
import com.intellij.vcs.log.ui.render.LabelIcon;
|
||||
import com.intellij.vcs.log.ui.render.RectanglePainter;
|
||||
import com.intellij.vcs.log.util.VcsUserUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -500,7 +500,7 @@ class CommitPanel extends JBPanel {
|
||||
Icon icon = null;
|
||||
if (index == 0) {
|
||||
Color color = type.getBackgroundColor();
|
||||
icon = new TagIcon(height, getBackground(),
|
||||
icon = new LabelIcon(height, getBackground(),
|
||||
typeAndRefs.getValue().size() > 1 ? new Color[]{color, color} : new Color[]{color});
|
||||
}
|
||||
JBLabel label =
|
||||
@@ -544,12 +544,12 @@ class CommitPanel extends JBPanel {
|
||||
}
|
||||
|
||||
private static class ReferencePanel extends JPanel {
|
||||
@NotNull private final TextLabelPainter myLabelPainter;
|
||||
@NotNull private final RectanglePainter myLabelPainter;
|
||||
@NotNull private final VcsRef myReference;
|
||||
|
||||
private ReferencePanel(@NotNull VcsRef reference) {
|
||||
myReference = reference;
|
||||
myLabelPainter = new TextLabelPainter(false);
|
||||
myLabelPainter = new RectanglePainter(false);
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ class CommitPanel extends JBPanel {
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension dimension = myLabelPainter.calculateSize(myReference.getName(), getFontMetrics(TextLabelPainter.getFont()));
|
||||
Dimension dimension = myLabelPainter.calculateSize(myReference.getName(), getFontMetrics(RectanglePainter.getFont()));
|
||||
return new Dimension(dimension.width, dimension.height + JBUI.scale(ReferencesPanel.PADDING));
|
||||
}
|
||||
|
||||
@@ -574,12 +574,12 @@ class CommitPanel extends JBPanel {
|
||||
|
||||
private static class RootPanel extends JPanel {
|
||||
private static final int RIGHT_BORDER = 5;
|
||||
@NotNull private final TextLabelPainter myLabelPainter;
|
||||
@NotNull private final RectanglePainter myLabelPainter;
|
||||
@NotNull private String myText = "";
|
||||
@NotNull private Color myColor = getCommitDetailsBackground();
|
||||
|
||||
RootPanel() {
|
||||
myLabelPainter = new TextLabelPainter(true) {
|
||||
myLabelPainter = new RectanglePainter(true) {
|
||||
@Override
|
||||
protected Font getLabelFont() {
|
||||
return RootPanel.getLabelFont();
|
||||
|
||||
+3
-3
@@ -36,7 +36,7 @@ public class GraphCommitCellRenderer extends ColoredTableCellRenderer {
|
||||
@NotNull private final VcsLogGraphTable myGraphTable;
|
||||
@NotNull private final IssueLinkRenderer myIssueLinkRenderer;
|
||||
@NotNull private final ReferencePainter myTextLabelPainter =
|
||||
isRedesignedLabels() ? new TagLabelPainter() : new RectangleReferencePainter();
|
||||
isRedesignedLabels() ? new LabelPainter() : new RectangleReferencePainter();
|
||||
|
||||
@Nullable private PaintInfo myGraphImage;
|
||||
@NotNull private Font myFont;
|
||||
@@ -49,7 +49,7 @@ public class GraphCommitCellRenderer extends ColoredTableCellRenderer {
|
||||
myPainter = painter;
|
||||
myGraphTable = table;
|
||||
myIssueLinkRenderer = new IssueLinkRenderer(myLogData.getProject(), this);
|
||||
myFont = TextLabelPainter.getFont();
|
||||
myFont = RectanglePainter.getFont();
|
||||
myHeight = calculateHeight();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class GraphCommitCellRenderer extends ColoredTableCellRenderer {
|
||||
}
|
||||
|
||||
public int getPreferredHeight() {
|
||||
Font font = TextLabelPainter.getFont();
|
||||
Font font = RectanglePainter.getFont();
|
||||
if (myFont != font) {
|
||||
myFont = font;
|
||||
myHeight = calculateHeight();
|
||||
|
||||
+2
-2
@@ -25,12 +25,12 @@ import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Path2D;
|
||||
|
||||
public class TagIcon implements Icon {
|
||||
public class LabelIcon implements Icon {
|
||||
private final int mySize;
|
||||
@NotNull private final Color[] myColors;
|
||||
@NotNull private final Color myBgColor;
|
||||
|
||||
public TagIcon(int size, @NotNull Color bgColor, @NotNull Color... colors) {
|
||||
public LabelIcon(int size, @NotNull Color bgColor, @NotNull Color... colors) {
|
||||
mySize = size;
|
||||
myBgColor = bgColor;
|
||||
myColors = colors;
|
||||
+10
-10
@@ -54,7 +54,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TagLabelPainter implements ReferencePainter {
|
||||
public class LabelPainter implements ReferencePainter {
|
||||
public static final int TOP_TEXT_PADDING = JBUI.scale(2);
|
||||
public static final int BOTTOM_TEXT_PADDING = JBUI.scale(1);
|
||||
public static final int GRADIENT_WIDTH = JBUI.scale(50);
|
||||
@@ -66,7 +66,7 @@ public class TagLabelPainter implements ReferencePainter {
|
||||
private static final String SEPARATOR = "/";
|
||||
|
||||
@NotNull
|
||||
private List<Pair<String, TagIcon>> myLabels = ContainerUtil.newArrayList();
|
||||
private List<Pair<String, LabelIcon>> myLabels = ContainerUtil.newArrayList();
|
||||
private int myHeight = JBUI.scale(22);
|
||||
private int myWidth = 0;
|
||||
@NotNull
|
||||
@@ -92,20 +92,20 @@ public class TagLabelPainter implements ReferencePainter {
|
||||
for (RefGroup group : manager.groupForTable(references)) {
|
||||
if (group.isExpanded()) {
|
||||
for (VcsRef ref : group.getRefs()) {
|
||||
TagIcon tagIcon = new TagIcon(myHeight, myBackground, ref.getType().getBackgroundColor());
|
||||
LabelIcon labelIcon = new LabelIcon(myHeight, myBackground, ref.getType().getBackgroundColor());
|
||||
String text = shortenRefName(ref.getName());
|
||||
|
||||
myLabels.add(Pair.create(text, tagIcon));
|
||||
myWidth += tagIcon.getIconWidth() + metrics.stringWidth(text) + MIDDLE_PADDING;
|
||||
myLabels.add(Pair.create(text, labelIcon));
|
||||
myWidth += labelIcon.getIconWidth() + metrics.stringWidth(text) + MIDDLE_PADDING;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
TagIcon tagIcon = new TagIcon(myHeight, myBackground, getGroupColors(group));
|
||||
LabelIcon labelIcon = new LabelIcon(myHeight, myBackground, getGroupColors(group));
|
||||
String text = shortenRefName(group.getName());
|
||||
|
||||
myLabels.add(Pair.create(text, tagIcon));
|
||||
myWidth += tagIcon.getIconWidth() + metrics.stringWidth(text) + MIDDLE_PADDING;
|
||||
myLabels.add(Pair.create(text, labelIcon));
|
||||
myWidth += labelIcon.getIconWidth() + metrics.stringWidth(text) + MIDDLE_PADDING;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,8 +159,8 @@ public class TagLabelPainter implements ReferencePainter {
|
||||
g2.setColor(myBackground);
|
||||
g2.fillRect(x, y, myWidth - GRADIENT_WIDTH, height);
|
||||
|
||||
for (Pair<String, TagIcon> label : myLabels) {
|
||||
TagIcon icon = label.second;
|
||||
for (Pair<String, LabelIcon> label : myLabels) {
|
||||
LabelIcon icon = label.second;
|
||||
String text = label.first;
|
||||
|
||||
icon.paintIcon(null, g2, x, y + (height - icon.getIconHeight()) / 2);
|
||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
public class TextLabelPainter {
|
||||
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);
|
||||
@@ -34,7 +34,7 @@ public class TextLabelPainter {
|
||||
|
||||
private final boolean mySquare;
|
||||
|
||||
public TextLabelPainter(boolean square) {
|
||||
public RectanglePainter(boolean square) {
|
||||
mySquare = square;
|
||||
}
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ public class RectangleReferencePainter implements ReferencePainter {
|
||||
private int myHeight = JBUI.scale(22);
|
||||
private int myWidth = 0;
|
||||
|
||||
private final TextLabelPainter myLabelPainter = new TextLabelPainter(false) {
|
||||
private final RectanglePainter myLabelPainter = new RectanglePainter(false) {
|
||||
@Override
|
||||
protected Font getLabelFont() {
|
||||
return getReferenceFont();
|
||||
@@ -56,7 +56,7 @@ public class RectangleReferencePainter implements ReferencePainter {
|
||||
@NotNull Color background,
|
||||
@NotNull Color foreground) {
|
||||
FontMetrics metrics = component.getFontMetrics(getReferenceFont());
|
||||
myHeight = metrics.getHeight() + TextLabelPainter.TOP_TEXT_PADDING + TextLabelPainter.BOTTOM_TEXT_PADDING;
|
||||
myHeight = metrics.getHeight() + RectanglePainter.TOP_TEXT_PADDING + RectanglePainter.BOTTOM_TEXT_PADDING;
|
||||
myWidth = 2 * PaintParameters.LABEL_PADDING;
|
||||
|
||||
myLabels = ContainerUtil.newArrayList();
|
||||
|
||||
@@ -38,6 +38,6 @@ public interface ReferencePainter {
|
||||
boolean isLeftAligned();
|
||||
|
||||
default Font getReferenceFont() {
|
||||
return TextLabelPainter.getFont();
|
||||
return RectanglePainter.getFont();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user