Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Schaaaf committed Jul 9, 2024
1 parent f4957bb commit bd8769d
Show file tree
Hide file tree
Showing 134 changed files with 267 additions and 314 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ as yet unclassified
addDatapointsToLine

| dataPoint |

self removeAllDatapoints.
1 to: self data size do: [:index |
dataPoint := SWDataPoint create: (self data at: index) at: (self vertices at: (index+1)).
dataPoint := SWDataPoint create: (self data at: index) at: (self vertices at: (index + 1)).
dataPoint
color: Color transparent;
suffix: self dataSuffix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ as yet unclassified
createVertices

| modifiedData |

modifiedData := SWData create.
modifiedData
addVector: (SWVector fromPoint: (self data first x @ 0));
addMany: self data;
addVector: (SWVector fromPoint: (self data last x @ 0)).

^ modifiedData collect: [:vector | self coordinateSystem positionFor: vector asPoint]

^ modifiedData collect: [:vector | self coordinateSystem positionFor: vector asPoint]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ update
self applyTheme: self diagram colorTheme.
self diagram updateCoordinateSystem.
self vertices: self createVertices.
self lineMorph setVertices: self vertices asArray.
self lineMorph borderColor: Color black.
self lineMorph color: self lineColor.
self lineMorph
setVertices: self vertices asArray;
borderColor: Color black;
color: self lineColor.
self addDatapointsToLine
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"class" : {
"create" : "Nils Urban 5/28/2024 10:10" },
"instance" : {
"addDatapointsToLine" : "Nils Urban 7/8/2024 22:26",
"addDatapointsToLine" : "JB 7/9/2024 15:50",
"createLineMorph" : "JB 6/18/2024 22:50",
"createVertices" : "Nils Urban 5/28/2024 10:47",
"createVertices" : "JB 7/9/2024 15:50",
"initialize" : "Nils Urban 7/8/2024 23:33",
"update" : "Nils Urban 7/8/2024 22:26" } }
"update" : "JB 7/9/2024 15:51" } }
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ accessing
bottomCaption: aString

| bottomTextMorph labelMorph |

bottomTextMorph := TextMorph new.
bottomTextMorph
contents: aString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ accessing
bottomCaptionHeight

| height |

height := 0.
self bottomLabelMorph ifNotNil: [height := self bottomLabelMorph height].

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defaults
defaultBarLabelOffset

^ (0 @ 20)
^ 0 @ 20
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defaults
defaultLabelOffset

^ (3 @ 5)
^ 3 @ 5
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ geometry
isLabelTooLong

| charWidth textWidth |

charWidth := self defaultCharWidth.
textWidth := self barLabelMorph width.

(textWidth = self minimumLabelWidth)
ifTrue: [textWidth := self barLabelMorph text size * charWidth].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mouseDown: anEvent
ifTrue: [
owner data at: self datapointIndex put: (SWVector fromPoint: ((owner data at: self datapointIndex) x) @ 0).
owner originalData at: self datapointIndex put: (SWVector fromPoint: ((owner originalData at: self datapointIndex) x) @ 0).
owner diagram redrawChangedData.].
owner diagram redrawChangedData].
(anEvent redButtonPressed)
ifTrue: [self switchColor].
anEvent hand waitForClicksOrDrag: self event: anEvent
anEvent hand waitForClicksOrDrag: self event: anEvent
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ event handling
mouseEnter: anEvent

| popup popupText |

popupText := 'X: ' , (self round:(self vector x) to: 0.001) asString , String cr , 'Y: ' , (self round:(self vector y) to: 0.01) asString, self owner dataSuffix.
popup := TextMorph new contents: popupText.
popup bottomLeft: self topLeft.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ geometry
rotateLabel

| rotationAngle |

rotationAngle := 3/2 * (Float pi).
self isLabelHorizontal: false.
self rotationMorph
self
rotationMorph
angle: rotationAngle;
bottomLeft: self rotatedLabelPosition
bottomLeft: self rotatedLabelPosition
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defaults
rotatedLabelOffset

^ (5 @ 55)
^ 5 @ 55
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@
"instance" : {
"barLabelMorph" : "ds 6/19/2020 19:12",
"barLabelMorph:" : "ds 6/19/2020 19:12",
"bottomCaption:" : "Nils Urban 7/8/2024 22:30",
"bottomCaptionHeight" : "Nils Urban 6/21/2024 16:59",
"bottomCaption:" : "JB 7/9/2024 15:59",
"bottomCaptionHeight" : "JB 7/9/2024 16:00",
"bottomLabelMorph" : "Nils Urban 6/21/2024 16:36",
"bottomLabelMorph:" : "Nils Urban 6/21/2024 16:36",
"caption:" : "Nils Urban 7/8/2024 22:31",
"captionColor" : "Nils Urban 6/13/2024 01:42",
"captionColor:" : "Nils Urban 6/13/2024 01:42",
"defaultBarLabelOffset" : "ds 6/19/2020 19:13",
"defaultBarLabelOffset" : "JB 7/9/2024 16:00",
"defaultCharWidth" : "ds 6/19/2020 19:13",
"defaultLabelOffset" : "ds 6/19/2020 19:13",
"defaultLabelOffset" : "JB 7/9/2024 16:00",
"handlesMouseOver:" : "FM 5/30/2021 10:35",
"infoPopup" : "Nils Urban 7/9/2024 10:23",
"infoPopup:" : "Nils Urban 7/9/2024 10:23",
"initialize" : "Nils Urban 7/8/2024 23:32",
"isLabelHorizontal" : "ds 6/19/2020 19:13",
"isLabelHorizontal:" : "ds 6/19/2020 19:13",
"isLabelTooLong" : "ds 6/19/2020 19:38",
"isLabelTooLong" : "JB 7/9/2024 16:00",
"isTextHigherThanBar" : "ds 6/19/2020 19:39",
"minimumLabelWidth" : "ds 6/19/2020 19:39",
"mouseDown:" : "Nils Urban 7/8/2024 22:34",
"mouseEnter:" : "Nils Urban 7/8/2024 22:36",
"mouseDown:" : "JB 7/9/2024 16:00",
"mouseEnter:" : "JB 7/9/2024 16:01",
"mouseLeave:" : "Nils Urban 6/14/2024 14:16",
"raiseBarLabel" : "ds 6/19/2020 19:39",
"rotateLabel" : "Nils Urban 6/14/2024 15:52",
"rotatedLabelOffset" : "ds 6/19/2020 19:39",
"rotateLabel" : "JB 7/9/2024 16:01",
"rotatedLabelOffset" : "JB 7/9/2024 16:01",
"rotatedLabelPosition" : "Nils Urban 6/14/2024 15:48",
"rotationMorph" : "ds 6/19/2020 19:39",
"rotationMorph:" : "ds 6/19/2020 19:39" } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
geometry
barBottom

^ (self coordinateSystem positionFor: (0 @ 0)) y
^ (self coordinateSystem positionFor: 0 @ 0) y
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
barPositionFor: xValue

^ (self coordinateSystem positionFor: (xValue @ 0)) x + (self barWidth / 2)
^ (self coordinateSystem positionFor: xValue @ 0) x + (self barWidth / 2)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ creation
createBarsFrom: aSWData

| xOfBar height bar |

aSWData doWithIndex: [:vector :index |
xOfBar := self barPositionFor: vector x.
height := self barBottom - (self coordinateSystem positionFor: (0 @ vector y)) y.
Expand All @@ -15,7 +14,8 @@ createBarsFrom: aSWData
captionColor: self barLabelColor;
yourself).
((self data at: index) y = 0)
ifFalse: [(self diagram stacked)
ifTrue: [bar caption: vector labelName.]
ifFalse: [bar bottomCaption: vector labelName.]].
self add: bar]
ifFalse: [
(self diagram stacked)
ifTrue: [bar caption: vector labelName.]
ifFalse: [bar bottomCaption: vector labelName.]].
self add: bar]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ geometry
maxBarWidth

| calculatedMaxBarWidth minimumBarGap |

minimumBarGap := ((self data allDifferences: #x) reject: [:each | each = 0]) min.
calculatedMaxBarWidth := (self coordinateSystem xAxis normedMarkerLength) * minimumBarGap * self class maximumSizeFactor.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
"instance" : {
"add:" : "Nils Urban 6/13/2024 00:34",
"applyTheme:" : "Nils Urban 6/14/2024 15:28",
"barBottom" : "ds 6/19/2020 18:53",
"barBottom" : "JB 7/9/2024 15:42",
"barColor" : "ds 6/19/2020 18:53",
"barColor:" : "ds 6/19/2020 18:56",
"barLabelColor" : "ds 6/19/2020 18:53",
"barLabelColor:" : "ds 6/19/2020 18:56",
"barPositionFor:" : "ds 6/19/2020 18:53",
"barPositionFor:" : "JB 7/9/2024 15:42",
"barWidth" : "jvm 8/5/2020 11:58",
"barWidth:" : "ds 6/19/2020 18:54",
"bars" : "ds 6/19/2020 18:54",
"bars:" : "ds 6/19/2020 18:54",
"createBarsFrom:" : "Nils Urban 7/9/2024 11:36",
"createBarsFrom:" : "JB 7/9/2024 15:43",
"dataColor" : "PAR 8/6/2021 13:30",
"dynamicBarWidth" : "JB 6/19/2024 22:33",
"initialize" : "Nils Urban 7/8/2024 22:37",
"maxBarWidth" : "jk 7/31/2020 12:18",
"maxBarWidth" : "JB 7/9/2024 15:43",
"maxBottomCaptionHeight" : "Nils Urban 6/21/2024 17:03",
"needsCoordinateSystem" : "ds 6/19/2020 18:55",
"remove:" : "CK 5/14/2021 15:06",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ as yet unclassified
createDataPoint: aSWVector

| dataPoint |

dataPoint := SWDataPoint create: aSWVector at: (self coordinateSystem positionFor: aSWVector asPoint) size: (self scaledBubbleSize: (aSWVector third)).
dataPoint color: (self pointColor alpha: 0.7).

(aSWVector third > (self threshold)) ifTrue: [dataPoint height: 0. dataPoint width: 0].
(aSWVector third > self threshold)
ifTrue: [dataPoint height: 0. dataPoint width: 0].

^ dataPoint
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ as yet unclassified
initialize

super initialize.
self threshold: 0.
self pointColor: self class defaultColor.
self dataPoints: OrderedCollection new.
self maxValuesPerData: 1
self
threshold: 0;
pointColor: self class defaultColor;
dataPoints: OrderedCollection new;
maxValuesPerData: 1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
as yet unclassified
scaledBubbleSize: aSize

^ (aSize) / (self diagram globalMaximum: #z) * (self dynamicMaxBubbleSize)
^ aSize / (self diagram globalMaximum: #z) * self dynamicMaxBubbleSize
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"class" : {
"create" : "Nils Urban 6/13/2024 10:24" },
"instance" : {
"createDataPoint:" : "JB 6/19/2024 21:45",
"createDataPoint:" : "JB 7/9/2024 15:55",
"data:" : "Nils Urban 7/8/2024 22:38",
"diagram:" : "Nils Urban 6/21/2024 15:20",
"dynamicMaxBubbleSize" : "Nils Urban 6/21/2024 14:48",
"initialize" : "Nils Urban 6/21/2024 15:11",
"initialize" : "JB 7/9/2024 15:57",
"maxValuesPerData" : "Nils Urban 7/8/2024 22:38",
"maxValuesPerData:" : "Nils Urban 6/21/2024 14:48",
"receiveValue:" : "Nils Urban 7/8/2024 22:38",
"scaledBubbleSize:" : "Nils Urban 6/21/2024 15:23",
"scaledBubbleSize:" : "JB 7/9/2024 15:57",
"threshold" : "Nils Urban 7/8/2024 22:38",
"threshold:" : "Nils Urban 6/13/2024 11:20" } }
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
instance creation
create

|coordinateSystem|

coordinateSystem := SWCartesianCoordinateSystem createAt: self defaultStartPoint
xMin: self defaultMin
xMax: self defaultMax
Expand All @@ -14,4 +14,4 @@ create
boundsThreshold: self defaultBoundsThreshold.
coordinateSystem percentageBased: false.

^ coordinateSystem
^ coordinateSystem
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ instance creation
createAt: startPoint xMin: xMin xMax: xMax xStep: xStep xLength: xLength yMin: yMin yMax: yMax yStep: yStep yLength: yLength boundsThreshold: boundsThreshold

| xAxis yAxis |

xAxis := SWAxis createAt: startPoint withMin: xMin length: xLength withMax: xMax step: xStep orientation: #horizontal.
yAxis := SWAxis createAt: startPoint withMin: yMin length: yLength withMax: yMax step: yStep orientation: #vertical.

Expand All @@ -15,4 +14,4 @@ createAt: startPoint xMin: xMin xMax: xMax xStep: xStep xLength: xLength yMin: y
centeredAxes: false;
setProperty: #indicateKeyboardFocus toValue: #never;
color: SWCoordinateSystem defaultColor;
yourself
yourself
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ geometry
axisPadding

| paddedMaximumX paddedMaximumY paddingFactorX paddingFactorY|

paddingFactorX := self class defaultAxisValuePaddingFactor.
paddingFactorY := (percentageBased) ifTrue: 1.0 ifFalse: self class defaultAxisValuePaddingFactor.
paddingFactorY := (percentageBased)
ifTrue: 1.0 ifFalse: self class defaultAxisValuePaddingFactor.
paddedMaximumX := (self xAxis maximum * paddingFactorX) ceiling.
paddedMaximumY := ( self yAxis maximum * paddingFactorY) ceiling.

self xAxis maximum: paddedMaximumX.
self yAxis maximum: paddedMaximumY



self yAxis maximum: paddedMaximumY
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ geometry
extent: aPoint

super extent: aPoint.

(self xAxis notNil and: [self yAxis notNil])
ifTrue: [self update]
(self xAxis notNil and: (self yAxis notNil))
ifTrue: [self update]
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ geometry
positionFor: aPoint

| origin relativeOffset |

origin := ((self startPoint x - self minimumOffsetX) @ (self startPoint y + self minimumOffsetY)).
relativeOffset := ((self xAxis positionForValue: aPoint x) @ ((self yAxis positionForValue: aPoint y) negated)).

^ origin + relativeOffset
^ origin + relativeOffset
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ accessing
rangeForDimension: aDimension

| range globalMax globalMin |

(self diagram charts)
ifEmpty: [^ SWAxisRange from: SWAxis defaultMin to: SWAxis defaultMax].

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
startPoint

^ ((self bounds origin x + (self boundsThreshold x / 2)) @ (self bounds corner y - (self boundsThreshold y / 2)))
^ (self bounds origin x + (self boundsThreshold x / 2)) @ (self bounds corner y - (self boundsThreshold y / 2))
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ updating
updateRanges

| rangeX rangeY |

rangeX := self rangeForDimension: #x.
rangeY := self rangeForDimension: #y.

self updateMinX: rangeX min minY: rangeY min.
self updateMaxX: rangeX max maxY: rangeY max
self updateMaxX: rangeX max maxY: rangeY max
Loading

0 comments on commit bd8769d

Please sign in to comment.