-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from hpi-swa-teaching/save_json
Save json
- Loading branch information
Showing
40 changed files
with
437 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
OrderedDictionary { | ||
'packages\/BaselineOfAnimationsEditor.package' : #SquotCypressCodeSerializer, | ||
'packages\/AnimationsEditor-Tests.package' : #SquotCypressCodeSerializer, | ||
'packages\/AnimationsEditor-Core.package' : #SquotCypressCodeSerializer | ||
'packages/BaselineOfAnimationsEditor.package' : #SquotCypressCodeSerializer, | ||
'packages/AnimationsEditor-Tests.package' : #SquotCypressCodeSerializer, | ||
'packages/AnimationsEditor-Core.package' : #SquotCypressCodeSerializer | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/AnimationsEditor-Core.package/AnimationsEditor.class/instance/addColorFrame..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
saveJson | ||
addColorFrame: aTreeNode | ||
| jsonFrame | | ||
|
||
jsonFrame := Dictionary | ||
with: #frame -> aTreeNode targetDuration | ||
with: #properties -> { | ||
Dictionary | ||
with: #name -> aTreeNode title asLowercase | ||
with: #value -> aTreeNode targetColor rgbTriplet. | ||
}. | ||
|
||
^ jsonFrame. | ||
|
||
|
7 changes: 7 additions & 0 deletions
7
packages/AnimationsEditor-Core.package/AnimationsEditor.class/instance/addFrame..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
saveJson | ||
addFrame: aTreeNode | ||
|
||
^ { #Position -> [self addPositionFrame: aTreeNode]. | ||
#Color -> [self addColorFrame: aTreeNode]. | ||
#Rotation -> [self addRotationFrame: aTreeNode]. | ||
#Size -> [self addSizeFrame: aTreeNode]. } as: IdentityDictionary. |
11 changes: 11 additions & 0 deletions
11
...ges/AnimationsEditor-Core.package/AnimationsEditor.class/instance/addMorphToJson.with..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
saveJson | ||
addMorphToJson: aJsonStructure with: aTreeNode | ||
| frame MorphJson originMorph | | ||
|
||
originMorph := aTreeNode copyOfTargetMorph. | ||
MorphJson := self createStartInformation: originMorph. | ||
frame := ((self addFrame: aTreeNode) at: aTreeNode title asSymbol) value. | ||
MorphJson add: #frames -> {frame}. | ||
aJsonStructure add: #morphs -> {MorphJson}. | ||
|
||
^ aJsonStructure. |
18 changes: 18 additions & 0 deletions
18
packages/AnimationsEditor-Core.package/AnimationsEditor.class/instance/addPositionFrame..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
saveJson | ||
addPositionFrame: aTreeNode | ||
| jsonFrame | | ||
|
||
jsonFrame := Dictionary | ||
with: #frame -> aTreeNode targetDuration | ||
with: #properties -> { | ||
Dictionary | ||
with: #name -> (aTreeNode title asLowercase , 'X') | ||
with: #value -> aTreeNode targetPosition x. | ||
Dictionary | ||
with: #name -> (aTreeNode title asLowercase, 'Y') | ||
with: #value -> aTreeNode targetPosition y. | ||
}. | ||
|
||
^ jsonFrame. | ||
|
||
|
13 changes: 13 additions & 0 deletions
13
packages/AnimationsEditor-Core.package/AnimationsEditor.class/instance/addRotationFrame..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
saveJson | ||
addRotationFrame: aTreeNode | ||
| jsonFrame | | ||
|
||
jsonFrame := Dictionary | ||
with: #frame -> aTreeNode targetDuration | ||
with: #properties -> { | ||
Dictionary | ||
with: #name -> aTreeNode title asLowercase | ||
with: #value -> aTreeNode targetRotation. | ||
}. | ||
|
||
^ jsonFrame. |
16 changes: 16 additions & 0 deletions
16
packages/AnimationsEditor-Core.package/AnimationsEditor.class/instance/addSizeFrame..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
saveJson | ||
addSizeFrame: aTreeNode | ||
| jsonFrame | | ||
|
||
jsonFrame := Dictionary | ||
with: #frame -> aTreeNode targetDuration | ||
with: #properties -> { | ||
Dictionary | ||
with: #name -> 'width' | ||
with: #value -> aTreeNode targetSize x. | ||
Dictionary | ||
with: #name -> 'height' | ||
with: #value -> aTreeNode targetSize y. | ||
}. | ||
|
||
^ jsonFrame. |
25 changes: 25 additions & 0 deletions
25
.../AnimationsEditor-Core.package/AnimationsEditor.class/instance/createStartInformation..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
saveJson | ||
createStartInformation: aMorph | ||
|
||
^ Dictionary | ||
with: #type -> aMorph class asString | ||
with: #properties -> { | ||
Dictionary | ||
with: #name -> 'rotation' | ||
with: #value -> aMorph rotationDegrees. | ||
Dictionary | ||
with: #name -> 'positionX' | ||
with: #value -> aMorph x. | ||
Dictionary | ||
with: #name -> 'positionY' | ||
with: #value -> aMorph y. | ||
Dictionary | ||
with: #name -> 'width' | ||
with: #value -> aMorph width. | ||
Dictionary | ||
with: #name -> 'height' | ||
with: #value -> aMorph height. | ||
Dictionary | ||
with: #name -> 'color' | ||
with: #value -> aMorph color rgbTriplet. | ||
}. |
10 changes: 10 additions & 0 deletions
10
...es/AnimationsEditor-Core.package/AnimationsEditor.class/instance/createStructure.with..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
saveJson | ||
createStructure: aStartTime with: anEndTime | ||
| jsonStructure | | ||
|
||
jsonStructure := Dictionary | ||
with: #start -> aStartTime | ||
with: #end -> anEndTime | ||
with: #morphs -> {}. | ||
|
||
^ jsonStructure. |
8 changes: 8 additions & 0 deletions
8
packages/AnimationsEditor-Core.package/AnimationsEditor.class/instance/dictionaryToJson..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
saveJson | ||
dictionaryToJson: aDictionary | ||
^ String streamContents: [ :stream | | ||
(STON writer on: stream) | ||
prettyPrint: true; | ||
jsonMode: true; | ||
referencePolicy: #error; | ||
nextPut: aDictionary ]. |
5 changes: 5 additions & 0 deletions
5
...ages/AnimationsEditor-Core.package/AnimationsEditor.class/instance/outputFileDirectory.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
saveJson | ||
outputFileDirectory | ||
^ UIManager default saveFilenameRequest: 'Please, enter file name.' initialAnswer: 'animation'. | ||
|
||
|
3 changes: 2 additions & 1 deletion
3
packages/AnimationsEditor-Core.package/AnimationsEditor.class/instance/saveAnimations.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
eventHandling | ||
saveAnimations | ||
self updateInformationText: 'Copied animation code to clipboard!'. | ||
Clipboard clipboardText: self selectedTreeNode animationString. | ||
Clipboard clipboardText: self selectedTreeNode animationString. | ||
self saveToJson: self selectedTreeNode. |
9 changes: 9 additions & 0 deletions
9
packages/AnimationsEditor-Core.package/AnimationsEditor.class/instance/saveToJson..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
saveJson | ||
saveToJson: aTreeNode | ||
| jsonStructure jsonString | | ||
|
||
jsonStructure := self createStructure: self propertyStartEnd startTime with: self propertyStartEnd endTime. | ||
jsonStructure := self addMorphToJson: jsonStructure with: aTreeNode. | ||
jsonString := self dictionaryToJson: jsonStructure. | ||
self writeJsonToFile: jsonString with: self outputFileDirectory. | ||
|
7 changes: 7 additions & 0 deletions
7
...es/AnimationsEditor-Core.package/AnimationsEditor.class/instance/writeJsonToFile.with..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
saveJson | ||
writeJsonToFile: aJsonString with: aDirectory | ||
aDirectory | ||
ifNotNil: [ | ||
FileDirectory default forceNewFileNamed: aDirectory, '.json' do: [:stream | | ||
stream nextPutAll: aJsonString]. | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...ionsEditor-Tests.package/AnimationsEditorTest.class/instance/animationsEditorInstance..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
accessing | ||
animationsEditorInstance: anObject | ||
|
||
animationsEditorInstance := anObject. |
4 changes: 4 additions & 0 deletions
4
...tionsEditor-Tests.package/AnimationsEditorTest.class/instance/animationsEditorInstance.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
accessing | ||
animationsEditorInstance | ||
|
||
^ animationsEditorInstance |
10 changes: 10 additions & 0 deletions
10
...nimationsEditor-Tests.package/AnimationsEditorTest.class/instance/colorFrameDictionary.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
saveJson | ||
colorFrameDictionary | ||
|
||
^ Dictionary | ||
with: #frame->500 | ||
with: #properties->{ | ||
Dictionary | ||
with: #name->'color' | ||
with: #value-> #(1.0 0.0 0.0). | ||
}. |
15 changes: 15 additions & 0 deletions
15
packages/AnimationsEditor-Tests.package/AnimationsEditorTest.class/instance/colorTreeNode.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
saveJson | ||
colorTreeNode | ||
| aTreeNode animationsEditorProperty | | ||
|
||
animationsEditorProperty := self animationsEditorInstance propertyList at: 2. | ||
aTreeNode := AnimationsEditorPropertyColor new. | ||
aTreeNode | ||
copyOfTargetMorph: animationsEditorProperty targetMorph; | ||
targetMorph: aTreeNode copyOfTargetMorph copy. | ||
aTreeNode targetMorph color: Color red. | ||
aTreeNode | ||
targetDuration: animationsEditorProperty defaultTargetDuration; | ||
targetColor: 'red'. | ||
|
||
^ aTreeNode. |
12 changes: 12 additions & 0 deletions
12
...ationsEditor-Tests.package/AnimationsEditorTest.class/instance/positionFrameDictionary.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
saveJson | ||
positionFrameDictionary | ||
^ Dictionary | ||
with: #frame -> 500 | ||
with: #properties -> { | ||
Dictionary | ||
with: #name -> 'positionX' | ||
with: #value -> 100. | ||
Dictionary | ||
with: #name -> 'positionY' | ||
with: #value -> 200. | ||
}. |
16 changes: 16 additions & 0 deletions
16
...es/AnimationsEditor-Tests.package/AnimationsEditorTest.class/instance/positionTreeNode.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
saveJson | ||
positionTreeNode | ||
| aTreeNode animationsEditorProperty | | ||
|
||
animationsEditorProperty := self animationsEditorInstance propertyList at: 2. | ||
aTreeNode := AnimationsEditorPropertyPosition new. | ||
aTreeNode | ||
copyOfTargetMorph: animationsEditorProperty targetMorph; | ||
targetMorph: aTreeNode copyOfTargetMorph copy. | ||
aTreeNode targetMorph position: 100 @ 200. | ||
aTreeNode | ||
targetDuration: animationsEditorProperty defaultTargetDuration; | ||
targetPosition: 100 @ 200. | ||
|
||
^ aTreeNode. | ||
|
9 changes: 9 additions & 0 deletions
9
...ationsEditor-Tests.package/AnimationsEditorTest.class/instance/rotationFrameDictionary.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
saveJson | ||
rotationFrameDictionary | ||
^ Dictionary | ||
with: #frame -> 500 | ||
with: #properties -> { | ||
Dictionary | ||
with: #name -> 'rotation' | ||
with: #value -> 70. | ||
}. |
15 changes: 15 additions & 0 deletions
15
...es/AnimationsEditor-Tests.package/AnimationsEditorTest.class/instance/rotationTreeNode.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
saveJson | ||
rotationTreeNode | ||
| aTreeNode animationsEditorProperty | | ||
|
||
animationsEditorProperty := self animationsEditorInstance propertyList at: 2. | ||
aTreeNode := AnimationsEditorPropertyRotation new. | ||
aTreeNode | ||
copyOfTargetMorph: animationsEditorProperty targetMorph; | ||
targetMorph: aTreeNode copyOfTargetMorph copy. | ||
aTreeNode targetMorph rotationDegrees: 70. | ||
aTreeNode | ||
targetDuration: animationsEditorProperty defaultTargetDuration; | ||
targetRotation: 70. | ||
|
||
^ aTreeNode. |
11 changes: 11 additions & 0 deletions
11
packages/AnimationsEditor-Tests.package/AnimationsEditorTest.class/instance/setUp.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
saveJson | ||
setUp | ||
| morph | | ||
|
||
super setUp. | ||
self animationsEditorInstance: AnimationsEditor open. | ||
morph := Morph new. | ||
morph openInWorld. | ||
animationsEditorInstance addTargetMorph: morph. | ||
|
||
|
12 changes: 12 additions & 0 deletions
12
...AnimationsEditor-Tests.package/AnimationsEditorTest.class/instance/sizeFrameDictionary.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
saveJson | ||
sizeFrameDictionary | ||
^ Dictionary | ||
with: #frame -> 500 | ||
with: #properties -> { | ||
Dictionary | ||
with: #name -> 'width' | ||
with: #value -> 100. | ||
Dictionary | ||
with: #name -> 'height' | ||
with: #value -> 200. | ||
}. |
15 changes: 15 additions & 0 deletions
15
packages/AnimationsEditor-Tests.package/AnimationsEditorTest.class/instance/sizeTreeNode.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
saveJson | ||
sizeTreeNode | ||
| aTreeNode animationsEditorProperty | | ||
|
||
animationsEditorProperty := self animationsEditorInstance propertyList at: 2. | ||
aTreeNode := AnimationsEditorPropertySize new. | ||
aTreeNode | ||
copyOfTargetMorph: animationsEditorProperty targetMorph; | ||
targetMorph: aTreeNode copyOfTargetMorph copy. | ||
aTreeNode targetMorph extent: 100 @ 200. | ||
aTreeNode | ||
targetDuration: animationsEditorProperty defaultTargetDuration; | ||
targetSize: 100 @ 200. | ||
|
||
^ aTreeNode. |
Oops, something went wrong.