Skip to content

Commit

Permalink
Pair-programming with Milton
Browse files Browse the repository at this point in the history
  • Loading branch information
olekscode committed Aug 30, 2023
1 parent 39477ad commit 9facbcf
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 52 deletions.
93 changes: 43 additions & 50 deletions repository/Cormas-UI-Roassal3/CMR3ChartDiagram.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ CMR3ChartDiagram class >> owner: anOwningPresenter on: aDomainObject [

^ self basicNew
owner: anOwningPresenter;
setModelBeforeInitialization: aDomainObject;
initialize;
setModel: aDomainObject;
yourself
]

Expand All @@ -32,9 +32,9 @@ CMR3ChartDiagram >> addAZeroDataSet [
initialPlot
x: xValue
y: { 0 };
color: Color blue "trans".
color: Color blue.

self chartBuilder
chartBuilder
maxValueX: self newMaxX;
addPlot: initialPlot;
renderIn: self canvas.
Expand All @@ -57,7 +57,7 @@ CMR3ChartDiagram >> addControllers: aCanvas [
CMR3ChartDiagram >> addDataSet [
" Private - The receiver was opened but the model already has simulation data. Replicate into the diagram "

self chartBuilder maxValueX: self cormasModel timeStep.
chartBuilder maxValueX: self cormasModel timeStep.
self updateYAxis.

self updateProbes.
Expand All @@ -67,7 +67,6 @@ CMR3ChartDiagram >> addDataSet [
CMR3ChartDiagram >> chartBuilder [

^ chartBuilder
ifNil: [ chartBuilder := self newChartBuilder ]
]

{ #category : #accessing }
Expand All @@ -76,13 +75,14 @@ CMR3ChartDiagram >> chartBuilder: anObject [
chartBuilder := anObject
]

{ #category : #initialization }
{ #category : #private }
CMR3ChartDiagram >> configureCanvas: canvas [
canvas shapes first borderColor: Color black.
canvas shapes
reject: [ :each | each class = RSPolyline or: [ each class = RSBox ] ]"there are plots"
thenDo: [ :each | each color: Color black ].
"we need css"

| interaction |
interaction := RSCanvasController new.
interaction noLegend.
canvas addInteraction: interaction
]

{ #category : #accessing }
Expand Down Expand Up @@ -120,6 +120,12 @@ CMR3ChartDiagram >> detectMaxProbeValue [

]

{ #category : #initialization }
CMR3ChartDiagram >> initialize [
super initialize.
chartBuilder := self newChartBuilder.
]

{ #category : #defaults }
CMR3ChartDiagram >> maxYValue [
" Private - Answer a <Number> of the maximum value for the Y axis in the receiver "
Expand All @@ -138,34 +144,28 @@ CMR3ChartDiagram >> minYValue [
]

{ #category : #'accessing - chart' }
CMR3ChartDiagram >> newBasicChartBuilder [
" Private - Answer a new <RSChart> with the basic decorations and settings "

CMR3ChartDiagram >> newChartBuilder [
" Private - Answer a new <RSChart> with ticksAssoc as the number of X ticks"
^ RSChart new
extent: 400@300;
padding: 5;
addDecoration: self newHorizontalTick;
addDecoration: self newVerticalTick;
addDecoration: (RSXLabelDecoration new title: 'Time'; offset: 0 @ self newMaxX);
"addDecoration: (RSYLabelDecoration new title: 'Value'; offset: 0 @ 0);"
addDecoration: (RSXLabelDecoration new
in: [ :label | label baseShape color: Color black ];
title: 'Time';
fontSize: 12);
minValueY: self minYValue;
maxValueY: self maxYValue;
yourself.
]

{ #category : #'accessing - chart' }
CMR3ChartDiagram >> newChartBuilder [
" Private - Answer a new <RSChart> with ticksAssoc as the number of X ticks"

^ self newBasicChartBuilder
]

{ #category : #'accessing - ticks' }
CMR3ChartDiagram >> newHorizontalTick [
" Answer a new <RSHorizontalTick> with default or applied settings "

^ RSHorizontalTick new
integer;
fontSize: 10;
numberOfTicks: 10;
yourself.
]
Expand All @@ -182,8 +182,8 @@ CMR3ChartDiagram >> newVerticalTick [
" Answer a new <RSVerticalTick> with default or applied settings "

^ RSVerticalTick new
doNotUseNiceLabel;
numberOfTicks: 10;
fontSize: 10;
yourself.
]

Expand Down Expand Up @@ -222,26 +222,22 @@ CMR3ChartDiagram >> probeYValuesAt: x in: probeValues [
^ probeValues at: x + 1
]

{ #category : #callbacks }
CMR3ChartDiagram >> refreshProbesChart [
" Private - A probe has been selected/deselected. Update the receiver including the Y Axis "

self removeAllElements.
self chartBuilder plots removeAll.
self canvas signalUpdate.
self updateYAxis.
self updateProbes
]

{ #category : #initialization }
{ #category : #rendering }
CMR3ChartDiagram >> renderIn: canvas [

| chart |
chart := self newBasicChartBuilder.
self probeLines do: [ :linePlot | chart addPlot: linePlot ].
chart plots ifNotEmpty: [ chart renderIn: canvas. ].
| group interaction |
chartBuilder := self newChartBuilder.

self probeLines do: [ :linePlot | chartBuilder addPlot: linePlot ].
group := RSGroup new.
chartBuilder plots
ifNotEmpty: [ chartBuilder renderIn: group. ].

self configureCanvas: canvas
canvas addAll: group.
self configureCanvas: canvas.

interaction := RSCanvasController new.
interaction noLegend.
canvas addInteraction: interaction.
]

{ #category : #'accessing - chart' }
Expand All @@ -259,7 +255,7 @@ CMR3ChartDiagram >> selectedProbes [
]

{ #category : #'accessing - model' }
CMR3ChartDiagram >> setModelBeforeInitialization: aDomainObject [
CMR3ChartDiagram >> setModel: aDomainObject [
" Private - See superimplementor's comment "

cormasModel := aDomainObject.
Expand All @@ -280,20 +276,17 @@ CMR3ChartDiagram >> setModelBeforeInitialization: aDomainObject [
CMR3ChartDiagram >> timeChanged: aNewTimeStep [

newMaxX := aNewTimeStep.
self refresh.
"self removeAllElements.
self chartBuilder maxValueX: newMaxX + 1.
chartBuilder maxValueX: newMaxX + 1.
self updateYAxis.
self updateProbes."
self updateProbes.

self refresh.
]

{ #category : #'accessing - chart' }
CMR3ChartDiagram >> updateProbes [

| probesToDisplay |
self halt.
"probesToDisplay := self cormasModelClass activeProbes asOrderedCollection.
(self owner selectedProbes hasEqualElements: probesToDisplay)
ifFalse: [ probesToDisplay addAll: (self selectedProbes difference: probesToDisplay) ]."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ CMSpChartOptionsPresenter >> probesMinMaxOptionsPresenter: anObject [
{ #category : #callbacks }
CMSpChartOptionsPresenter >> refreshProbesChart [
" Private - See comment in #refreshProbesChart "

self roassalChartPresenter refreshProbesChart.
self roassalChartPresenter refresh.
"self roassalChartPresenter refreshProbesChart"

]

Expand Down

0 comments on commit 9facbcf

Please sign in to comment.