git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[EGIT PATCH 2/8] Move AWTPlotRenderer to its own file.

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
Sep 30, 2008, 23:53 UTC
Message-ID
<1222818823-22780-2-git-send-email-robin.rosenberg@dewire.com>
In-Reply-To
<1222818823-22780-1-git-send-email-robin.rosenberg@dewire.com>

This is mostly a convenience issue as it allows the use of the JVM hotswap feature while debugging.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 .../org/spearce/jgit/awtui/AWTPlotRenderer.java    |  104 ++++++++++++++++++++
 .../org/spearce/jgit/awtui/CommitGraphPane.java    |   92 -----------------
 2 files changed, 104 insertions(+), 92 deletions(-)
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/awtui/AWTPlotRenderer.java
diff --git a/org.spearce.jgit/src/org/spearce/jgit/awtui/AWTPlotRenderer.java b/org.spearce.jgit/src/org/spearce/jgit/awtui/AWTPlotRenderer.java
new file mode 100644
index 0000000..a9933a4
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/awtui/AWTPlotRenderer.java
@@ -0,0 +1,104 @@
+/**
+ * 
+ */
+package org.spearce.jgit.awtui;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Polygon;
+
+import org.spearce.jgit.awtui.CommitGraphPane.GraphCellRender;
+import org.spearce.jgit.awtui.SwingCommitList.SwingLane;
+import org.spearce.jgit.lib.Ref;
+import org.spearce.jgit.revplot.AbstractPlotRenderer;
+import org.spearce.jgit.revplot.PlotCommit;
+
+final class AWTPlotRenderer extends AbstractPlotRenderer<SwingLane, Color> {
+
+	final GraphCellRender cell;
+
+	Graphics2D g;
+
+	AWTPlotRenderer(final GraphCellRender c) {
+		cell = c;
+	}
+
+	void paint(final Graphics in, final PlotCommit<SwingLane> commit) {
+		g = (Graphics2D) in.create();
+		try {
+			final int h = cell.getHeight();
+			g.setColor(cell.getBackground());
+			g.fillRect(0, 0, cell.getWidth(), h);
+			if (commit != null)
+				paintCommit(commit, h);
+		} finally {
+			g.dispose();
+			g = null;
+		}
+	}
+
+	@Override
+	protected void drawLine(final Color color, int x1, int y1, int x2,
+			int y2, int width) {
+		if (y1 == y2) {
+			x1 -= width / 2;
+			x2 -= width / 2;
+		} else if (x1 == x2) {
+			y1 -= width / 2;
+			y2 -= width / 2;
+		}
+
+		g.setColor(color);
+		g.setStroke(CommitGraphPane.stroke(width));
+		g.drawLine(x1, y1, x2, y2);
+	}
+
+	@Override
+	protected void drawCommitDot(final int x, final int y, final int w,
+			final int h) {
+		g.setColor(Color.blue);
+		g.setStroke(CommitGraphPane.strokeCache[1]);
+		g.fillOval(x, y, w, h);
+		g.setColor(Color.black);
+		g.drawOval(x, y, w, h);
+	}
+
+	@Override
+	protected void drawBoundaryDot(final int x, final int y, final int w,
+			final int h) {
+		g.setColor(cell.getBackground());
+		g.setStroke(CommitGraphPane.strokeCache[1]);
+		g.fillOval(x, y, w, h);
+		g.setColor(Color.black);
+		g.drawOval(x, y, w, h);
+	}
+
+	@Override
+	protected void drawText(final String msg, final int x, final int y) {
+		final int texty = g.getFontMetrics().getHeight()
+				- g.getFontMetrics().getDescent();
+		g.setColor(cell.getForeground());
+		g.drawString(msg, x, texty - (cell.getHeight() - y * 2));
+	}
+
+	@Override
+	protected Color laneColor(final SwingLane myLane) {
+		return myLane != null ? myLane.color : Color.black;
+	}
+
+	void paintTriangleDown(final int cx, final int y, final int h) {
+		final int tipX = cx;
+		final int tipY = y + h;
+		final int baseX1 = cx - 10 / 2;
+		final int baseX2 = tipX + 10 / 2;
+		final int baseY = y;
+		final Polygon triangle = new Polygon();
+		triangle.addPoint(tipX, tipY);
+		triangle.addPoint(baseX1, baseY);
+		triangle.addPoint(baseX2, baseY);
+		g.fillPolygon(triangle);
+		g.drawPolygon(triangle);
+	}
+
+}
\ No newline at end of file
diff --git a/org.spearce.jgit/src/org/spearce/jgit/awtui/CommitGraphPane.java b/org.spearce.jgit/src/org/spearce/jgit/awtui/CommitGraphPane.java
index 4ab2136..d35bd5e 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/awtui/CommitGraphPane.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/awtui/CommitGraphPane.java
@@ -38,11 +38,8 @@
 package org.spearce.jgit.awtui;
 
 import java.awt.BasicStroke;
-import java.awt.Color;
 import java.awt.Component;
 import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.Polygon;
 import java.awt.Stroke;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
@@ -59,7 +56,6 @@
 
 import org.spearce.jgit.awtui.SwingCommitList.SwingLane;
 import org.spearce.jgit.lib.PersonIdent;
-import org.spearce.jgit.revplot.AbstractPlotRenderer;
 import org.spearce.jgit.revplot.PlotCommit;
 import org.spearce.jgit.revplot.PlotCommitList;
 
@@ -251,92 +247,4 @@ static Stroke stroke(final int width) {
 		return new BasicStroke(width);
 	}
 
-	final class AWTPlotRenderer extends AbstractPlotRenderer<SwingLane, Color> {
-
-		final GraphCellRender cell;
-
-		Graphics2D g;
-
-		AWTPlotRenderer(final GraphCellRender c) {
-			cell = c;
-		}
-
-		void paint(final Graphics in, final PlotCommit<SwingLane> commit) {
-			g = (Graphics2D) in.create();
-			try {
-				final int h = cell.getHeight();
-				g.setColor(cell.getBackground());
-				g.fillRect(0, 0, cell.getWidth(), h);
-				if (commit != null)
-					paintCommit(commit, h);
-			} finally {
-				g.dispose();
-				g = null;
-			}
-		}
-
-		@Override
-		protected void drawLine(final Color color, int x1, int y1, int x2,
-				int y2, int width) {
-			if (y1 == y2) {
-				x1 -= width / 2;
-				x2 -= width / 2;
-			} else if (x1 == x2) {
-				y1 -= width / 2;
-				y2 -= width / 2;
-			}
-
-			g.setColor(color);
-			g.setStroke(stroke(width));
-			g.drawLine(x1, y1, x2, y2);
-		}
-
-		@Override
-		protected void drawCommitDot(final int x, final int y, final int w,
-				final int h) {
-			g.setColor(Color.blue);
-			g.setStroke(strokeCache[1]);
-			g.fillOval(x, y, w, h);
-			g.setColor(Color.black);
-			g.drawOval(x, y, w, h);
-		}
-
-		@Override
-		protected void drawBoundaryDot(final int x, final int y, final int w,
-				final int h) {
-			g.setColor(cell.getBackground());
-			g.setStroke(strokeCache[1]);
-			g.fillOval(x, y, w, h);
-			g.setColor(Color.black);
-			g.drawOval(x, y, w, h);
-		}
-
-		@Override
-		protected void drawText(final String msg, final int x, final int y) {
-			final int texty = g.getFontMetrics().getHeight()
-					- g.getFontMetrics().getDescent();
-			g.setColor(cell.getForeground());
-			g.drawString(msg, x, texty - (cell.getHeight() - y * 2));
-		}
-
-		@Override
-		protected Color laneColor(final SwingLane myLane) {
-			return myLane != null ? myLane.color : Color.black;
-		}
-
-		void paintTriangleDown(final int cx, final int y, final int h) {
-			final int tipX = cx;
-			final int tipY = y + h;
-			final int baseX1 = cx - 10 / 2;
-			final int baseX2 = tipX + 10 / 2;
-			final int baseY = y;
-			final Polygon triangle = new Polygon();
-			triangle.addPoint(tipX, tipY);
-			triangle.addPoint(baseX1, baseY);
-			triangle.addPoint(baseX2, baseY);
-			g.fillPolygon(triangle);
-			g.drawPolygon(triangle);
-		}
-	}
-
 }
-- 
1.6.0.1.310.gf789d0.dirty
Previous: Robin RosenbergNext: Robin Rosenberg
Message 2 of 13 in “Set table row height for the glog JTable”
  1. 1/8 Set table row height for the glog JTableRobin Rosenberg, Sep 30, 2008
  2. 2/8 Move AWTPlotRenderer to its own file.Robin Rosenberg, Sep 30, 2008
  3. 3/8 Dispose of allocated colors on finalize()Robin Rosenberg, Sep 30, 2008
  4. 4/8 Align commit text properly in jgit glogRobin Rosenberg, Sep 30, 2008
  5. Robin RosenbergOct 1, 2008
  6. Shawn O. PearceOct 1, 2008
  7. 0/3 jgit glog alignment fixesRobin Rosenberg, Oct 1, 2008
  8. 1/3 Set table row height for the glog JTableRobin Rosenberg, Oct 1, 2008
  9. 2/3 Move AWTPlotRenderer to its own file.Robin Rosenberg, Oct 1, 2008
  10. 3/3 Align commit text properly in jgit glogRobin Rosenberg, Oct 1, 2008
  11. Shawn O. PearceOct 1, 2008
  12. Robin RosenbergOct 1, 2008
  13. Shawn O. PearceOct 1, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.