<commit_before>Class {
	#name : #RSTreeLayoutTest,
	#superclass : #RSLayoutTest,
	#category : #'Roassal3-Layouts-Tests'
}

{ #category : #tests }
RSTreeLayoutTest >> exampleRoassal3CommitsWithTimeGaps [

	<script: 'RSTreeLayoutTest new exampleRoassal3CommitsWithTimeGaps'>
	| icerepo commits edges dict aCanvas |
	icerepo := IceRepository registry detect: [ :each | 
		           each name = 'Roassal3' ].

	dict := Dictionary new.

	icerepo allBranches do: [ :aBranch | 
		(icerepo newCommitWalk fromBranch: aBranch) commits do: [ :aCommit | 
			| circle |
			circle := dict at: aCommit id put: (RSCircle new
					           model: aCommit id asSymbol;
					           "radius:
						           ((aCommit changesTo: aCommit parent) size / Float pi)
							           sqrt;"
					           propertyAt: #gitCommit
					           put: aCommit;<commit_msg>Add an example that visualize class hierarchies.<commit_after>Class {
	#name : #RSTreeLayoutTest,
	#superclass : #RSLayoutTest,
	#category : #'Roassal3-Layouts-Tests'
}

{ #category : #tests }
RSTreeLayoutTest >> exampleClassHierarchies: aCollection [

	<script:
	'RSTreeLayoutTest new exampleClassHierarchies: { Collection . Magnitude . RSObject . RBNode }'>
	| commits edges aCanvas gr |
	gr := 1.61803398875.
	commits := Array streamContents: [ :aStream | 
		           aCollection do: [ :aClass | 
			           aClass withAllSubclassesDo: [ :aSubClass | 
				           | label box |
				           label := RSLabel new text: aSubClass name.
				           aSubClass isAbstract ifTrue: [ 
					           label
						           bold;
						           italic ].
				           box := RSBox new
					                  color: Color white;
					                  withBorder;
					                  cornerRadius: gr double;
					                  extent: label extent + gr double double asPoint;
					                  yourself.
				           RSLocation new center stick: label on: box.
				           aStream nextPut: (RSComposite new
						            model: aSubClass;
						            shapes: (Array with: box with: label);
						            when: RSMouseLeftClick
						            do: [ :ev | aSubClass browse ];
						            yourself) ] ] ].

	edges := RSLineBuilder horizontalBezier
		         shapes: commits;
		         withHorizontalAttachPoint;
		         connectToAll: [ :aSubClass | aSubClass subclasses ].

	edges sort: [ :a :b | 
		| aName bName |
		aName := a from model name.
		bName := b from model name.
		aName = bName
			ifTrue: [ a to model name < b to model name ]
			ifFalse: [ aName < bName ] ].

	RSHorizontalVanDerPloegTreeLayout new
		doNotValidateCycles;
		on: commits edges: edges.

	aCanvas := RSCanvas new
		           addAll: commits , edges;
		           yourself.

	aCanvas
		zoomToFit;
		exportToSVG;
		@ RSCanvasController;
		open
]

{ #category : #tests }
RSTreeLayoutTest >> exampleRoassal3CommitsWithTimeGaps [

	<script: 'RSTreeLayoutTest new exampleRoassal3CommitsWithTimeGaps'>
	| icerepo commits edges dict aCanvas |
	icerepo := IceRepository registry detect: [ :each | 
		           each name = 'Roassal3' ].

	dict := Dictionary new.

	icerepo allBranches do: [ :aBranch | 
		(icerepo newCommitWalk fromBranch: aBranch) commits do: [ :aCommit | 
			| circle |
			circle := dict at: aCommit id put: (RSCircle new
					           model: aCommit id asSymbol;
					           "radius:
						           ((aCommit changesTo: aCommit parent) size / Float pi)
							           sqrt;"
					           propertyAt: #gitCommit
					           put: aCommit;
{'fraction_non_alphanumeric': 0.0855374226223973, 'fraction_numerical': 0.005627462014631401, 'mean_word_length': 2.0384615384615383, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3744544', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1053, 'n_words': 287}