Skip to content

Commit

Permalink
Merge 0fa29ea
Browse files Browse the repository at this point in the history
  • Loading branch information
anquetil committed Oct 27, 2024
2 parents 836e7b2 + 0fa29ea commit 239b43a
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 61 deletions.
2 changes: 1 addition & 1 deletion src/MooseIDE-Dependency/FamixTTypedEntity.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Extension { #name : #FamixTTypedEntity }
{ #category : #'*MooseIDE-Dependency' }
FamixTTypedEntity >> addDeclaredTypesIn: dependencies [

self declaredType ifNotNil: [dependencies add: self declaredType. "1haltIf: [ dependencies anySatisfy: [:e | e isLocalVariable] ]".]
self declaredType ifNotNil: [dependencies add: self declaredType]
]
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ Class {
'nodeColors',
'orderedNodesX',
'orderedNodesY',
'dependencyDictionary'
'dependencyDictionary',
'selectedEntities'
],
#category : #'MooseIDE-Dependency-DSM'
}

{ #category : #accessing }
{ #category : #buildGraph }
MiDependencyStructuralMatrixBrowserModel >> buildGraph: aCollection [

self newGraph.
Expand Down Expand Up @@ -83,7 +84,7 @@ MiDependencyStructuralMatrixBrowserModel >> defaultColor [

{ #category : #settings }
MiDependencyStructuralMatrixBrowserModel >> dependencyColor [
"a 'nice' blue for cells with dependency"

^ nodeColors at: #dependency
]

Expand Down Expand Up @@ -119,6 +120,8 @@ MiDependencyStructuralMatrixBrowserModel >> entity: aCandidate belongsTo: anEnti
{ #category : #actions }
MiDependencyStructuralMatrixBrowserModel >> followEntity: aCollection [

self selectedEntities: aCollection.

self buildGraph: aCollection.

orderedNodesX := self orderNodes: graph nodes.
Expand All @@ -139,12 +142,7 @@ MiDependencyStructuralMatrixBrowserModel >> getDependenciesFrom: entityX to: ent
ifTrue: [ opposites anySatisfy: [ :each |
self entity: each belongsTo: entityY ]
]
ifFalse: [
self flag: 'can be nil because of a bug in the model with generic types'.
opposites
ifNotNil: [ self entity: opposites belongsTo: entityY ]
ifNil: [false]
]
ifFalse: [ self entity: opposites belongsTo: entityY ]
]
ifFalse: [
"case of declaredType"
Expand All @@ -160,7 +158,7 @@ MiDependencyStructuralMatrixBrowserModel >> getTupleDependencyWeight: tuple [
"generic algorithm is to take all dependencies of the `tuple key` (row of the DSM) and count
those that can be scoped up to the `tuple value` (column of the DSM)"

^(dependencyDictionary at:(tuple key model -> tuple value model ))
^(dependencyDictionary at: (tuple key model -> tuple value model ))
size
]

Expand All @@ -176,22 +174,26 @@ MiDependencyStructuralMatrixBrowserModel >> increment: dictionary key: key value
{ #category : #initialization }
MiDependencyStructuralMatrixBrowserModel >> initialize [
super initialize.

self initializeColors.
self newGraph.
selectedEntities := #()
]

{ #category : #initialization }
MiDependencyStructuralMatrixBrowserModel >> initializeColors [
nodeColors := Dictionary new: 5.

nodeColors at: #diagonalCell put: Color veryLightGray.

nodeColors at: #scc put: Color lightRed.
nodeColors at: #showSCC put: Color red.
"extremely light gray for cell not in diagonal and not in dependency"

"very light gray for cell not in diagonal and not in dependency"
nodeColors at: #defaultCell put: (Color r: 0.9 g: 0.9 b: 0.9).
"a 'nice' blue for cells with dependency"
nodeColors at: #dependency put: (Color colorFrom: '#4d79ff').

"a 'nice' blue for cells with dependency"
nodeColors at: #dependency put: (Color colorFrom: '#659ef6').
]

{ #category : #buildGraph }
Expand All @@ -211,38 +213,45 @@ MiDependencyStructuralMatrixBrowserModel >> initializeDependencies [
{ #category : #testing }
MiDependencyStructuralMatrixBrowserModel >> isCycle: tuple [

^tuple key cycleNodes includes: tuple value
^tuple key cycleNodes
includes: tuple value
]

{ #category : #testing }
MiDependencyStructuralMatrixBrowserModel >> isDependency: tuple [

^tuple key adjacentNodes includes: tuple value
^tuple key adjacentNodes
includes: tuple value
]

{ #category : #testing }
MiDependencyStructuralMatrixBrowserModel >> isDiagonal: tuple [

^tuple key = tuple value

]

{ #category : #accessing }
MiDependencyStructuralMatrixBrowserModel >> miSelectedItem [

^ self entities
^selectedEntities
]

{ #category : #buildGraph }
MiDependencyStructuralMatrixBrowserModel >> newGraph [
graph := AITarjan new.
"orderedNodes := #()"

orderedNodesX := #().
orderedNodesY := #()
]

{ #category : #actions }
MiDependencyStructuralMatrixBrowserModel >> openDetailedDSMOn: aTuple [
MiDependencyStructuralMatrixBrowser openWithX: aTuple value model children withY: aTuple key model children
"note: RSDSM calls X the columns (#value of aTuple) and Y the rows (#key of aTuple)"

MiDependencyStructuralMatrixBrowser
openWithX: aTuple value model children
withY: aTuple key model children
]

{ #category : #initialization }
Expand Down Expand Up @@ -351,6 +360,14 @@ MiDependencyStructuralMatrixBrowserModel >> sccTuplesForTuple: tuple [
]
]

{ #category : #accessing }
MiDependencyStructuralMatrixBrowserModel >> selectedEntities: anObject [

selectedEntities := anObject.

browser updateToolbar
]

{ #category : #settings }
MiDependencyStructuralMatrixBrowserModel >> settings [

Expand All @@ -373,13 +390,26 @@ MiDependencyStructuralMatrixBrowserModel >> showSCCColorForTuple: tuple [
^ self dependencyColor
]

{ #category : #accessing }
{ #category : #actions }
MiDependencyStructuralMatrixBrowserModel >> userActionOn: aTuple [


self selectedEntities: { aTuple key model . aTuple value model }.
self openDetailedDSMOn: aTuple

]

{ #category : #actions }
MiDependencyStructuralMatrixBrowserModel >> withX: entitiesX withY: entitiesY [

| aCollection |
aCollection := entitiesX union: entitiesY.
self buildGraph: aCollection.
| allEntities |
allEntities := entitiesX union: entitiesY.

self selectedEntities: allEntities.
self buildGraph: allEntities.

orderedNodesX := self orderNodes: (entitiesX collect: [ :each | graph findNode: each]).
orderedNodesY := self orderNodes: (entitiesX collect: [ :each | graph findNode: each]).
orderedNodesY := self orderNodes: (entitiesY collect: [ :each | graph findNode: each]).

browser buildDSM
]
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ Class {

{ #category : #initialization }
MiDependencyStructuralMatrixVisualization >> buildInCanvas: aRSCanvas [
| dsm entitiesX entitiesY |
"change legend by adding #noLegend to RSCanvasController new
and add RSLegend new ..."

entitiesX := viewModel orderedNodesX.
entitiesY := viewModel orderedNodesY.
entitiesX ifEmpty: [ ^self ].
entitiesY ifEmpty: [ ^self ].
| dsm |

viewModel orderedNodesX ifEmpty: [ ^self ].
viewModel orderedNodesY ifEmpty: [ ^self ].

aRSCanvas addInteraction: RSCanvasController new.
dsm := MiRSDependencyStructuralMatrix new.
Expand All @@ -31,8 +27,8 @@ MiDependencyStructuralMatrixVisualization >> buildInCanvas: aRSCanvas [
dsm labelShapeX textBlock: [ :columnNode | viewModel displayValueForNode: columnNode].
dsm labelShapeY textBlock: [ :rowNode | viewModel displayValueForNode: rowNode ].
dsm container: aRSCanvas.
dsm objectsX: entitiesX.
dsm objectsY: entitiesY.
dsm objectsX: viewModel orderedNodesX.
dsm objectsY: viewModel orderedNodesY.
dsm color: [ :tuple | self cellColor: tuple ].

dsm build.
Expand Down
26 changes: 4 additions & 22 deletions src/MooseIDE-Dependency/MiRSDSMShape.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ This is a modified version of the `RSComposite` to accomodate our new DSM
Class {
#name : #MiRSDSMShape,
#superclass : #RSComposite,
#instVars : [
'weight',
'viewModel'
],
#category : #'MooseIDE-Dependency-DSM'
}

{ #category : #accessing }
MiRSDSMShape >> color: aColor [
self children first color: aColor
self children first
color: aColor
]

{ #category : #initialization }
Expand All @@ -28,22 +25,7 @@ MiRSDSMShape >> initialize [

{ #category : #accessing }
MiRSDSMShape >> text: aString [
self children second text: aString
]

{ #category : #accessing }
MiRSDSMShape >> viewModel: aMiDependencyStructuralMatrixBrowserModel [
viewModel := aMiDependencyStructuralMatrixBrowserModel
]

{ #category : #accessing }
MiRSDSMShape >> weight [

^ weight
]

{ #category : #accessing }
MiRSDSMShape >> weight: anObject [

weight := anObject
self children second
text: aString
]
15 changes: 10 additions & 5 deletions src/MooseIDE-Dependency/MiRSDependencyStructuralMatrix.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ MiRSDependencyStructuralMatrix >> createShape: tuple [
weight := self getTupleDependencyWeight: tuple.

shape := MiRSDSMShape new
text: (weight = 0 ifTrue: [''] ifFalse: [ weight asString]);
weight: weight ;
model: tuple;
color: (self color cull: tuple);
text: (weight = 0 ifTrue: [''] ifFalse: [ weight asString]) ;
color: (self color cull: tuple) ;
model: tuple ;
yourself.

shape
when: RSMouseDoubleClick do: [ self viewModel openDetailedDSMOn: tuple] for: shape ;
when: RSMouseDoubleClick do: [ self userActionOn: tuple] for: shape ;
when: RSMouseEnter send: #highlight: to: self ;
when: RSMouseLeave send: #unhighlight: to: self.

Expand Down Expand Up @@ -83,6 +82,12 @@ MiRSDependencyStructuralMatrix >> unhighlight: evt [
]
]

{ #category : #'as yet unclassified' }
MiRSDependencyStructuralMatrix >> userActionOn: aTuple [

self viewModel userActionOn: aTuple
]

{ #category : #accessing }
MiRSDependencyStructuralMatrix >> viewModel [
^self owner viewModel.
Expand Down

0 comments on commit 239b43a

Please sign in to comment.