Skip to content

Commit

Permalink
Writing examples to help fixing #23, not API problem but user problem :)
Browse files Browse the repository at this point in the history
  • Loading branch information
LabordePierre committed Aug 30, 2024
1 parent daf443b commit da26613
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
34 changes: 34 additions & 0 deletions GeoView-Examples-Bloc/GeoViewExamplesBloc.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,40 @@ GeoViewExamplesBloc class >> createGeoObjects [
^ list
]

{ #category : #examples }
GeoViewExamplesBloc class >> exampleWithGeoCircle [

| element circle |
element := BlGeoViewAeElement new.

"configure layers and process datas : objects that can be displayed and how"
element addLayer: (GeoViewUtils createGeoObjectsLayer: #layer1).

"create sample datas"
circle := GeoCircle new key: 1; radiusInMeters: 1000000; strokeStyle: (Color white asSmockStrokeStyle); absoluteCoordinates: AbsoluteCoordinates zero.
element addObject: circle.

^ self openViewInWindow: element
]

{ #category : #examples }
GeoViewExamplesBloc class >> exampleWithGeoLabeledCircle [

| element circle layer |
element := BlGeoViewAeElement new.

"configure layers and process datas : objects that can be displayed and how"
layer := GeoViewUtils createGeoObjectsLayer: #layer1.
layer setProcessData: GeoLabeledCircleProcessData new for: GeoCircle.
element addLayer: layer.

"create sample datas"
circle := GeoCircle new key: 1; radiusInMeters: 1000000; strokeStyle: (Color white asSmockStrokeStyle); absoluteCoordinates: AbsoluteCoordinates zero.
element addObject: circle.

^ self openViewInWindow: element
]

{ #category : #examples }
GeoViewExamplesBloc class >> exampleWithGeoObjects [
"This example use ready-to-use geo-object classes (GeoObject and processData) to represent a static (no updates) geographical view with a lot of data."
Expand Down
34 changes: 34 additions & 0 deletions GeoView-GeoObjects/GeoLabeledCircleProcessData.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Class {
#name : #GeoLabeledCircleProcessData,
#superclass : #GeoShapeLabeledProcessData,
#category : #'GeoView-GeoObjects-ProcessData'
}

{ #category : #processing }
GeoLabeledCircleProcessData >> processCreatedData: aKey incoming: aGeoCircle with: aDCompositeShape context: aContext [
| dLeafShape dCompositeShape |
dCompositeShape := super processCreatedData: aKey incoming: aGeoCircle with: aDCompositeShape context: aContext.

dLeafShape := SmockDCircle key: #geoShape.
dLeafShape radius: aGeoCircle radiusInMeters.
dLeafShape fillStyle: aGeoCircle fillStyle copy.
dLeafShape strokeStyle: aGeoCircle strokeStyle copy.

dCompositeShape addChild: dLeafShape.

^ dCompositeShape
]

{ #category : #processing }
GeoLabeledCircleProcessData >> processUpdatedData: aKey incoming: aGeoCircle with: aDCompositeShape context: aContext [
| dCompositeShape |
dCompositeShape := aDCompositeShape.
super processUpdatedData: aKey incoming: aGeoCircle with: aDCompositeShape context: aContext.

(dCompositeShape getChild: #geoShape) ifNotNil:[ :e |
e radius: aGeoCircle radiusInMeters.
dCompositeShape updateChild: e.
].

^dCompositeShape
]
36 changes: 36 additions & 0 deletions GeoView-GeoObjects/GeoShapeLabeledProcessData.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Class {
#name : #GeoShapeLabeledProcessData,
#superclass : #GeoObjectProcessData,
#category : #'GeoView-GeoObjects-ProcessData'
}

{ #category : #processing }
GeoShapeLabeledProcessData >> processCreatedData: aKey incoming: aGeoShape with: aDCompositeShape context: aContext [
| dCompositeShape dLabel |
dCompositeShape := aDCompositeShape ifNil:[SmockDCompositeShape new].
super processCreatedData: aKey incoming: aGeoShape with: dCompositeShape context: aContext.

"create a label"
dLabel := SmockDText key: #label.
dLabel fillColor: Color white.
dLabel smockFont: SmockFont defaultFont.
dLabel text: aGeoShape printString.
dLabel coordinatesDeviceOffset: -30 @ -30.
dCompositeShape addChild: dLabel.

^ dCompositeShape
]

{ #category : #processing }
GeoShapeLabeledProcessData >> processUpdatedData: aKey incoming: aGeoShape with: aDCompositeShape context: aContext [
| dCompositeShape |
dCompositeShape := aDCompositeShape.
super processUpdatedData: aKey incoming: aGeoShape with: dCompositeShape context: aContext.

(aDCompositeShape getChild: #geoShape) ifNotNil: [ :e |
e fillStyle: aGeoShape fillStyle copy.
e strokeStyle: aGeoShape strokeStyle copy.
].

^ dCompositeShape
]

0 comments on commit da26613

Please sign in to comment.