Skip to content

Commit

Permalink
fix other usages of braceWith:with:
Browse files Browse the repository at this point in the history
  • Loading branch information
noha committed Dec 10, 2024
1 parent 83503cb commit 6df9036
Show file tree
Hide file tree
Showing 11 changed files with 763 additions and 761 deletions.
114 changes: 57 additions & 57 deletions OGC-Viewer/OGCCurve.extension.st
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
Extension { #name : #OGCCurve }

{ #category : #'*OGC-Viewer' }
OGCCurve >> displayWithZoom: zoom offsetX: offsetX offsetY: offsetY [
| allXPixel allYPixel surface amplitudeX amplitudeY initialOffsetX initialOffsetY coordInit coordNext pointInit morph path |
" 1. define working surface "
allXPixel := points collect: [ :each | each xPixelWithZoom: zoom ].
allYPixel := points collect: [ :each | each yPixelWithZoom: zoom ].
amplitudeX := allXPixel max - allXPixel min.
amplitudeY := allYPixel max - allYPixel min.
surface := AthensCairoSurface extent: amplitudeX@amplitudeY.
" 2. define first point coordinates: reference "
initialOffsetX := (self startPoint xPixelWithZoom: zoom) - allXPixel min.
initialOffsetY := (self startPoint yPixelWithZoom: zoom) - allYPixel min.
coordInit := initialOffsetX @ initialOffsetY .

surface drawDuring: [ :can |
" 3. init surface "
surface clear: Color transparent .
" to do : consider style dictionary "

" 4. draw linestring "
path := can createPath: [ :p |

pointInit := points first.
p relative.
p moveTo: coordInit.

points allButFirst do: [ :point_i |
coordNext :=
(Point x: (point_i xPixelWithZoom: zoom) y: (point_i yPixelWithZoom: zoom) )
- (Point x: (pointInit xPixelWithZoom: zoom) y: (pointInit yPixelWithZoom: zoom) ).

p lineTo: coordNext.

coordInit := coordInit + coordNext.
pointInit := point_i.
]
].
can setShape: path.
].

surface drawDuring: [ :can |
can setPaint: self styleFillColor.
can draw
].
surface drawDuring: [ :can |
(can setStrokePaint: self styleStrokeColor ) width: self styleStrokeWidth.
can draw
].
" 5. change result position "
morph := surface asMorph.
morph position:
((initialOffsetX sign: (-1) ) + (self startPoint xPixelWithOffset: offsetX withZoom: zoom))
@ ((initialOffsetY sign: (-1) ) + (self startPoint yPixelWithOffset: offsetY withZoom: zoom)).
^ morph
]
Extension { #name : 'OGCCurve' }

{ #category : '*OGC-Viewer' }
OGCCurve >> displayWithZoom: zoom offsetX: offsetX offsetY: offsetY [
| allXPixel allYPixel surface amplitudeX amplitudeY initialOffsetX initialOffsetY coordInit coordNext pointInit morph path |
" 1. define working surface "
allXPixel := points collect: [ :each | each xPixelWithZoom: zoom ].
allYPixel := points collect: [ :each | each yPixelWithZoom: zoom ].
amplitudeX := allXPixel max - allXPixel min.
amplitudeY := allYPixel max - allYPixel min.
surface := AthensCairoSurface extent: amplitudeX@amplitudeY.
" 2. define first point coordinates: reference "
initialOffsetX := (self startPoint xPixelWithZoom: zoom) - allXPixel min.
initialOffsetY := (self startPoint yPixelWithZoom: zoom) - allYPixel min.
coordInit := initialOffsetX @ initialOffsetY .

surface drawDuring: [ :can |
" 3. init surface "
surface clear: Color transparent .
" to do : consider style dictionary "

" 4. draw linestring "
path := can createPath: [ :p |

pointInit := points first.
p relative.
p moveTo: coordInit.

points allButFirst do: [ :point_i |
coordNext :=
(Point x: (point_i xPixelWithZoom: zoom) y: (point_i yPixelWithZoom: zoom) )
- (Point x: (pointInit xPixelWithZoom: zoom) y: (pointInit yPixelWithZoom: zoom) ).

p lineTo: coordNext.

coordInit := coordInit + coordNext.
pointInit := point_i.
]
].
can setShape: path.
].

surface drawDuring: [ :can |
can setPaint: self styleFillColor.
can draw
].
surface drawDuring: [ :can |
(can setStrokePaint: self styleStrokeColor ) width: self styleStrokeWidth.
can draw
].
" 5. change result position "
morph := surface asMorph.
morph position:
((initialOffsetX sign: (-1) ) + (self startPoint xPixelWithOffset: offsetX withZoom: zoom))
@ ((initialOffsetY sign: (-1) ) + (self startPoint yPixelWithOffset: offsetY withZoom: zoom)).
^ morph
]
44 changes: 22 additions & 22 deletions OGC-Viewer/OGCFeature.extension.st
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
Extension { #name : #OGCFeature }

{ #category : #'*OGC-Viewer' }
OGCFeature >> displayWithZoom: aZoom offsetX: aXValue offsetY: aYValue [
| morph |
morph := self geometry displayWithZoom: aZoom offsetX: aXValue offsetY: aYValue.
morph on: #click send: #handleClick to: self.
^ morph
]

{ #category : #'*OGC-Viewer' }
OGCFeature >> handleClick [
" at click on my morph: open window with properties "
| textToDisplay |
textToDisplay := String new.
self properties keysAndValuesDo: [ :aKey :aValue |
textToDisplay := textToDisplay , aKey asString , ' : ' , aValue asString , '
' ].
OGCInformationWindowPresenter isClosed ifTrue: [ OGCInformationWindowPresenter open ].
OGCInformationWindowPresenter textPresenter text: textToDisplay .
OGCInformationWindowPresenter inspectButton action: [ self inspect ].
]
Extension { #name : 'OGCFeature' }

{ #category : '*OGC-Viewer' }
OGCFeature >> displayWithZoom: aZoom offsetX: aXValue offsetY: aYValue [
| morph |
morph := self geometry displayWithZoom: aZoom offsetX: aXValue offsetY: aYValue.
morph on: #click send: #handleClick to: self.
^ morph
]

{ #category : '*OGC-Viewer' }
OGCFeature >> handleClick [
" at click on my morph: open window with properties "
| textToDisplay |
textToDisplay := String new.
self properties keysAndValuesDo: [ :aKey :aValue |
textToDisplay := textToDisplay , aKey asString , ' : ' , aValue asString , '
' ].
OGCInformationWindowPresenter isClosed ifTrue: [ OGCInformationWindowPresenter open ].
OGCInformationWindowPresenter textPresenter text: textToDisplay .
OGCInformationWindowPresenter inspectButton action: [ self inspect ].
]
30 changes: 15 additions & 15 deletions OGC-Viewer/OGCFeatureCollection.extension.st
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Extension { #name : #OGCFeatureCollection }

{ #category : #'*OGC-Viewer' }
OGCFeatureCollection >> displayWithZoom: aZoom offsetX: aXValue offsetY: aYValue [
| morph initialOffsetX initialOffsetY |
initialOffsetX := (self rectangularTileEnvelopeWithZoom: aZoom) origin x.
initialOffsetY := (self rectangularTileEnvelopeWithZoom: aZoom) origin y.
morph := ImageMorph new.
self features do: [ :each |
| morphFeature |
morphFeature := each displayWithZoom: aZoom offsetX: (aXValue + initialOffsetX) offsetY: (aYValue + initialOffsetY).
morph addMorph: morphFeature.
].
^ morph
]
Extension { #name : 'OGCFeatureCollection' }

{ #category : '*OGC-Viewer' }
OGCFeatureCollection >> displayWithZoom: aZoom offsetX: aXValue offsetY: aYValue [
| morph initialOffsetX initialOffsetY |
initialOffsetX := (self rectangularTileEnvelopeWithZoom: aZoom) origin x.
initialOffsetY := (self rectangularTileEnvelopeWithZoom: aZoom) origin y.
morph := ImageMorph new.
self features do: [ :each |
| morphFeature |
morphFeature := each displayWithZoom: aZoom offsetX: (aXValue + initialOffsetX) offsetY: (aYValue + initialOffsetY).
morph addMorph: morphFeature.
].
^ morph
]
12 changes: 6 additions & 6 deletions OGC-Viewer/OGCGeometry.extension.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #OGCGeometry }

{ #category : #'*OGC-Viewer' }
OGCGeometry >> displayWithZoom: zoom offsetX: offsetX offsetY: offsetY [
self subclassResponsibility
]
Extension { #name : 'OGCGeometry' }

{ #category : '*OGC-Viewer' }
OGCGeometry >> displayWithZoom: zoom offsetX: offsetX offsetY: offsetY [
self subclassResponsibility
]
26 changes: 13 additions & 13 deletions OGC-Viewer/OGCGeometryCollection.extension.st
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Extension { #name : #OGCGeometryCollection }

{ #category : #'*OGC-Viewer' }
OGCGeometryCollection >> displayWithZoom: zoom offsetX: offsetX offsetY: offsetY [
| morph |
morph := ImageMorph new.
geometries do: [ :each |
| morphGeometry |
morphGeometry := each displayWithZoom: zoom offsetX: (offsetX) offsetY: (offsetY).
morph addMorph: morphGeometry.
].
^ morph
]
Extension { #name : 'OGCGeometryCollection' }

{ #category : '*OGC-Viewer' }
OGCGeometryCollection >> displayWithZoom: zoom offsetX: offsetX offsetY: offsetY [
| morph |
morph := ImageMorph new.
geometries do: [ :each |
| morphGeometry |
morphGeometry := each displayWithZoom: zoom offsetX: (offsetX) offsetY: (offsetY).
morph addMorph: morphGeometry.
].
^ morph
]
137 changes: 69 additions & 68 deletions OGC-Viewer/OGCInformationWindowPresenter.class.st
Original file line number Diff line number Diff line change
@@ -1,68 +1,69 @@
Class {
#name : #OGCInformationWindowPresenter,
#superclass : #SpWindowPresenter,
#classInstVars : [
'presenter'
],
#category : #'OGC-Viewer'
}

{ #category : #'as yet unclassified' }
OGCInformationWindowPresenter class >> getNewPresenter [
^ self new
presenter: self getNewSubPresenter ;
title: 'Information'
]

{ #category : #'as yet unclassified' }
OGCInformationWindowPresenter class >> getNewSubPresenter [
| newPresenter |

newPresenter := SpPresenter new.
newPresenter layout: (SpBoxLayout newTopToBottom
add: 'Properties' expand: false;
add: (newPresenter newText beNotEditable) expand: true;
addLast: (SpBoxLayout newLeftToRight
addLast: (newPresenter newButton label: 'Inspect') expand: false;
yourself)
expand: false;
yourself).

^ newPresenter
]

{ #category : #'as yet unclassified' }
OGCInformationWindowPresenter class >> inspectButton [
^ self presenter presenter layout children third children first
]

{ #category : #testing }
OGCInformationWindowPresenter class >> isClosed [
^ self isOpened not
]

{ #category : #testing }
OGCInformationWindowPresenter class >> isOpened [
^ self presenter isOpen
]

{ #category : #testing }
OGCInformationWindowPresenter class >> open [
presenter := self getNewPresenter .
self presenter open.
]

{ #category : #accessing }
OGCInformationWindowPresenter class >> presenter [
^ presenter ifNil: [ ^ presenter := self getNewPresenter ]
]

{ #category : #accessing }
OGCInformationWindowPresenter class >> textPresenter [
^ self presenter presenter layout children second
]

{ #category : #accessing }
OGCInformationWindowPresenter class >> title [
^ 'Informations'
]
Class {
#name : 'OGCInformationWindowPresenter',
#superclass : 'SpWindowPresenter',
#classInstVars : [
'presenter'
],
#category : 'OGC-Viewer',
#package : 'OGC-Viewer'
}

{ #category : 'as yet unclassified' }
OGCInformationWindowPresenter class >> getNewPresenter [
^ self new
presenter: self getNewSubPresenter ;
title: 'Information'
]

{ #category : 'as yet unclassified' }
OGCInformationWindowPresenter class >> getNewSubPresenter [
| newPresenter |

newPresenter := SpPresenter new.
newPresenter layout: (SpBoxLayout newTopToBottom
add: 'Properties' expand: false;
add: (newPresenter newText beNotEditable) expand: true;
addLast: (SpBoxLayout newLeftToRight
addLast: (newPresenter newButton label: 'Inspect') expand: false;
yourself)
expand: false;
yourself).

^ newPresenter
]

{ #category : 'as yet unclassified' }
OGCInformationWindowPresenter class >> inspectButton [
^ self presenter presenter layout children third children first
]

{ #category : 'testing' }
OGCInformationWindowPresenter class >> isClosed [
^ self isOpened not
]

{ #category : 'testing' }
OGCInformationWindowPresenter class >> isOpened [
^ self presenter isOpen
]

{ #category : 'testing' }
OGCInformationWindowPresenter class >> open [
presenter := self getNewPresenter .
self presenter open.
]

{ #category : 'accessing' }
OGCInformationWindowPresenter class >> presenter [
^ presenter ifNil: [ ^ presenter := self getNewPresenter ]
]

{ #category : 'accessing' }
OGCInformationWindowPresenter class >> textPresenter [
^ self presenter presenter layout children second
]

{ #category : 'accessing' }
OGCInformationWindowPresenter class >> title [
^ 'Informations'
]
Loading

0 comments on commit 6df9036

Please sign in to comment.