Skip to content

Commit

Permalink
Merge pull request #56 from HPI-SWA-Teaching/final-graph
Browse files Browse the repository at this point in the history
Add new graph Algorithm
  • Loading branch information
bjrne committed Jul 6, 2017
2 parents ed4229a + 7fa92cd commit 19edc04
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .squot
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ OrderedDictionary {
'GANA-Performance.package' : #SquotCypressCodeSerializer,
'GANA-Tests.package' : #SquotCypressCodeSerializer,
'GANA-UI.package' : #SquotCypressCodeSerializer
}
}
4 changes: 2 additions & 2 deletions GANA-UI.package/GanaBrowser.class/instance/commitList.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ commitList
self flag: #refactor. "How do we save the list heights etc.?"
list := GanaVersionListBuilder new searchFrom: self repository.
g := GanaGraphMorph newFor: self repository.
x := 200.
y := 14.
x := 400.
y := 30.
segmentSize := x@y.
list withIndexDo: [:each :index| | bubbleSegment |
bubbleSegment := ( 0 @ y * (index - 1) extent: segmentSize).
Expand Down
2 changes: 1 addition & 1 deletion GANA-UI.package/GanaBrowser.class/methodProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"buildRepositorySelectionButton:" : "FB 5/26/2017 14:44",
"buildSearchBar:" : "JK 6/28/2017 23:04",
"buildWith:" : "JK 6/28/2017 22:54",
"commitList" : "JK 6/15/2017 21:49",
"commitList" : "BS 7/6/2017 12:17",
"dummyWorkingCopy" : "FB 6/22/2017 14:17",
"hasSearchTerm" : "JK 6/15/2017 14:32",
"initialize" : "FB 6/29/2017 13:56",
Expand Down
4 changes: 4 additions & 0 deletions GANA-UI.package/GanaGraphMorph.class/instance/cellSize.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
as yet unclassified
cellSize

^ 30
Original file line number Diff line number Diff line change
@@ -1,12 +1,47 @@
as yet unclassified
initializeSubmorphs

| circleSize vertices commitList |
| circleSize vertices commitList "pq" heapSortBlock childDict infoDict positionDict lastCommitPerColumn |
self flag: #refactor. "Create a class for this?"

heapSortBlock := [ :a :b | (a metadata at: #timestamp) > (b metadata at: #timestamp) ]. "Potentially dangerous when using multiple time zones"
"pq := Heap sortBlock: heapSortBlock. - We don't need a priority queue anymore as we get a complete commitlist already sorted by timestamps"
childDict := Dictionary new.
infoDict := Dictionary new.
positionDict := Dictionary new.
lastCommitPerColumn := OrderedCollection new.
circleSize := self nodeSize asPoint.
vertices := OrderedCollection new.
commitList := self graphSource.
1 to: commitList size do: [ :row || p |
p := self positionNodeAt: row For: (commitList at: row).
vertices add: p].
vertices := (vertices * circleSize) + (self nodeSize / 2) asPoint.
self addMorphBack: (self defaultLine setVertices: vertices asArray; yourself).
1 to: commitList size do: [ :rowIndex || commit |
commit := (commitList at: rowIndex) version.
1 to: (commit parents size) do: [ :count | | parent | "What if it has no parent?"
parent := (commit parents at: count).
childDict at: parent ifPresent: [:childCollection | childDict at: parent put: (childCollection add: commit; yourself)] ifAbsentPut: [
(Heap sortBlock: heapSortBlock)
add: commit;
yourself.]
].
childDict at: commit ifPresent: [:pqchildren | | child childInfo |
child := pqchildren first.
childInfo := infoDict at: child. "Consists of painted Column and potential Successor"
(childInfo size < 2) ifTrue: [positionDict at: commit put: (self positionNodeAt: rowIndex withColumn: (childInfo first)). "We can be sure this exists because if we have children then they already have had to be painted and thus added to this dict"
lastCommitPerColumn at: (childInfo first) put: commit.
infoDict at: child put: (Array with: (childInfo first) with: commit).
infoDict at: commit put: (Array with: (childInfo first))

]
ifFalse: [lastCommitPerColumn add: commit.
positionDict at: commit put: (self positionNodeAt: rowIndex withColumn: (lastCommitPerColumn size)).
infoDict at: commit put: (Array with: (lastCommitPerColumn size)).
].
1 to: (pqchildren size) do: [ :count |
self positionLineBetween: (positionDict at: (pqchildren removeFirst)) And: (positionDict at: commit).
].
]
ifAbsent: [ "This should only be called for children-less commits, eg branch pointer"
lastCommitPerColumn add: commit.
positionDict at: commit put: (self positionNodeAt: rowIndex withColumn: (lastCommitPerColumn size)).
infoDict at: commit put: (Array with: (lastCommitPerColumn size))
].
].
2 changes: 1 addition & 1 deletion GANA-UI.package/GanaGraphMorph.class/instance/nodeSize.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
as yet unclassified
nodeSize

^ 14
^ 24
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
as yet unclassified
positionLineBetween: child And: parent

| start end |
start := self cellSize asPoint * child + (self cellSize / 2 asPoint).
end := self cellSize asPoint * parent + (self cellSize / 2 asPoint).

self addMorphBack:( LineMorph from: start to: end color: (Color black) width: 2).

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
as yet unclassified
positionNodeAt: row withColumn: column

| p |
p := column@row - (1@1).
self addMorph:( self defaultNode
position: (self cellSize asPoint * p) + (self cellSize - self nodeSize / 2) asPoint;
yourself).
^ p
8 changes: 5 additions & 3 deletions GANA-UI.package/GanaGraphMorph.class/methodProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
"class" : {
"newFor:" : "FB 6/14/2017 17:00" },
"instance" : {
"cellSize" : "BS 7/6/2017 12:16",
"defaultLine" : "FB 6/15/2017 13:31",
"defaultNode" : "FB 6/15/2017 13:30",
"graphSource" : "FB 6/13/2017 17:48",
"graphSourceRandomLeftness" : "FB 6/4/2017 12:34",
"historians" : "FB 6/4/2017 12:50",
"initializeFor:" : "FB 6/14/2017 16:59",
"initializeSubmorphs" : "FB 6/6/2017 19:41",
"nodeSize" : "FB 6/6/2017 19:43",
"positionNodeAt:For:" : "FB 6/14/2017 16:40",
"initializeSubmorphs" : "BS 7/6/2017 12:16",
"nodeSize" : "BS 7/6/2017 12:17",
"positionLineBetween:And:" : "BS 7/6/2017 12:15",
"positionNodeAt:withColumn:" : "BS 7/6/2017 12:13",
"repo" : "FB 6/14/2017 16:54",
"repository:" : "FB 6/14/2017 16:54" } }

0 comments on commit 19edc04

Please sign in to comment.