<commit_before>"
Define a time line, a bit like a Gantt diagram.

Here is an example:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
	| b d |
	b := RTTimeLine new.
	b addEntry: (RTTimeLineEntry new identifier: #c1; start: 0; end: 5).
	b addEntry: (RTTimeLineEntry new identifier: #c1; start: 6; end: 8).

	b addEntry: (RTTimeLineEntry new identifier: #c2; start: 0; end: 5).
	b addEntry: (RTTimeLineEntry new identifier: #c2; start: 8; end: 10).

	b addEntry: (RTTimeLineEntry new identifier: #c3; start: 0; end: 10).

	b addEntry: (RTTimeLineEntry new identifier: #c4; start: 5; end: 10).

	b addEntry: (RTTimeLineEntry new identifier: #c5; start: 5; end: 8).

	d := RTVerticalTickLineDecorator new.
	d shape line color: Color white.
	b addDecorator: d.
	b axisX 
		numberOfLabels: 5;
		labelRotation: -45;
		labelConversion: [ :v | Date year: 2015 day: v ]. 

	b shape color: (RTMultiLinearColorForIdentity new command: #identifier; objects: #(c1 c2 c3 c4 c5)).
	b  open
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"
Class {
	#name : #RTTimeLine,
	#superclass : #RTAbstractGrapher,
	#instVars : [
		'entries',
		'maxWidth',
		'timeLineLabel',
		'timeLineElements',
		'smalestEntryWidth'
	],
	#category : #'Roassal2-Builder-TimeLine'
}

{ #category : #adding }
RTTimeLine >> addEntry: anEntry [
	entries add: anEntry
]

{ #category : #hooks }
RTTimeLine >> createInteractionBuilder [
	^ super createInteractionBuilder
			popupText: #identifier;
			yourself
]

{ #category : #hooks }
RTTimeLine >> createShapeBuilder [
	^ super createShapeBuilder
		rectangle;
		height: [ :obj | self extent y / self numberOfTimeLines - self gapBetweenTimeLines ];
		color: (Color blue alpha: 0.4);
		yourself
]

{ #category : #accessing }
RTTimeLine >> entries [
	"return a list of entries"
	^ entries copy
]

{ #category : #examples }
RTTimeLine >> example01 [
	"
	self new example01
	"
	
	| b |
	b := RTTimeLine new.
	b addEntry: (RTTimeLineEntry new identifier: #c1; start: 0; end: 5).
	b addEntry: (RTTimeLineEntry new identifier: #c2; start: 0; end: 5).
	b addEntry: (RTTimeLineEntry new identifier: #c1; start: 6; end: 8).
	b addEntry: (RTTimeLineEntry new identifier: #c2; start: 8; end: 10).
	^ b
]

{ #category : #examples }
RTTimeLine >> example02 [
	"
	self new example02
	"	
	| b |
	b := RTTimeLine new.
	b addEntry: (RTTimeLineEntry new identifier: #c1; start: 0; end: 5).
	b addEntry: (RTTimeLineEntry new identifier: #c1; start: 6; end: 8).

	b addEntry: (RTTimeLineEntry new identifier: #c2; start: 0; end: 5).
	b addEntry: (RTTimeLineEntry new identifier: #c2; start: 8; end: 10).

	b addEntry: (RTTimeLineEntry new identifier: #c3; start: 0; end: 10).

	b addEntry: (RTTimeLineEntry new identifier: #c4; start: 5; end: 10).

	b addEntry: (RTTimeLineEntry new identifier: #c5; start: 5; end: 8).

	b addDecorator: RTVerticalTickLineDecorator new.
	b axisX numberOfLabels: 5.
	^ b
]

{ #category : #configuration }
RTTimeLine >> gapBetweenTimeLines [
	^ 3
]

{ #category : #'min and max' }
RTTimeLine >> homogenizeMinAndMax [
	self getAxisX minValue: self minX.
	self getAxisX maxValue: self maxX.
	
	self getAxisY minValue: self minY.
	self getAxisY maxValue: self maxY.
]

{ #category : #initialization }
RTTimeLine >> initialize [
	super initialize.
	entries := OrderedCollection new.
	self axisY noTick; noLabel.
	self timeLineLabel: #asString.
	self smalestEntryWidth: 1.
]

{ #category : #utility }
RTTimeLine >> label: aString on: position [
	"Add a label in the view"
	| e |
	e := RTLabel elementOn: aString.
	e translateTo: position.
	self view add: e.
	^ e
]

{ #category : #'accessing-computed' }
RTTimeLine >> maxEnd [
	^ entries max: #end
]

{ #category : #accessing }
RTTimeLine >> numberOfEntries [
	^ entries size
]

{ #category : #'accessing-computed' }
RTTimeLine >> numberOfTimeLines [
	"Return the number of time lines contained in myself"
	^ self timeLines size
]

{ #category : #hooks }
RTTimeLine >> renderIn: aView [
	| groupEntries elements t |
	self maxX: self maxEnd.
	self maxY: self numberOfTimeLines.
	self defineAxesIfNecessary.
	timeLineElements := OrderedCollection new.
	self timeLinesIdentifiers doWithIndex: [ :identifier :index | 	
			groupEntries := (self timeLines at: identifier) value.
			elements := self elementsOn: groupEntries.
			RTMetricNormalizer new<commit_msg>Added noTimeLineLabel<commit_after>"
Define a time line, a bit like a Gantt diagram.

Here is an example:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
	| b d |
	b := RTTimeLine new.
	b addEntry: (RTTimeLineEntry new identifier: #c1; start: 0; end: 5).
	b addEntry: (RTTimeLineEntry new identifier: #c1; start: 6; end: 8).

	b addEntry: (RTTimeLineEntry new identifier: #c2; start: 0; end: 5).
	b addEntry: (RTTimeLineEntry new identifier: #c2; start: 8; end: 10).

	b addEntry: (RTTimeLineEntry new identifier: #c3; start: 0; end: 10).

	b addEntry: (RTTimeLineEntry new identifier: #c4; start: 5; end: 10).

	b addEntry: (RTTimeLineEntry new identifier: #c5; start: 5; end: 8).

	d := RTVerticalTickLineDecorator new.
	d shape line color: Color white.
	b addDecorator: d.
	b axisX 
		numberOfLabels: 5;
		labelRotation: -45;
		labelConversion: [ :v | Date year: 2015 day: v ]. 

	b shape color: (RTMultiLinearColorForIdentity new command: #identifier; objects: #(c1 c2 c3 c4 c5)).
	b  open
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"
Class {
	#name : #RTTimeLine,
	#superclass : #RTAbstractGrapher,
	#instVars : [
		'entries',
		'maxWidth',
		'timeLineLabel',
		'timeLineElements',
		'smalestEntryWidth'
	],
	#category : #'Roassal2-Builder-TimeLine'
}

{ #category : #adding }
RTTimeLine >> addEntry: anEntry [
	entries add: anEntry
]

{ #category : #hooks }
RTTimeLine >> createInteractionBuilder [
	^ super createInteractionBuilder
			popupText: #identifier;
			yourself
]

{ #category : #hooks }
RTTimeLine >> createShapeBuilder [
	^ super createShapeBuilder
		rectangle;
		height: [ :obj | self extent y / self numberOfTimeLines - self gapBetweenTimeLines ];
		color: (Color blue alpha: 0.4);
		yourself
]

{ #category : #accessing }
RTTimeLine >> entries [
	"return a list of entries"
	^ entries copy
]

{ #category : #examples }
RTTimeLine >> example01 [
	"
	self new example01
	"
	
	| b |
	b := RTTimeLine new.
	b addEntry: (RTTimeLineEntry new identifier: #c1; start: 0; end: 5).
	b addEntry: (RTTimeLineEntry new identifier: #c2; start: 0; end: 5).
	b addEntry: (RTTimeLineEntry new identifier: #c1; start: 6; end: 8).
	b addEntry: (RTTimeLineEntry new identifier: #c2; start: 8; end: 10).
	^ b
]

{ #category : #examples }
RTTimeLine >> example02 [
	"
	self new example02
	"	
	| b |
	b := RTTimeLine new.
	b addEntry: (RTTimeLineEntry new identifier: #c1; start: 0; end: 5).
	b addEntry: (RTTimeLineEntry new identifier: #c1; start: 6; end: 8).

	b addEntry: (RTTimeLineEntry new identifier: #c2; start: 0; end: 5).
	b addEntry: (RTTimeLineEntry new identifier: #c2; start: 8; end: 10).

	b addEntry: (RTTimeLineEntry new identifier: #c3; start: 0; end: 10).

	b addEntry: (RTTimeLineEntry new identifier: #c4; start: 5; end: 10).

	b addEntry: (RTTimeLineEntry new identifier: #c5; start: 5; end: 8).

	b addDecorator: RTVerticalTickLineDecorator new.
	b axisX numberOfLabels: 5.
	^ b
]

{ #category : #configuration }
RTTimeLine >> gapBetweenTimeLines [
	^ 3
]

{ #category : #'min and max' }
RTTimeLine >> homogenizeMinAndMax [
	self getAxisX minValue: self minX.
	self getAxisX maxValue: self maxX.
	
	self getAxisY minValue: self minY.
	self getAxisY maxValue: self maxY.
]

{ #category : #initialization }
RTTimeLine >> initialize [
	super initialize.
	entries := OrderedCollection new.
	self axisY noTick; noLabel.
	self timeLineLabel: #asString.
	self smalestEntryWidth: 1.
]

{ #category : #utility }
RTTimeLine >> label: aString on: position [
	"Add a label in the view"
	| e |
	e := RTLabel elementOn: aString.
	e translateTo: position.
	self view add: e.
	^ e
]

{ #category : #'accessing-computed' }
RTTimeLine >> maxEnd [
	^ entries max: #end
]

{ #category : #configuration }
RTTimeLine >> noTimeLineLabel [

	self timeLineLabel: ''
]

{ #category : #accessing }
RTTimeLine >> numberOfEntries [
	^ entries size
]

{ #category : #'accessing-computed' }
RTTimeLine >> numberOfTimeLines [
	"Return the number of time lines contained in myself"
	^ self timeLines size
]

{ #category : #hooks }
RTTimeLine >> renderIn: aView [
	| groupEntries elements t |
	self maxX: self maxEnd.
	self maxY: self numberOfTimeLines.
	self defineAxesIfNecessary.
	timeLineElements := OrderedCollection new.
	self timeLinesIdentifiers doWithIndex: [ :identifier :index | 	
			groupEntries := (self timeLines at: identifier) value.
			elements := self elementsOn: groupEntries.
			RTMetricNormalizer new
{'fraction_non_alphanumeric': 0.13288729957319184, 'fraction_numerical': 0.020071519206367516, 'mean_word_length': 4.034843205574913, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 61, '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': '5428191', 'n_tokens_mistral': 3299, 'n_tokens_neox': 3134, 'n_words': 962}