1 The core of the graphing functionality is in the PBGitGrapher class. This
2 class has one function - parseCommits() that takes an NSArray of commits and
3 creates a PBGraphCellInfo for each commit. These PBGraphCellInfo are stored in
4 an array that can later be accessed using the cellInfoForRow: function.
6 The PBGraphCellInfo has only basic information -- The column the commit
7 associated with this commit should be drawn in, and other lines that should be
10 These lines are in an array of PBLines. A PBLine has a few pieces of
11 information -- a start column, an end column and whether the line should be
12 drawn on the top or bottom part of the row. Furthermore, it has a colorIndex
13 to indicate the color the line should be given. Note that this number
14 increases forever, so you can modulo it with the number of colors you have.
16 In the PBGitWindowController, the -
17 (void)tableView:willDisplayCell:forTableColumn:row: is implemented which sets
18 the correct PBGraphCellInfo for the cell to be drawn. This cell is of the
19 class PBGitRevisionCell, which has the actual drawing implementation.
21 The basic algorithm for the graphing is like this:
24 For each previous column
25 If this commit should be in this column
26 mark this position and set this commits first parent
27 as the next commit for this lane
28 Else if this commit should be in a previous column
29 add a line to that column and discard the previous
32 Keep this column for the current row
33 For each parent of this commit
34 If it has not been displayed, add it as a column