diff --git a/src/BaselineOfMoleculeGeographicalPositionExample/BaselineOfMoleculeGeographicalPositionExample.class.st b/src/BaselineOfMoleculeGeographicalPositionExample/BaselineOfMoleculeGeographicalPositionExample.class.st index 0b42963..99e0d9b 100644 --- a/src/BaselineOfMoleculeGeographicalPositionExample/BaselineOfMoleculeGeographicalPositionExample.class.st +++ b/src/BaselineOfMoleculeGeographicalPositionExample/BaselineOfMoleculeGeographicalPositionExample.class.st @@ -46,13 +46,7 @@ BaselineOfMoleculeGeographicalPositionExample >> loadPyramid: spec [ { #category : #'load scripts' } BaselineOfMoleculeGeographicalPositionExample >> postload: loader package: packageSpec [ - | molGeoDownloadedRessource molGeoPosHelper | - "Download ressources." - molGeoDownloadedRessource := #MolGeoDownloadedRessource - asClassInEnvironment: - self class environment. - molGeoDownloadedRessource ensureAllDownloaded. - + | molGeoPosHelper | "Open helper." molGeoPosHelper := #MolGeoPosHelper asClassInEnvironment: self class environment. diff --git a/src/Molecule-Geographical-Position-Example/MolGeoDownloadedRessource.class.st b/src/Molecule-Geographical-Position-Example/MolGeoDownloadedRessource.class.st deleted file mode 100644 index 73f625c..0000000 --- a/src/Molecule-Geographical-Position-Example/MolGeoDownloadedRessource.class.st +++ /dev/null @@ -1,96 +0,0 @@ -Class { - #name : #MolGeoDownloadedRessource, - #superclass : #Object, - #category : #'Molecule-Geographical-Position-Example-downloader' -} - -{ #category : #converting } -MolGeoDownloadedRessource class >> asForm [ - - ^ (Form fromFileNamed: self new fileReference) mapColor: Color white to: Color transparent -] - -{ #category : #converting } -MolGeoDownloadedRessource class >> asForm: anExtent [ - - ^ self asForm - scaledToSize: anExtent -] - -{ #category : #'as yet unclassified' } -MolGeoDownloadedRessource class >> ensureAllDownloaded [ - - - self allSubclassesDo: [ :each | - each new - ensureDownloaded ] -] - -{ #category : #'as yet unclassified' } -MolGeoDownloadedRessource class >> forceAllDownloaded [ - - - self allSubclassesDo: [ :each | | downloader | - downloader := each new. - DiskStore current delete: downloader fileReference asPath. - downloader - download ] -] - -{ #category : #'as yet unclassified' } -MolGeoDownloadedRessource class >> ressourcesDirectory [ - | reference | - reference := FileLocator imageDirectory asFileReference / 'ressources'. - (reference exists and: [ reference isDirectory ]) ifTrue: [ ^ reference ]. - (reference exists and: [ reference isDirectory not ]) ifTrue: [ Error signal: 'ressources directory is not a directory.' ]. - DiskStore current createDirectory: reference asPath. - ^ reference -] - -{ #category : #testing } -MolGeoDownloadedRessource >> baseUrl [ - - ^ 'https://github.com/OpenSmock/Molecule-Geographical-Position-Example/raw/main/ressources/' -] - -{ #category : #testing } -MolGeoDownloadedRessource >> download [ - - ('Downloading {1}...' format: { self fileName }) traceCr. - - [ - ZnClient new - url: self baseUrl , self fileName; - numberOfRetries: 5; - timeout: 100; - logToTranscript; - downloadTo: self class ressourcesDirectory ensureCreateDirectory; - yourself. - - ' -Download finished - ' trace ] timeToRun traceCr -] - -{ #category : #testing } -MolGeoDownloadedRessource >> ensureDownloaded [ - - self isDownloaded ifFalse: [ self download ] -] - -{ #category : #testing } -MolGeoDownloadedRessource >> fileName [ - - ^ self subclassResponsibility -] - -{ #category : #testing } -MolGeoDownloadedRessource >> fileReference [ - - ^ self class ressourcesDirectory / self fileName -] - -{ #category : #testing } -MolGeoDownloadedRessource >> isDownloaded [ - - ^ self fileReference exists -] diff --git a/src/Molecule-Geographical-Position-Example/MolGeoGPSDownloaded.class.st b/src/Molecule-Geographical-Position-Example/MolGeoGPSDownloaded.class.st deleted file mode 100644 index b8922fc..0000000 --- a/src/Molecule-Geographical-Position-Example/MolGeoGPSDownloaded.class.st +++ /dev/null @@ -1,11 +0,0 @@ -Class { - #name : #MolGeoGPSDownloaded, - #superclass : #MolGeoDownloadedRessource, - #category : #'Molecule-Geographical-Position-Example-downloader' -} - -{ #category : #testing } -MolGeoGPSDownloaded >> fileName [ - - ^ 'link.png' -] diff --git a/src/Molecule-Geographical-Position-Example/MolGeoGPSInaccurateDownloaded.class.st b/src/Molecule-Geographical-Position-Example/MolGeoGPSInaccurateDownloaded.class.st deleted file mode 100644 index 567e978..0000000 --- a/src/Molecule-Geographical-Position-Example/MolGeoGPSInaccurateDownloaded.class.st +++ /dev/null @@ -1,11 +0,0 @@ -Class { - #name : #MolGeoGPSInaccurateDownloaded, - #superclass : #MolGeoDownloadedRessource, - #category : #'Molecule-Geographical-Position-Example-downloader' -} - -{ #category : #testing } -MolGeoGPSInaccurateDownloaded >> fileName [ - - ^ 'chains.png' -] diff --git a/src/Molecule-Geographical-Position-Example/MolGeoGSMDownloaded.class.st b/src/Molecule-Geographical-Position-Example/MolGeoGSMDownloaded.class.st deleted file mode 100644 index 14b04a8..0000000 --- a/src/Molecule-Geographical-Position-Example/MolGeoGSMDownloaded.class.st +++ /dev/null @@ -1,11 +0,0 @@ -Class { - #name : #MolGeoGSMDownloaded, - #superclass : #MolGeoDownloadedRessource, - #category : #'Molecule-Geographical-Position-Example-downloader' -} - -{ #category : #testing } -MolGeoGSMDownloaded >> fileName [ - - ^ 'antenna.png' -] diff --git a/src/Molecule-Geographical-Position-Example/MolGeoGalileoDownloaded.class.st b/src/Molecule-Geographical-Position-Example/MolGeoGalileoDownloaded.class.st deleted file mode 100644 index 4b3d324..0000000 --- a/src/Molecule-Geographical-Position-Example/MolGeoGalileoDownloaded.class.st +++ /dev/null @@ -1,11 +0,0 @@ -Class { - #name : #MolGeoGalileoDownloaded, - #superclass : #MolGeoDownloadedRessource, - #category : #'Molecule-Geographical-Position-Example-downloader' -} - -{ #category : #testing } -MolGeoGalileoDownloaded >> fileName [ - - ^ 'favorite.png' -] diff --git a/src/Molecule-Geographical-Position-Example/MolGeoMapDownloaded.class.st b/src/Molecule-Geographical-Position-Example/MolGeoMapDownloaded.class.st deleted file mode 100644 index be32c28..0000000 --- a/src/Molecule-Geographical-Position-Example/MolGeoMapDownloaded.class.st +++ /dev/null @@ -1,11 +0,0 @@ -Class { - #name : #MolGeoMapDownloaded, - #superclass : #MolGeoDownloadedRessource, - #category : #'Molecule-Geographical-Position-Example-downloader' -} - -{ #category : #testing } -MolGeoMapDownloaded >> fileName [ - - ^ 'map.png' -] diff --git a/src/Molecule-Geographical-Position-Example/MolGeoPosApplication.class.st b/src/Molecule-Geographical-Position-Example/MolGeoPosApplication.class.st index 24ba838..5a79e85 100644 --- a/src/Molecule-Geographical-Position-Example/MolGeoPosApplication.class.st +++ b/src/Molecule-Geographical-Position-Example/MolGeoPosApplication.class.st @@ -71,7 +71,7 @@ MolGeoPosApplication >> makeGPSButton [ ^ MolGeoSwitchElement new label: 'GPS'; - icon: (MolGeoGPSDownloaded asForm: self iconSize); + icon: (MolGeoRessource gps asForm: self iconSize); whenActivatedDo: [ self stopGeoPosEquipement. MolGNSSGPS start ]; @@ -83,8 +83,10 @@ MolGeoPosApplication >> makeGPSInaccurateButton [ ^ MolGeoSwitchElement new label: 'GPSInaccurate'; - icon: (MolGeoGPSInaccurateDownloaded asForm: self iconSize); - whenActivatedDo: [ self stopGeoPosEquipement.MolGNSSGPSInaccurate start ]; + icon: (MolGeoRessource gpsInacurrate asForm: self iconSize); + whenActivatedDo: [ + self stopGeoPosEquipement. + MolGNSSGPSInaccurate start ]; yourself ] @@ -93,7 +95,7 @@ MolGeoPosApplication >> makeGSMButton [ ^ MolGeoSwitchElement new label: 'GSM'; - icon: (MolGeoGSMDownloaded asForm: self iconSize); + icon: (MolGeoRessource gsm asForm: self iconSize); whenActivatedDo: [ self stopGeoPosEquipement. MolGSM start ]; @@ -105,8 +107,10 @@ MolGeoPosApplication >> makeGalileoButton [ ^ MolGeoSwitchElement new label: 'Galileo'; - icon: (MolGeoGalileoDownloaded asForm: self iconSize); - whenActivatedDo: [ self stopGeoPosEquipement. MolGNSSGalileo start ]; + icon: (MolGeoRessource galileo asForm: self iconSize); + whenActivatedDo: [ + self stopGeoPosEquipement. + MolGNSSGalileo start ]; yourself ] @@ -115,15 +119,17 @@ MolGeoPosApplication >> makeWiFiButton [ ^ MolGeoSwitchElement new label: 'WiFi'; - icon: (MolGeoWiFiDownloaded asForm: self iconSize); - whenActivatedDo: [ self stopGeoPosEquipement. MolWiFi start ]; + icon: (MolGeoRessource wiFi asForm: self iconSize); + whenActivatedDo: [ + self stopGeoPosEquipement. + MolWiFi start ]; yourself ] { #category : #'as yet unclassified' } MolGeoPosApplication >> mapForm [ - ^ (MolGeoMapDownloaded asForm: self maximumMapSize) + ^ MolGeoRessource map asForm: self maximumMapSize ] { #category : #'as yet unclassified' } diff --git a/src/Molecule-Geographical-Position-Example/MolGeoPosHelper.class.st b/src/Molecule-Geographical-Position-Example/MolGeoPosHelper.class.st index ab192f6..bf5cff9 100644 --- a/src/Molecule-Geographical-Position-Example/MolGeoPosHelper.class.st +++ b/src/Molecule-Geographical-Position-Example/MolGeoPosHelper.class.st @@ -10,7 +10,7 @@ MolGeoPosHelper >> openTheExample [ ^ Lesson title: 'Molecule Geographical Position - help' lesson: - '"To launch the applicaiton you can copy/paste the following line in a playground and clic on ." + '"To launch the application you can copy/paste the following line in a playground and clic on ." MolGeoPosApplication open. "You can also select the previous line with your mouse and press (ctrl + D or cmd + D) to reopen it at any moment." diff --git a/src/Molecule-Geographical-Position-Example/MolGeoRessource.class.st b/src/Molecule-Geographical-Position-Example/MolGeoRessource.class.st new file mode 100644 index 0000000..f83dc67 --- /dev/null +++ b/src/Molecule-Geographical-Position-Example/MolGeoRessource.class.st @@ -0,0 +1,125 @@ +Class { + #name : #MolGeoRessource, + #superclass : #Object, + #instVars : [ + 'fileName' + ], + #category : #'Molecule-Geographical-Position-Example-ressources' +} + +{ #category : #'as yet unclassified' } +MolGeoRessource class >> galileo [ + + ^ self new + fileName: 'favorite.png'; + yourself +] + +{ #category : #'as yet unclassified' } +MolGeoRessource class >> gps [ + + ^ self new + fileName: 'link.png'; + yourself +] + +{ #category : #'as yet unclassified' } +MolGeoRessource class >> gpsInacurrate [ + + ^ self new + fileName: 'chains.png'; + yourself +] + +{ #category : #'as yet unclassified' } +MolGeoRessource class >> gsm [ + + ^ self new + fileName: 'antenna.png'; + yourself +] + +{ #category : #'as yet unclassified' } +MolGeoRessource class >> map [ + + ^ self new + fileName: 'map.png'; + yourself +] + +{ #category : #'as yet unclassified' } +MolGeoRessource class >> wiFi [ + + ^ self new + fileName: 'wifi.png'; + yourself +] + +{ #category : #converting } +MolGeoRessource >> asForm [ + + ^ (Form fromFileNamed: self fileReference) + mapColor: Color white + to: Color transparent +] + +{ #category : #converting } +MolGeoRessource >> asForm: anExtent [ + + ^ self asForm scaledToSize: anExtent +] + +{ #category : #default } +MolGeoRessource >> baseIcebergDirectory [ + + | expectedName myRepository | + expectedName := 'molecule-geographical-position-example'. + +myRepository := IceRepository registry + detect: [ :each | + each name asLowercase = expectedName ] + ifNone: [ + self error: + ('Did not find any repository named ''{1}'' in Iceberg (case insensitive). Alexandrie tests require it to access resources.' + format: { expectedName }) ]. + +^ myRepository location +] + +{ #category : #default } +MolGeoRessource >> baseRessourceDirectory [ + + ^ self baseIcebergDirectory / 'ressources' +] + +{ #category : #accessing } +MolGeoRessource >> fileName [ + + ^ fileName +] + +{ #category : #accessing } +MolGeoRessource >> fileName: aString [ + + fileName := aString +] + +{ #category : #accessing } +MolGeoRessource >> fileReference [ + + ^ self baseRessourceDirectory / self fileName +] + +{ #category : #initialization } +MolGeoRessource >> initialize [ + + super initialize. + + fileName := 'doesnotexist.png' +] + +{ #category : #testing } +MolGeoRessource >> isDownloaded [ + + ^ self fileReference exists +] diff --git a/src/Molecule-Geographical-Position-Example/MolGeoWiFiDownloaded.class.st b/src/Molecule-Geographical-Position-Example/MolGeoWiFiDownloaded.class.st deleted file mode 100644 index db3fdc7..0000000 --- a/src/Molecule-Geographical-Position-Example/MolGeoWiFiDownloaded.class.st +++ /dev/null @@ -1,11 +0,0 @@ -Class { - #name : #MolGeoWiFiDownloaded, - #superclass : #MolGeoDownloadedRessource, - #category : #'Molecule-Geographical-Position-Example-downloader' -} - -{ #category : #testing } -MolGeoWiFiDownloaded >> fileName [ - - ^ 'wifi.png' -]