From d14059d40de6a98d1743a667108c042666ce510b Mon Sep 17 00:00:00 2001 From: Milton Mamani Torres Date: Wed, 11 Oct 2023 17:47:25 +0200 Subject: [PATCH] update layout algo --- .../RSLayoutNode.class.st | 21 ++++++++++++++++++- .../RSConditionalLayout.class.st | 2 +- .../RSTWalkBasedRegularTreeLayout.trait.st | 7 ++++--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/Roassal-Layouts-Util/RSLayoutNode.class.st b/src/Roassal-Layouts-Util/RSLayoutNode.class.st index be42fe2..beb2287 100644 --- a/src/Roassal-Layouts-Util/RSLayoutNode.class.st +++ b/src/Roassal-Layouts-Util/RSLayoutNode.class.st @@ -12,7 +12,8 @@ Class { 'children', 'model', 'connectedLines', - 'parent' + 'parent', + 'properties' ], #category : #'Roassal-Layouts-Util' } @@ -199,6 +200,24 @@ RSLayoutNode >> position: aPoint [ position := aPoint ] +{ #category : #accessing } +RSLayoutNode >> propertyAt: key [ + properties ifNil: [ ^ nil ]. + ^ properties at: key +] + +{ #category : #accessing } +RSLayoutNode >> propertyAt: key ifAbsent: aBlock [ + properties ifNil: [ ^ aBlock value ]. + ^ properties at: key ifAbsent: aBlock +] + +{ #category : #accessing } +RSLayoutNode >> propertyAt: key put: anObject [ + properties ifNil: [ properties := Dictionary new ]. + ^ properties at: key put: anObject +] + { #category : #actions } RSLayoutNode >> remove [ parent ifNil: [ ^ self ]. diff --git a/src/Roassal-Layouts/RSConditionalLayout.class.st b/src/Roassal-Layouts/RSConditionalLayout.class.st index 6f0b64f..c451955 100644 --- a/src/Roassal-Layouts/RSConditionalLayout.class.st +++ b/src/Roassal-Layouts/RSConditionalLayout.class.st @@ -45,7 +45,7 @@ RSConditionalLayout >> doExecute: shapes [ thenLayout on: thenShapes. elseLayout on: elseShapes. - clusterLayout on: { thenShapes. elseShapes }. + clusterLayout on: { thenShapes. elseShapes } asGroup. ] { #category : #accessing } diff --git a/src/Roassal-Layouts/RSTWalkBasedRegularTreeLayout.trait.st b/src/Roassal-Layouts/RSTWalkBasedRegularTreeLayout.trait.st index 9b1c5f6..b2de4a4 100644 --- a/src/Roassal-Layouts/RSTWalkBasedRegularTreeLayout.trait.st +++ b/src/Roassal-Layouts/RSTWalkBasedRegularTreeLayout.trait.st @@ -220,10 +220,11 @@ RSTWalkBasedRegularTreeLayout >> initialize: elements associationEdges: associat multipleParents ifFalse: [ children add: child ] ]. - rootNode := roots size > 1 ifTrue: [ | rootShape | + rootNode := roots size > 1 ifTrue: [ roots do: [ :each | self assert: (fathers includesKey: each) not ]. - rootShape := elements anyOne class new. - self childrenOf: rootShape put: roots asArray + RSLayoutNode new + in: [ :aRootNode | self childrenOf: aRootNode put: roots asArray ]; + yourself ] ifFalse: [ roots anyOne ]. leaves do: [ :each |