Draw with custom subclasses of RevWalk and RevCommit
[jgit/dscho.git] / graphgui / CommitDrawer.java
blobdb203babf23b7ff6b3a761ab4d7939528a388541
1 import java.awt.Color;
2 import java.awt.Dimension;
3 import java.awt.Graphics2D;
4 import java.awt.GradientPaint;
6 class CommitDrawer {
7 private int xPos = 0;
8 private int yPos = 0;
9 private int width = 50;
10 private int height = 40;
11 private int arrowLength = 30;
12 private boolean hasParent = true;
14 public void setX(int xPos) {
15 this.xPos = xPos;
18 public int getX() {
19 return xPos;
22 public void setY(int yPos) {
23 this.yPos = yPos;
26 public int getY() {
27 return yPos;
30 public int getWidth() {
31 return width;
34 public int getHeight() {
35 return height;
38 public int getArrowLength() {
39 return arrowLength;
42 public void setHasParent(boolean hasParent) {
43 this.hasParent = hasParent;
46 public boolean hasParent() {
47 return this.hasParent;
50 public void paintCommit(Graphics2D g2d) {
51 Color color1 = Color.LIGHT_GRAY;
52 Color color2 = color1.darker();
53 GradientPaint gp = new GradientPaint(
54 xPos, yPos, color1,
55 xPos, yPos + height, color2);
56 g2d.setPaint(gp);
57 g2d.fillRect(xPos, yPos, width, height);
58 g2d.setColor(Color.GRAY);
59 g2d.drawRect(xPos, yPos, width, height);
61 if (hasParent) {
62 g2d.drawLine(xPos + width / 2, yPos + height,
63 xPos + width / 2, yPos + height + arrowLength);