-
Notifications
You must be signed in to change notification settings - Fork 3
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
9 changed files
with
375 additions
and
44 deletions.
There are no files selected for viewing
131 changes: 131 additions & 0 deletions
131
packages/Sandblocks-Babylonian/SBCorrelationCluster.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,131 @@ | ||
Class { | ||
#name : #SBCorrelationCluster, | ||
#superclass : #SBCluster, | ||
#instVars : [ | ||
'multiverse', | ||
'displayedExample', | ||
'displayedWatch', | ||
'opponentPermutations', | ||
'basePermutation' | ||
], | ||
#category : #'Sandblocks-Babylonian' | ||
} | ||
|
||
{ #category : #'instance creation' } | ||
SBCorrelationCluster class >> newForSize: aSBMorphResizer multiverse: aMultiverse example: anExample watch: aWatch basePermutation: base opponentPermutations: opponent [ | ||
|
||
^ self new | ||
morphResizer: aSBMorphResizer; | ||
multiverse: aMultiverse; | ||
displayedExample: anExample; | ||
displayedWatch: aWatch; | ||
basePermutation: base; | ||
opponentPermutations: opponent; | ||
visualize; | ||
yourself | ||
] | ||
|
||
{ #category : #accessing } | ||
SBCorrelationCluster >> basePermutation [ | ||
|
||
^ basePermutation | ||
] | ||
|
||
{ #category : #accessing } | ||
SBCorrelationCluster >> basePermutation: aSBPermutation [ | ||
|
||
basePermutation := aSBPermutation | ||
] | ||
|
||
{ #category : #building } | ||
SBCorrelationCluster >> buildDisplayMatrix [ | ||
|
||
| matrix | | ||
|
||
matrix := Matrix | ||
rows: 2 | ||
columns: self opponentPermutations size + 1. | ||
|
||
matrix atRow: 1 put: ({TextMorph new contents: self basePermutation asVariantString}, | ||
(self extractedTopHeadingsFrom: self opponentPermutations)). | ||
|
||
matrix at: 2 at: 1 put: (SBPermutationLabel newDisplaying: self basePermutation). | ||
|
||
self extractRow withIndexDo: [:aCellMorph :column | matrix at: 2 at: column+1 put: aCellMorph]. | ||
|
||
^ matrix | ||
] | ||
|
||
{ #category : #accessing } | ||
SBCorrelationCluster >> displayedExample [ | ||
|
||
^ displayedExample | ||
] | ||
|
||
{ #category : #accessing } | ||
SBCorrelationCluster >> displayedExample: aSBExample [ | ||
|
||
displayedExample := aSBExample | ||
] | ||
|
||
{ #category : #accessing } | ||
SBCorrelationCluster >> displayedWatch [ | ||
|
||
^ displayedWatch | ||
] | ||
|
||
{ #category : #accessing } | ||
SBCorrelationCluster >> displayedWatch: anSBExampleWatch [ | ||
|
||
displayedWatch := anSBExampleWatch | ||
] | ||
|
||
{ #category : #building } | ||
SBCorrelationCluster >> extractRow [ | ||
|
||
^ self multiverse universes | ||
select: [:aUniverse | (aUniverse activePermutation contains: self basePermutation)] | ||
thenCollect: [:aUniverse | | display | | ||
display := ((aUniverse watches detect: [:aWatch | aWatch originalIdentifier = self displayedWatch identifier]) | ||
exampleToDisplay at: self displayedExample) value display. | ||
self compressedMorphsForDisplay: display] | ||
] | ||
|
||
{ #category : #building } | ||
SBCorrelationCluster >> extractedLeftHeadingsFrom: aCollectionOfPermutations [ | ||
|
||
^ aCollectionOfPermutations collect: [:aPermutation | SBPermutationLabel newDisplaying: aPermutation] | ||
] | ||
|
||
{ #category : #building } | ||
SBCorrelationCluster >> extractedTopHeadingsFrom: aCollectionOfPermutations [ | ||
|
||
^ aCollectionOfPermutations collect: [:aPermutation | | ||
aPermutation isNilPermutation | ||
ifTrue: [StringMorph new contents: ' / '] | ||
ifFalse: [SBPermutationLabel newDisplaying: aPermutation]] | ||
] | ||
|
||
{ #category : #accessing } | ||
SBCorrelationCluster >> multiverse [ | ||
|
||
^ multiverse | ||
] | ||
|
||
{ #category : #accessing } | ||
SBCorrelationCluster >> multiverse: aSBMultiverse [ | ||
|
||
multiverse := aSBMultiverse | ||
] | ||
|
||
{ #category : #accessing } | ||
SBCorrelationCluster >> opponentPermutations [ | ||
|
||
^ opponentPermutations | ||
] | ||
|
||
{ #category : #accessing } | ||
SBCorrelationCluster >> opponentPermutations: aCollectionOfSBPermutations [ | ||
|
||
opponentPermutations := aCollectionOfSBPermutations | ||
] |
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,99 @@ | ||
Class { | ||
#name : #SBCorrelationView, | ||
#superclass : #SBResizableResultsView, | ||
#instVars : [ | ||
'basePermutations' | ||
], | ||
#category : #'Sandblocks-Babylonian' | ||
} | ||
|
||
{ #category : #accessing } | ||
SBCorrelationView >> basePermutations [ | ||
^ basePermutations | ||
] | ||
|
||
{ #category : #accessing } | ||
SBCorrelationView >> basePermutations: anObject [ | ||
basePermutations := anObject | ||
] | ||
|
||
{ #category : #building } | ||
SBCorrelationView >> buildAllPossibleResults [ | ||
|
||
| base thisVariant | | ||
self multiverse activeExamples | ||
ifEmpty: [gridContainer addMorph: (TextMorph new contents: 'No examples active'). | ||
gridContainer width: gridContainer firstSubmorph width + 5 "a bit of margin"]. | ||
|
||
thisVariant := self multiverse universes first activePermutation referencedVariants third. | ||
base := SBPermutation new referencedVariants: (self multiverse universes first activePermutation referencedVariants select: [:var | var = thisVariant]). | ||
self multiverse universes first activePermutation associationsDo: [:idToNum | idToNum key = thisVariant id ifTrue: [base add: idToNum]]. | ||
self halt. | ||
self basePermutations: {base}. | ||
|
||
self multiverse activeExamples do: [:anExample | | ||
self multiverse watches do: [:aWatch | | ||
self buildForExample: anExample watching: aWatch]] | ||
] | ||
|
||
{ #category : #building } | ||
SBCorrelationView >> buildForExample: anExample watching: aWatch [ | ||
|
||
gridContainer addMorphBack: (self containerRow cellPositioning: #center; | ||
addAllMorphsBack: { | ||
self containerRow listDirection: #topToBottom; | ||
addAllMorphsBack: { | ||
SBOwnTextMorph new contents: ( | ||
'{1}, {2}' format: {anExample label. | ||
(aWatch cleanedExpression sourceString)}). | ||
self buildGridsFor: anExample watching: aWatch} flatten}) | ||
] | ||
|
||
{ #category : #building } | ||
SBCorrelationView >> buildGridsFor: anExample watching: aWatch [ | ||
|
||
^ (self basePermutations collect: [:aBasePermutation | | split | | ||
split := self getAllUniversesContainingPermutation: aBasePermutation. | ||
{SBCorrelationCluster | ||
newForSize: self selectedResizer | ||
multiverse: self multiverse | ||
example: anExample | ||
watch: aWatch | ||
basePermutation: aBasePermutation | ||
opponentPermutations: split first }, | ||
(split second collect: [:nonContainingPermutation | | ||
SBCorrelationCluster | ||
newForSize: self selectedResizer | ||
multiverse: self multiverse | ||
example: anExample | ||
watch: aWatch | ||
basePermutation: nonContainingPermutation | ||
opponentPermutations: {SBNilPermutation new referencedVariants: {}}]) | ||
]) flatten | ||
|
||
] | ||
|
||
{ #category : #building } | ||
SBCorrelationView >> getAllUniversesContainingPermutation: aPermutation [ | ||
|
||
| containsBase rest | | ||
containsBase := OrderedCollection new. | ||
rest := OrderedCollection new. | ||
|
||
self multiverse universes do: [:aUniverse | | ||
((aUniverse activePermutation contains: aPermutation)) | ||
ifTrue: [containsBase add: (aUniverse activePermutation copyRemoving: {aPermutation}) ] | ||
ifFalse: [rest add: aUniverse activePermutation]]. | ||
|
||
^ {containsBase reject: [:aContainingPermutation | aContainingPermutation = aPermutation]. | ||
rest ifEmpty: [{SBNilPermutation new referencedVariants: {}}]} | ||
] | ||
|
||
{ #category : #initialization } | ||
SBCorrelationView >> initialize [ | ||
|
||
super initialize. | ||
|
||
self name: 'Correlation'. | ||
|
||
] |
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
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
55 changes: 55 additions & 0 deletions
55
packages/Sandblocks-Babylonian/SBResizableResultsView.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,55 @@ | ||
Class { | ||
#name : #SBResizableResultsView, | ||
#superclass : #SBGridResultsView, | ||
#instVars : [ | ||
'dimensionOptions' | ||
], | ||
#category : #'Sandblocks-Babylonian' | ||
} | ||
|
||
{ #category : #actions } | ||
SBResizableResultsView >> applyResizer [ | ||
|
||
self visualize. | ||
self multiverse sandblockEditor markSaved: SBExploriants uniqueInstance | ||
] | ||
|
||
{ #category : #building } | ||
SBResizableResultsView >> buildDimensionOptions [ | ||
|
||
| options | | ||
options := SBMorphResizer standardOptions. | ||
|
||
^ SBComboBox new | ||
prefix: 'Image Dimensions: '; | ||
labels: (options collect: #label); | ||
values: options; | ||
object: options third; | ||
when: #selectionChanged send: #applyResizer to: self | ||
] | ||
|
||
{ #category : #initialization } | ||
SBResizableResultsView >> initialize [ | ||
|
||
super initialize. | ||
|
||
dimensionOptions := self buildDimensionOptions | ||
] | ||
|
||
{ #category : #accessing } | ||
SBResizableResultsView >> selectedResizer [ | ||
|
||
^ dimensionOptions object | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
SBResizableResultsView >> visualize [ | ||
|
||
self clean. | ||
|
||
self block addMorph: dimensionOptions. | ||
self buildButtonRow. | ||
|
||
self buildAllPossibleResults . | ||
self concludeContainerWidth. | ||
] |
Oops, something went wrong.