From 037bb6087d0b043655de2345e8b67c34bc8e2090 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 21 Nov 2023 21:46:35 +0100 Subject: [PATCH 1/6] Resizing on watches now applies on any display, instead of the default watchview --- .../SBExampleValueDisplay.class.st | 12 +++++ .../SBExampleWatch.class.st | 13 ++--- .../SBVisualization.extension.st | 10 ++++ packages/Sandblocks-Watch/SBBarChart.class.st | 9 ++-- .../Sandblocks-Watch/SBLineChart.class.st | 11 ++-- .../SBRectangleChart.class.st | 40 +++++++------- .../Sandblocks-Watch/SBVisualization.class.st | 54 ++++++++++++++----- .../Sandblocks-Watch/SBWatchView.class.st | 37 +++++++++++-- 8 files changed, 131 insertions(+), 55 deletions(-) create mode 100644 packages/Sandblocks-Core/SBVisualization.extension.st diff --git a/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st b/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st index 0a93f4f6..0b650aa5 100644 --- a/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st @@ -21,6 +21,12 @@ SBExampleValueDisplay >> clear [ hadValue := false ] +{ #category : #'as yet unclassified' } +SBExampleValueDisplay >> display [ + + ^ display +] + { #category : #accessing } SBExampleValueDisplay >> displayedWatchValueBlocks [ @@ -127,6 +133,12 @@ SBExampleValueDisplay >> reportValues: aCollectionOfObjects name: aString sized: hadValue := true ] +{ #category : #actions } +SBExampleValueDisplay >> resizeThrough: aMorphResizer [ + + display resizeThrough: aMorphResizer +] + { #category : #actions } SBExampleValueDisplay >> updateDisplay [ diff --git a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st index 3be95f48..bf28a3ea 100644 --- a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st @@ -116,8 +116,8 @@ SBExampleWatch >> applyModifyExpressionOnValues [ { #category : #'event handling' } SBExampleWatch >> applyResizerOnValues [ - "Clearing everything here as Morphs get distorted when resized multiple times." - self applyModifyExpressionOnValues. + exampleToDisplay associationsDo: [:anExampleDisplayPair | + anExampleDisplayPair value resizeThrough: self selectedMorphResizer] ] @@ -171,11 +171,12 @@ SBExampleWatch >> exampleStarting: anExample [ exampleToValues at: anExample put: OrderedCollection new. - (exampleToDisplay at: anExample ifAbsentPut: [ | display | - display := SBExampleValueDisplay new. - self addMorph: (exampleToDisplay at: anExample put: display) atIndex: 2. + (exampleToDisplay at: anExample ifAbsentPut: [ | watchview | + watchview := SBExampleValueDisplay new. + watchview display fallbackResizer: self selectedMorphResizer. + self addMorph: (exampleToDisplay at: anExample put: watchview) atIndex: 2. anExample when: #outOfWorld send: #exampleStopped: to: self with: anExample. - display]) + watchview]) exampleStarting: anExample; name: anExample label ] diff --git a/packages/Sandblocks-Core/SBVisualization.extension.st b/packages/Sandblocks-Core/SBVisualization.extension.st new file mode 100644 index 00000000..456c014e --- /dev/null +++ b/packages/Sandblocks-Core/SBVisualization.extension.st @@ -0,0 +1,10 @@ +Extension { #name : #SBVisualization } + +{ #category : #'*Sandblocks-Core-geometry-override' } +SBVisualization >> extent: aPoint [ + + super extent: aPoint. + self targetHeight: aPoint y. + self scaleY range: (0 to: aPoint y). + self visualize +] diff --git a/packages/Sandblocks-Watch/SBBarChart.class.st b/packages/Sandblocks-Watch/SBBarChart.class.st index 0bc2eaa5..4b111277 100644 --- a/packages/Sandblocks-Watch/SBBarChart.class.st +++ b/packages/Sandblocks-Watch/SBBarChart.class.st @@ -5,17 +5,18 @@ Class { } { #category : #'initialize-release' } -SBBarChart class >> newWithValues: traceValues [ +SBBarChart class >> newWithValues: traceValues havingHeight: aNumber [ | valuesToVisualize | valuesToVisualize := traceValues ifEmpty: [#(0)] ifNotEmpty: [traceValues]. ^ self new + targetHeight: aNumber; traceValues: valuesToVisualize; scaleY: (SBScale newLinearScaleWithDomain: (({valuesToVisualize min. 0} min) to: valuesToVisualize max) - forRange: (0 to: self canvasHeight)); + forRange: (0 to: aNumber)); yourself ] @@ -30,7 +31,7 @@ SBBarChart >> newBarFor: aValue at: positionIndex [ "There is an extra Morph containing the datapoint itself so the tooltip is far easier to activate through more area" ^ Morph new - height: self class preferredHeight; + height: self targetHeight; left: ((positionIndex - 0.5) * self spaceBetweenPoints) rounded; width: self spaceBetweenPoints; color: Color transparent; @@ -39,7 +40,7 @@ SBBarChart >> newBarFor: aValue at: positionIndex [ color: self datapointDefaultColor; width: self barWidth; height: {(self scaleY scaledValueOf: aValue). 1} max; - bottom: self class canvasHeight + self class heightMargin; + bottom: self canvasHeight + self class heightMargin; left: positionIndex * self spaceBetweenPoints; setProperty: #chartValue toValue: (self scaleY scaledValueOf: aValue); yourself); diff --git a/packages/Sandblocks-Watch/SBLineChart.class.st b/packages/Sandblocks-Watch/SBLineChart.class.st index c3429539..f89ac2b3 100644 --- a/packages/Sandblocks-Watch/SBLineChart.class.st +++ b/packages/Sandblocks-Watch/SBLineChart.class.st @@ -5,17 +5,18 @@ Class { } { #category : #'initialize-release' } -SBLineChart class >> newWithValues: traceValues [ +SBLineChart class >> newWithValues: traceValues havingHeight: aNumber [ | valuesToVisualize | valuesToVisualize := traceValues ifEmpty: [#(0)] ifNotEmpty: [traceValues]. ^ self new + targetHeight: aNumber; traceValues: valuesToVisualize; scaleY: (SBScale newLinearScaleWithDomain: (valuesToVisualize min to: valuesToVisualize max) - forRange: (0 to: self canvasHeight)); + forRange: (0 to: aNumber)); yourself ] @@ -71,7 +72,7 @@ SBLineChart >> newDatapointFor: aValue at: positionIndex [ "There is an extra Morph containing the datapoint itself so the tooltip is far easier to activate through more area" ^ Morph new - height: self class preferredHeight; + height: self targetHeight; left: ((positionIndex - 0.5) * self spaceBetweenPoints) rounded; width: self spaceBetweenPoints; color: Color transparent; @@ -81,7 +82,7 @@ SBLineChart >> newDatapointFor: aValue at: positionIndex [ color: self datapointDefaultColor; borderWidth: 0; left: positionIndex * self spaceBetweenPoints; - top: self class canvasHeight - (self scaleY scaledValueOf: aValue); + top: self canvasHeight - (self scaleY scaledValueOf: aValue); setProperty: #chartValue toValue: (self scaleY scaledValueOf: aValue); yourself); yourself @@ -135,7 +136,7 @@ SBLineChart >> newScaleLineHeight: height length: length [ SBLineChart >> newScaleLinesOn: aMorph [ | section | - section := self class canvasHeight / (self numberScaleLines - 1). + section := self canvasHeight / (self numberScaleLines - 1). ^ (0 to: (self numberScaleLines - 1)) collect: [:i | self newScaleLineHeight: (section * i) + self scaleYOffset length: aMorph width] diff --git a/packages/Sandblocks-Watch/SBRectangleChart.class.st b/packages/Sandblocks-Watch/SBRectangleChart.class.st index 8534b6a8..65d4248b 100644 --- a/packages/Sandblocks-Watch/SBRectangleChart.class.st +++ b/packages/Sandblocks-Watch/SBRectangleChart.class.st @@ -7,35 +7,25 @@ Class { #category : #'Sandblocks-Watch' } -{ #category : #constants } -SBRectangleChart class >> coordinateSystemSize [ - - ^ self canvasHeight @ self canvasHeight -] - { #category : #'initialize-release' } -SBRectangleChart class >> newWithValues: traceValues [ +SBRectangleChart class >> newWithValues: traceValues havingHeight: aNumber [ - | biggestCoordinate absolutePoints | + | biggestCoordinate absolutePoints coordinateSystemSize | absolutePoints := traceValues collect: [:aPoint | aPoint abs]. biggestCoordinate := {absolutePoints max x. absolutePoints max y} max. + coordinateSystemSize := aNumber - self heightMargin. ^ self new + targetHeight: aNumber; traceValues: traceValues; scaleY: (SBScale newLinearScaleWithDomain: (biggestCoordinate negated to: biggestCoordinate) - forRange: (self coordinateSystemSize y / 2 negated to: self coordinateSystemSize y / 2)) + forRange: (coordinateSystemSize / 2 negated to: coordinateSystemSize / 2)) scaleX: (SBScale newLinearScaleWithDomain: (biggestCoordinate negated to: biggestCoordinate) - forRange: (self coordinateSystemSize x / 2 negated to: self coordinateSystemSize x / 2)); + forRange: (coordinateSystemSize / 2 negated to: coordinateSystemSize / 2)); yourself ] -{ #category : #constants } -SBRectangleChart class >> preferredHeight [ - - ^ 40 -] - { #category : #conversion } SBRectangleChart class >> supportedInterface [ @@ -62,6 +52,12 @@ SBRectangleChart >> borderStyleFor: scaledValues [ ^ BorderStyle width: borderWidth color: color ] +{ #category : #'visualization - constants' } +SBRectangleChart >> coordinateSystemSize [ + + ^ self canvasHeight @ self canvasHeight +] + { #category : #visualization } SBRectangleChart >> newCoordinateSystemFor: aValue at: positionIndex [ @@ -70,7 +66,7 @@ SBRectangleChart >> newCoordinateSystemFor: aValue at: positionIndex [ left := ((positionIndex - 1) * self spaceBetweenPoints) rounded. center := ((positionIndex - 0.5) * self spaceBetweenPoints) rounded. ^ Morph new - extent: self class coordinateSystemSize; + extent: self coordinateSystemSize; left: left; width: self spaceBetweenPoints; color: Color transparent; @@ -78,11 +74,11 @@ SBRectangleChart >> newCoordinateSystemFor: aValue at: positionIndex [ addAllMorphs: {LineMorph from: center@0 - to: center@(self class coordinateSystemSize y) + to: center@(self coordinateSystemSize y) color: self lineColor width: self scaleLineWidth. LineMorph - from: left@(self class coordinateSystemSize y / 2) - to: (left + self spaceBetweenPoints)@(self class coordinateSystemSize y / 2) + from: left@(self coordinateSystemSize y / 2) + to: (left + self spaceBetweenPoints)@(self coordinateSystemSize y / 2) color: self lineColor width: self scaleLineWidth.}; yourself ] @@ -107,7 +103,7 @@ SBRectangleChart >> newRectangleFor: aValue at: positionIndex [ color: (self rectangleColorForValue: aValue); borderStyle: (self borderStyleFor: (scaledWidth @ scaledHeight)); left: (scaledWidth / 2) + left; - top: (self class coordinateSystemSize y / 2) - (scaledHeight abs / 2) - (scaledHeight/2) ; + top: (self coordinateSystemSize y / 2) - (scaledHeight abs / 2) - (scaledHeight/2) ; yourself ] @@ -178,7 +174,7 @@ SBRectangleChart >> scaleY: aYSBScale scaleX: aXSBScale [ { #category : #'visualization - constants' } SBRectangleChart >> spaceBetweenPoints [ - ^ self class coordinateSystemSize x + ^ self coordinateSystemSize x ] { #category : #'visualization - constants' } diff --git a/packages/Sandblocks-Watch/SBVisualization.class.st b/packages/Sandblocks-Watch/SBVisualization.class.st index 5d2e8296..435e5c1e 100644 --- a/packages/Sandblocks-Watch/SBVisualization.class.st +++ b/packages/Sandblocks-Watch/SBVisualization.class.st @@ -20,21 +20,22 @@ Class { #superclass : #SBBlock, #instVars : [ 'scaleY', - 'traceValues' + 'traceValues', + 'targetHeight' ], #category : #'Sandblocks-Watch' } { #category : #constants } -SBVisualization class >> canvasHeight [ +SBVisualization class >> defaultHeight [ - ^ self preferredHeight - self heightMargin + ^ 100 sbScaled ] { #category : #constants } -SBVisualization class >> heightMargin [ - - ^ 5 sbScaled +SBVisualization class >> heightMargin [ + + ^ 5 sbScaled ] { #category : #constants } @@ -46,13 +47,13 @@ SBVisualization class >> highlightedDataPercentage [ { #category : #'initialize-release' } SBVisualization class >> newWithValues: traceValues [ - ^ self subclassResponsibility + ^ self newWithValues: traceValues havingHeight: self defaultHeight ] -{ #category : #constants } -SBVisualization class >> preferredHeight [ +{ #category : #'initialize-release' } +SBVisualization class >> newWithValues: traceValues havingHeight: aNumber [ - ^ 100 sbScaled + ^ self subclassResponsibility ] { #category : #conversion } @@ -93,6 +94,20 @@ SBVisualization >> axisYNotation [ ^ SBAxisNotation newFromScale: self scaleY ticking: 5 ] +{ #category : #'visualization - constants' } +SBVisualization >> canvasHeight [ + + ^ self targetHeight - self class heightMargin +] + +{ #category : #nil } +SBVisualization >> extent: aPoint [ + + super extent: aPoint. + self targetHeight: aPoint. + self visualize +] + { #category : #initialization } SBVisualization >> initialize [ @@ -118,17 +133,16 @@ SBVisualization >> isTopLevel [ { #category : #'visualization - constants' } SBVisualization >> lineColor [ - ^ self drawnColor + ^ self foregroundColor ] { #category : #visualization } SBVisualization >> newBackground [ - - + ^ Morph new color: self drawnColor; width: (self traceValues size + 2 "to have some margin") * self spaceBetweenPoints; - height: self class preferredHeight; + height: self targetHeight; borderWidth: 0; yourself ] @@ -165,6 +179,18 @@ SBVisualization >> spaceBetweenPoints [ ^ 10 sbScaled ] +{ #category : #accessing } +SBVisualization >> targetHeight [ + + ^ targetHeight ifNil: [targetHeight:= self class defaultHeight] +] + +{ #category : #accessing } +SBVisualization >> targetHeight: aNumber [ + + targetHeight := aNumber +] + { #category : #accessing } SBVisualization >> traceValues [ diff --git a/packages/Sandblocks-Watch/SBWatchView.class.st b/packages/Sandblocks-Watch/SBWatchView.class.st index f7fb96ea..c4ed4b2c 100644 --- a/packages/Sandblocks-Watch/SBWatchView.class.st +++ b/packages/Sandblocks-Watch/SBWatchView.class.st @@ -10,8 +10,8 @@ Class { 'dark', 'count', 'clear', - 'updateScheduled', - 'env' + 'fallbackResizer', + 'updateScheduled' ], #category : #'Sandblocks-Watch' } @@ -52,6 +52,7 @@ SBWatchView >> changeDisplay [ | index options | options := Array streamContents: [:stream | self values allConversionsFor: SBInterfaces topLevel do: [:pair | stream nextPut: pair]]. + options := options do: [:aPair | aPair at: 2 put: (self watchValuesContainer addMorphBack: (self fallbackResizer applyOn: aPair second))]. options := options, {{'default'. self watchValuesContainer addAllMorphsBack: (watchValues collect: #asValueMorph)}}. index := UIManager default chooseFrom: (options collect: #first). index = 0 ifTrue: [^ self]. @@ -164,6 +165,18 @@ SBWatchView >> exploreValues [ self object explore ] +{ #category : #accessing } +SBWatchView >> fallbackResizer [ + + ^ fallbackResizer +] + +{ #category : #accessing } +SBWatchView >> fallbackResizer: aSBMorphResizer [ + + fallbackResizer := aSBMorphResizer +] + { #category : #accessing } SBWatchView >> incrementCount [ @@ -179,6 +192,7 @@ SBWatchView >> initialize [ updateScheduled := false. numSavedValues := 1. watchValues := LinkedList new. + fallbackResizer := SBMorphResizer newSmall. self layoutPolicy: SBAlgebraLayout new; @@ -247,15 +261,16 @@ SBWatchView >> printOn: aStream [ self object printOn: aStream ] -{ #category : #accessing } +{ #category : #actions } SBWatchView >> reportValue: anObject [ self reportValue: {anObject} sized: SBMorphResizer newIdentity ] -{ #category : #accessing } +{ #category : #actions } SBWatchView >> reportValues: aCollectionOfObjects sized: aMorphResizer [ + self fallbackResizer: aMorphResizer. aCollectionOfObjects do: [:anObject | self addValue: anObject sized: aMorphResizer]. self count: self count contents + aCollectionOfObjects size. @@ -264,6 +279,20 @@ SBWatchView >> reportValues: aCollectionOfObjects sized: aMorphResizer [ Project current addDeferredUIMessage: [self updateDisplay]] ] +{ #category : #actions } +SBWatchView >> resizeThrough: aMorphResizer [ + + "Clearing everything here as Morphs get distorted when resized multiple times." + | valuesMorph | + valuesMorph := self watchValuesContainer. + valuesMorph addAllMorphsBack: (self displayedMorphs + collect: #sbSnapshot + thenDo: [:aMorph | aMorphResizer applyOn: aMorph]). + + self displayOnScrollPane: valuesMorph. + self fallbackResizer: aMorphResizer. +] + { #category : #layout } SBWatchView >> scrollBarHeight [ From 6300cdde24d3231993866cf5e0add87699fc6dda Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 21 Nov 2023 21:47:09 +0100 Subject: [PATCH 2/6] rename variable --- packages/Sandblocks-Babylonian/SBExampleWatch.class.st | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st index bf28a3ea..e48cb2a7 100644 --- a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st @@ -171,12 +171,12 @@ SBExampleWatch >> exampleStarting: anExample [ exampleToValues at: anExample put: OrderedCollection new. - (exampleToDisplay at: anExample ifAbsentPut: [ | watchview | - watchview := SBExampleValueDisplay new. - watchview display fallbackResizer: self selectedMorphResizer. - self addMorph: (exampleToDisplay at: anExample put: watchview) atIndex: 2. + (exampleToDisplay at: anExample ifAbsentPut: [ | valueDisplay | + valueDisplay := SBExampleValueDisplay new. + valueDisplay display fallbackResizer: self selectedMorphResizer. + self addMorph: (exampleToDisplay at: anExample put: valueDisplay) atIndex: 2. anExample when: #outOfWorld send: #exampleStopped: to: self with: anExample. - watchview]) + valueDisplay]) exampleStarting: anExample; name: anExample label ] From 9a5c63582d68a67036a08623d065396222002e9c Mon Sep 17 00:00:00 2001 From: Tom Beckmann Date: Wed, 8 Nov 2023 09:02:29 +0100 Subject: [PATCH 3/6] Merge pull request #128 from hpi-swa/feature/dynamic-variants Adds support for variants in dynamic ui methods (cherry-picked from commit 677d5137dd9f1bf30d93ddabf61ebd1da1fda37b) From ffb0e13e0e2b853497329a661efa32c3d5fd2cd0 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 21 Nov 2023 22:07:00 +0100 Subject: [PATCH 4/6] Revert "rename variable" This reverts commit 6300cdd "rename variable" --- packages/Sandblocks-Babylonian/SBExampleWatch.class.st | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st index e48cb2a7..bf28a3ea 100644 --- a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st @@ -171,12 +171,12 @@ SBExampleWatch >> exampleStarting: anExample [ exampleToValues at: anExample put: OrderedCollection new. - (exampleToDisplay at: anExample ifAbsentPut: [ | valueDisplay | - valueDisplay := SBExampleValueDisplay new. - valueDisplay display fallbackResizer: self selectedMorphResizer. - self addMorph: (exampleToDisplay at: anExample put: valueDisplay) atIndex: 2. + (exampleToDisplay at: anExample ifAbsentPut: [ | watchview | + watchview := SBExampleValueDisplay new. + watchview display fallbackResizer: self selectedMorphResizer. + self addMorph: (exampleToDisplay at: anExample put: watchview) atIndex: 2. anExample when: #outOfWorld send: #exampleStopped: to: self with: anExample. - valueDisplay]) + watchview]) exampleStarting: anExample; name: anExample label ] From c88d5224243b7ff755640f46734814c5b4940287 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 21 Nov 2023 22:07:30 +0100 Subject: [PATCH 5/6] Revert "Resizing on watches now applies on any display, instead of the default watchview" This reverts commit 037bb60 "Resizing on watches now applies on any display, instead of the default watchview" --- .../SBExampleValueDisplay.class.st | 12 ----- .../SBExampleWatch.class.st | 13 +++-- packages/Sandblocks-Watch/SBBarChart.class.st | 9 ++-- .../Sandblocks-Watch/SBLineChart.class.st | 11 ++-- .../SBRectangleChart.class.st | 40 +++++++------- .../Sandblocks-Watch/SBVisualization.class.st | 54 +++++-------------- .../Sandblocks-Watch/SBWatchView.class.st | 37 ++----------- 7 files changed, 55 insertions(+), 121 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st b/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st index 0b650aa5..0a93f4f6 100644 --- a/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st @@ -21,12 +21,6 @@ SBExampleValueDisplay >> clear [ hadValue := false ] -{ #category : #'as yet unclassified' } -SBExampleValueDisplay >> display [ - - ^ display -] - { #category : #accessing } SBExampleValueDisplay >> displayedWatchValueBlocks [ @@ -133,12 +127,6 @@ SBExampleValueDisplay >> reportValues: aCollectionOfObjects name: aString sized: hadValue := true ] -{ #category : #actions } -SBExampleValueDisplay >> resizeThrough: aMorphResizer [ - - display resizeThrough: aMorphResizer -] - { #category : #actions } SBExampleValueDisplay >> updateDisplay [ diff --git a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st index bf28a3ea..3be95f48 100644 --- a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st @@ -116,8 +116,8 @@ SBExampleWatch >> applyModifyExpressionOnValues [ { #category : #'event handling' } SBExampleWatch >> applyResizerOnValues [ - exampleToDisplay associationsDo: [:anExampleDisplayPair | - anExampleDisplayPair value resizeThrough: self selectedMorphResizer] + "Clearing everything here as Morphs get distorted when resized multiple times." + self applyModifyExpressionOnValues. ] @@ -171,12 +171,11 @@ SBExampleWatch >> exampleStarting: anExample [ exampleToValues at: anExample put: OrderedCollection new. - (exampleToDisplay at: anExample ifAbsentPut: [ | watchview | - watchview := SBExampleValueDisplay new. - watchview display fallbackResizer: self selectedMorphResizer. - self addMorph: (exampleToDisplay at: anExample put: watchview) atIndex: 2. + (exampleToDisplay at: anExample ifAbsentPut: [ | display | + display := SBExampleValueDisplay new. + self addMorph: (exampleToDisplay at: anExample put: display) atIndex: 2. anExample when: #outOfWorld send: #exampleStopped: to: self with: anExample. - watchview]) + display]) exampleStarting: anExample; name: anExample label ] diff --git a/packages/Sandblocks-Watch/SBBarChart.class.st b/packages/Sandblocks-Watch/SBBarChart.class.st index 4b111277..0bc2eaa5 100644 --- a/packages/Sandblocks-Watch/SBBarChart.class.st +++ b/packages/Sandblocks-Watch/SBBarChart.class.st @@ -5,18 +5,17 @@ Class { } { #category : #'initialize-release' } -SBBarChart class >> newWithValues: traceValues havingHeight: aNumber [ +SBBarChart class >> newWithValues: traceValues [ | valuesToVisualize | valuesToVisualize := traceValues ifEmpty: [#(0)] ifNotEmpty: [traceValues]. ^ self new - targetHeight: aNumber; traceValues: valuesToVisualize; scaleY: (SBScale newLinearScaleWithDomain: (({valuesToVisualize min. 0} min) to: valuesToVisualize max) - forRange: (0 to: aNumber)); + forRange: (0 to: self canvasHeight)); yourself ] @@ -31,7 +30,7 @@ SBBarChart >> newBarFor: aValue at: positionIndex [ "There is an extra Morph containing the datapoint itself so the tooltip is far easier to activate through more area" ^ Morph new - height: self targetHeight; + height: self class preferredHeight; left: ((positionIndex - 0.5) * self spaceBetweenPoints) rounded; width: self spaceBetweenPoints; color: Color transparent; @@ -40,7 +39,7 @@ SBBarChart >> newBarFor: aValue at: positionIndex [ color: self datapointDefaultColor; width: self barWidth; height: {(self scaleY scaledValueOf: aValue). 1} max; - bottom: self canvasHeight + self class heightMargin; + bottom: self class canvasHeight + self class heightMargin; left: positionIndex * self spaceBetweenPoints; setProperty: #chartValue toValue: (self scaleY scaledValueOf: aValue); yourself); diff --git a/packages/Sandblocks-Watch/SBLineChart.class.st b/packages/Sandblocks-Watch/SBLineChart.class.st index f89ac2b3..c3429539 100644 --- a/packages/Sandblocks-Watch/SBLineChart.class.st +++ b/packages/Sandblocks-Watch/SBLineChart.class.st @@ -5,18 +5,17 @@ Class { } { #category : #'initialize-release' } -SBLineChart class >> newWithValues: traceValues havingHeight: aNumber [ +SBLineChart class >> newWithValues: traceValues [ | valuesToVisualize | valuesToVisualize := traceValues ifEmpty: [#(0)] ifNotEmpty: [traceValues]. ^ self new - targetHeight: aNumber; traceValues: valuesToVisualize; scaleY: (SBScale newLinearScaleWithDomain: (valuesToVisualize min to: valuesToVisualize max) - forRange: (0 to: aNumber)); + forRange: (0 to: self canvasHeight)); yourself ] @@ -72,7 +71,7 @@ SBLineChart >> newDatapointFor: aValue at: positionIndex [ "There is an extra Morph containing the datapoint itself so the tooltip is far easier to activate through more area" ^ Morph new - height: self targetHeight; + height: self class preferredHeight; left: ((positionIndex - 0.5) * self spaceBetweenPoints) rounded; width: self spaceBetweenPoints; color: Color transparent; @@ -82,7 +81,7 @@ SBLineChart >> newDatapointFor: aValue at: positionIndex [ color: self datapointDefaultColor; borderWidth: 0; left: positionIndex * self spaceBetweenPoints; - top: self canvasHeight - (self scaleY scaledValueOf: aValue); + top: self class canvasHeight - (self scaleY scaledValueOf: aValue); setProperty: #chartValue toValue: (self scaleY scaledValueOf: aValue); yourself); yourself @@ -136,7 +135,7 @@ SBLineChart >> newScaleLineHeight: height length: length [ SBLineChart >> newScaleLinesOn: aMorph [ | section | - section := self canvasHeight / (self numberScaleLines - 1). + section := self class canvasHeight / (self numberScaleLines - 1). ^ (0 to: (self numberScaleLines - 1)) collect: [:i | self newScaleLineHeight: (section * i) + self scaleYOffset length: aMorph width] diff --git a/packages/Sandblocks-Watch/SBRectangleChart.class.st b/packages/Sandblocks-Watch/SBRectangleChart.class.st index 65d4248b..8534b6a8 100644 --- a/packages/Sandblocks-Watch/SBRectangleChart.class.st +++ b/packages/Sandblocks-Watch/SBRectangleChart.class.st @@ -7,25 +7,35 @@ Class { #category : #'Sandblocks-Watch' } +{ #category : #constants } +SBRectangleChart class >> coordinateSystemSize [ + + ^ self canvasHeight @ self canvasHeight +] + { #category : #'initialize-release' } -SBRectangleChart class >> newWithValues: traceValues havingHeight: aNumber [ +SBRectangleChart class >> newWithValues: traceValues [ - | biggestCoordinate absolutePoints coordinateSystemSize | + | biggestCoordinate absolutePoints | absolutePoints := traceValues collect: [:aPoint | aPoint abs]. biggestCoordinate := {absolutePoints max x. absolutePoints max y} max. - coordinateSystemSize := aNumber - self heightMargin. ^ self new - targetHeight: aNumber; traceValues: traceValues; scaleY: (SBScale newLinearScaleWithDomain: (biggestCoordinate negated to: biggestCoordinate) - forRange: (coordinateSystemSize / 2 negated to: coordinateSystemSize / 2)) + forRange: (self coordinateSystemSize y / 2 negated to: self coordinateSystemSize y / 2)) scaleX: (SBScale newLinearScaleWithDomain: (biggestCoordinate negated to: biggestCoordinate) - forRange: (coordinateSystemSize / 2 negated to: coordinateSystemSize / 2)); + forRange: (self coordinateSystemSize x / 2 negated to: self coordinateSystemSize x / 2)); yourself ] +{ #category : #constants } +SBRectangleChart class >> preferredHeight [ + + ^ 40 +] + { #category : #conversion } SBRectangleChart class >> supportedInterface [ @@ -52,12 +62,6 @@ SBRectangleChart >> borderStyleFor: scaledValues [ ^ BorderStyle width: borderWidth color: color ] -{ #category : #'visualization - constants' } -SBRectangleChart >> coordinateSystemSize [ - - ^ self canvasHeight @ self canvasHeight -] - { #category : #visualization } SBRectangleChart >> newCoordinateSystemFor: aValue at: positionIndex [ @@ -66,7 +70,7 @@ SBRectangleChart >> newCoordinateSystemFor: aValue at: positionIndex [ left := ((positionIndex - 1) * self spaceBetweenPoints) rounded. center := ((positionIndex - 0.5) * self spaceBetweenPoints) rounded. ^ Morph new - extent: self coordinateSystemSize; + extent: self class coordinateSystemSize; left: left; width: self spaceBetweenPoints; color: Color transparent; @@ -74,11 +78,11 @@ SBRectangleChart >> newCoordinateSystemFor: aValue at: positionIndex [ addAllMorphs: {LineMorph from: center@0 - to: center@(self coordinateSystemSize y) + to: center@(self class coordinateSystemSize y) color: self lineColor width: self scaleLineWidth. LineMorph - from: left@(self coordinateSystemSize y / 2) - to: (left + self spaceBetweenPoints)@(self coordinateSystemSize y / 2) + from: left@(self class coordinateSystemSize y / 2) + to: (left + self spaceBetweenPoints)@(self class coordinateSystemSize y / 2) color: self lineColor width: self scaleLineWidth.}; yourself ] @@ -103,7 +107,7 @@ SBRectangleChart >> newRectangleFor: aValue at: positionIndex [ color: (self rectangleColorForValue: aValue); borderStyle: (self borderStyleFor: (scaledWidth @ scaledHeight)); left: (scaledWidth / 2) + left; - top: (self coordinateSystemSize y / 2) - (scaledHeight abs / 2) - (scaledHeight/2) ; + top: (self class coordinateSystemSize y / 2) - (scaledHeight abs / 2) - (scaledHeight/2) ; yourself ] @@ -174,7 +178,7 @@ SBRectangleChart >> scaleY: aYSBScale scaleX: aXSBScale [ { #category : #'visualization - constants' } SBRectangleChart >> spaceBetweenPoints [ - ^ self coordinateSystemSize x + ^ self class coordinateSystemSize x ] { #category : #'visualization - constants' } diff --git a/packages/Sandblocks-Watch/SBVisualization.class.st b/packages/Sandblocks-Watch/SBVisualization.class.st index 435e5c1e..5d2e8296 100644 --- a/packages/Sandblocks-Watch/SBVisualization.class.st +++ b/packages/Sandblocks-Watch/SBVisualization.class.st @@ -20,22 +20,21 @@ Class { #superclass : #SBBlock, #instVars : [ 'scaleY', - 'traceValues', - 'targetHeight' + 'traceValues' ], #category : #'Sandblocks-Watch' } { #category : #constants } -SBVisualization class >> defaultHeight [ +SBVisualization class >> canvasHeight [ - ^ 100 sbScaled + ^ self preferredHeight - self heightMargin ] { #category : #constants } -SBVisualization class >> heightMargin [ - - ^ 5 sbScaled +SBVisualization class >> heightMargin [ + + ^ 5 sbScaled ] { #category : #constants } @@ -47,13 +46,13 @@ SBVisualization class >> highlightedDataPercentage [ { #category : #'initialize-release' } SBVisualization class >> newWithValues: traceValues [ - ^ self newWithValues: traceValues havingHeight: self defaultHeight + ^ self subclassResponsibility ] -{ #category : #'initialize-release' } -SBVisualization class >> newWithValues: traceValues havingHeight: aNumber [ +{ #category : #constants } +SBVisualization class >> preferredHeight [ - ^ self subclassResponsibility + ^ 100 sbScaled ] { #category : #conversion } @@ -94,20 +93,6 @@ SBVisualization >> axisYNotation [ ^ SBAxisNotation newFromScale: self scaleY ticking: 5 ] -{ #category : #'visualization - constants' } -SBVisualization >> canvasHeight [ - - ^ self targetHeight - self class heightMargin -] - -{ #category : #nil } -SBVisualization >> extent: aPoint [ - - super extent: aPoint. - self targetHeight: aPoint. - self visualize -] - { #category : #initialization } SBVisualization >> initialize [ @@ -133,16 +118,17 @@ SBVisualization >> isTopLevel [ { #category : #'visualization - constants' } SBVisualization >> lineColor [ - ^ self foregroundColor + ^ self drawnColor ] { #category : #visualization } SBVisualization >> newBackground [ - + + ^ Morph new color: self drawnColor; width: (self traceValues size + 2 "to have some margin") * self spaceBetweenPoints; - height: self targetHeight; + height: self class preferredHeight; borderWidth: 0; yourself ] @@ -179,18 +165,6 @@ SBVisualization >> spaceBetweenPoints [ ^ 10 sbScaled ] -{ #category : #accessing } -SBVisualization >> targetHeight [ - - ^ targetHeight ifNil: [targetHeight:= self class defaultHeight] -] - -{ #category : #accessing } -SBVisualization >> targetHeight: aNumber [ - - targetHeight := aNumber -] - { #category : #accessing } SBVisualization >> traceValues [ diff --git a/packages/Sandblocks-Watch/SBWatchView.class.st b/packages/Sandblocks-Watch/SBWatchView.class.st index c4ed4b2c..f7fb96ea 100644 --- a/packages/Sandblocks-Watch/SBWatchView.class.st +++ b/packages/Sandblocks-Watch/SBWatchView.class.st @@ -10,8 +10,8 @@ Class { 'dark', 'count', 'clear', - 'fallbackResizer', - 'updateScheduled' + 'updateScheduled', + 'env' ], #category : #'Sandblocks-Watch' } @@ -52,7 +52,6 @@ SBWatchView >> changeDisplay [ | index options | options := Array streamContents: [:stream | self values allConversionsFor: SBInterfaces topLevel do: [:pair | stream nextPut: pair]]. - options := options do: [:aPair | aPair at: 2 put: (self watchValuesContainer addMorphBack: (self fallbackResizer applyOn: aPair second))]. options := options, {{'default'. self watchValuesContainer addAllMorphsBack: (watchValues collect: #asValueMorph)}}. index := UIManager default chooseFrom: (options collect: #first). index = 0 ifTrue: [^ self]. @@ -165,18 +164,6 @@ SBWatchView >> exploreValues [ self object explore ] -{ #category : #accessing } -SBWatchView >> fallbackResizer [ - - ^ fallbackResizer -] - -{ #category : #accessing } -SBWatchView >> fallbackResizer: aSBMorphResizer [ - - fallbackResizer := aSBMorphResizer -] - { #category : #accessing } SBWatchView >> incrementCount [ @@ -192,7 +179,6 @@ SBWatchView >> initialize [ updateScheduled := false. numSavedValues := 1. watchValues := LinkedList new. - fallbackResizer := SBMorphResizer newSmall. self layoutPolicy: SBAlgebraLayout new; @@ -261,16 +247,15 @@ SBWatchView >> printOn: aStream [ self object printOn: aStream ] -{ #category : #actions } +{ #category : #accessing } SBWatchView >> reportValue: anObject [ self reportValue: {anObject} sized: SBMorphResizer newIdentity ] -{ #category : #actions } +{ #category : #accessing } SBWatchView >> reportValues: aCollectionOfObjects sized: aMorphResizer [ - self fallbackResizer: aMorphResizer. aCollectionOfObjects do: [:anObject | self addValue: anObject sized: aMorphResizer]. self count: self count contents + aCollectionOfObjects size. @@ -279,20 +264,6 @@ SBWatchView >> reportValues: aCollectionOfObjects sized: aMorphResizer [ Project current addDeferredUIMessage: [self updateDisplay]] ] -{ #category : #actions } -SBWatchView >> resizeThrough: aMorphResizer [ - - "Clearing everything here as Morphs get distorted when resized multiple times." - | valuesMorph | - valuesMorph := self watchValuesContainer. - valuesMorph addAllMorphsBack: (self displayedMorphs - collect: #sbSnapshot - thenDo: [:aMorph | aMorphResizer applyOn: aMorph]). - - self displayOnScrollPane: valuesMorph. - self fallbackResizer: aMorphResizer. -] - { #category : #layout } SBWatchView >> scrollBarHeight [ From fbd0332d9118748a51f9bca42acc394c0830deae Mon Sep 17 00:00:00 2001 From: Joana Bergsiek <33000454+JoeAtHPI@users.noreply.github.com> Date: Thu, 23 Nov 2023 14:29:53 +0100 Subject: [PATCH 6/6] Resolves wrongly added extension --- packages/Sandblocks-Core/SBVisualization.extension.st | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 packages/Sandblocks-Core/SBVisualization.extension.st diff --git a/packages/Sandblocks-Core/SBVisualization.extension.st b/packages/Sandblocks-Core/SBVisualization.extension.st deleted file mode 100644 index 456c014e..00000000 --- a/packages/Sandblocks-Core/SBVisualization.extension.st +++ /dev/null @@ -1,10 +0,0 @@ -Extension { #name : #SBVisualization } - -{ #category : #'*Sandblocks-Core-geometry-override' } -SBVisualization >> extent: aPoint [ - - super extent: aPoint. - self targetHeight: aPoint y. - self scaleY range: (0 to: aPoint y). - self visualize -]