-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
92 changed files
with
8,515 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
'srcDirectory' : 'src' | ||
} |
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,3 @@ | ||
{ | ||
#format : #tonel | ||
} |
21 changes: 21 additions & 0 deletions
21
src/BaselineOfRoassalLayouts/BaselineOfRoassalLayouts.class.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,21 @@ | ||
" | ||
Based on roassal | ||
https://github.com/ObjectProfile/Roassal3 | ||
" | ||
Class { | ||
#name : #BaselineOfRoassalLayouts, | ||
#superclass : #BaselineOf, | ||
#category : #BaselineOfRoassalLayouts | ||
} | ||
|
||
{ #category : #baselines } | ||
BaselineOfRoassalLayouts >> baseline: spec [ | ||
<baseline> | ||
spec for: #common do: [ | ||
spec | ||
package: 'Roassal-Layouts'; | ||
package: 'Roassal-Layouts-Tests'; | ||
package: 'Roassal-Layouts-Util'. | ||
spec group: 'default' with: 'Roassal-Layouts' | ||
]. | ||
] |
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 @@ | ||
Package { #name : #BaselineOfRoassalLayouts } |
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,136 @@ | ||
Class { | ||
#name : #RSAlignmentTest, | ||
#superclass : #TestCase, | ||
#instVars : [ | ||
'align' | ||
], | ||
#category : #'Roassal-Layouts-Tests' | ||
} | ||
|
||
{ #category : #running } | ||
RSAlignmentTest >> setUp [ | ||
super setUp. | ||
align := RSAlignment new | ||
] | ||
|
||
{ #category : #tests } | ||
RSAlignmentTest >> testCenter [ | ||
| es | | ||
es := (1 to: 5) collect: [ :v | RSBox new size: 10 ] as: RSGroup. | ||
RSHorizontalLineLayout on: es. | ||
align shapes: es. | ||
self assert: align middle equals: align. | ||
self assert: es encompassingRectangle equals: ((0.0@0.0) corner: (70.0@10.0)) | ||
] | ||
|
||
{ #category : #tests } | ||
RSAlignmentTest >> testFromBottom [ | ||
| es | | ||
es := (10 to: 100 by: 10) collect: [ :n | RSBox new size: n; yourself ]. | ||
align shapes: es. | ||
RSHorizontalLineLayout on: es. | ||
es second translateBy: 0 @ 150. | ||
self assert: (es collect: [ :e | e encompassingRectangle bottom ]) asArray equals: #(10.0 170.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0). | ||
self assert: align bottomMostShape equals: es second. | ||
align bottom. | ||
self assert: (es collect: [ :e | e encompassingRectangle bottom ]) asArray equals: #(170.0 170.0 170.0 170.0 170.0 170.0 170.0 170.0 170.0 170.0) | ||
] | ||
|
||
{ #category : #tests } | ||
RSAlignmentTest >> testFromLeft [ | ||
| es | | ||
es := (10 to: 100 by: 10) collect: [ :n | RSBox new size: n; yourself ]. | ||
align shapes: es. | ||
RSVerticalLineLayout on: es. | ||
es second translateBy: -150 @ 0. | ||
self assert: (es collect: [ :e | e encompassingRectangle left ]) asArray equals: #(0.0 -150.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0). | ||
self assert: align leftMostShape equals: es second. | ||
align left. | ||
self assert: (es collect: [ :e | e encompassingRectangle left ]) asArray equals: #(-150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0) | ||
] | ||
|
||
{ #category : #tests } | ||
RSAlignmentTest >> testFromLeftWithAFixShape [ | ||
| es | | ||
es := (10 to: 100 by: 10) collect: [ :n | RSBox new size: n; yourself ]. | ||
align shapes: es. | ||
RSVerticalLineLayout on: es. | ||
es second translateBy: -150 @ 0. | ||
align fixedShape: es first. | ||
align left. | ||
self assert: (es collect: [ :e | e encompassingRectangle left ]) asArray equals: #(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0) | ||
] | ||
|
||
{ #category : #tests } | ||
RSAlignmentTest >> testFromLeftWithFixedShape [ | ||
| es c | | ||
es := (10 to: 100 by: 10) collect: [ :n | RSBox new size: n; yourself ]. | ||
align shapes: es. | ||
RSVerticalLineLayout on: es. | ||
es second translateBy: -150 @ 0. | ||
|
||
c := RSCanvas new. | ||
c addAll: es. | ||
es do: [ :s | s setAsFixed ]. | ||
|
||
self assert: (es collect: [ :e | e encompassingRectangle left ]) asArray equals: #(0.0 -150.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0). | ||
self assert: align leftMostShape equals: es second. | ||
align left. | ||
self assert: (es collect: [ :e | e encompassingRectangle left ]) asArray equals: #(-150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0) | ||
] | ||
|
||
{ #category : #tests } | ||
RSAlignmentTest >> testFromRight [ | ||
| es | | ||
es := (10 to: 100 by: 10) collect: [ :n | RSBox new size: n; yourself ]. | ||
align shapes: es. | ||
RSVerticalLineLayout on: es. | ||
es second translateBy: 150 @ 0. | ||
self assert: (es collect: [ :e | e encompassingRectangle right ]) asArray equals: #(10.0 170.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0). | ||
self assert: align rightMostShape equals: es second. | ||
align right. | ||
self assert: (es collect: [ :e | e encompassingRectangle right ]) asArray equals: #(170.0 170.0 170.0 170.0 170.0 170.0 170.0 170.0 170.0 170.0) | ||
] | ||
|
||
{ #category : #tests } | ||
RSAlignmentTest >> testFromTop [ | ||
| es | | ||
es := (10 to: 100 by: 10) collect: [ :n | RSBox new size: n; yourself ]. | ||
align shapes: es. | ||
RSHorizontalLineLayout on: es. | ||
es second translateBy: 0 @ -50. | ||
self assert: (es collect: [ :e | e encompassingRectangle top ]) asArray equals: #(0.0 -50.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0). | ||
self assert: align topMostShape equals: es second. | ||
align top. | ||
self assert: (es collect: [ :e | e encompassingRectangle top ]) asArray equals: #(-50.0 -50.0 -50.0 -50.0 -50.0 -50.0 -50.0 -50.0 -50.0 -50.0) | ||
] | ||
|
||
{ #category : #tests } | ||
RSAlignmentTest >> testFromTopWithAFixShape [ | ||
| es | | ||
es := (10 to: 100 by: 10) collect: [ :n | RSBox new size: n; yourself ]. | ||
align shapes: es. | ||
RSHorizontalLineLayout on: es. | ||
es second translateBy: 0 @ -50. | ||
align fixedShape: es third. | ||
|
||
self assert: (es collect: [ :e | e encompassingRectangle top ]) asArray equals: #(0.0 -50.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0). | ||
self assert: align topMostShape equals: es third. | ||
align top. | ||
self assert: (es collect: [ :e | e encompassingRectangle top ]) asArray equals: #(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0) | ||
] | ||
|
||
{ #category : #tests } | ||
RSAlignmentTest >> testHasElement [ | ||
self deny: align hasShape. | ||
align shapes: (Array with: RSBox new). | ||
self assert: align hasShape. | ||
align shapes: #(). | ||
self deny: align hasShape | ||
] | ||
|
||
{ #category : #tests } | ||
RSAlignmentTest >> testNoErrorOnDefault [ | ||
|
||
RSAlignment new left; right; top; bottom | ||
] |
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,68 @@ | ||
Class { | ||
#name : #RSAngleLineLayoutTest, | ||
#superclass : #RSLayoutTest, | ||
#category : #'Roassal-Layouts-Tests' | ||
} | ||
|
||
{ #category : #tests } | ||
RSAngleLineLayoutTest >> testBasic [ | ||
|
||
| layout angle | | ||
layout := RSAngleLineLayout new. | ||
self assert: layout angle equals: layout defaultAngle. | ||
angle := 45 degreesToRadians. | ||
layout angle: angle. | ||
self assert: layout angle equals: angle | ||
] | ||
|
||
{ #category : #tests } | ||
RSAngleLineLayoutTest >> testGapSize [ | ||
|
||
| layout var1st var2nd | | ||
layout := RSAngleLineLayout new gapSize: 100. | ||
layout on: shapes. | ||
var1st := shapes first. | ||
var2nd := shapes second. | ||
self assert: var1st position closeTo: 2.5 @ 2.5. | ||
self assert: var2nd position closeTo: 107.5 @ 2.5 | ||
] | ||
|
||
{ #category : #tests } | ||
RSAngleLineLayoutTest >> testLayoutWith0Angle [ | ||
|
||
| layout x gap | | ||
layout := RSAngleLineLayout new angle: 0. | ||
gap := layout gapSize. | ||
layout on: shapes. | ||
x := 2.5. | ||
shapes do: [ :each | | ||
self assert: each position closeTo: x @ 2.5. | ||
x := x + each width + gap ] | ||
] | ||
|
||
{ #category : #tests } | ||
RSAngleLineLayoutTest >> testLayoutWith90Angle [ | ||
|
||
| layout y gap | | ||
layout := RSAngleLineLayout new. | ||
layout angleByDegrees: 90. | ||
gap := layout gapSize. | ||
layout on: shapes. | ||
y := 2.5. | ||
shapes do: [ :each | | ||
self assert: each position closeTo: 2.5 @ y. | ||
y := y + each height + gap ] | ||
] | ||
|
||
{ #category : #tests } | ||
RSAngleLineLayoutTest >> testLayoutWithThreeElements [ | ||
| layout gap extent | | ||
layout := RSAngleLineLayout new. | ||
gap := layout gapSize. | ||
shapes := shapes first: 3. | ||
extent := shapes first extent. | ||
layout on: shapes. | ||
self assert: shapes first position equals: extent * (0.5@ 0.5). | ||
self assert: shapes second position equals: extent * (1.5 @ 0.5) + (gap@0). | ||
self assert: shapes third position equals: extent * (2.5 @ 0.5) + (gap*2@0). | ||
] |
39 changes: 39 additions & 0 deletions
39
src/Roassal-Layouts-Tests/RSCircularAroundAVertexLayoutTest.class.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,39 @@ | ||
" | ||
A RSCircularAroundAVertexLayoutTest is a test class for testing the behavior of RSCircularAroundAVertexLayout | ||
" | ||
Class { | ||
#name : #RSCircularAroundAVertexLayoutTest, | ||
#superclass : #RSLayoutTest, | ||
#category : #'Roassal-Layouts-Tests' | ||
} | ||
|
||
{ #category : #tests } | ||
RSCircularAroundAVertexLayoutTest >> testApplyDefaultLayoutOverlapsShapes [ | ||
| layout first second | | ||
layout := RSCircularAroundAVertexLayout new. | ||
layout on: canvas nodes. | ||
first := canvas nodes first. | ||
second := canvas nodes second. | ||
self deny: (first encompassingRectangle intersects: second encompassingRectangle). | ||
self deny: first position equals: second position. | ||
] | ||
|
||
{ #category : #tests } | ||
RSCircularAroundAVertexLayoutTest >> testApplyLayoutShouldChangeOldPositions [ | ||
| layout oldPositions | | ||
layout := RSCircularAroundAVertexLayout new. | ||
oldPositions := canvas nodes collect: #position. | ||
layout on: canvas nodes. | ||
self deny: (canvas nodes collect: #position) equals: oldPositions | ||
] | ||
|
||
{ #category : #tests } | ||
RSCircularAroundAVertexLayoutTest >> testRadius [ | ||
| layout boundingBox | | ||
layout := RSCircularAroundAVertexLayout new. | ||
layout radius: 1000. | ||
layout on: canvas nodes. | ||
|
||
boundingBox := canvas encompassingRectangle. | ||
self assert: boundingBox width > 100 | ||
] |
Oops, something went wrong.