From 36c9c60ef72a3a0873abbd291c174fe169b8fb23 Mon Sep 17 00:00:00 2001 From: ClotildeToullec Date: Tue, 26 Nov 2024 09:52:56 +0100 Subject: [PATCH] Working on #1248 --- .../MiCoHighlightManager.class.st | 30 +++++++++---------- .../MiCoTagLegendBuilder.class.st | 13 +++++--- .../MiCoUsageMapBuilder.class.st | 19 +++++------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/MooseIDE-CoUsageMap/MiCoHighlightManager.class.st b/src/MooseIDE-CoUsageMap/MiCoHighlightManager.class.st index 4b3958f31..340dbb23a 100644 --- a/src/MooseIDE-CoUsageMap/MiCoHighlightManager.class.st +++ b/src/MooseIDE-CoUsageMap/MiCoHighlightManager.class.st @@ -21,24 +21,23 @@ MiCoHighlightManager >> defaultBoxBorder [ { #category : #selection } MiCoHighlightManager >> deselectInnerBox: evt [ - "called when clicking on a shape ('permanent' highlight)" + "Called when clicking on a shape ('permanent' highlight)" - evt canvas - propertyAt: highlight propertyKey + mapBuilder selectedInnerShape ifNil: [ ^ self ]. + evt canvas + propertyAt: highlight propertyKey put: (highlight highlightShapesFor: mapBuilder selectedInnerShape). mapBuilder selectedInnerShape: nil. highlight unhighlightRecordedShapes: evt shape. - evt signalUpdate. + evt signalUpdate ] { #category : #highlighting } MiCoHighlightManager >> highlight: evt [ "called on mouse entering a shape" - mapBuilder selectedInnerEntity - ifNil: [ evt shape border: self selectedBoxBorder ] - ifNotNil: [ - ]. + mapBuilder selectedInnerEntity ifNil: [ + evt shape border: self selectedBoxBorder ] ] { #category : #initialization } @@ -70,12 +69,13 @@ MiCoHighlightManager >> mapBuilder: aCoUsageMapBuilder [ { #category : #hooks } MiCoHighlightManager >> onShape: aShape [ - (aShape isShape not or: [aShape isComposite]) ifTrue: [ + + (aShape isShape not or: [ aShape isComposite ]) ifTrue: [ aShape when: RSMouseClick send: #deselectInnerBox: to: self. ^ self ]. - aShape + aShape addInteraction: highlight; - when: RSMouseLeftClick send: #selectInnerBox: to: self. + when: RSMouseLeftClick send: #selectInnerBox: to: self ] { #category : #selection } @@ -85,7 +85,7 @@ MiCoHighlightManager >> selectInnerBox: evt [ mapBuilder selectedInnerEntity ifNotNil: [ self deselectInnerBox: evt ]. highlight doHighlight: evt shape. - mapBuilder selectedInnerShape: evt shape. + mapBuilder selectedInnerShape: evt shape ] { #category : #accessing } @@ -101,8 +101,6 @@ MiCoHighlightManager >> selectedBoxBorder [ MiCoHighlightManager >> unhighlight: evt [ "called on mouse leaving a shape" - mapBuilder selectedInnerEntity - ifNil: [ evt shape border: self defaultBoxBorder ] - ifNotNil: [ - ]. + mapBuilder selectedInnerEntity ifNil: [ + evt shape border: self defaultBoxBorder ] ] diff --git a/src/MooseIDE-CoUsageMap/MiCoTagLegendBuilder.class.st b/src/MooseIDE-CoUsageMap/MiCoTagLegendBuilder.class.st index 233ac9e61..518d824e9 100644 --- a/src/MooseIDE-CoUsageMap/MiCoTagLegendBuilder.class.st +++ b/src/MooseIDE-CoUsageMap/MiCoTagLegendBuilder.class.st @@ -149,22 +149,27 @@ MiCoTagLegendBuilder >> removeOldLegend [ ] -{ #category : #hooks } +{ #category : #rendering } MiCoTagLegendBuilder >> renderIn: aCanvas [ - | tagShapes legend | + | legend | + self removeOldLegend. + legend := RSLegend new container: aCanvas; yourself. + shapes := RSGroup new. - tagShapes := self tags collect: [ :tag | self legendTagLine: tag ]. - shapes addAll: tagShapes. + shapes addAll: + (self tags collect: [ :tag | self legendTagLine: tag ]). shapes add: self legendBottomLine. legend shapes ifNotNil: [ :collection | collection addAll: shapes ]. + legend layout vertical gapSize: 2. legend defaultTitle color: Color black; fontSize: 12. + legend legendDo: [ :l | self legendDo: l ]; beFixedWithTitle: self legendTitle; diff --git a/src/MooseIDE-CoUsageMap/MiCoUsageMapBuilder.class.st b/src/MooseIDE-CoUsageMap/MiCoUsageMapBuilder.class.st index 21208a80e..c8a0cd3ff 100644 --- a/src/MooseIDE-CoUsageMap/MiCoUsageMapBuilder.class.st +++ b/src/MooseIDE-CoUsageMap/MiCoUsageMapBuilder.class.st @@ -289,28 +289,25 @@ MiCoUsageMapBuilder >> resizeLabelIfNecessary: label [ { #category : #accessing } MiCoUsageMapBuilder >> selectedInnerEntity [ - ^visualization selectedInnerEntity + ^ visualization selectedInnerEntity ] { #category : #accessing } MiCoUsageMapBuilder >> selectedInnerShape [ - | selectedEntity | - selectedEntity := visualization selectedInnerEntity. - self canvas children do: [:containerShape | + + self canvas children do: [ :containerShape | containerShape innerBoxShapes detect: [ :innerShape | - innerShape model mooseEntity = selectedEntity ] - ifOne: [ :innerShape | ^innerShape ] - ifNone: [ nil ] - ]. - - Error signal: 'Shape of selected entity not found' + innerShape model mooseEntity = self selectedInnerEntity ] + ifFound: [ :innerShape | ^ innerShape ] ]. + ^ nil ] { #category : #accessing } MiCoUsageMapBuilder >> selectedInnerShape: anInnerShape [ - ^visualization selectedInnerEntity: (anInnerShape ifNil: [ nil ] ifNotNil: [anInnerShape model mooseEntity]) + ^ visualization selectedInnerEntity: + (anInnerShape ifNotNil: [ anInnerShape model mooseEntity ]) ] { #category : #accessing }