From 5df6902eae60414373d5514859c6e4f7ed39a7f3 Mon Sep 17 00:00:00 2001 From: Jan Bliznicenko Date: Wed, 18 Nov 2020 17:59:25 +0100 Subject: [PATCH 1/3] added comments icon to classifiers --- .../OPUmlClassifierShape.class.st | 44 ++++++++++++++- .../OPUmlCompartmentableShape.class.st | 12 +++- repository/OpenPonk-UML-DI/OPUmlIcon.class.st | 55 +++++++++++++++++++ .../OpenPonk-UML-DI/OPUmlShape.class.st | 7 ++- 4 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 repository/OpenPonk-UML-DI/OPUmlIcon.class.st diff --git a/repository/OpenPonk-UML-DI/OPUmlClassifierShape.class.st b/repository/OpenPonk-UML-DI/OPUmlClassifierShape.class.st index dbb2d46..39f2cf2 100644 --- a/repository/OpenPonk-UML-DI/OPUmlClassifierShape.class.st +++ b/repository/OpenPonk-UML-DI/OPUmlClassifierShape.class.st @@ -1,5 +1,47 @@ Class { #name : #OPUmlClassifierShape, #superclass : #OPUmlCompartmentableShape, - #category : 'OpenPonk-UML-DI-UML' + #instVars : [ + 'commentIcon', + 'commentBlock' + ], + #category : #'OpenPonk-UML-DI-UML' } + +{ #category : #accessing } +OPUmlClassifierShape >> comments: aBlock [ + commentBlock := aBlock +] + +{ #category : #testing } +OPUmlClassifierShape >> hasComments [ + | comments | + comments := commentBlock value. + ^ comments isNotEmpty + and: [ comments anySatisfy: [ :any | any body isNotEmpty ] ] +] + +{ #category : #initialization } +OPUmlClassifierShape >> initialize [ + super initialize. + commentIcon := OPUmlIcon new. + commentIcon display: [ self hasComments ]. + commentIcon form: (self iconNamed: #announcement). + commentIcon localStyle: OPUmlStyle new. + commentIcon owningElement: self +] + +{ #category : #'Roassal2 - updating' } +OPUmlClassifierShape >> layout [ + super layout. + commentIcon + translateTo: + self rtElement encompassingRectangle bottomRight + - (commentIcon rtElement extent / 2) - (2 @ 2) +] + +{ #category : #'Roassal2 - updating' } +OPUmlClassifierShape >> update [ + commentIcon update. + super update +] diff --git a/repository/OpenPonk-UML-DI/OPUmlCompartmentableShape.class.st b/repository/OpenPonk-UML-DI/OPUmlCompartmentableShape.class.st index 7406eb9..9fbe6b5 100644 --- a/repository/OpenPonk-UML-DI/OPUmlCompartmentableShape.class.st +++ b/repository/OpenPonk-UML-DI/OPUmlCompartmentableShape.class.st @@ -33,8 +33,7 @@ OPUmlCompartmentableShape >> createRtElement [ { #category : #'Roassal2 - accessing' } OPUmlCompartmentableShape >> figures [ - - ^ RTGroup withAll: self labels , self compartmentFigures + ^ RTGroup withAll: self labels , self compartmentFigures , self icons ] { #category : #'Roassal2 - manipulation' } @@ -42,6 +41,12 @@ OPUmlCompartmentableShape >> figuresDo: aBlock [ ^ self figures do: aBlock ] +{ #category : #'Roassal2 - accessing' } +OPUmlCompartmentableShape >> icons [ + ^ RTGroup + withAll: (self ownedElements select: [ :each | each isKindOf: OPUmlIcon ]) +] + { #category : #initialization } OPUmlCompartmentableShape >> initialize [ super initialize. @@ -76,7 +81,8 @@ OPUmlCompartmentableShape >> layout [ rect height < minSize height ifTrue: [ rect := rect withHeight: minSize height ]. self rtElement trachelShape extent: rect width @ rect height. - off := self rtElement trachelShape encompassingRectangle center - rect center. + off := self rtElement trachelShape encompassingRectangle center + - rect center. off := off asIntegerPoint + (5 @ 5). self figures do: [ :e | e translateBy: off ] ] diff --git a/repository/OpenPonk-UML-DI/OPUmlIcon.class.st b/repository/OpenPonk-UML-DI/OPUmlIcon.class.st new file mode 100644 index 0000000..9780616 --- /dev/null +++ b/repository/OpenPonk-UML-DI/OPUmlIcon.class.st @@ -0,0 +1,55 @@ +Class { + #name : #OPUmlIcon, + #superclass : #OPUmlShape, + #instVars : [ + 'form', + 'displayBlock', + 'view' + ], + #category : #'OpenPonk-UML-DI-UML' +} + +{ #category : #'Roassal2 - manipulation' } +OPUmlIcon >> createRtElement [ + ^ RTBitmap new + form: self form; + extent: 32@32"self form extent"; + elementOn: self +] + +{ #category : #accessing } +OPUmlIcon >> display: aBlock [ + displayBlock := aBlock +] + +{ #category : #accessing } +OPUmlIcon >> form [ + ^ form +] + +{ #category : #accessing } +OPUmlIcon >> form: aForm [ + form := aForm +] + +{ #category : #initialization } +OPUmlIcon >> initialize [ + super initialize. + isIcon := true +] + +{ #category : #rendering } +OPUmlIcon >> renderIn: aView [ + view ifNotNil: [ ^ self ]. + view := aView +] + +{ #category : #'Roassal2 - updating' } +OPUmlIcon >> update [ + | shouldBeDisplayed | + shouldBeDisplayed := displayBlock value. + self view isNil & shouldBeDisplayed + ifTrue: [ ^ view add: self rtElement ]. + self view isNotNil & shouldBeDisplayed not + ifTrue: [ ^ self rtElement remove ] +] diff --git a/repository/OpenPonk-UML-DI/OPUmlShape.class.st b/repository/OpenPonk-UML-DI/OPUmlShape.class.st index 49a424d..d8b969c 100644 --- a/repository/OpenPonk-UML-DI/OPUmlShape.class.st +++ b/repository/OpenPonk-UML-DI/OPUmlShape.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'rtElement' ], - #category : 'OpenPonk-UML-DI-UML' + #category : #'OpenPonk-UML-DI-UML' } { #category : #Roassal2 } @@ -54,6 +54,11 @@ OPUmlShape >> position [ ^ self rtElement position ] +{ #category : #rendering } +OPUmlShape >> renderIn: aView [ + self subclassResponsibility +] + { #category : #'Roassal2 - accessing' } OPUmlShape >> rtElement [ ^ rtElement ifNil: [ rtElement := self createRtElement ] From 9f4185de26c2e70c58382f7680c3c31fc0fd3f36 Mon Sep 17 00:00:00 2001 From: Jan Bliznicenko Date: Tue, 24 Nov 2020 21:17:06 +0100 Subject: [PATCH 2/3] fixed case when commentBlock is not provided --- repository/OpenPonk-UML-DI/OPUmlClassifierShape.class.st | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repository/OpenPonk-UML-DI/OPUmlClassifierShape.class.st b/repository/OpenPonk-UML-DI/OPUmlClassifierShape.class.st index 39f2cf2..7c5030d 100644 --- a/repository/OpenPonk-UML-DI/OPUmlClassifierShape.class.st +++ b/repository/OpenPonk-UML-DI/OPUmlClassifierShape.class.st @@ -28,7 +28,8 @@ OPUmlClassifierShape >> initialize [ commentIcon display: [ self hasComments ]. commentIcon form: (self iconNamed: #announcement). commentIcon localStyle: OPUmlStyle new. - commentIcon owningElement: self + commentIcon owningElement: self. + commentBlock := #() ] { #category : #'Roassal2 - updating' } From b92c8a84996f2e2c2b9ac30a44450b62c0136da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Blizni=C4=8Denko?= <9571633+JanBliznicenko@users.noreply.github.com> Date: Tue, 24 Nov 2020 21:20:01 +0100 Subject: [PATCH 3/3] Update .travis.yml --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0254732..ed06671 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,5 @@ os: - linux smalltalk: - - Pharo64-7.0 - - Pharo32-8.0 - Pharo64-8.0 - Pharo64-9.0