3150
|
1 |
"{ Package: 'stx:libwidg2' }"
|
|
2 |
|
4851
|
3 |
"{ NameSpace: Smalltalk }"
|
|
4 |
|
741
|
5 |
GraphColumnView subclass:#GraphColumnView2D
|
750
|
6 |
instanceVariableNames:'colorMap gridXoffset gridX gridY actionBlock doubleClickBlock
|
|
7 |
buttonReleaseBlock menuAccessBlock'
|
741
|
8 |
classVariableNames:''
|
|
9 |
poolDictionaries:''
|
|
10 |
category:'Views-Graphs'
|
|
11 |
!
|
|
12 |
|
750
|
13 |
!GraphColumnView2D class methodsFor:'documentation'!
|
|
14 |
|
|
15 |
documentation
|
|
16 |
"
|
|
17 |
The class provides all the functionality for showing, scrolling and manipulating graphs
|
|
18 |
described through to a GraphColumn description. Each change in a graph description
|
|
19 |
immediately take affect.
|
|
20 |
|
|
21 |
|
|
22 |
[See also:]
|
3150
|
23 |
GraphColumn
|
|
24 |
GraphColumnView
|
|
25 |
GraphColumnView3D
|
750
|
26 |
|
|
27 |
[Author:]
|
3150
|
28 |
Claus Atzkern
|
750
|
29 |
"
|
|
30 |
|
|
31 |
|
|
32 |
! !
|
741
|
33 |
|
|
34 |
!GraphColumnView2D class methodsFor:'defaults'!
|
|
35 |
|
|
36 |
gridStep
|
|
37 |
^ 8
|
|
38 |
! !
|
|
39 |
|
|
40 |
!GraphColumnView2D class methodsFor:'examples'!
|
|
41 |
|
4903
|
42 |
test0
|
|
43 |
"testing references and actions
|
|
44 |
|
|
45 |
start with:
|
|
46 |
self test0
|
|
47 |
"
|
|
48 |
|top col view x|
|
|
49 |
|
|
50 |
top := StandardSystemView extent:800 @ 400.
|
|
51 |
view := GraphColumnView2D origin:0@0 extent:1.0@1.0 in:top.
|
|
52 |
|
|
53 |
top label:'2D-View'.
|
|
54 |
|
|
55 |
col := GraphColumn name:' sqrt(x) '.
|
|
56 |
col relativeXaxis:0.5.
|
|
57 |
col lineStyle:#solid.
|
|
58 |
|
|
59 |
col hLineStyle:#dashed.
|
|
60 |
col hLineList:#( 0 ).
|
|
61 |
col scaleY:40.
|
|
62 |
|
|
63 |
col functionYblock:[:start :array|
|
|
64 |
x := 0.001.
|
|
65 |
1 to:(array size) do:[:i| array at:i put:(x ln - (0.1*x)). x := x + 0.1 ].
|
|
66 |
array
|
|
67 |
].
|
|
68 |
|
|
69 |
view showDefaultMenu:true.
|
|
70 |
view showGrid:true.
|
|
71 |
view columns:{ col }.
|
|
72 |
top openAndWait.
|
|
73 |
!
|
|
74 |
|
741
|
75 |
test1
|
754
|
76 |
"testing references and actions
|
741
|
77 |
|
|
78 |
start with:
|
3150
|
79 |
self test1
|
741
|
80 |
"
|
|
81 |
|top list view x|
|
|
82 |
|
|
83 |
top := StandardSystemView extent:800 @ 400.
|
|
84 |
view := GraphColumnView2D origin:0@0 extent:1.0@1.0 in:top.
|
|
85 |
list := OrderedCollection new.
|
|
86 |
|
|
87 |
top label:'2D-View'.
|
|
88 |
|
|
89 |
#( 0.25 0.5 0.75 ) keysAndValuesDo:[:aKey :xAxis||aCol|
|
3150
|
90 |
aCol := GraphColumn name:aKey.
|
|
91 |
aCol relativeXaxis:xAxis.
|
741
|
92 |
|
3150
|
93 |
xAxis ~= 0.5 ifTrue:[
|
|
94 |
xAxis < 0.5 ifTrue:[
|
|
95 |
aCol foregroundColor:(Color red).
|
|
96 |
] ifFalse:[
|
|
97 |
aCol foregroundColor:(Color blue).
|
|
98 |
aCol lineStyle:#dashed
|
|
99 |
]
|
|
100 |
].
|
|
101 |
aCol hLineStyle:#dashed.
|
|
102 |
aCol hLineList:#( 0 ).
|
|
103 |
aCol scaleY:40.
|
741
|
104 |
|
3150
|
105 |
aCol functionYblock:[:start :array|
|
|
106 |
x := (start - 1) * 0.2.
|
|
107 |
1 to:(array size) do:[:i| array at:i put:(x sin). x := x + 0.2 ].
|
|
108 |
array
|
|
109 |
].
|
|
110 |
list add:aCol.
|
741
|
111 |
].
|
|
112 |
|
|
113 |
view action:[:column :indexX :deltaY|
|
3150
|
114 |
Transcript showCR:'SINGLE CLICK:'.
|
741
|
115 |
|
3150
|
116 |
Transcript showCR:' column: ', column printString,
|
|
117 |
' indexX: ', indexX printString,
|
|
118 |
' deltaY: ', deltaY printString.
|
741
|
119 |
|
3150
|
120 |
view referenceAdd:indexX
|
741
|
121 |
].
|
|
122 |
|
|
123 |
view doubleClickAction:[:column :indexX :deltaY|
|
3150
|
124 |
Transcript showCR:'DOUBLE CLICK:'.
|
741
|
125 |
|
3150
|
126 |
Transcript showCR:' column: ', column printString,
|
|
127 |
' indexX: ', indexX printString,
|
|
128 |
' deltaY: ', deltaY printString.
|
741
|
129 |
].
|
|
130 |
view showDefaultMenu:true.
|
|
131 |
view showGrid:true.
|
|
132 |
view columns:list.
|
|
133 |
top openAndWait.
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
!
|
|
138 |
|
|
139 |
test2
|
|
140 |
"testing models and change notifications
|
|
141 |
|
|
142 |
start with:
|
3150
|
143 |
self test2
|
741
|
144 |
"
|
3150
|
145 |
|top list cols listView graph red blue yellow sav pause time
|
750
|
146 |
label butAct button b1 b2|
|
741
|
147 |
|
|
148 |
top := StandardSystemView extent:950 @ 400.
|
750
|
149 |
listView := ListView origin:0.0@20 corner:150@1.0 in:top.
|
741
|
150 |
graph := GraphColumnView2D origin:150@0 corner:1.0@1.0 in:top.
|
750
|
151 |
listView level:1.
|
|
152 |
(Label origin:2@2 in:top) label:'Delay:'.
|
|
153 |
|
|
154 |
time := 0.1.
|
|
155 |
label := Label origin:82@1 corner:128@19 in:top.
|
|
156 |
label sizeFixed:true.
|
|
157 |
label label:(time printString).
|
|
158 |
label level:1.
|
|
159 |
|
|
160 |
butAct := [:dT| time := (time + dT) max:0.0. label label:(time printString) ].
|
|
161 |
|
|
162 |
button := (ArrowButton leftIn:top) origin:60@0 extent:20@20.
|
|
163 |
button action:[butAct value:-0.05].
|
|
164 |
button autoRepeat:true.
|
|
165 |
button := (ArrowButton rightIn:top) origin:130@0 extent:20@20.
|
|
166 |
button action:[butAct value:0.05].
|
|
167 |
button autoRepeat:true.
|
|
168 |
|
|
169 |
|
741
|
170 |
cols := OrderedCollection new.
|
|
171 |
list := List new.
|
|
172 |
|
|
173 |
top label:'Testing 2D-View: Models & Style'.
|
|
174 |
|
|
175 |
listView list:OrderedCollection new.
|
|
176 |
graph showGrid:true.
|
|
177 |
graph listHolder:list.
|
|
178 |
top openAndWait.
|
|
179 |
|
|
180 |
#( 0.2 0.8 ) keysAndValuesDo:[:aKey :xAxis||aCol x|
|
3150
|
181 |
aCol := GraphColumn name:'Column <', aKey printString, '>'.
|
|
182 |
aCol relativeXaxis:xAxis.
|
|
183 |
aCol hLineFgColor:(Color blue).
|
|
184 |
aCol scaleY:40.
|
|
185 |
aCol hLineStyle:#dashed.
|
741
|
186 |
|
3150
|
187 |
aCol functionYblock:[:start :array|
|
|
188 |
x := (start - 1) * 0.2.
|
|
189 |
1 to:(array size) do:[:i| array at:i put:(x sin). x := x + 0.2 ].
|
|
190 |
array
|
|
191 |
].
|
|
192 |
cols add:aCol.
|
741
|
193 |
].
|
|
194 |
|
|
195 |
red := Color red.
|
|
196 |
blue := Color blue.
|
|
197 |
yellow := Color yellow lightened.
|
750
|
198 |
|
741
|
199 |
pause := [ |l|
|
3150
|
200 |
l := listView list.
|
|
201 |
l size > 500 ifTrue:[l removeFromIndex:1 toIndex:400. listView list:l].
|
|
202 |
listView scrollToBottom.
|
750
|
203 |
|
3150
|
204 |
(top realized and:[time > 0]) ifTrue:[Delay waitForSeconds:time] ].
|
741
|
205 |
|
805
|
206 |
[ [top realized] whileTrue:[
|
3150
|
207 |
listView add:'ADD COLUMNS'.
|
|
208 |
cols do:[:el|
|
|
209 |
listView add:( ' ', el printString ).
|
|
210 |
list add:el.
|
|
211 |
pause value
|
|
212 |
].
|
741
|
213 |
|
3150
|
214 |
listView add:( 'GRAPH' ).
|
|
215 |
listView add:( ' Background' ).
|
|
216 |
sav := graph backgroundColor.
|
|
217 |
graph backgroundColor:yellow.
|
|
218 |
pause value.
|
|
219 |
graph backgroundColor:sav.
|
|
220 |
sav := graph foregroundColor.
|
|
221 |
listView add:( ' Foreground' ).
|
|
222 |
graph foregroundColor:blue.
|
|
223 |
pause value.
|
|
224 |
graph foregroundColor:sav.
|
741
|
225 |
|
3150
|
226 |
listView add:( 'GRID' ).
|
|
227 |
listView add:( ' Grid X' ).
|
|
228 |
graph gridExtent:(4 @ 0).
|
|
229 |
pause value.
|
|
230 |
listView add:( ' Grid Y' ).
|
|
231 |
graph gridExtent:(0 @ 4).
|
|
232 |
pause value.
|
|
233 |
listView add:( ' Grid X/Y' ).
|
|
234 |
graph gridExtent:(8 @ 8).
|
|
235 |
pause value.
|
|
236 |
listView add:( ' Color' ).
|
|
237 |
sav := graph gridColor.
|
|
238 |
graph gridColor:yellow.
|
|
239 |
pause value.
|
|
240 |
graph gridColor:sav.
|
|
241 |
listView add:( ' Off' ).
|
|
242 |
graph showGrid:false.
|
|
243 |
pause value.
|
|
244 |
listView add:( ' On' ).
|
|
245 |
graph showGrid:true.
|
741
|
246 |
|
3150
|
247 |
listView add:( 'REFERENCES' ).
|
|
248 |
listView add:( ' Add' ).
|
|
249 |
#( 7 15 43 90 ) do:[:i| graph referenceAdd:i. pause value].
|
|
250 |
top realized ifTrue:[Delay waitForSeconds:time].
|
|
251 |
sav := graph referenceColor.
|
|
252 |
listView add:( ' Color' ).
|
|
253 |
graph referenceColor:blue.
|
|
254 |
pause value.
|
|
255 |
graph referenceColor:sav.
|
|
256 |
listView add:( ' Remove' ).
|
|
257 |
#( 7 15 43 90 ) do:[:i| graph referenceRemove:i. pause value ].
|
|
258 |
pause value.
|
741
|
259 |
|
3150
|
260 |
listView add:'REMOVE COLUMNS'.
|
|
261 |
[list notEmpty] whileTrue:[
|
|
262 |
listView add:( ' ', list removeFirst printString ).
|
|
263 |
pause value
|
|
264 |
].
|
|
265 |
].
|
741
|
266 |
|
|
267 |
] forkAt:1.
|
|
268 |
|
|
269 |
|
|
270 |
!
|
|
271 |
|
|
272 |
test3
|
|
273 |
"testing models and change notifications
|
|
274 |
|
|
275 |
start with:
|
3150
|
276 |
self test3
|
741
|
277 |
"
|
|
278 |
|top list slices index view graph column actLbl tmOut button bAction tmLbl title pause toggle auto next|
|
|
279 |
|
|
280 |
top := StandardSystemView extent:800 @ 400.
|
|
281 |
view := View origin:0@0 corner:1.0@28 in:top.
|
|
282 |
graph := GraphColumnView2D origin:0@28 corner:1.0@1.0 in:top.
|
|
283 |
list := OrderedCollection new.
|
|
284 |
top label:'Testing 2D-View: Model-Column'.
|
|
285 |
|
|
286 |
slices := #( ( foregroundColor #color )
|
3150
|
287 |
( lineStyle #dashed )
|
|
288 |
( lineWidth 4 )
|
741
|
289 |
|
3150
|
290 |
( hLineFgColor #color )
|
|
291 |
( hLineStyle #dashed )
|
|
292 |
( hLineWidth 4 )
|
|
293 |
( hLineList #( -0.8 -0.5 0 0.5 0.8 ) )
|
741
|
294 |
|
3150
|
295 |
( shown false )
|
|
296 |
( scaleY 10 )
|
|
297 |
( transY 20 )
|
|
298 |
( relativeXaxis 0.2 )
|
|
299 |
).
|
741
|
300 |
|
|
301 |
|
|
302 |
column := GraphColumn name:'test'.
|
|
303 |
column relativeXaxis:0.5.
|
|
304 |
column scaleY:40.
|
|
305 |
column hLineList:#( -1 1 ).
|
|
306 |
column functionYblock:[:start :array||x|
|
3150
|
307 |
x := (start - 1) * 0.2.
|
|
308 |
1 to:(array size) do:[:i| array at:i put:(x sin). x := x + 0.2 ].
|
|
309 |
array
|
741
|
310 |
].
|
|
311 |
tmOut := 1.0.
|
|
312 |
auto := true.
|
|
313 |
index := 1.
|
|
314 |
next := false.
|
|
315 |
|
|
316 |
view level:1.
|
|
317 |
|
|
318 |
toggle := CheckBox origin:0@0.0 corner:100@1.0 in:view.
|
|
319 |
toggle label:'Auto/Step'.
|
|
320 |
toggle turnOn.
|
|
321 |
toggle action:[:aState|
|
3150
|
322 |
(next := auto := aState) ifTrue:[
|
|
323 |
title label:'Time: '.
|
|
324 |
tmLbl label:(tmOut printString).
|
|
325 |
] ifFalse:[
|
|
326 |
title label:'Step: '.
|
|
327 |
tmLbl label:(index printString).
|
|
328 |
]
|
741
|
329 |
].
|
|
330 |
|
|
331 |
title := Label origin:100@0.0 corner:160@1.0 in:view.
|
|
332 |
title adjust:#right.
|
|
333 |
title sizeFixed:true.
|
|
334 |
title label:'Time: '.
|
|
335 |
|
|
336 |
bAction := [:add|
|
3150
|
337 |
auto ifTrue:[
|
|
338 |
tmOut := (tmOut + (add ifTrue:[0.1] ifFalse:[-0.1])) max:0.1.
|
|
339 |
tmLbl label:(tmOut printString).
|
|
340 |
] ifFalse:[
|
|
341 |
add ifTrue:[
|
|
342 |
(index := index + 1) > slices size ifTrue:[index := 1]
|
|
343 |
] ifFalse:[
|
|
344 |
(index := index - 1) < 1 ifTrue:[index := slices size]
|
|
345 |
].
|
|
346 |
tmLbl label:(index printString).
|
|
347 |
next := true.
|
|
348 |
]
|
741
|
349 |
].
|
|
350 |
|
|
351 |
button := ArrowButton leftIn:view.
|
|
352 |
button origin:160@0.0 corner:180@1.0.
|
|
353 |
button autoRepeat:true.
|
|
354 |
button pressAction:[ bAction value:false ].
|
|
355 |
|
|
356 |
button := ArrowButton rightIn:view.
|
|
357 |
button origin:181@0.0 corner:201@1.0.
|
|
358 |
button autoRepeat:true.
|
|
359 |
button pressAction:[ bAction value:true ].
|
|
360 |
|
|
361 |
tmLbl := Label origin:202 @0.0 corner:230@1.0 in:view.
|
|
362 |
tmLbl adjust:#center.
|
|
363 |
tmLbl sizeFixed:true.
|
|
364 |
tmLbl label:(tmOut printString).
|
|
365 |
|
|
366 |
actLbl := Label origin:230 @0.0 corner:290@1.0 in:view.
|
|
367 |
actLbl sizeFixed:true.
|
|
368 |
actLbl adjust:#right.
|
|
369 |
actLbl label:'Action: '.
|
|
370 |
|
|
371 |
actLbl := Label origin:290 @0.0 corner:1.0@1.0 in:view.
|
|
372 |
actLbl adjust:#left.
|
|
373 |
view subViews do:[:v| v verticalInset:2 ].
|
|
374 |
|
|
375 |
graph gridExtent:( 4 @ 4 ).
|
|
376 |
graph showDefaultMenu:true.
|
|
377 |
graph listHolder:(Array with:column).
|
|
378 |
top openAndWait.
|
|
379 |
|
|
380 |
pause := [
|
3150
|
381 |
auto ifTrue:[
|
|
382 |
top realized ifTrue:[Delay waitForSeconds:tmOut]
|
|
383 |
] ifFalse:[
|
|
384 |
next := false.
|
741
|
385 |
|
3150
|
386 |
[(next not and:[top realized])] whileTrue:[
|
|
387 |
Delay waitForSeconds:0.2
|
|
388 |
]
|
|
389 |
]
|
741
|
390 |
].
|
|
391 |
|
|
392 |
[ |sav rsl wsl arg dsc|
|
|
393 |
|
3150
|
394 |
[top realized] whileTrue:[
|
741
|
395 |
|
3150
|
396 |
dsc := slices at:index.
|
741
|
397 |
|
3150
|
398 |
auto ifTrue:[
|
|
399 |
(index := index + 1) > slices size ifTrue:[
|
|
400 |
index := 1
|
|
401 |
]
|
|
402 |
].
|
|
403 |
rsl := dsc at:1.
|
|
404 |
wsl := (rsl, ':') asSymbol.
|
|
405 |
(arg := dsc at:2) == #color ifTrue:[arg := Color red].
|
|
406 |
sav := column perform:rsl.
|
741
|
407 |
|
3150
|
408 |
actLbl label:wsl printString, ' ', arg printString.
|
|
409 |
column perform:wsl with:arg.
|
|
410 |
pause value.
|
|
411 |
column perform:wsl with:sav.
|
|
412 |
]
|
741
|
413 |
|
|
414 |
] forkAt:1.
|
|
415 |
|
|
416 |
|
|
417 |
!
|
|
418 |
|
|
419 |
testRun
|
|
420 |
"running view
|
|
421 |
|
|
422 |
start with:
|
3150
|
423 |
self testRun
|
741
|
424 |
"
|
750
|
425 |
|top list view step x offs time lblX lblT lblC cbox halt xOrigin|
|
741
|
426 |
|
814
|
427 |
halt := false.
|
741
|
428 |
top := StandardSystemView extent:800 @ 400.
|
750
|
429 |
view := GraphColumnView2D origin:0@20 extent:1.0@1.0 in:top.
|
|
430 |
cbox := CheckBox origin:0@0.0 corner:50@20 in:top.
|
|
431 |
cbox label:'Stop'.
|
|
432 |
cbox action:[:v| halt := v].
|
|
433 |
xOrigin := 1 asValue.
|
|
434 |
|
|
435 |
lblX := Label origin:100@0.0 corner:0.4@20 in:top.
|
|
436 |
lblT := Label origin:0.4@0.0 corner:0.7@20 in:top.
|
|
437 |
lblC := Label origin:0.7@0.0 corner:1.0@20 in:top.
|
|
438 |
lblX level:1. lblX adjust:#left.
|
|
439 |
lblT level:1. lblT adjust:#left.
|
|
440 |
lblC level:1. lblC adjust:#left.
|
|
441 |
offs := 0.
|
741
|
442 |
step := 2.
|
|
443 |
list := OrderedCollection new.
|
|
444 |
|
|
445 |
top label:'Testing 2D-View: Performance Test'.
|
|
446 |
|
|
447 |
#( 0.25 0.5 0.75 ) do:[:xAxis||aCol|
|
3150
|
448 |
aCol := GraphColumn new.
|
|
449 |
aCol relativeXaxis:xAxis.
|
|
450 |
xAxis ~= 0.5 ifTrue:[
|
|
451 |
xAxis < 0.5 ifTrue:[aCol foregroundColor:(Color red)]
|
|
452 |
ifFalse:[aCol foregroundColor:(Color blue)]
|
|
453 |
].
|
|
454 |
aCol hLineStyle:#dashed.
|
|
455 |
aCol hLineList:#( 0 ).
|
|
456 |
aCol scaleY:40.
|
741
|
457 |
|
3150
|
458 |
aCol functionYblock:[:start :array|
|
|
459 |
x := start * 0.2.
|
|
460 |
1 to:(array size) do:[:i| array at:i put:(x sin). x := x + 0.2 ].
|
|
461 |
array
|
|
462 |
].
|
|
463 |
list add:aCol.
|
741
|
464 |
].
|
|
465 |
view showGrid:true.
|
|
466 |
view gridExtent:(4 @ 4).
|
|
467 |
view columns:list.
|
750
|
468 |
view windowSize:50.
|
|
469 |
view scrollUpdatesOriginX:true.
|
|
470 |
view graphOriginXHolder:xOrigin.
|
|
471 |
|
741
|
472 |
top openAndWait.
|
|
473 |
|
750
|
474 |
[ |tm total inc|
|
3150
|
475 |
inc := 0.
|
|
476 |
total := 0.
|
750
|
477 |
|
3150
|
478 |
[top realized] whileTrue:[
|
|
479 |
halt ifFalse:[
|
|
480 |
lblX label:('X-Offset: ', view graphOriginX printString).
|
|
481 |
lblT label:('Total Time: ', (total // 1000) printString, '::', (total \\ 1000) printString ).
|
|
482 |
lblC label:('Runs: ', inc printString).
|
750
|
483 |
|
3150
|
484 |
tm := Time millisecondsToRun:[
|
|
485 |
xOrigin value:(xOrigin value + step)
|
|
486 |
].
|
|
487 |
inc := inc + 1.
|
|
488 |
total := total + tm.
|
|
489 |
] ifTrue:[
|
|
490 |
Delay waitForSeconds:0.2
|
|
491 |
]
|
|
492 |
]
|
741
|
493 |
|
|
494 |
] forkAt:1.
|
|
495 |
! !
|
|
496 |
|
|
497 |
!GraphColumnView2D class methodsFor:'menu'!
|
|
498 |
|
|
499 |
defaultMenu
|
|
500 |
"this window spec was automatically generated by the ST/X MenuEditor"
|
|
501 |
|
|
502 |
"do not manually edit this - the builder may not be able to
|
|
503 |
handle the specification if its corrupted."
|
|
504 |
|
|
505 |
"
|
|
506 |
MenuEditor new openOnClass:GraphColumnView2D andSelector:#defaultMenu
|
|
507 |
(Menu new fromLiteralArrayEncoding:(GraphColumnView2D defaultMenu)) startUp
|
|
508 |
"
|
|
509 |
|
|
510 |
<resource: #menu>
|
|
511 |
|
|
512 |
^
|
805
|
513 |
|
741
|
514 |
#(#Menu
|
805
|
515 |
|
3150
|
516 |
#(
|
|
517 |
#(#MenuItem
|
|
518 |
#label: 'Show Grid'
|
|
519 |
#indication: #showGrid:
|
|
520 |
)
|
|
521 |
#(#MenuItem
|
|
522 |
#label: 'Show References'
|
|
523 |
#indication: #showReferences:
|
|
524 |
)
|
|
525 |
#(#MenuItem
|
|
526 |
#label: 'Grid Extent'
|
|
527 |
#enabled: #showGrid
|
|
528 |
#submenu:
|
|
529 |
#(#Menu
|
805
|
530 |
|
3150
|
531 |
#(
|
|
532 |
#(#MenuItem
|
|
533 |
#label: 'Extent'
|
|
534 |
#submenu:
|
|
535 |
#(#Menu
|
805
|
536 |
|
3150
|
537 |
#(
|
|
538 |
#(#MenuItem
|
|
539 |
#label: 'larger'
|
|
540 |
#value: #doGridExtent:
|
|
541 |
#argument: #larger
|
|
542 |
)
|
|
543 |
#(#MenuItem
|
|
544 |
#label: 'smaller'
|
|
545 |
#value: #doGridExtent:
|
|
546 |
#argument: #smaller
|
|
547 |
)
|
|
548 |
) nil
|
|
549 |
nil
|
|
550 |
)
|
|
551 |
)
|
|
552 |
#(#MenuItem
|
|
553 |
#label: 'X-Step'
|
|
554 |
#argument: #doGridStepX:
|
|
555 |
#submenuChannel: #gridStepMenuSelector:
|
|
556 |
)
|
|
557 |
#(#MenuItem
|
|
558 |
#label: 'Y-Step'
|
|
559 |
#argument: #doGridStepY:
|
|
560 |
#submenuChannel: #gridStepMenuSelector:
|
|
561 |
)
|
|
562 |
) nil
|
|
563 |
nil
|
|
564 |
)
|
|
565 |
)
|
|
566 |
#(#MenuItem
|
|
567 |
#label: 'Zoom Y'
|
|
568 |
#submenuChannel: #subMenuZoomY
|
|
569 |
)
|
|
570 |
#(#MenuItem
|
|
571 |
#label: 'Print'
|
|
572 |
#value: #doPrint
|
|
573 |
)
|
|
574 |
) nil
|
|
575 |
nil
|
741
|
576 |
)
|
805
|
577 |
|
|
578 |
|
741
|
579 |
!
|
|
580 |
|
|
581 |
gridStepMenuSelector:aSelector
|
|
582 |
|menu width height item bitmap|
|
|
583 |
|
|
584 |
menu := Menu new.
|
|
585 |
width := 40.
|
|
586 |
height := 10.
|
|
587 |
|
|
588 |
#( off 1 2 4 8 ) do:[:aNumberOrSymbol|
|
3150
|
589 |
item := MenuItem labeled:(aNumberOrSymbol printString).
|
|
590 |
item value:aSelector.
|
|
591 |
item argument:aNumberOrSymbol.
|
|
592 |
menu addItem:item.
|
741
|
593 |
].
|
|
594 |
^ menu
|
|
595 |
|
|
596 |
"
|
|
597 |
(self styleMenuSelector:#lineStyle) startUp
|
|
598 |
"
|
|
599 |
|
|
600 |
|
|
601 |
! !
|
|
602 |
|
|
603 |
!GraphColumnView2D methodsFor:'accessing actions'!
|
|
604 |
|
|
605 |
action
|
|
606 |
"action block which is performed on a single button click.
|
|
607 |
Number of arguments to the block can be 0 upto 4.
|
|
608 |
|
|
609 |
argument 1: nearest column to the click point
|
|
610 |
argument 2: the logical index (X)
|
|
611 |
argument 3: the distance y from the click point to the columns's graph
|
|
612 |
argument 4: physical y value
|
|
613 |
"
|
|
614 |
^ actionBlock
|
|
615 |
!
|
|
616 |
|
|
617 |
action:aBlockUpTo4Args
|
|
618 |
"action block which is performed on a single button click.
|
|
619 |
Number of arguments to the block can be 0 upto 4.
|
|
620 |
|
|
621 |
argument 1: nearest column to the click point
|
|
622 |
argument 2: the logical index (X)
|
|
623 |
argument 3: the distance y from the click point to the columns's graph
|
|
624 |
argument 4: physical y value
|
|
625 |
"
|
|
626 |
actionBlock := aBlockUpTo4Args
|
|
627 |
!
|
|
628 |
|
|
629 |
buttonReleaseBlock
|
|
630 |
"action block which is performed if the button is released; the number
|
|
631 |
of arguments to the block can be 0 upto 3.
|
|
632 |
|
|
633 |
argument 1: physical x value
|
|
634 |
argument 2: physical y value
|
|
635 |
argument 3: the logical index (X)
|
|
636 |
"
|
|
637 |
^ buttonReleaseBlock
|
|
638 |
!
|
|
639 |
|
|
640 |
buttonReleaseBlock:aThreeArgAction
|
|
641 |
"action block which is performed if the button is released; the number
|
|
642 |
of arguments to the block can be 0 upto 3.
|
|
643 |
|
|
644 |
argument 1: physical x value
|
|
645 |
argument 2: physical x value
|
|
646 |
argument 3: the logical index (X)
|
|
647 |
"
|
|
648 |
buttonReleaseBlock := aThreeArgAction
|
|
649 |
!
|
|
650 |
|
|
651 |
doubleClickAction
|
|
652 |
"action block which is performed on a double button click.
|
|
653 |
Number of arguments to the block can be 0 upto 4.
|
|
654 |
|
|
655 |
argument 1: nearest column to the click point
|
|
656 |
argument 2: the logical index (X)
|
|
657 |
argument 3: the distance y from the click point to the columns's graph
|
|
658 |
argument 4: physical y value
|
|
659 |
"
|
|
660 |
^ doubleClickBlock
|
|
661 |
!
|
|
662 |
|
|
663 |
doubleClickAction:aBlockUpTo4Args
|
|
664 |
"action block which is performed on a double button click.
|
|
665 |
Number of arguments to the block can be 0 upto 4.
|
|
666 |
|
|
667 |
argument 1: nearest column to the click point
|
|
668 |
argument 2: the logical index (X)
|
|
669 |
argument 3: the distance y from the click point to the columns's graph
|
|
670 |
argument 4: physical y value
|
|
671 |
"
|
|
672 |
doubleClickBlock := aBlockUpTo4Args
|
|
673 |
!
|
|
674 |
|
|
675 |
menuAccessBlock
|
|
676 |
"action block which is performed if a menu is required; if the block returns
|
|
677 |
nil, the default middlebutton menu is evaluated.
|
|
678 |
|
|
679 |
Number of arguments to the block can be 0 upto 4.
|
|
680 |
|
|
681 |
argument 1: nearest column to the click point
|
|
682 |
argument 2: the logical index (X)
|
|
683 |
argument 3: the distance y from the click point to the columns's graph
|
|
684 |
argument 4: physical y value
|
|
685 |
"
|
|
686 |
^ menuAccessBlock
|
|
687 |
!
|
|
688 |
|
|
689 |
menuAccessBlock:aBlockUpTo4Args
|
|
690 |
"action block which is performed if a menu is required; if the block returns
|
|
691 |
nil, the default middlebutton menu is evaluated.
|
|
692 |
|
|
693 |
Number of arguments to the block can be 0 upto 4.
|
|
694 |
|
|
695 |
argument 1: nearest column to the click point
|
|
696 |
argument 2: the logical index (X)
|
|
697 |
argument 3: the distance y from the click point to the columns's graph
|
|
698 |
argument 4: physical y value
|
|
699 |
"
|
|
700 |
menuAccessBlock:= aBlockUpTo4Args
|
|
701 |
! !
|
|
702 |
|
|
703 |
!GraphColumnView2D methodsFor:'accessing dimensions'!
|
|
704 |
|
|
705 |
gridExtent
|
750
|
706 |
"returns the x/y extent of the grid
|
741
|
707 |
"
|
|
708 |
^ gridX @ gridY
|
|
709 |
!
|
|
710 |
|
|
711 |
gridExtent:anExtent
|
|
712 |
"set the x/y extent of the grid
|
|
713 |
"
|
|
714 |
|gX gY|
|
|
715 |
|
|
716 |
anExtent isNil ifTrue:[
|
3150
|
717 |
gX := gY := 0
|
741
|
718 |
] ifFalse:[
|
3150
|
719 |
gX := (anExtent x) max:0.
|
|
720 |
gY := (anExtent y) max:0.
|
741
|
721 |
].
|
|
722 |
|
|
723 |
gridX == gX ifTrue:[
|
3150
|
724 |
self gridY:gY
|
741
|
725 |
] ifFalse:[
|
3150
|
726 |
gridY := gY.
|
|
727 |
self gridX:gX
|
741
|
728 |
]
|
|
729 |
!
|
|
730 |
|
|
731 |
gridX
|
750
|
732 |
"returns the horizontal size of the grid or 0 if the horizontal grid is disabled
|
741
|
733 |
"
|
|
734 |
^ gridX
|
|
735 |
!
|
|
736 |
|
|
737 |
gridX:aValue
|
750
|
738 |
"set the horizontal size of the grid or 0 if the horizontal grid should be invisible
|
741
|
739 |
"
|
|
740 |
|x|
|
|
741 |
|
|
742 |
x := self unsignedIntegerFrom:aValue onError:[gridX].
|
|
743 |
|
|
744 |
x ~~ gridX ifTrue:[
|
3150
|
745 |
gridX := x.
|
|
746 |
self doRecomputeGraph.
|
741
|
747 |
]
|
|
748 |
!
|
|
749 |
|
|
750 |
gridY
|
750
|
751 |
"returns the vertical size of the grid or 0 if the vertical grid is disabled
|
741
|
752 |
"
|
|
753 |
^ gridY
|
|
754 |
!
|
|
755 |
|
|
756 |
gridY:aValue
|
750
|
757 |
"set the vertical size of the grid or 0 if the vertical grid should be invisible
|
741
|
758 |
"
|
|
759 |
|y|
|
|
760 |
|
|
761 |
y := self unsignedIntegerFrom:aValue onError:[gridY].
|
|
762 |
|
|
763 |
y ~~ gridY ifTrue:[
|
3150
|
764 |
gridY := y.
|
|
765 |
self doRecomputeGraph
|
741
|
766 |
]
|
|
767 |
|
|
768 |
|
|
769 |
! !
|
|
770 |
|
|
771 |
!GraphColumnView2D methodsFor:'change & update'!
|
|
772 |
|
|
773 |
changedGraphIn:aColumn what:what from:oldValue
|
750
|
774 |
"the graph assigned to the column description changed
|
741
|
775 |
"
|
|
776 |
|widthC scaleY transY dataY stepX|
|
|
777 |
|
|
778 |
widthC := aColumn lineWidth.
|
|
779 |
scaleY := self scaleYofColumn:aColumn.
|
|
780 |
transY := self transYofColumn:aColumn.
|
|
781 |
stepX := self stepX.
|
|
782 |
dataY := self yDataForColumn:aColumn.
|
|
783 |
|
|
784 |
what == #lineWidth ifTrue:[
|
3150
|
785 |
widthC < oldValue ifTrue:[widthC := oldValue]
|
|
786 |
ifFalse:[widthC := nil]
|
741
|
787 |
] ifFalse:[
|
3150
|
788 |
(what ~~ #lineStyle or:[aColumn lineStyle == #solid]) ifTrue:[
|
|
789 |
widthC := nil
|
|
790 |
]
|
741
|
791 |
].
|
|
792 |
|
|
793 |
widthC notNil ifTrue:[
|
3150
|
794 |
self drawGRX:0
|
|
795 |
step:stepX
|
|
796 |
scaleY:scaleY
|
|
797 |
transY:transY
|
|
798 |
ydata:dataY
|
|
799 |
with:bgColor
|
|
800 |
style:#solid
|
|
801 |
width:widthC.
|
741
|
802 |
|
3150
|
803 |
what == #lineWidth ifTrue:[
|
|
804 |
^ self drawX:0 y:0 width:width height:height
|
|
805 |
]
|
741
|
806 |
].
|
|
807 |
|
|
808 |
self drawGRC:aColumn
|
3150
|
809 |
x:0
|
|
810 |
step:stepX
|
|
811 |
scaleY:scaleY
|
|
812 |
transY:transY
|
|
813 |
ydata:dataY.
|
741
|
814 |
|
|
815 |
|
|
816 |
|
|
817 |
|
|
818 |
|
|
819 |
|
|
820 |
|
|
821 |
|
|
822 |
|
|
823 |
|
|
824 |
|
|
825 |
|
|
826 |
|
|
827 |
!
|
|
828 |
|
|
829 |
changedHLineIn:aColumn what:what from:oldValue
|
750
|
830 |
"the horizontal lines assigned to the column description changed
|
741
|
831 |
"
|
|
832 |
|widthC scaleY transY list|
|
|
833 |
|
|
834 |
widthC := aColumn hLineWidth.
|
|
835 |
scaleY := self scaleYofColumn:aColumn.
|
|
836 |
transY := self transYofColumn:aColumn.
|
|
837 |
|
|
838 |
what == #hLineList ifTrue:[
|
3150
|
839 |
oldValue notNil ifTrue:[list := oldValue]
|
|
840 |
ifFalse:[widthC := nil].
|
741
|
841 |
] ifFalse:[
|
3150
|
842 |
(list := aColumn hLineList) isNil ifTrue:[
|
|
843 |
^ self
|
|
844 |
].
|
741
|
845 |
|
3150
|
846 |
what == #hLineWidth ifTrue:[
|
|
847 |
widthC < oldValue ifTrue:[widthC := oldValue]
|
|
848 |
ifFalse:[widthC := nil]
|
|
849 |
] ifFalse:[
|
|
850 |
(what ~~ #hLineStyle or:[aColumn hLineStyle == #solid]) ifTrue:[
|
|
851 |
widthC := nil
|
|
852 |
]
|
|
853 |
].
|
741
|
854 |
].
|
|
855 |
|
|
856 |
widthC notNil ifTrue:[
|
3150
|
857 |
self drawHLN:list
|
|
858 |
x:0
|
|
859 |
y:0
|
|
860 |
toX:width
|
|
861 |
y:height
|
|
862 |
scaleY:scaleY
|
|
863 |
transY:transY
|
|
864 |
with:bgColor
|
|
865 |
style:#solid
|
|
866 |
width:widthC.
|
741
|
867 |
|
3150
|
868 |
what ~~ #hLineStyle ifTrue:[
|
|
869 |
^ self drawX:0 y:0 width:width height:height
|
|
870 |
]
|
741
|
871 |
].
|
|
872 |
|
|
873 |
self drawHLC:aColumn
|
3150
|
874 |
x:0
|
|
875 |
y:0
|
|
876 |
toX:width
|
|
877 |
y:height
|
|
878 |
scaleY:scaleY
|
|
879 |
transY:transY.
|
741
|
880 |
|
|
881 |
! !
|
|
882 |
|
805
|
883 |
!GraphColumnView2D methodsFor:'displaying'!
|
|
884 |
|
|
885 |
displayOn:aGC
|
|
886 |
"ST-80 Compatibility
|
|
887 |
display the receiver in a graphicsContext at 0@0
|
|
888 |
- this method allows for any object to be displayed in some view
|
|
889 |
or on a printer
|
|
890 |
(although the fallBack is to display its printString ...)
|
|
891 |
"
|
|
892 |
self displayOn:aGC x:0 y:0
|
|
893 |
|
|
894 |
!
|
|
895 |
|
|
896 |
displayOn:aGC at:aPoint
|
|
897 |
"ST-80 Compatibility
|
|
898 |
display the receiver in a graphicsContext - this method allows
|
|
899 |
for any object to be displayed on a Printer - for example.
|
|
900 |
"
|
|
901 |
self displayOn:aGC x:(aPoint x) y:(aPoint y)
|
|
902 |
|
|
903 |
!
|
|
904 |
|
|
905 |
displayOn:aGC x:x y:y
|
|
906 |
"ST-80 Compatibility
|
|
907 |
display the receiver in a graphicsContext - this method allows
|
|
908 |
for any object to be displayed on a Printer - for example.
|
|
909 |
"
|
|
910 |
|w h|
|
|
911 |
|
|
912 |
w := aGC width - x.
|
|
913 |
h := aGC height - y.
|
|
914 |
|
|
915 |
(w > 0 and:[h > 0]) ifTrue:[
|
3150
|
916 |
self displayOn:aGC x:x y:y w:w h:(h min:height)
|
805
|
917 |
] ifFalse:[
|
3150
|
918 |
self halt
|
805
|
919 |
]
|
|
920 |
|
|
921 |
!
|
|
922 |
|
|
923 |
displayOn:aGC x:x y:y w:w h:h
|
|
924 |
|n s sX tY list yData maxX maxY oldClip oldTrans|
|
|
925 |
|
|
926 |
oldClip := aGC clippingRectangleOrNil.
|
|
927 |
oldTrans := aGC transformation.
|
|
928 |
|
|
929 |
sX := (w / (windowSize - 1)) asFloat.
|
|
930 |
aGC transformation:(WindowingTransformation scale:1 translation:(x @ y)).
|
|
931 |
aGC clippingRectangle:(Rectangle left:0 top:0 width:w height:h).
|
|
932 |
|
|
933 |
showGrid ifTrue:[
|
3150
|
934 |
aGC viewBackground ~= gridColor ifTrue:[
|
|
935 |
aGC paint:gridColor.
|
|
936 |
] ifFalse:[
|
|
937 |
aGC paint:(Color green lightened)
|
|
938 |
].
|
805
|
939 |
|
3150
|
940 |
gridX ~~ 0 ifTrue:[
|
|
941 |
s := gridX * self class gridStep.
|
|
942 |
n := 0.
|
|
943 |
[ n < w ] whileTrue:[ aGC displayLineFromX:n y:0 toX:n y:h. n := n + s ]
|
|
944 |
].
|
|
945 |
gridY > 0 ifTrue:[
|
|
946 |
s := gridY * self class gridStep.
|
|
947 |
n := 0.
|
|
948 |
[ n < h ] whileTrue:[ aGC displayLineFromX:0 y:n toX:w y:n. n := n + s ]
|
|
949 |
]
|
805
|
950 |
].
|
|
951 |
|
|
952 |
(list := self listOfVisibleRefIndices) isEmpty ifFalse:[
|
3150
|
953 |
aGC paint:referenceColor.
|
805
|
954 |
|
3150
|
955 |
list do:[:i||rX|
|
|
956 |
((rX := (i * sX) rounded) >= 0 and:[rX <= w]) ifTrue:[
|
|
957 |
aGC displayLineFromX:rX y:0 toX:rX y:h
|
|
958 |
]
|
|
959 |
]
|
805
|
960 |
].
|
|
961 |
yData := Array new:((w // sX + 2) min:windowSize).
|
|
962 |
aGC paint:fgColor.
|
|
963 |
|
|
964 |
self listOfVisibleColumns do:[:aCol|
|
3150
|
965 |
tY := zoomY * aCol zoomY.
|
|
966 |
tY := h * (aCol relativeXaxis) / tY + (aCol transY) * tY.
|
805
|
967 |
|
3150
|
968 |
aGC transformation:(WindowingTransformation scale:(sX @ (self scaleYofColumn:aCol))
|
|
969 |
translation:(x @ (y + tY))).
|
805
|
970 |
|
3150
|
971 |
(list := aCol hLineList) size ~~ 0 ifTrue:[
|
|
972 |
list do:[:y|
|
|
973 |
aGC paint:(aCol hLineFgColor ? fgColor).
|
|
974 |
aGC lineStyle:aCol hLineStyle.
|
|
975 |
aGC lineWidth:(aCol hLineWidth).
|
|
976 |
aGC displayLineFromX:0 y:y toX:(windowSize - 1) y:y.
|
|
977 |
]
|
|
978 |
].
|
805
|
979 |
|
3150
|
980 |
(aCol yValuesStartAt:graphOriginX into:yData) keysAndValuesDo:[:i :y|
|
|
981 |
yData at:i put:(i - 1 @ y)
|
|
982 |
].
|
|
983 |
aGC paint:(aCol foregroundColor ? fgColor).
|
|
984 |
aGC lineStyle:aCol lineStyle.
|
|
985 |
aGC lineWidth:(aCol lineWidth).
|
|
986 |
aGC displayPolygon:yData.
|
805
|
987 |
].
|
|
988 |
aGC transformation:oldTrans.
|
|
989 |
aGC clippingRectangle:oldClip.
|
|
990 |
aGC lineStyle:#solid.
|
|
991 |
aGC lineWidth:0.
|
|
992 |
aGC paint:fgColor.
|
|
993 |
aGC displayRectangleX:x y:y width:w height:h
|
|
994 |
|
|
995 |
|
|
996 |
|
|
997 |
!
|
|
998 |
|
|
999 |
doPrint
|
|
1000 |
"print the current visible contents on the printer
|
|
1001 |
"
|
|
1002 |
|printer w h|
|
|
1003 |
|
|
1004 |
(printer := Printer new) isNil ifTrue:[
|
3150
|
1005 |
self error:'cannot open printer'.
|
805
|
1006 |
^ self
|
|
1007 |
].
|
|
1008 |
|
|
1009 |
self withWaitCursorDo:[
|
3150
|
1010 |
Printer writeErrorSignal handle:[:ex |
|
|
1011 |
self warn:('error while printing:\\'
|
|
1012 |
, ex errorString
|
|
1013 |
, '\\(printing with: ' , (Printer printCommand) , ')') withCRs
|
|
1014 |
] do:[
|
|
1015 |
printer setNative:true.
|
|
1016 |
printer nextPutAll:'OriginalState setgstate'; cr.
|
|
1017 |
printer := PSGraphicsContext on:printer origin:(0 @ 0) corner:( 1.0 @ 1.0 ).
|
|
1018 |
w := printer width - printer rightMargin - printer leftMargin.
|
|
1019 |
h := printer height min:height.
|
|
1020 |
self displayOn:printer x:0 y:0 w:w h:h.
|
|
1021 |
].
|
|
1022 |
printer close
|
805
|
1023 |
].
|
|
1024 |
|
|
1025 |
|
|
1026 |
|
|
1027 |
! !
|
|
1028 |
|
741
|
1029 |
!GraphColumnView2D methodsFor:'drawing'!
|
|
1030 |
|
|
1031 |
clearColumnAndRedraw:aColumn
|
|
1032 |
"undraw a column and redraw the view without clearing the background
|
|
1033 |
"
|
|
1034 |
shown ifTrue:[
|
3150
|
1035 |
(self sensor hasDamageFor:self) ifTrue:[
|
|
1036 |
self invalidate
|
|
1037 |
] ifFalse:[
|
|
1038 |
self undrawColumn:aColumn
|
|
1039 |
scaleY:(self scaleYofColumn:aColumn)
|
|
1040 |
transY:(self transYofColumn:aColumn)
|
|
1041 |
]
|
741
|
1042 |
]
|
|
1043 |
!
|
|
1044 |
|
|
1045 |
redrawColumn:aColumn
|
|
1046 |
"redraw a column including the horizontal lines
|
|
1047 |
and the graph of the column
|
|
1048 |
"
|
|
1049 |
|transY scaleY stepX values|
|
|
1050 |
|
|
1051 |
(shown and:[aColumn shown]) ifTrue:[
|
3150
|
1052 |
scaleY := self scaleYofColumn:aColumn.
|
|
1053 |
transY := self transYofColumn:aColumn.
|
|
1054 |
stepX := self stepX.
|
741
|
1055 |
|
3150
|
1056 |
self drawHLC:aColumn
|
|
1057 |
x:0
|
|
1058 |
y:0
|
|
1059 |
toX:width
|
|
1060 |
y:height
|
|
1061 |
scaleY:scaleY
|
|
1062 |
transY:transY.
|
741
|
1063 |
|
3150
|
1064 |
self drawGRC:aColumn
|
|
1065 |
x:0
|
|
1066 |
step:stepX
|
|
1067 |
scaleY:scaleY
|
|
1068 |
transY:transY
|
|
1069 |
ydata:(self yDataForColumn:aColumn)
|
741
|
1070 |
]
|
|
1071 |
|
|
1072 |
|
|
1073 |
!
|
|
1074 |
|
|
1075 |
redrawColumnAt:anIndex
|
|
1076 |
"redraw a column at an index including the horizontal lines
|
|
1077 |
and the graph of the column
|
|
1078 |
"
|
|
1079 |
self redrawColumn:(columns at:anIndex)
|
|
1080 |
!
|
|
1081 |
|
|
1082 |
redrawX:x y:y width:w height:h
|
|
1083 |
"clear and redraw
|
|
1084 |
"
|
|
1085 |
shown ifTrue:[
|
3150
|
1086 |
self paint:bgColor.
|
|
1087 |
self fillRectangleX:x y:y width:w height:h.
|
|
1088 |
self drawX:x y:y width:w height:h.
|
741
|
1089 |
].
|
|
1090 |
! !
|
|
1091 |
|
|
1092 |
!GraphColumnView2D methodsFor:'drawing basics'!
|
|
1093 |
|
3150
|
1094 |
drawGRC:aColumn x:xStart step:xStep scaleY:yScale transY:yTrans ydata:yData
|
741
|
1095 |
"draw a graph
|
|
1096 |
"
|
|
1097 |
self drawGRX:xStart
|
3150
|
1098 |
step:xStep
|
|
1099 |
scaleY:yScale
|
|
1100 |
transY:yTrans
|
|
1101 |
ydata:yData
|
|
1102 |
with:(self mapColor:(aColumn foregroundColor))
|
|
1103 |
style:(aColumn lineStyle)
|
|
1104 |
width:(aColumn lineWidth)
|
741
|
1105 |
!
|
|
1106 |
|
|
1107 |
drawGRX:xStart step:xStep scaleY:yScale transY:yTrans ydata:ydata with:aColor style:aStyle width:aWidth
|
|
1108 |
"draw a graph
|
|
1109 |
"
|
3243
|
1110 |
"
|
|
1111 |
self test1
|
|
1112 |
"
|
|
1113 |
|xNext xLast yLast yNext|
|
|
1114 |
|
|
1115 |
ydata size == 0 ifTrue:[^ self].
|
|
1116 |
|
741
|
1117 |
self paint:aColor.
|
|
1118 |
self lineStyle:aStyle.
|
|
1119 |
self lineWidth:aWidth.
|
|
1120 |
|
3243
|
1121 |
ydata size == 0 ifTrue:[^ self].
|
|
1122 |
|
|
1123 |
xLast := xStart.
|
|
1124 |
yLast := (ydata at:1) * yScale + yTrans.
|
741
|
1125 |
|
3243
|
1126 |
ydata from:2 do:[:y |
|
|
1127 |
xNext := xLast + xStep.
|
|
1128 |
yNext := y * yScale + yTrans.
|
|
1129 |
self displayLineFromX:xLast rounded y:yLast rounded toX:xNext rounded y:yNext rounded.
|
|
1130 |
xLast := xNext.
|
|
1131 |
yLast := yNext.
|
|
1132 |
].
|
741
|
1133 |
!
|
|
1134 |
|
|
1135 |
drawHLC:aColumn x:x y:y toX:xMax y:yMax scaleY:yScale transY:yTrans
|
|
1136 |
"draw horizontal lines derrived from column
|
|
1137 |
"
|
|
1138 |
|list|
|
|
1139 |
|
|
1140 |
(list := aColumn hLineList) notNil ifTrue:[
|
3150
|
1141 |
self drawHLN:list
|
|
1142 |
x:x
|
|
1143 |
y:y
|
|
1144 |
toX:xMax
|
|
1145 |
y:yMax
|
|
1146 |
scaleY:yScale
|
|
1147 |
transY:yTrans
|
|
1148 |
with:(self mapColor:(aColumn hLineFgColor))
|
|
1149 |
style:(aColumn hLineStyle)
|
|
1150 |
width:(aColumn hLineWidth)
|
741
|
1151 |
].
|
|
1152 |
|
|
1153 |
|
|
1154 |
!
|
|
1155 |
|
|
1156 |
drawHLN:aList x:x y:y toX:xMax y:yMax scaleY:yScale transY:yTrans with:aColor style:aStyle width:aWidth
|
|
1157 |
"draw horizontal lines derrived from list
|
|
1158 |
"
|
|
1159 |
self paint:aColor.
|
|
1160 |
self lineStyle:aStyle.
|
|
1161 |
self lineWidth:aWidth.
|
|
1162 |
|
|
1163 |
aList do:[:hY||dY|
|
3150
|
1164 |
dY := (hY * yScale + yTrans) rounded.
|
741
|
1165 |
|
3150
|
1166 |
(dY < y or:[dY > yMax]) ifFalse:[
|
|
1167 |
self displayLineFromX:x y:dY toX:xMax y:dY.
|
|
1168 |
]
|
741
|
1169 |
].
|
|
1170 |
aStyle ~~ #solid ifTrue:[self lineStyle:#solid].
|
|
1171 |
aWidth ~~ 1 ifTrue:[self lineWidth:1].
|
|
1172 |
|
|
1173 |
|
|
1174 |
!
|
|
1175 |
|
754
|
1176 |
drawReferencesFromX:x0 y:y0 to:x1 y:y1
|
|
1177 |
"redraw visible references
|
750
|
1178 |
"
|
754
|
1179 |
|x stepX refLines|
|
750
|
1180 |
|
754
|
1181 |
refLines := self listOfVisibleRefIndices.
|
|
1182 |
|
|
1183 |
refLines notEmpty ifTrue:[
|
3150
|
1184 |
stepX := self stepX.
|
750
|
1185 |
|
3150
|
1186 |
self paint:referenceColor.
|
750
|
1187 |
|
3150
|
1188 |
refLines do:[:anIndex|
|
|
1189 |
x := (anIndex * stepX) rounded.
|
750
|
1190 |
|
3150
|
1191 |
(x >= x0 and:[x <= x1]) ifTrue:[
|
|
1192 |
self displayLineFromX:x y:y0 toX:x y:y1
|
|
1193 |
]
|
|
1194 |
]
|
750
|
1195 |
].
|
|
1196 |
!
|
|
1197 |
|
741
|
1198 |
drawX:x y:y width:w height:h
|
|
1199 |
"redraw without clearing the background
|
|
1200 |
"
|
750
|
1201 |
|saveClip yValues xStep xStart yScale yTrans
|
|
1202 |
xIndex "{ Class:SmallInteger }"
|
|
1203 |
x0 "{ Class:SmallInteger }"
|
|
1204 |
y0 "{ Class:SmallInteger }"
|
|
1205 |
xMax "{ Class:SmallInteger }"
|
|
1206 |
yMax "{ Class:SmallInteger }"
|
|
1207 |
step "{ Class:SmallInteger }"
|
|
1208 |
gstep "{ Class:SmallInteger }"
|
|
1209 |
start "{ Class:SmallInteger }"
|
|
1210 |
stop "{ Class:SmallInteger }"
|
741
|
1211 |
|
|
750
|
1212 |
xStep := self stepX.
|
741
|
1213 |
xMax := x + w.
|
|
1214 |
yMax := y + h.
|
750
|
1215 |
x0 := x // xStep.
|
741
|
1216 |
start := x0 + 1.
|
750
|
1217 |
stop := (xMax // xStep + 2) min:windowSize.
|
741
|
1218 |
|
|
1219 |
start < stop ifFalse:[^ self].
|
|
1220 |
|
|
1221 |
saveClip := clipRect.
|
|
1222 |
self clippingRectangle:(Rectangle left:x top:y width:w height:h).
|
|
1223 |
|
|
1224 |
showGrid ifTrue:[
|
3150
|
1225 |
self paint:gridColor.
|
|
1226 |
gstep := self class gridStep.
|
741
|
1227 |
|
|
1228 |
"/ X-Grid
|
3150
|
1229 |
gridX ~~ 0 ifTrue:[
|
|
1230 |
step := gridX * gstep.
|
|
1231 |
x0 := (x // step) * step + gridXoffset.
|
741
|
1232 |
|
3150
|
1233 |
[ x0 < xMax ] whileTrue:[
|
|
1234 |
self displayLineFromX:x0 y:y toX:x0 y:yMax.
|
|
1235 |
x0 := x0 + step.
|
|
1236 |
]
|
|
1237 |
].
|
741
|
1238 |
|
|
1239 |
"/ Y-Grid
|
3150
|
1240 |
gridY > 0 ifTrue:[
|
|
1241 |
step := gridY * gstep.
|
741
|
1242 |
|
3150
|
1243 |
y0 := (y // step) * step.
|
741
|
1244 |
|
3150
|
1245 |
[ y0 < yMax ] whileTrue:[
|
|
1246 |
self displayLineFromX:x y:y0 toX:xMax y:y0.
|
|
1247 |
y0 := y0 + step
|
|
1248 |
]
|
|
1249 |
]
|
741
|
1250 |
].
|
|
1251 |
|
|
1252 |
columns notNil ifTrue:[
|
3150
|
1253 |
xStart := start - 1 * xStep.
|
|
1254 |
xIndex := start - 1 + graphOriginX.
|
|
1255 |
yValues := Array new:(stop - start + 1).
|
741
|
1256 |
|
|
1257 |
"/ Column
|
3150
|
1258 |
columns do:[:aCol|
|
|
1259 |
aCol shown ifTrue:[
|
|
1260 |
yScale := self scaleYofColumn:aCol.
|
|
1261 |
yTrans := self transYofColumn:aCol.
|
741
|
1262 |
|
3150
|
1263 |
self drawHLC:aCol x:x y:y toX:xMax y:yMax scaleY:yScale transY:yTrans.
|
741
|
1264 |
|
3150
|
1265 |
self drawGRC:aCol x:xStart step:xStep scaleY:yScale transY:yTrans
|
|
1266 |
ydata:(aCol yValuesStartAt:xIndex into:yValues)
|
|
1267 |
]
|
|
1268 |
].
|
741
|
1269 |
|
|
1270 |
"/ V-Lines
|
3150
|
1271 |
self drawReferencesFromX:x y:y to:xMax y:yMax.
|
741
|
1272 |
].
|
|
1273 |
|
|
1274 |
self clippingRectangle:saveClip.
|
|
1275 |
!
|
|
1276 |
|
|
1277 |
undrawColumn:aColumn scaleY:scaleY transY:transY
|
|
1278 |
"undraw a column, than redraw all without clearing the background
|
|
1279 |
"
|
|
1280 |
|stepX hlines|
|
|
1281 |
|
|
1282 |
stepX := self stepX.
|
|
1283 |
|
|
1284 |
(hlines := aColumn hLineList) notNil ifTrue:[
|
3150
|
1285 |
self drawHLN:hlines
|
|
1286 |
x:0
|
|
1287 |
y:0
|
|
1288 |
toX:width
|
|
1289 |
y:height
|
|
1290 |
scaleY:scaleY
|
|
1291 |
transY:transY
|
|
1292 |
with:bgColor
|
|
1293 |
style:#solid
|
|
1294 |
width:(aColumn hLineWidth)
|
|
1295 |
].
|
741
|
1296 |
|
|
1297 |
self drawGRX:0
|
3150
|
1298 |
step:stepX
|
|
1299 |
scaleY:scaleY
|
|
1300 |
transY:transY
|
|
1301 |
ydata:(self yDataForColumn:aColumn)
|
|
1302 |
with:bgColor
|
|
1303 |
style:#solid
|
|
1304 |
width:(aColumn lineWidth).
|
741
|
1305 |
|
|
1306 |
self drawX:0 y:0 width:width height:height
|
|
1307 |
! !
|
|
1308 |
|
|
1309 |
!GraphColumnView2D methodsFor:'event handling'!
|
|
1310 |
|
|
1311 |
buttonMultiPress:button x:x y:y
|
|
1312 |
"handle a button double click event
|
|
1313 |
"
|
|
1314 |
((button == 1) or:[button == #select]) ifFalse:[
|
3150
|
1315 |
^ super buttonMultiPress:button x:x y:y
|
741
|
1316 |
].
|
|
1317 |
self buttonPressBlock:doubleClickBlock x:x y:y
|
|
1318 |
!
|
|
1319 |
|
|
1320 |
buttonPress:button x:x y:y
|
|
1321 |
"handle a button press event
|
|
1322 |
"
|
|
1323 |
|menu|
|
|
1324 |
|
|
1325 |
((button == 2) or:[button == #menu]) ifTrue:[
|
3150
|
1326 |
menu := self buttonPressBlock:menuAccessBlock x:x y:y.
|
741
|
1327 |
|
3150
|
1328 |
menu notNil ifTrue:[
|
|
1329 |
^ menu startUp
|
|
1330 |
]
|
741
|
1331 |
] ifFalse:[
|
3150
|
1332 |
((button == 1) or:[button == #select]) ifTrue:[
|
|
1333 |
^ self buttonPressBlock:actionBlock x:x y:y
|
|
1334 |
]
|
741
|
1335 |
].
|
|
1336 |
|
|
1337 |
super buttonPress:button x:x y:y
|
|
1338 |
!
|
|
1339 |
|
|
1340 |
buttonPressBlock:aBlock x:x y:y
|
754
|
1341 |
"evaluate the user defined block if not nil dependent on its required
|
741
|
1342 |
arguments; the result of the block is returned
|
|
1343 |
"
|
|
1344 |
|numArgs desc index|
|
|
1345 |
|
|
1346 |
aBlock isNil ifTrue:[
|
3150
|
1347 |
^ nil
|
741
|
1348 |
].
|
|
1349 |
(numArgs := aBlock numArgs) == 0 ifTrue:[
|
3150
|
1350 |
^ aBlock value
|
741
|
1351 |
].
|
|
1352 |
|
|
1353 |
(desc := self nearestColumnAtX:x y:y) isNil ifTrue:[
|
3150
|
1354 |
^ nil
|
741
|
1355 |
].
|
754
|
1356 |
index := self absoluteIndexOfX:x.
|
741
|
1357 |
|
|
1358 |
numArgs == 1 ifTrue:[ ^ aBlock value:(desc key) ].
|
|
1359 |
numArgs == 2 ifTrue:[ ^ aBlock value:(desc key) value:index ].
|
|
1360 |
numArgs == 3 ifTrue:[ ^ aBlock value:(desc key) value:index value:(desc value) ].
|
|
1361 |
|
|
1362 |
^ aBlock value:(desc key) value:index value:(desc value) value:y
|
|
1363 |
|
|
1364 |
!
|
|
1365 |
|
|
1366 |
buttonRelease:button x:x y:y
|
|
1367 |
"handle a button release event
|
|
1368 |
"
|
|
1369 |
|numArgs|
|
|
1370 |
|
|
1371 |
buttonReleaseBlock isNil ifTrue:[
|
3150
|
1372 |
^ super buttonRelease:button x:x y:y
|
741
|
1373 |
].
|
|
1374 |
numArgs := buttonReleaseBlock numArgs.
|
|
1375 |
|
|
1376 |
numArgs == 0 ifTrue:[ ^ buttonReleaseBlock value ].
|
|
1377 |
numArgs == 1 ifTrue:[ ^ buttonReleaseBlock value:x ].
|
|
1378 |
numArgs == 2 ifTrue:[ ^ buttonReleaseBlock value:x value:y ].
|
|
1379 |
|
754
|
1380 |
buttonReleaseBlock value:x value:y value:(self absoluteIndexOfX:x)
|
741
|
1381 |
! !
|
|
1382 |
|
|
1383 |
!GraphColumnView2D methodsFor:'initialize'!
|
|
1384 |
|
|
1385 |
initialize
|
|
1386 |
"setup default values
|
|
1387 |
"
|
|
1388 |
super initialize.
|
|
1389 |
|
|
1390 |
gridXoffset := 0.
|
|
1391 |
colorMap := Dictionary new.
|
|
1392 |
gridX := 2.
|
|
1393 |
gridY := 2.
|
814
|
1394 |
!
|
|
1395 |
|
|
1396 |
unrealize
|
|
1397 |
"clear colorMap
|
|
1398 |
"
|
|
1399 |
super unrealize.
|
|
1400 |
colorMap := Dictionary new.
|
|
1401 |
|
741
|
1402 |
! !
|
|
1403 |
|
|
1404 |
!GraphColumnView2D methodsFor:'private'!
|
|
1405 |
|
|
1406 |
mapColor:aColor
|
|
1407 |
"get the same color on the device. If the argument is
|
|
1408 |
nil, the foreground color is returned.
|
|
1409 |
"
|
|
1410 |
|fg|
|
|
1411 |
|
|
1412 |
aColor isNil ifTrue:[
|
4851
|
1413 |
^ fgColor
|
741
|
1414 |
].
|
|
1415 |
(fg := colorMap at:aColor ifAbsent:nil) isNil ifTrue:[
|
4851
|
1416 |
colorMap at:aColor put:(fg := aColor onDevice:device)
|
741
|
1417 |
].
|
|
1418 |
^ fg
|
|
1419 |
!
|
|
1420 |
|
|
1421 |
yDataForColumn:aColumn
|
|
1422 |
"returns collection of visible Y-data for a column
|
|
1423 |
"
|
750
|
1424 |
^ aColumn yValuesStartAt:graphOriginX into:(Array new:windowSize)
|
741
|
1425 |
|
|
1426 |
|
|
1427 |
! !
|
|
1428 |
|
|
1429 |
!GraphColumnView2D methodsFor:'protocol'!
|
|
1430 |
|
754
|
1431 |
doRecomputeGraph
|
|
1432 |
"called to recompute drawable objects and to set the graph to invalidate
|
750
|
1433 |
"
|
754
|
1434 |
gridXoffset := 0.
|
741
|
1435 |
|
750
|
1436 |
shown ifTrue:[
|
3150
|
1437 |
self invalidate.
|
741
|
1438 |
]
|
754
|
1439 |
|
741
|
1440 |
!
|
|
1441 |
|
754
|
1442 |
updateColumns:what with:oldValue from:aColumn
|
|
1443 |
"called if the list of columns changed
|
3150
|
1444 |
#size the size of the columns
|
|
1445 |
#color: color changed
|
754
|
1446 |
or a specific column:( aColumn notNil )
|
3150
|
1447 |
#insert: insert a new column
|
|
1448 |
#remove: remove a column
|
754
|
1449 |
|
3150
|
1450 |
or a specific attribute derived from the
|
|
1451 |
changed column.
|
741
|
1452 |
"
|
|
1453 |
|colSY colZY colTY colRX|
|
|
1454 |
|
754
|
1455 |
shown ifFalse:[
|
3150
|
1456 |
^ self
|
754
|
1457 |
].
|
741
|
1458 |
|
|
1459 |
(what == nil or:[self sensor hasDamageFor:self]) ifTrue:[
|
3150
|
1460 |
^ self invalidate
|
741
|
1461 |
].
|
|
1462 |
|
754
|
1463 |
aColumn isNil ifTrue:[
|
3150
|
1464 |
^ self doRecomputeGraph
|
754
|
1465 |
].
|
|
1466 |
|
|
1467 |
what == #insert: ifTrue:[ ^ self redrawColumn:aColumn ].
|
|
1468 |
what == #remove: ifTrue:[ ^ self clearColumnAndRedraw:aColumn ].
|
|
1469 |
|
741
|
1470 |
what == #shown ifTrue:[
|
3150
|
1471 |
aColumn shown ifTrue:[self redrawColumn:aColumn]
|
|
1472 |
ifFalse:[self clearColumnAndRedraw:aColumn].
|
741
|
1473 |
|
3150
|
1474 |
^ self
|
741
|
1475 |
].
|
|
1476 |
|
|
1477 |
aColumn shown ifFalse:[ ^ self ].
|
|
1478 |
|
|
1479 |
( what == #lineStyle
|
|
1480 |
or:[what == #foregroundColor
|
|
1481 |
or:[what == #lineWidth]]
|
|
1482 |
) ifTrue:[
|
3150
|
1483 |
^ self changedGraphIn:aColumn what:what from:oldValue
|
741
|
1484 |
].
|
|
1485 |
|
|
1486 |
( what == #hLineStyle
|
|
1487 |
or:[what == #hLineFgColor
|
|
1488 |
or:[what == #hLineWidth
|
|
1489 |
or:[what == #hLineList ]]]
|
|
1490 |
) ifTrue:[
|
3150
|
1491 |
^ self changedHLineIn:aColumn what:what from:oldValue
|
741
|
1492 |
].
|
|
1493 |
colSY := aColumn scaleY.
|
|
1494 |
colZY := aColumn zoomY.
|
|
1495 |
colTY := aColumn transY.
|
|
1496 |
colRX := aColumn relativeXaxis.
|
|
1497 |
|
|
1498 |
what == #scaleY ifTrue:[ colSY := oldValue ] ifFalse:[
|
|
1499 |
what == #transY ifTrue:[ colTY := oldValue ] ifFalse:[
|
|
1500 |
what == #relativeXaxis ifTrue:[ colRX := oldValue ] ifFalse:[
|
754
|
1501 |
what == #zoomY ifTrue:[ colZY := oldValue ] ifFalse:[ ^ self doRecomputeGraph ]]]].
|
741
|
1502 |
|
|
1503 |
self undrawColumn:aColumn
|
3150
|
1504 |
scaleY:(self absScaleY:colSY zoomY:colZY)
|
|
1505 |
transY:(self absTransY:colTY
|
|
1506 |
relativeTo:colRX
|
|
1507 |
zoomY:colZY
|
|
1508 |
).
|
754
|
1509 |
|
|
1510 |
|
|
1511 |
|
741
|
1512 |
!
|
|
1513 |
|
754
|
1514 |
updateOriginX:nIndices
|
750
|
1515 |
"scroll left or right n x-steps. A positive value scrolls to the right
|
|
1516 |
a negative value to the left.
|
|
1517 |
"
|
|
1518 |
|
|
|
1519 |
x "{ Class:SmallInteger }"
|
|
1520 |
w "{ Class:SmallInteger }"
|
|
1521 |
gridDeltaX "{ Class:SmallInteger }"
|
|
1522 |
|
|
|
1523 |
|
|
1524 |
x := (nIndices * self stepX) rounded.
|
|
1525 |
w := width - (x abs).
|
|
1526 |
|
|
1527 |
"/ update offset X for the grid
|
|
1528 |
|
|
1529 |
(showGrid and:[gridX ~~ 0]) ifTrue:[
|
3150
|
1530 |
gridDeltaX := gridXoffset + x.
|
|
1531 |
gridXoffset := gridDeltaX \\ (gridX * self class gridStep).
|
750
|
1532 |
|
3150
|
1533 |
gridDeltaX < 0 ifTrue:[
|
|
1534 |
gridXoffset := gridXoffset negated
|
|
1535 |
].
|
750
|
1536 |
].
|
|
1537 |
|
|
1538 |
"/ scrolling & redraw
|
|
1539 |
|
|
1540 |
x := x abs.
|
|
1541 |
|
|
1542 |
self catchExpose.
|
|
1543 |
|
|
1544 |
nIndices < 0 ifTrue:[ "/ scroll left
|
|
1545 |
|
3150
|
1546 |
self copyFrom:self x:x y:0 toX:0 y:0 width:w height:height async:true.
|
|
1547 |
self redrawX:w y:0 width:x height:height.
|
750
|
1548 |
|
|
1549 |
] ifFalse:[ "/ scroll right
|
|
1550 |
|
3150
|
1551 |
self copyFrom:self x:0 y:0 toX:x y:0 width:w height:height async:true.
|
|
1552 |
self redrawX:0 y:0 width:x height:height.
|
750
|
1553 |
].
|
|
1554 |
self waitForExpose.
|
|
1555 |
!
|
|
1556 |
|
754
|
1557 |
updateReferences:what atRelX:relX
|
|
1558 |
"called when the list of references changed.
|
3150
|
1559 |
#remove: the reference at the relative X index is removed
|
|
1560 |
#insert: a reference is inserted at the relative X index
|
|
1561 |
#size the list of references changed
|
|
1562 |
#state visibility state changed
|
|
1563 |
#color the foreground color changed
|
741
|
1564 |
"
|
754
|
1565 |
|x|
|
741
|
1566 |
|
754
|
1567 |
shown ifTrue:[
|
3150
|
1568 |
showReferences ifFalse:[
|
|
1569 |
what == #state ifTrue:[
|
|
1570 |
self doRecomputeGraph
|
|
1571 |
]
|
|
1572 |
] ifTrue:[
|
|
1573 |
(what == #color or:[what == #state]) ifTrue:[
|
|
1574 |
self drawReferencesFromX:0 y:0 to:width y:height
|
|
1575 |
] ifFalse:[
|
|
1576 |
(what == #insert: or:[what == #remove:]) ifTrue:[
|
|
1577 |
x := (relX * self stepX) rounded.
|
750
|
1578 |
|
3150
|
1579 |
what == #insert: ifTrue:[
|
|
1580 |
self paint:referenceColor.
|
|
1581 |
self displayLineFromX:x y:0 toX:x y:height
|
|
1582 |
] ifFalse:[
|
|
1583 |
self redrawX:x y:0 width:1 height:height
|
|
1584 |
]
|
|
1585 |
] ifFalse:[
|
|
1586 |
self doRecomputeGraph
|
|
1587 |
]
|
|
1588 |
]
|
|
1589 |
]
|
750
|
1590 |
]
|
741
|
1591 |
! !
|
|
1592 |
|
|
1593 |
!GraphColumnView2D methodsFor:'queries'!
|
|
1594 |
|
754
|
1595 |
absoluteIndexOfX:x
|
|
1596 |
"returns the absolute X value for a visible x
|
|
1597 |
"
|
|
1598 |
^ (x // self stepX) + graphOriginX
|
|
1599 |
|
|
1600 |
!
|
|
1601 |
|
741
|
1602 |
nearestColumnAtX:x y:y
|
|
1603 |
"returns an association containing the nearest column as key and the absolute y-distance
|
|
1604 |
to the point x/y. If no columns exists nil is returned
|
|
1605 |
"
|
750
|
1606 |
|sX dX dtY data col
|
|
1607 |
i0 "{ Class:SmallInteger }"
|
|
1608 |
|
|
741
|
1609 |
|
750
|
1610 |
columns size == 0 ifTrue:[^ nil ].
|
741
|
1611 |
|
|
1612 |
col := nil.
|
|
1613 |
sX := self stepX.
|
|
1614 |
i0 := x // sX.
|
|
1615 |
|
|
1616 |
sX > 1 ifFalse:[
|
3150
|
1617 |
dX := 0
|
741
|
1618 |
] ifTrue:[
|
3150
|
1619 |
(dX := x - (i0 * sX)) > 0.5 ifTrue:[dX := dX / sX]
|
|
1620 |
ifFalse:[dX := 0]
|
|
1621 |
].
|
741
|
1622 |
i0 := (i0 + 1) min:windowSize.
|
|
1623 |
|
|
1624 |
(i0 < windowSize and:[dX ~= 0]) ifTrue:[data := Array new:2]
|
3150
|
1625 |
ifFalse:[data := Array new:1].
|
741
|
1626 |
|
750
|
1627 |
i0 := i0 + graphOriginX.
|
|
1628 |
|
741
|
1629 |
columns do:[:aCol||vlY scY trY yL yR|
|
3150
|
1630 |
aCol shown ifTrue:[
|
|
1631 |
vlY := aCol yValuesStartAt:i0 into:data.
|
|
1632 |
scY := self scaleYofColumn:aCol.
|
|
1633 |
trY := self transYofColumn:aCol.
|
|
1634 |
yL := vlY first * scY.
|
|
1635 |
yR := vlY last * scY.
|
|
1636 |
yL := (yL + trY + (yR - yL * dX)) rounded.
|
|
1637 |
yR := (y - yL) abs.
|
741
|
1638 |
|
3150
|
1639 |
(col isNil or:[dtY > yR]) ifTrue:[
|
|
1640 |
dtY := yR.
|
|
1641 |
col := aCol.
|
|
1642 |
]
|
|
1643 |
]
|
741
|
1644 |
].
|
|
1645 |
|
|
1646 |
^ col notNil ifTrue:[Association key:col value:dtY] ifFalse:[nil]
|
|
1647 |
|
|
1648 |
! !
|
|
1649 |
|
|
1650 |
!GraphColumnView2D methodsFor:'transformations'!
|
|
1651 |
|
|
1652 |
absScaleY:aNumber zoomY:aZoomY
|
|
1653 |
"returns y-scale for a scale Y and a zoom factor
|
|
1654 |
"
|
|
1655 |
^ (aNumber negated) * zoomY * aZoomY
|
|
1656 |
!
|
|
1657 |
|
|
1658 |
absTransY:aNumber relativeTo:xAxis zoomY:aZoomY
|
|
1659 |
"returns absolute transition Y for a number relative
|
|
1660 |
to a x-axis
|
|
1661 |
"
|
|
1662 |
|zY|
|
|
1663 |
|
|
1664 |
zY := zoomY * aZoomY.
|
|
1665 |
^ height * xAxis / zY + aNumber * zY
|
|
1666 |
|
|
1667 |
|
|
1668 |
|
|
1669 |
!
|
|
1670 |
|
|
1671 |
scaleYofColumn:aColumn
|
|
1672 |
"returns current y-scale of a column on my view
|
|
1673 |
"
|
|
1674 |
^ (aColumn scaleY negated) * zoomY * (aColumn zoomY)
|
|
1675 |
!
|
|
1676 |
|
|
1677 |
stepX
|
|
1678 |
"returns width of X measured in pixels; no fraction returned
|
|
1679 |
"
|
|
1680 |
|x|
|
|
1681 |
|
|
1682 |
x := width / (windowSize - 1).
|
|
1683 |
^ x isInteger ifTrue:[x] ifFalse:[x asFloat]
|
|
1684 |
!
|
|
1685 |
|
|
1686 |
transYofColumn:aColumn
|
|
1687 |
"returns current y-transition of a column on my view
|
|
1688 |
"
|
|
1689 |
^ self absTransY:(aColumn transY)
|
3150
|
1690 |
relativeTo:(aColumn relativeXaxis)
|
|
1691 |
zoomY:(aColumn zoomY)
|
741
|
1692 |
! !
|
|
1693 |
|
|
1694 |
!GraphColumnView2D methodsFor:'user interaction & notifications'!
|
|
1695 |
|
|
1696 |
doGridExtent:what
|
|
1697 |
"change the grid extent factorial 2 (larger or smaller)
|
|
1698 |
"
|
|
1699 |
|ext|
|
|
1700 |
|
|
1701 |
ext := self gridExtent.
|
|
1702 |
|
|
1703 |
what == #larger ifTrue:[
|
3150
|
1704 |
ext := ext * 2
|
741
|
1705 |
] ifFalse:[
|
3150
|
1706 |
what == #smaller ifFalse:[
|
|
1707 |
^ self
|
|
1708 |
].
|
|
1709 |
ext := ext // 2.
|
|
1710 |
(ext x == 0) ifTrue:[gridX ~~ 0 ifTrue:[ext x:1]].
|
|
1711 |
(ext y == 0) ifTrue:[gridY ~~ 0 ifTrue:[ext y:1]].
|
741
|
1712 |
].
|
|
1713 |
self gridExtent:ext.
|
|
1714 |
|
|
1715 |
!
|
|
1716 |
|
|
1717 |
doGridStepX:aNumberOrSymbol
|
|
1718 |
"change the grid step X
|
|
1719 |
"
|
|
1720 |
self gridX:(aNumberOrSymbol == #off ifFalse:[aNumberOrSymbol] ifTrue:[0])
|
|
1721 |
!
|
|
1722 |
|
|
1723 |
doGridStepY:aNumberOrSymbol
|
|
1724 |
"change the grid step Y
|
|
1725 |
"
|
|
1726 |
self gridY:(aNumberOrSymbol == #off ifFalse:[aNumberOrSymbol] ifTrue:[0])
|
|
1727 |
! !
|
|
1728 |
|
|
1729 |
!GraphColumnView2D class methodsFor:'documentation'!
|
|
1730 |
|
|
1731 |
version
|
4851
|
1732 |
^ '$Header$'
|
741
|
1733 |
! !
|
4851
|
1734 |
|