-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use tree layout if dominance tree fails
- Loading branch information
1 parent
cc943ba
commit 8cf4a36
Showing
4 changed files
with
117 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
Class { | ||
#name : #OPLayoutLoopDetector, | ||
#superclass : #Object, | ||
#instVars : [ | ||
'boxes', | ||
'links', | ||
'processedBoxes' | ||
], | ||
#category : #'OpenPonk-Spec-Layouting' | ||
} | ||
|
||
{ #category : #actions } | ||
OPLayoutLoopDetector class >> haveLoopsBoxes: boxes links: links [ | ||
|
||
^ self new | ||
boxes: boxes; | ||
links: links; | ||
haveLoops | ||
] | ||
|
||
{ #category : #actions } | ||
OPLayoutLoopDetector class >> popupHaveLoopsBoxes: boxes links: links [ | ||
|
||
^ self new | ||
boxes: boxes; | ||
links: links; | ||
popupHaveLoops | ||
] | ||
|
||
{ #category : #accessing } | ||
OPLayoutLoopDetector >> boxes [ | ||
|
||
^ boxes | ||
] | ||
|
||
{ #category : #accessing } | ||
OPLayoutLoopDetector >> boxes: anObject [ | ||
|
||
boxes := Array withAll: anObject | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
OPLayoutLoopDetector >> hasBox: box loopsBackTo: loopsTo [ | ||
|
||
| toBoxes | | ||
(processedBoxes includes: box) ifTrue: [ ^ false ]. | ||
|
||
toBoxes := (links | ||
select: [ :each | each from = box ] | ||
thenCollect: [ :each | each to ]) intersection: boxes. | ||
|
||
processedBoxes add: box. | ||
|
||
^ toBoxes anySatisfy: [ :any | | ||
(loopsTo includes: any) or: [ | ||
self hasBox: any loopsBackTo: loopsTo , { box } ] ] | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
OPLayoutLoopDetector >> haveLoops [ | ||
|
||
^ boxes anySatisfy: [ :box | self hasBox: box loopsBackTo: Set new ] | ||
] | ||
|
||
{ #category : #initialization } | ||
OPLayoutLoopDetector >> initialize [ | ||
|
||
super initialize. | ||
|
||
links := Set new. | ||
boxes := Array new. | ||
processedBoxes := Set new | ||
] | ||
|
||
{ #category : #accessing } | ||
OPLayoutLoopDetector >> links [ | ||
|
||
^ links | ||
] | ||
|
||
{ #category : #accessing } | ||
OPLayoutLoopDetector >> links: anObject [ | ||
|
||
links addAll: anObject | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
OPLayoutLoopDetector >> popupHaveLoops [ | ||
|
||
^ self haveLoops | ||
ifTrue: [ | ||
(GrowlMorph | ||
label: 'Unable to use dominance tree layout' | ||
contents: | ||
'Unable to use dominance tree layout as the diagram contains loops. Trying tree layout...') | ||
backgroundColor: GrowlMorph theme warningBackgroundColor; | ||
labelColor: GrowlMorph theme textColor; | ||
textColor: GrowlMorph theme textColorForNonStandardBackground; | ||
openInWorld. | ||
^ true ] | ||
ifFalse: [ false ] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters