import com.intellij.openapi.ui.GraphicsConfig;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vcs.changes.issueLinks.IssueLinkRenderer;
-import com.intellij.ui.JBColor;
import com.intellij.ui.SimpleColoredRenderer;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.TableCell;
}
public int getTooltipXCoordinate(int row) {
- return myComponent.getTooltipXCoordinate(getValue(myGraphTable.getModel().getValueAt(row, GraphTableModel.COMMIT_COLUMN)));
+ GraphCommitCell cell = getValue(myGraphTable.getModel().getValueAt(row, GraphTableModel.COMMIT_COLUMN));
+ Collection<VcsRef> refs = cell.getRefsToThisCommit();
+ if (!refs.isEmpty()) {
+ int labelWidth = LabelPainter.calculateWidth(myLogData, refs, myComponent, getPreferredHeight());
+ TableColumn commitColumn = myGraphTable.getColumnModel().getColumn(GraphTableModel.COMMIT_COLUMN);
+ return commitColumn.getWidth() - (labelWidth - LabelPainter.GRADIENT_WIDTH) / 2;
+ }
+ return -1;
}
private static class MyComponent extends SimpleColoredRenderer {
int width = (int)(maxIndex * PaintParameters.getNodeWidth(myGraphTable.getRowHeight()));
return new PaintInfo(image, width);
}
-
- public int getTooltipXCoordinate(@NotNull GraphCommitCell cell) {
- Collection<VcsRef> refs = cell.getRefsToThisCommit();
- if (!refs.isEmpty()) {
- myReferencePainter.customizePainter(this, refs, getBackground(), getForeground());
- TableColumn commitColumn = myGraphTable.getColumnModel().getColumn(GraphTableModel.COMMIT_COLUMN);
- return commitColumn.getWidth() - (myReferencePainter.getSize().width - LabelPainter.GRADIENT_WIDTH) / 2;
- }
- return -1;
- }
}
private static class PaintInfo {
}
private class FadeOutPainter {
- @NotNull private final LabelPainter myEmptyPainter = new LabelPainter(myLogData);
private int myWidth = LabelPainter.GRADIENT_WIDTH;
public void customize(@NotNull Collection<VcsRef> currentRefs, int row, int column, @NotNull JTable table) {
int prevWidth = 0;
if (row > 0) {
GraphCommitCell commitCell = getValue(table.getValueAt(row - 1, column));
- myEmptyPainter.customizePainter(myComponent, commitCell.getRefsToThisCommit(), myComponent.getBackground(), JBColor.black);
- prevWidth = myEmptyPainter.getSize().width;
+ prevWidth = LabelPainter.calculateWidth(myLogData, commitCell.getRefsToThisCommit(), myComponent, getPreferredHeight());
}
int nextWidth = 0;
if (row < table.getRowCount() - 1) {
GraphCommitCell commitCell = getValue(table.getValueAt(row + 1, column));
- myEmptyPainter.customizePainter(myComponent, commitCell.getRefsToThisCommit(), myComponent.getBackground(), JBColor.black);
- nextWidth = myEmptyPainter.getSize().width;
+ nextWidth = LabelPainter.calculateWidth(myLogData, commitCell.getRefsToThisCommit(), myComponent, getPreferredHeight());
}
myWidth = Math.max(Math.max(prevWidth, nextWidth), LabelPainter.GRADIENT_WIDTH);
import com.intellij.openapi.ui.GraphicsConfig;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.ui.JBColor;
import com.intellij.ui.SimpleColoredComponent;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
}
@NotNull
- public static Pair<List<Pair<String, LabelIcon>>, Integer> calculatePresentation(@NotNull List<RefGroup> refGroups,
- @NotNull FontMetrics fontMetrics,
- int height,
- @NotNull Color background) {
+ private static Pair<List<Pair<String, LabelIcon>>, Integer> calculatePresentation(@NotNull List<RefGroup> refGroups,
+ @NotNull FontMetrics fontMetrics,
+ int height,
+ @NotNull Color background) {
int width = GRADIENT_WIDTH + RIGHT_PADDING;
List<Pair<String, LabelIcon>> labels = ContainerUtil.newArrayList();
return Pair.create(labels, width);
}
+ public static int calculateWidth(@NotNull VcsLogData logData,
+ @NotNull Collection<VcsRef> references,
+ @NotNull JComponent component,
+ int height) {
+ VcsLogRefManager manager = ReferencePainter.getRefManager(logData, references);
+ List<RefGroup> refGroups = manager == null ? ContainerUtil.emptyList() : manager.groupForTable(references);
+ return calculatePresentation(refGroups, component.getFontMetrics(RectanglePainter.getFont()), height, JBColor.white/*bg color does not affect width*/).second;
+ }
+
@NotNull
private static String shortenRefName(@NotNull String refName) {
int textLength = refName.length();