|
This discussion originates from Mondrian on Moose 4.7 where layouts
which previously were exactly reproducible now randomly alternate
between two arrangements. I have cross-posted since upstream behaviour
of Collection>>difference: has changed between Pharo 1.3 and
1.4. The issue in Mondrian has been isolated so that it can be observed using the attached changeset 'isolate-unstable-972.2.cs' against a fresh Moose 4.7 image downloaded a few moments ago. After loading the cs, open a Transcript and then <Generate> the following script in Modrian Easel a dozen times. view shape label. view nodes: #(1 2 3 4 ). view edgesFromAssociations: { 1 -> 2. 1 ->3 . 3 -> 4}. view treeLayout At some point you will see a change in the order that nodes are drawn between runs as reflected in lines B2 and A2 shown below... ------------------------------RUN 1 B1>an OrderedCollection(a MONode model: 2 a MONode model: 3) B2>an OrderedCollection(a MONode model: 3 a MONode model: 2) A2>a MONode model: 1 A2>a MONode model: 3 A2>a MONode model: 4 A2>a MONode model: 2 ------------------------------RUN 2 B1>an OrderedCollection(a MONode model: 2 a MONode model: 3) B2>an OrderedCollection(a MONode model: 2 a MONode model: 3) A2>a MONode model: 1 A2>a MONode model: 2 A2>a MONode model: 3 A2>a MONode model: 4 ------------------------------END The cause of this is a change in behaviour of Collection>>#difference: between Pharo 1.3 & 1.4. This can be observed by executing the following in Workspace... 20 timesRepeat: [ one := TextMorph new newContents: '1'. two := TextMorph new newContents: '2'. collection := (OrderedCollection with: one with: two). diff := collection difference: OrderedCollection new. Transcript crShow: diff first text, diff second text. ] In Pharo 1.3 the result never deviates from '12'. In Pharo 1.4 the result is sometimes '21'. Pharo 1.3 has... Collection>>difference: aCollection "Answer the set theoretic difference of two collections." ^ self reject: [:each | aCollection includes: each] Pharo 1.4 has... Collection>>difference: aCollection "Answer the set theoretic difference of two collections." | set| set := self asSet. aCollection do: [ :each| set remove: each ifAbsent: []]. ^ self species withAll: set asArray Your thoughts? cheers -ben Tudor Girba wrote: Could it be a Pharo issue, because I think it happened since we moved to Pharo 1.4.Doru On 15 May 2012, at 21:51, Alexandre Bergel wrote:Well… this happens since the changes in the collection hierarchy a few weeks ago. The tree layout should indeed preserver the order. I spent some time but I could not see where the problem came from. I should spent some more time on this. Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. On May 13, 2012, at 11:21 PM, Tudor Girba wrote: |
'From Pharo1.4 of 18 April 2012 [Latest update: #14438] on 16 May 2012 at
11:15:20 pm'!
!MOAbstractRegularTreeLayout methodsFor: 'hook' stamp: 'BenComan 5/16/2012
23:14'!
doExecute: node
| rootNodes btcdebug|
alreadyLayoutedNodes := OrderedCollection new.
rootNodes := self rootNodesFor: node nodes.
nodesByLayer := OrderedCollection new.
self flag: #btcdebug.
"Regarding [email protected] emails 'Jenkins build is
still unstable: moose-latest-dev #972'
To isolate the issue, open a Transcript then generate the
following in Mondrian Easel twenty times
view shape label.
view nodes: #(1 2 3 4 ).
view edgesFromAssociations: { 1 -> 2. 1 ->3 . 3 -> 4}.
view treeLayout.
"
btcdebug := rootNodes first.
Transcript cr; crShow: '------------------------------'.
Transcript crShow: 'B1>', (self childrenFor: btcdebug)
asString.
Transcript crShow: 'B2>', (self computeChildrenFor: btcdebug)
asString.
self
layout: rootNodes
atPoint: self leftGap @ self topGap
atLayer: 1.
self isLayered ifTrue: [
self rearrangeByLayers: node ]! !
!MOAbstractVerticalTreeLayout methodsFor: 'hook-private' stamp: 'BenComan
5/16/2012 23:02'!
layout: aNodeCollection atPoint: aPoint atLayer: aNumber
| treeSize childrenPosition x y middleOfTree |
aNodeCollection isEmpty ifTrue: [ ^ 0 ].
x := aPoint x.
y := aPoint y.
alreadyLayoutedNodes addAll: aNodeCollection.
self atLayer: aNumber add: aNodeCollection.
aNodeCollection do: [ :each |
self flag: #btcdebug. Transcript crShow: 'A2>', each asString.
childrenPosition := y + each height + self verticalGap.
treeSize := each width
max: (self layout: (self computeChildrenFor: each)
atPoint: x @ childrenPosition atLayer: aNumber + 1).
middleOfTree := x + (treeSize / 2.0) - (each width / 2.0).
each translateTo: middleOfTree @ y.
x := x + treeSize + self horizontalGap ].
^ x - aPoint x - self horizontalGap! !
