From 07cfb765c94f811d641f833b84fe625c5b562017 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 9 May 2011 11:48:55 -0700 Subject: [historyView] Reduce commit dot size and expand lane color palette. Bug: 345182 Change-Id: I8e3253d510d85c2c9bfd1b0650094a62bf6ba27b Signed-off-by: Kevin Sawicki --- .../egit/ui/internal/history/CommitGraphTable.java | 8 ++++ .../egit/ui/internal/history/SWTCommitList.java | 36 +++++++++++------ .../egit/ui/internal/history/SWTPlotRenderer.java | 45 +++++++++++++--------- 3 files changed, 60 insertions(+), 29 deletions(-) diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java index 5dee2ce50a..2bf660948e 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java @@ -244,6 +244,14 @@ class CommitGraphTable { } } }); + + table.getTable().addDisposeListener(new DisposeListener() { + + public void widgetDisposed(DisposeEvent e) { + allCommits.dispose(); + renderer.dispose(); + } + }); } CommitGraphTable(final Composite parent, final IPageSite site, diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommitList.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommitList.java index fb187e721c..f73ec1c099 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommitList.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommitList.java @@ -11,30 +11,44 @@ package org.eclipse.egit.ui.internal.history; import java.util.ArrayList; import java.util.LinkedList; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Display; import org.eclipse.jgit.revplot.PlotCommitList; import org.eclipse.jgit.revplot.PlotLane; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; class SWTCommitList extends PlotCommitList { + + private static final RGB[] COMMIT_RGB = new RGB[] { new RGB(131, 150, 98), + new RGB(221, 205, 93), new RGB(199, 134, 57), + new RGB(133, 166, 214), new RGB(197, 123, 127), + new RGB(139, 136, 140), new RGB(48, 135, 144), + new RGB(190, 93, 66), new RGB(143, 163, 54), new RGB(180, 148, 74), + new RGB(101, 101, 217), new RGB(72, 153, 119), + new RGB(23, 101, 160), new RGB(132, 164, 118), + new RGB(255, 230, 59), new RGB(136, 176, 70), new RGB(255, 138, 1), + new RGB(123, 187, 95), new RGB(233, 88, 98), new RGB(93, 158, 254), + new RGB(175, 215, 0), new RGB(140, 134, 142), + new RGB(232, 168, 21), new RGB(0, 172, 191), new RGB(251, 58, 4), + new RGB(63, 64, 255), new RGB(27, 194, 130), new RGB(0, 104, 183) }; + private final ArrayList allColors; private final LinkedList availableColors; SWTCommitList(final Display d) { - allColors = new ArrayList(); - allColors.add(d.getSystemColor(SWT.COLOR_GREEN)); - allColors.add(d.getSystemColor(SWT.COLOR_BLUE)); - allColors.add(d.getSystemColor(SWT.COLOR_RED)); - allColors.add(d.getSystemColor(SWT.COLOR_MAGENTA)); - allColors.add(d.getSystemColor(SWT.COLOR_GRAY)); - allColors.add(d.getSystemColor(SWT.COLOR_DARK_YELLOW)); - allColors.add(d.getSystemColor(SWT.COLOR_DARK_CYAN)); + allColors = new ArrayList(COMMIT_RGB.length); + for (RGB rgb : COMMIT_RGB) + allColors.add(new Color(d, rgb)); availableColors = new LinkedList(); repackColors(); } + public void dispose() { + for (Color color : allColors) + color.dispose(); + } + private void repackColors() { availableColors.addAll(allColors); } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTPlotRenderer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTPlotRenderer.java index 82f152568e..5e8149e9b6 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTPlotRenderer.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTPlotRenderer.java @@ -24,26 +24,28 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.TableItem; import org.eclipse.ui.themes.ColorUtil; class SWTPlotRenderer extends AbstractPlotRenderer { - private final Color sys_blue; private final Color sys_black; private final Color sys_gray; - private final Color sys_darkblue; - private final Color sys_yellow; private final Color sys_green; private final Color sys_white; + private final Color commitDotFill; + + private final Color commitDotOutline; + private final Map labelCoordinates = new HashMap(); private int textHeight; @@ -63,13 +65,18 @@ class SWTPlotRenderer extends AbstractPlotRenderer { private Ref headRef; SWTPlotRenderer(final Display d) { - sys_blue = d.getSystemColor(SWT.COLOR_BLUE); sys_black = d.getSystemColor(SWT.COLOR_BLACK); sys_gray = d.getSystemColor(SWT.COLOR_GRAY); - sys_darkblue = d.getSystemColor(SWT.COLOR_DARK_BLUE); sys_yellow = d.getSystemColor(SWT.COLOR_YELLOW); sys_green = d.getSystemColor(SWT.COLOR_GREEN); sys_white = d.getSystemColor(SWT.COLOR_WHITE); + commitDotFill = new Color(d, new RGB(220, 220, 220)); + commitDotOutline = new Color(d, new RGB(110, 110, 110)); + } + + void dispose() { + commitDotFill.dispose(); + commitDotOutline.dispose(); } @SuppressWarnings("unchecked") @@ -102,25 +109,27 @@ class SWTPlotRenderer extends AbstractPlotRenderer { g.drawLine(cellX + x1, cellY + y1, cellX + x2, cellY + y2); } + protected void drawDot(final Color outline, final Color fill, final int x, + final int y, final int w, final int h) { + int dotX = cellX + x + 2; + int dotY = cellY + y + 1; + int dotW = w - 2; + int dotH = h - 2; + g.setBackground(fill); + g.fillOval(dotX, dotY, dotW, dotH); + g.setForeground(outline); + g.setLineWidth(2); + g.drawOval(dotX, dotY, dotW, dotH); + } + protected void drawCommitDot(final int x, final int y, final int w, final int h) { - g.setBackground(sys_blue); - g.fillOval(cellX + x, cellY + y, w, h); - g.setForeground(sys_darkblue); - g.setLineWidth(2); - g.drawOval(cellX + x + 1, cellY + y + 1, w - 2, h - 2); - g.setForeground(sys_black); - g.setLineWidth(1); - g.drawOval(cellX + x, cellY + y, w, h); + drawDot(commitDotOutline, commitDotFill, x, y, w, h); } protected void drawBoundaryDot(final int x, final int y, final int w, final int h) { - g.setForeground(sys_gray); - g.setBackground(cellBG); - g.setLineWidth(1); - g.fillOval(cellX + x, cellY + y, w, h); - g.drawOval(cellX + x, cellY + y, w, h); + drawDot(sys_gray, sys_white, x, y, w, h); } protected void drawText(final String msg, final int x, final int y) { -- cgit v1.2.3