Created
July 12, 2017 08:59
-
-
Save peteruhnak/87f27505a0389388f706399c09a0bfa7 to your computer and use it in GitHub Desktop.
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
xmi := OPUMLBootstrapGeneratorTest umlSpecs. | |
reader := OPUMLXMIReader new. | |
reader classPrefix: 'OPUML'. | |
model := (reader readXmi: xmi) first. | |
"select all classes in the entire metamodel" | |
cls := (model packagedElements flatCollect: #packagedElements) select: [ :each | each isKindOf: OPUMLClass ]. | |
rootName := 'Behavior'. | |
"Behav, Stru, Enc, Cls" | |
root := cls detect: [ :each | each name = rootName ]. | |
links := OrderedCollection new. | |
cls | |
select: [ :each | each generalizations isNotNil ] | |
thenDo: [ :each | | |
each generalizations do: [ :gen | | |
links add: each -> gen general | |
]. | |
]. | |
elements := OrderedCollection with: root. | |
unprocessed := OrderedCollection with: root. | |
[ unprocessed isNotEmpty ] whileTrue: [ |top layer| | |
top := unprocessed removeFirst. | |
elements addIfNotPresent: top. | |
layer := links select: [ :pair | pair value = top ] thenCollect: #key. | |
layer do: [ :each | unprocessed addIfNotPresent: each ]. | |
]. | |
b := RTMondrian new. | |
b shape text text: #name. | |
b nodes: elements. | |
b edges shape arrowedLine head: RTFilledNarrowArrow asHead; color: Color gray. | |
b edges useAssociations: links. | |
b layout dominanceTree verticallyReverse verticalGap: 50. | |
^ b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment