Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hiedra: Integrate latest version #7047

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/EpiceaBrowsers/EpLogNodeGraphPresenter.class.st
Expand Up @@ -79,9 +79,10 @@ EpLogNodeGraphPresenter >> initializeHiedraController [
hiedraColumnController renderer
rowHeight: self rowHeight;
cellWidth: self rowHeight // 3;
arrowSize: 2.0;
nodeConnectionOffset: 2.5
arrowSize: 1.0;
nodeConnectionOffset: 2.5.

hiedraColumnController renderer rowHeight: FTTableMorph defaultRowHeight floor.
]

{ #category : #initialization }
Expand Down
8 changes: 4 additions & 4 deletions src/Hiedra-Examples/HiExampleCommit.class.st
Expand Up @@ -31,7 +31,7 @@ Class {
'comment',
'parentIds'
],
#category : #'Hiedra-Examples'
#category : #'Hiedra-Examples-Model'
}

{ #category : #examples }
Expand Down Expand Up @@ -24122,13 +24122,13 @@ HiExampleCommit class >> randomlyGenerated [
| values random |
values := 60 to: 1 by: -1.
random := Random new.
^ values collect: [ :value |
^ (values collect: [ :value |
self new
id: value;
comment: 'Value ', value asString;
comment: 'Randomly Connected Element #', value asString;
parentIds: ((values copyWithout: value) intersection: { random nextInt: values max });
yourself
]
]) reversed
]

{ #category : #accessing }
Expand Down
24 changes: 10 additions & 14 deletions src/Hiedra-Examples/HiFastTableExample.class.st
Expand Up @@ -7,7 +7,7 @@ Class {
#instVars : [
'hiedraColumnController'
],
#category : #'Hiedra-Examples'
#category : #'Hiedra-Examples-FastTable'
}

{ #category : #examples }
Expand All @@ -34,8 +34,8 @@ HiFastTableExample class >> openExample: selector [

table := FTTableMorph new
extent: 500 @ 700;
addColumn: (FTColumn id: ' ');
addColumn: (FTColumn id: 'Comment');
addColumn: (FTColumn id: #'Comment');
hideColumnHeaders;
dataSource: dataSource;
beResizable;
yourself.
Expand All @@ -50,17 +50,16 @@ HiFastTableExample class >> openExample: selector [
HiFastTableExample >> cellColumn: column row: rowIndex [
"Answer a morph with the cell view."

column id = ' ' ifTrue: [
column id = #'Comment' ifTrue: [
| hiedraMorph commentMorph |
hiedraMorph := hiedraColumnController cellMorphAtRow: rowIndex.
commentMorph := (self elementAt: rowIndex) comment asMorph.
^ FTCellMorph new
addMorphBack: (hiedraColumnController cellMorphAtRow: rowIndex);
addMorphBack: hiedraMorph;
addMorphBack: commentMorph;
yourself
].

column id = 'Comment' ifTrue: [
| commit |
commit := self elementAt: rowIndex.
^ commit comment asMorph ].

^ self error
]

Expand All @@ -81,17 +80,14 @@ HiFastTableExample >> elements: commits [
"Reset the visualization"
hiedraColumnController reset.

"Adjust the column width in the table"
self table columns first width: hiedraColumnController rulerWidth.

]

{ #category : #initialization }
HiFastTableExample >> initialize [
super initialize.
hiedraColumnController := HiColumnController new.
hiedraColumnController renderer
arrowSize: 2;
arrowSize: 1;
nodeConnectionOffset: 2;
cellWidth: 7.

Expand Down
54 changes: 48 additions & 6 deletions src/Hiedra-Examples/HiSpecExample.class.st
Expand Up @@ -6,15 +6,17 @@ Class {
#superclass : #SpPresenter,
#instVars : [
'hiedraColumnController',
'table'
'table',
'actionBar'
],
#category : #'Hiedra-Examples'
#category : #'Hiedra-Examples-Spec2'
}

{ #category : #specs }
HiSpecExample class >> defaultSpec [
^ SpBoxLayout newVertical
add: #table;
add: #actionBar withConstraints: [ :constraints | constraints height: self toolbarHeight ];
yourself
]

Expand Down Expand Up @@ -60,24 +62,62 @@ HiSpecExample >> close [
HiSpecExample >> commits: commits [

table items: commits.

hiedraColumnController ruler: (HiRulerBuilder
newRulerValues: commits
linksBlock: [:aCommit |
aCommit parentIds collect: [:id |
commits detect: [:each | each id = id ] ] ]).

hiedraColumnController reset.
"After #reset, we can know the width of the column."

"After #reset, we know the desired width for the column."
table columns first width: hiedraColumnController rulerWidth.
]

{ #category : #initialization }
HiSpecExample >> initializeWidgets [
HiSpecExample >> forceRefreshHiedra [
hiedraColumnController reset.
table withAdapterDo: #refreshList.
]

{ #category : #initialization }
HiSpecExample >> initializeActionBar [

| refreshButton inspectButton |
refreshButton := self newButton
label: 'Redraw';
help: 'Refresh the table (and redraw all Hiedra cells with current rendering parameters).';
action: [ UIManager default defer: [ self forceRefreshHiedra ] ];
yourself.
inspectButton := self newButton
label: 'Renderer';
help: ('Inspect the Hiedra renderer, that has the rendering parameters. Press on {1} button to see the effect of any change on the renderer.' format: { refreshButton label });
action: [ UIManager default defer: [ hiedraColumnController renderer inspect ] ];
yourself.

actionBar := self newActionBar
add: inspectButton;
add: refreshButton;
yourself.

]

{ #category : #initialization }
HiSpecExample >> initializePresenters [
self initializeTable.
self initializeActionBar.
]

{ #category : #initialization }
HiSpecExample >> initializeTable [
table := self newTable.

"Configure hiedra controller"
hiedraColumnController := HiColumnController new.

hiedraColumnController renderer
linkWidth: 3.5;
nodeRadius: 1.5;
nodeBorderWidth: 3.0;
arrowSize: 0;
Expand All @@ -90,6 +130,8 @@ HiSpecExample >> initializeWidgets [

"Configure columns"
table
addColumn: (SpImageTableColumn evaluated: [ :item | hiedraColumnController cellMorphAtValue: item ]);
addColumn: (SpStringTableColumn evaluated: #comment)
addColumn: (SpImageTableColumn evaluated: [ :item |
hiedraColumnController cellMorphAtValue: item ]);
addColumn: (SpStringTableColumn evaluated: [ :item |
item comment ])
]
24 changes: 12 additions & 12 deletions src/Hiedra-Tests/HiExamplesTest.class.st
Expand Up @@ -4,28 +4,28 @@ Class {
#category : #'Hiedra-Tests-Model'
}

{ #category : #accessing }
HiExamplesTest class >> defaultTimeLimit [
{ #category : #testing }
HiExamplesTest class >> isAbstract [
^ self = HiExamplesTest
]

^ 30 seconds
{ #category : #tests }
HiExamplesTest >> exampleClassToTest [
^ self subclassResponsibility
]

{ #category : #tests }
HiExamplesTest >> exampleMethods [
^ (((RPackage organizer packages
select: [ :each | each name beginsWith: 'Hiedra' ])
flatCollect: #classes)
flatCollect: [ :each | each classSide methods ])
select: [ :each |
(each selector beginsWith: 'example') and: [ each numArgs = 0 ] ]
HiExamplesTest >> exampleMethods [

^ self exampleClassToTest classSide methods select: [ :each |
(each selector beginsWith: 'example') and: [ each numArgs = 0 ] ]
]

{ #category : #tests }
HiExamplesTest >> testAllExamples [
| exampleMethods |

self skip: 'This test fails randomly in the CI in different OS due a timeout, even with an increased time limit of 30 seconds'.
self timeLimit: 30 seconds.
self timeLimit: 1 minute.

exampleMethods := self exampleMethods.
self deny: exampleMethods isEmpty.
Expand Down
10 changes: 10 additions & 0 deletions src/Hiedra-Tests/HiFastTableExampleTest.class.st
@@ -0,0 +1,10 @@
Class {
#name : #HiFastTableExampleTest,
#superclass : #HiExamplesTest,
#category : #'Hiedra-Tests-Model'
}

{ #category : #tests }
HiFastTableExampleTest >> exampleClassToTest [
^ HiFastTableExample
]
10 changes: 10 additions & 0 deletions src/Hiedra-Tests/HiSpecExampleTest.class.st
@@ -0,0 +1,10 @@
Class {
#name : #HiSpecExampleTest,
#superclass : #HiExamplesTest,
#category : #'Hiedra-Tests-Model'
}

{ #category : #tests }
HiSpecExampleTest >> exampleClassToTest [
^ HiSpecExample
]
8 changes: 8 additions & 0 deletions src/Hiedra/HiAbstractRenderer.class.st
Expand Up @@ -51,6 +51,14 @@ HiAbstractRenderer >> rowHeight [
^ self subclassResponsibility
]

{ #category : #accessing }
HiAbstractRenderer >> rowWidthAt: rowIndex [
"Answer the width in pixels required by a row to be rendered."

"The +2 represents the left and right margin."
^ ((ruler numberOfColumnsAt: rowIndex) + 2) * self cellWidth
]

{ #category : #accessing }
HiAbstractRenderer >> rowsInterval [
^ rowsInterval
Expand Down
4 changes: 2 additions & 2 deletions src/Hiedra/HiColumnController.class.st
Expand Up @@ -27,7 +27,7 @@ HiColumnController >> cellBoundsForRow: rowIndex inPage: pageIndex [
rowIndexRelativeToPage := rowIndexRelativeToRuler - rowIndexOfFirstNodeInPage.

^ 0 @ (rowIndexRelativeToPage * renderer rowHeight)
corner: self rulerWidth @ ((rowIndexRelativeToPage + 1) * renderer rowHeight)
corner: (renderer rowWidthAt: rowIndex) @ ((rowIndexRelativeToPage + 1) * renderer rowHeight)
]

{ #category : #API }
Expand Down Expand Up @@ -93,7 +93,7 @@ HiColumnController >> newCellMorphForRow: rowIndex [
aForm getCanvas
translucentImage: (self formAtPage: pageIndex)
at: 0 @ 0
sourceRect: cellBoundsInPage truncated.
sourceRect: cellBoundsInPage.
^ aForm asMorph
]

Expand Down
6 changes: 6 additions & 0 deletions src/Hiedra/HiRuler.class.st
Expand Up @@ -176,6 +176,12 @@ HiRuler >> numberOfColumns [
ifNotEmpty: [ elementsByRow max: #size ]
]

{ #category : #accessing }
HiRuler >> numberOfColumnsAt: rowIndex [

^ (elementsByRow at: rowIndex) size
]

{ #category : #accessing }
HiRuler >> numberOfRows [

Expand Down