741
|
1 |
View subclass:#GraphColumnView
|
749
|
2 |
instanceVariableNames:'columns vLines listHolder vLinesHolder zoomYHolder oldMenuMessage
|
|
3 |
windowSizeHolder windowSize gridColor showGrid fgColor bgColor
|
|
4 |
vLinesColor zoomY scrollUpdatesOriginX graphOriginX
|
|
5 |
graphOriginXHolder'
|
741
|
6 |
classVariableNames:'DefaultBackgroundColor DefaultGridColor DefaultForegroundColor
|
|
7 |
DefaultVLinesColor'
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'Views-Graphs'
|
|
10 |
!
|
|
11 |
|
749
|
12 |
!GraphColumnView class methodsFor:'documentation'!
|
|
13 |
|
|
14 |
documentation
|
|
15 |
"
|
|
16 |
The class describes the common interface supported by the 2D or 3D GraphColumnView.
|
|
17 |
This Viewclasses provide a lot of functionality for showing and manipulating graphs
|
|
18 |
described through to a GraphColumn description. Each change in a graph description
|
|
19 |
immediately take affect in the garph view.
|
|
20 |
|
|
21 |
|
|
22 |
[See also:]
|
|
23 |
GraphColumn
|
|
24 |
GraphColumnView2D
|
|
25 |
GraphColumnView3D
|
|
26 |
|
|
27 |
[Author:]
|
|
28 |
Claus Atzkern
|
|
29 |
"
|
|
30 |
|
|
31 |
! !
|
741
|
32 |
|
|
33 |
!GraphColumnView class methodsFor:'defaults'!
|
|
34 |
|
|
35 |
defaultMenu
|
|
36 |
"redefined by subclass: should return the default middle button menu
|
|
37 |
"
|
|
38 |
^ nil
|
|
39 |
!
|
|
40 |
|
|
41 |
updateStyleCache
|
|
42 |
"extract values from the styleSheet and cache them in class variables
|
|
43 |
"
|
|
44 |
DefaultForegroundColor := Color black.
|
|
45 |
DefaultBackgroundColor := Color veryLightGray.
|
|
46 |
DefaultGridColor := Color lightGray.
|
|
47 |
DefaultVLinesColor := DefaultForegroundColor
|
|
48 |
"
|
|
49 |
self updateStyleCache
|
|
50 |
"
|
|
51 |
|
|
52 |
|
|
53 |
! !
|
|
54 |
|
|
55 |
!GraphColumnView methodsFor:'accessing'!
|
|
56 |
|
|
57 |
columns
|
749
|
58 |
"returns the list of column descriptions
|
741
|
59 |
"
|
|
60 |
^ columns
|
|
61 |
|
|
62 |
|
|
63 |
!
|
|
64 |
|
|
65 |
columns:aList
|
749
|
66 |
"set the list of columns descriptions
|
741
|
67 |
"
|
|
68 |
columns notNil ifTrue:[
|
|
69 |
columns do:[:aCol| aCol removeDependent:self ]
|
|
70 |
].
|
|
71 |
|
|
72 |
aList size ~~ 0 ifTrue:[
|
|
73 |
columns := OrderedCollection new.
|
|
74 |
|
|
75 |
aList do:[:aColumn|
|
|
76 |
aColumn addDependent:self.
|
|
77 |
columns add:aColumn
|
|
78 |
]
|
|
79 |
] ifFalse:[
|
|
80 |
columns := nil
|
|
81 |
].
|
|
82 |
self recomputeWholeGraph
|
|
83 |
!
|
|
84 |
|
749
|
85 |
graphOriginX
|
|
86 |
"returns the logical index X of the first visible row; this number is used for
|
|
87 |
accessing Y values from the GraphColumn description. On default, the value
|
|
88 |
is set to 1.
|
|
89 |
"
|
|
90 |
^ graphOriginX
|
|
91 |
|
|
92 |
|
|
93 |
!
|
|
94 |
|
|
95 |
graphOriginX:aNumber
|
|
96 |
"set the logical index X of the first visible row; this number is used for
|
|
97 |
accessing Y values from the GraphColumn description. On default, the value
|
|
98 |
is set to 1.
|
|
99 |
Changing the number, a scroll left or right is triggered.
|
|
100 |
"
|
|
101 |
|newX state|
|
|
102 |
|
|
103 |
aNumber isNumber ifTrue:[
|
|
104 |
newX := aNumber isInteger ifTrue:[aNumber]
|
|
105 |
ifFalse:[(aNumber asFloat) rounded]. "/ no fractions
|
|
106 |
|
|
107 |
newX ~~ graphOriginX ifTrue:[
|
|
108 |
state := scrollUpdatesOriginX.
|
|
109 |
scrollUpdatesOriginX := true.
|
|
110 |
self scroll:(graphOriginX - newX).
|
|
111 |
scrollUpdatesOriginX := state.
|
|
112 |
]
|
|
113 |
]
|
|
114 |
!
|
|
115 |
|
|
116 |
scrollUpdatesOriginX
|
|
117 |
"returns true, if the graphOriginX automatically is updated by
|
|
118 |
any scroll action. The default is set to false.
|
|
119 |
"
|
|
120 |
^ scrollUpdatesOriginX
|
|
121 |
!
|
|
122 |
|
|
123 |
scrollUpdatesOriginX:aBool
|
|
124 |
"set to true if the graphOriginX automatically should be updated by any
|
|
125 |
scroll action. Otherwise a scroll has no influnce to the current
|
|
126 |
graphOriginX.
|
|
127 |
The default is set to false.
|
|
128 |
"
|
|
129 |
scrollUpdatesOriginX := aBool
|
|
130 |
!
|
|
131 |
|
741
|
132 |
showDefaultMenu
|
749
|
133 |
"returns true, if the middleButton menu is set to the default menu
|
|
134 |
provided by the graph.
|
741
|
135 |
"
|
|
136 |
^ self menuMessage == #defaultMenu
|
|
137 |
!
|
|
138 |
|
|
139 |
showDefaultMenu:aBool
|
749
|
140 |
"enable or disable the default menu provided by the graph
|
741
|
141 |
"
|
|
142 |
|currMsg|
|
|
143 |
|
|
144 |
currMsg := self menuMessage.
|
|
145 |
|
|
146 |
aBool ifTrue:[
|
|
147 |
oldMenuMessage := currMsg.
|
|
148 |
self menuMessage:#defaultMenu
|
|
149 |
] ifFalse:[
|
|
150 |
currMsg == #defaultMenu ifTrue:[
|
|
151 |
self menuMessage:oldMenuMessage
|
|
152 |
]
|
|
153 |
].
|
|
154 |
|
|
155 |
|
|
156 |
! !
|
|
157 |
|
|
158 |
!GraphColumnView methodsFor:'accessing dimensions'!
|
|
159 |
|
|
160 |
windowSize
|
749
|
161 |
"get the number of horizontal steps ( X )
|
741
|
162 |
"
|
|
163 |
^ windowSize
|
|
164 |
|
|
165 |
|
|
166 |
!
|
|
167 |
|
|
168 |
windowSize:aValue
|
749
|
169 |
"set the number of horizontal steps ( X )
|
741
|
170 |
"
|
|
171 |
|sz|
|
|
172 |
|
|
173 |
sz := (self unsignedIntegerFrom:aValue onError:[101]) max:5.
|
|
174 |
|
|
175 |
sz ~~ windowSize ifTrue:[
|
|
176 |
windowSize := sz.
|
|
177 |
self recomputeWholeGraph
|
|
178 |
]
|
|
179 |
|
|
180 |
!
|
|
181 |
|
|
182 |
zoomY
|
|
183 |
"returns current y-zoom factor
|
|
184 |
"
|
|
185 |
^ zoomY
|
|
186 |
|
|
187 |
|
|
188 |
!
|
|
189 |
|
|
190 |
zoomY:aValue
|
749
|
191 |
"set the current y-zoom factor; if the argument is nil,
|
|
192 |
the y-zoom is set to 1.
|
741
|
193 |
"
|
|
194 |
|zY|
|
|
195 |
|
|
196 |
(zY := self floatFrom:aValue onError:[1]) <= 0 ifTrue:[
|
|
197 |
zY := 1
|
|
198 |
].
|
|
199 |
|
|
200 |
zY = zoomY ifFalse:[
|
|
201 |
zoomY := zY.
|
|
202 |
self invalidateGraph
|
|
203 |
]
|
|
204 |
|
|
205 |
|
|
206 |
! !
|
|
207 |
|
|
208 |
!GraphColumnView methodsFor:'accessing look'!
|
|
209 |
|
|
210 |
backgroundColor
|
749
|
211 |
"returns the current background color of the graph
|
741
|
212 |
"
|
|
213 |
^ bgColor
|
|
214 |
|
|
215 |
|
|
216 |
!
|
|
217 |
|
|
218 |
backgroundColor:aColor
|
749
|
219 |
"set the background color of the graph
|
741
|
220 |
"
|
|
221 |
(aColor isColor and:[bgColor ~= aColor]) ifTrue:[
|
|
222 |
shown ifTrue:[
|
|
223 |
bgColor := aColor on:device.
|
|
224 |
self colorChanged:#background.
|
|
225 |
] ifFalse:[
|
|
226 |
bgColor := aColor
|
|
227 |
]
|
|
228 |
]
|
|
229 |
!
|
|
230 |
|
|
231 |
foregroundColor
|
749
|
232 |
"returns the default foreground color used to draw graphs which
|
|
233 |
has no foreground color specified.
|
741
|
234 |
"
|
|
235 |
^ fgColor
|
|
236 |
|
|
237 |
!
|
|
238 |
|
|
239 |
foregroundColor:aColor
|
749
|
240 |
"set the default foreground color used to draw graphs which
|
|
241 |
has no foreground color specified.
|
741
|
242 |
"
|
|
243 |
(aColor isColor and:[fgColor ~= aColor]) ifTrue:[
|
|
244 |
shown ifTrue:[
|
|
245 |
fgColor := aColor on:device.
|
|
246 |
self colorChanged:#foreground
|
|
247 |
] ifFalse:[
|
|
248 |
fgColor := aColor
|
|
249 |
]
|
|
250 |
]
|
|
251 |
|
|
252 |
!
|
|
253 |
|
|
254 |
gridColor
|
749
|
255 |
"returns the foreground color of the grid
|
741
|
256 |
"
|
|
257 |
^ gridColor
|
|
258 |
|
|
259 |
!
|
|
260 |
|
|
261 |
gridColor:aColor
|
|
262 |
"set the foreground color of the grid
|
|
263 |
"
|
|
264 |
(aColor isColor and:[gridColor ~= aColor]) ifTrue:[
|
|
265 |
shown ifTrue:[
|
|
266 |
gridColor := aColor on:device.
|
|
267 |
|
|
268 |
showGrid ifTrue:[
|
|
269 |
self colorChanged:#grid
|
|
270 |
]
|
|
271 |
] ifFalse:[
|
|
272 |
gridColor := aColor
|
|
273 |
]
|
|
274 |
]
|
|
275 |
|
|
276 |
!
|
|
277 |
|
|
278 |
showGrid
|
749
|
279 |
"returns true if the grid is enabled
|
|
280 |
"
|
741
|
281 |
^ showGrid
|
|
282 |
|
|
283 |
!
|
|
284 |
|
|
285 |
showGrid:aBool
|
749
|
286 |
"set the visibility state of the grid
|
|
287 |
"
|
741
|
288 |
|hasGrid|
|
|
289 |
|
|
290 |
showGrid ~~ aBool ifTrue:[
|
|
291 |
showGrid := aBool.
|
|
292 |
|
|
293 |
shown ifTrue:[
|
|
294 |
self invalidateGraph
|
|
295 |
]
|
|
296 |
]
|
|
297 |
|
|
298 |
!
|
|
299 |
|
|
300 |
vLinesColor
|
749
|
301 |
"returns the foreground color used to draw vertical lines
|
741
|
302 |
"
|
|
303 |
^ vLinesColor
|
|
304 |
|
|
305 |
|
|
306 |
!
|
|
307 |
|
|
308 |
vLinesColor:aColor
|
749
|
309 |
"set the foreground color used to draw vertical lines
|
741
|
310 |
"
|
|
311 |
(aColor isColor and:[vLinesColor ~= aColor]) ifTrue:[
|
|
312 |
shown ifTrue:[
|
|
313 |
vLinesColor := aColor on:device.
|
|
314 |
self colorChanged:#vLines
|
|
315 |
] ifFalse:[
|
|
316 |
vLinesColor := aColor
|
|
317 |
]
|
|
318 |
]
|
|
319 |
|
|
320 |
! !
|
|
321 |
|
|
322 |
!GraphColumnView methodsFor:'accessing mvc'!
|
|
323 |
|
749
|
324 |
graphOriginXHolder
|
|
325 |
"returns the valueHolder, which keeps the current graphOriginX (see: #graphOriginX:)
|
|
326 |
"
|
|
327 |
^ graphOriginXHolder
|
|
328 |
!
|
|
329 |
|
|
330 |
graphOriginXHolder:aHolder
|
|
331 |
"set the valueHolder, which keeps the current graphOriginX (see: #graphOriginX:)
|
|
332 |
"
|
|
333 |
graphOriginXHolder == aHolder ifFalse:[
|
|
334 |
graphOriginXHolder notNil ifTrue:[
|
|
335 |
graphOriginXHolder removeDependent:self
|
|
336 |
].
|
|
337 |
(graphOriginXHolder := aHolder) notNil ifTrue:[
|
|
338 |
graphOriginXHolder addDependent:self
|
|
339 |
].
|
|
340 |
].
|
|
341 |
self graphOriginX:(graphOriginXHolder value)
|
|
342 |
|
|
343 |
!
|
|
344 |
|
741
|
345 |
listHolder
|
749
|
346 |
"returns the valueHolder, which keeps the list of column descriptions (see: #column:)
|
741
|
347 |
"
|
|
348 |
^ listHolder
|
|
349 |
|
|
350 |
|
|
351 |
!
|
|
352 |
|
|
353 |
listHolder:aHolder
|
749
|
354 |
"set the valueHolder, which keeps the list of column descriptions (see: #column:)
|
741
|
355 |
"
|
|
356 |
listHolder == aHolder ifFalse:[
|
|
357 |
listHolder notNil ifTrue:[
|
|
358 |
listHolder removeDependent:self
|
|
359 |
].
|
|
360 |
(listHolder := aHolder) notNil ifTrue:[
|
|
361 |
listHolder addDependent:self
|
|
362 |
].
|
|
363 |
].
|
|
364 |
self columns:(listHolder value)
|
|
365 |
|
|
366 |
!
|
|
367 |
|
|
368 |
model:aModel
|
|
369 |
"set the valueHolder which holds the selection and maybe the list of columnms
|
|
370 |
"
|
|
371 |
(model respondsTo:#list) ifTrue:[
|
|
372 |
(model list == listHolder) ifTrue:[
|
|
373 |
self listHolder:nil
|
|
374 |
]
|
|
375 |
].
|
|
376 |
super model:aModel.
|
|
377 |
|
|
378 |
aModel notNil ifTrue:[
|
|
379 |
(aModel respondsTo:#list) ifTrue:[
|
|
380 |
self listHolder:model list
|
|
381 |
]
|
|
382 |
]
|
|
383 |
|
|
384 |
!
|
|
385 |
|
749
|
386 |
vLinesHolder
|
|
387 |
"returns the valueHolder, which keeps the list of vLines (see: #vLines:)
|
|
388 |
"
|
|
389 |
^ vLinesHolder
|
|
390 |
|
|
391 |
|
|
392 |
!
|
|
393 |
|
|
394 |
vLinesHolder:aHolder
|
|
395 |
"set the valueHolder, which keeps the list of vLines (see: #vLines:)
|
|
396 |
"
|
|
397 |
vLinesHolder == aHolder ifFalse:[
|
|
398 |
vLinesHolder notNil ifTrue:[
|
|
399 |
vLinesHolder removeDependent:self
|
|
400 |
].
|
|
401 |
(vLinesHolder := aHolder) notNil ifTrue:[
|
|
402 |
vLinesHolder addDependent:self
|
|
403 |
].
|
|
404 |
].
|
|
405 |
self vLines:(vLinesHolder value)
|
|
406 |
|
|
407 |
!
|
|
408 |
|
741
|
409 |
windowSizeHolder
|
749
|
410 |
"returns the valueHolder, which keeps the windowSize (see: #windowSize:)
|
741
|
411 |
"
|
|
412 |
^ windowSizeHolder
|
|
413 |
|
|
414 |
!
|
|
415 |
|
|
416 |
windowSizeHolder:aHolder
|
749
|
417 |
"set the valueHolder, which keeps the windowSize (see: #windowSize:)
|
741
|
418 |
"
|
|
419 |
windowSizeHolder == aHolder ifFalse:[
|
|
420 |
windowSizeHolder notNil ifTrue:[
|
|
421 |
windowSizeHolder removeDependent:self
|
|
422 |
].
|
|
423 |
(windowSizeHolder := aHolder) notNil ifTrue:[
|
|
424 |
windowSizeHolder addDependent:self
|
|
425 |
].
|
|
426 |
].
|
|
427 |
self windowSize:(windowSizeHolder value)
|
|
428 |
|
|
429 |
!
|
|
430 |
|
|
431 |
zoomYHolder
|
749
|
432 |
"returns the valueHolder, which keeps the zoom Y factor (see: #zoomY:)
|
741
|
433 |
"
|
|
434 |
^ zoomYHolder
|
|
435 |
|
|
436 |
!
|
|
437 |
|
|
438 |
zoomYHolder:aHolder
|
749
|
439 |
"set the valueHolder, which keeps the zoom Y factor (see: #zoomY:)
|
741
|
440 |
"
|
|
441 |
zoomYHolder == aHolder ifFalse:[
|
|
442 |
zoomYHolder notNil ifTrue:[
|
|
443 |
zoomYHolder removeDependent:self
|
|
444 |
].
|
|
445 |
(zoomYHolder := aHolder) notNil ifTrue:[
|
|
446 |
zoomYHolder addDependent:self
|
|
447 |
]
|
|
448 |
].
|
|
449 |
self zoomY:(zoomYHolder value).
|
|
450 |
|
|
451 |
! !
|
|
452 |
|
749
|
453 |
!GraphColumnView methodsFor:'accessing vLines'!
|
|
454 |
|
|
455 |
vLineAdd:aLineIndex
|
|
456 |
"add vertical line index to end of list
|
|
457 |
"
|
|
458 |
^ self vLineAdd:aLineIndex beforeIndex:(vLines size + 1)
|
|
459 |
!
|
|
460 |
|
|
461 |
vLineAdd:aLineIndex beforeIndex:anIndex
|
|
462 |
"add a vertical line index before an index
|
|
463 |
"
|
|
464 |
|x|
|
|
465 |
|
|
466 |
vLines add:aLineIndex beforeIndex:anIndex.
|
|
467 |
|
|
468 |
(shown and:[aLineIndex > graphOriginX]) ifTrue:[
|
|
469 |
(x := ((aLineIndex - 1) * self stepX) rounded) < width ifTrue:[
|
|
470 |
self vLinesSizeChanged:#insert: atX:x.
|
|
471 |
]
|
|
472 |
].
|
|
473 |
^ aLineIndex
|
|
474 |
!
|
|
475 |
|
|
476 |
vLineAddAll:aCollection beforeIndex:anIndex
|
|
477 |
"add a collection of vertical line indices before an index
|
|
478 |
"
|
|
479 |
aCollection size ~~ 0 ifTrue:[
|
|
480 |
vLines size == 0 ifTrue:[
|
|
481 |
self vLines:aCollection
|
|
482 |
] ifFalse:[
|
|
483 |
vLines addAll:aCollection beforeIndex:anIndex.
|
|
484 |
self recomputeWholeGraph.
|
|
485 |
]
|
|
486 |
]
|
|
487 |
|
|
488 |
!
|
|
489 |
|
|
490 |
vLineRemove:aLineIndex
|
|
491 |
"remove a vertical line index
|
|
492 |
"
|
|
493 |
^ self vLineRemoveIndex:(vLines identityIndexOf:aLineIndex)
|
|
494 |
|
|
495 |
!
|
|
496 |
|
|
497 |
vLineRemoveAll
|
|
498 |
"remove all vertical line indices
|
|
499 |
"
|
|
500 |
self vLines:nil
|
|
501 |
!
|
|
502 |
|
|
503 |
vLineRemoveIndex:anIndex
|
|
504 |
"remove the vertical line index at an index
|
|
505 |
"
|
|
506 |
|lineIndex x|
|
|
507 |
|
|
508 |
lineIndex := vLines removeAtIndex:anIndex.
|
|
509 |
|
|
510 |
(shown and:[lineIndex > graphOriginX]) ifTrue:[
|
|
511 |
(x := ((lineIndex - 1) * self stepX) rounded) < width ifTrue:[
|
|
512 |
self vLinesSizeChanged:#remove: atX:x.
|
|
513 |
]
|
|
514 |
].
|
|
515 |
^ lineIndex
|
|
516 |
|
|
517 |
|
|
518 |
!
|
|
519 |
|
|
520 |
vLines
|
|
521 |
"returns list of vertical lines
|
|
522 |
"
|
|
523 |
^ vLines
|
|
524 |
|
|
525 |
|
|
526 |
!
|
|
527 |
|
|
528 |
vLines:aListOfIndices
|
|
529 |
"set list of vertical lines
|
|
530 |
"
|
|
531 |
aListOfIndices size == 0 ifTrue:[
|
|
532 |
vLines isEmpty ifTrue:[
|
|
533 |
^ self
|
|
534 |
]
|
|
535 |
] ifFalse:[
|
|
536 |
vLines := OrderedCollection new.
|
|
537 |
aListOfIndices do:[:i| vLines add:i ]
|
|
538 |
].
|
|
539 |
shown ifTrue:[
|
|
540 |
self recomputeWholeGraph
|
|
541 |
]
|
|
542 |
! !
|
|
543 |
|
741
|
544 |
!GraphColumnView methodsFor:'adding & removing'!
|
|
545 |
|
|
546 |
add:aColumn
|
|
547 |
"insert a column at end; returns the inserted column
|
|
548 |
"
|
|
549 |
^ self add:aColumn beforeIndex:(1 + columns size)
|
|
550 |
|
|
551 |
!
|
|
552 |
|
|
553 |
add:aColumn afterIndex:anIndex
|
|
554 |
"add a new column after an index; returns the inserted column
|
|
555 |
"
|
|
556 |
^ self add:aColumn beforeIndex:(anIndex + 1)
|
|
557 |
|
|
558 |
!
|
|
559 |
|
|
560 |
add:aColumn beforeIndex:anIndex
|
|
561 |
"add a column before an index; returns the inserted column
|
|
562 |
"
|
|
563 |
aColumn isNil ifTrue:[^ nil].
|
|
564 |
|
|
565 |
columns isNil ifTrue:[
|
|
566 |
self columns:(Array with:aColumn).
|
|
567 |
^ aColumn.
|
|
568 |
].
|
|
569 |
columns add:aColumn beforeIndex:anIndex.
|
|
570 |
aColumn addDependent:self.
|
|
571 |
|
|
572 |
aColumn shown ifTrue:[
|
|
573 |
self listSizeChanged:#insert: from:aColumn.
|
|
574 |
].
|
|
575 |
|
|
576 |
!
|
|
577 |
|
|
578 |
addAll:aCollection beforeIndex:anIndex
|
|
579 |
"add a collection of columns before an index
|
|
580 |
"
|
|
581 |
aCollection size ~~ 0 ifTrue:[
|
|
582 |
columns size == 0 ifTrue:[
|
|
583 |
self columns:aCollection
|
|
584 |
] ifFalse:[
|
|
585 |
columns addAll:aCollection beforeIndex:anIndex.
|
|
586 |
self recomputeWholeGraph.
|
|
587 |
]
|
|
588 |
]
|
|
589 |
|
|
590 |
!
|
|
591 |
|
|
592 |
addFirst:aColumn
|
|
593 |
"insert a column at start; returns the inserted column
|
|
594 |
"
|
|
595 |
^ self add:aColumn beforeIndex:1
|
|
596 |
|
|
597 |
!
|
|
598 |
|
|
599 |
removeAll
|
|
600 |
"remove all columns
|
|
601 |
"
|
|
602 |
self columns:nil
|
|
603 |
|
|
604 |
!
|
|
605 |
|
|
606 |
removeFirst
|
|
607 |
"remove first column; returns the removed column
|
|
608 |
"
|
|
609 |
^ self removeIndex:1
|
|
610 |
|
|
611 |
|
|
612 |
!
|
|
613 |
|
|
614 |
removeIndex:anIndex
|
|
615 |
"remove column at an index; returns the removed column
|
|
616 |
"
|
|
617 |
|col|
|
|
618 |
|
|
619 |
col := columns removeAtIndex:anIndex.
|
|
620 |
col removeDependent:self.
|
|
621 |
|
|
622 |
columns size == 0 ifTrue:[
|
|
623 |
columns := nil
|
|
624 |
].
|
|
625 |
col shown ifTrue:[
|
|
626 |
self listSizeChanged:#remove: from:col
|
|
627 |
].
|
|
628 |
^ col
|
|
629 |
|
|
630 |
|
|
631 |
!
|
|
632 |
|
|
633 |
removeLast
|
|
634 |
"remove last column; the removed column is returned
|
|
635 |
"
|
|
636 |
^ self removeIndex:(columns size)
|
|
637 |
|
|
638 |
! !
|
|
639 |
|
|
640 |
!GraphColumnView methodsFor:'change & update'!
|
|
641 |
|
|
642 |
update:what with:aPara from:chgObj
|
|
643 |
"catch and handle a change notification of any object
|
|
644 |
"
|
|
645 |
|list start size stop|
|
|
646 |
|
|
647 |
chgObj == windowSizeHolder ifTrue:[
|
|
648 |
^ self windowSize:(windowSizeHolder value)
|
|
649 |
].
|
|
650 |
|
|
651 |
chgObj == zoomYHolder ifTrue:[
|
|
652 |
^ self zoomY:(zoomYHolder value)
|
|
653 |
].
|
|
654 |
|
749
|
655 |
chgObj == graphOriginXHolder ifTrue:[
|
|
656 |
^ self graphOriginX:(graphOriginXHolder value)
|
|
657 |
].
|
|
658 |
|
|
659 |
chgObj == vLinesHolder ifTrue:[
|
|
660 |
(what == #insert:) ifTrue:[
|
|
661 |
self vLineAdd:(list at:aPara) beforeIndex:aPara
|
|
662 |
] ifFalse:[
|
|
663 |
(what == #remove:) ifTrue:[
|
|
664 |
self vLineRemoveIndex:aPara
|
|
665 |
] ifFalse:[
|
|
666 |
(what == #insertCollection:) ifTrue:[
|
|
667 |
start := aPara first.
|
|
668 |
size := aPara last.
|
|
669 |
|
|
670 |
size ~~ 0 ifTrue:[
|
|
671 |
size == 1 ifTrue:[
|
|
672 |
self vLineAdd:(list at:start) beforeIndex:start
|
|
673 |
] ifFalse:[
|
|
674 |
stop := start + size - 1.
|
|
675 |
self vLineAddAll:(list copyFrom:start to:stop) beforeIndex:start
|
|
676 |
]
|
|
677 |
]
|
|
678 |
] ifFalse:[
|
|
679 |
self vLinesHolder:chgObj
|
|
680 |
]
|
|
681 |
]
|
|
682 |
].
|
|
683 |
^ self
|
|
684 |
].
|
|
685 |
|
|
686 |
|
|
687 |
|
741
|
688 |
chgObj == model ifTrue:[
|
|
689 |
(what == #selectionIndex or:[what == #selection]) ifTrue:[
|
|
690 |
^ self
|
|
691 |
].
|
|
692 |
what == #list ifTrue:[
|
|
693 |
^ self listHolder:model list
|
|
694 |
].
|
|
695 |
model == listHolder ifFalse:[
|
|
696 |
^ self
|
|
697 |
].
|
|
698 |
].
|
|
699 |
|
|
700 |
chgObj == listHolder ifTrue:[
|
|
701 |
list := listHolder value.
|
|
702 |
|
|
703 |
(what == #insert:) ifTrue:[
|
|
704 |
self add:(list at:aPara) beforeIndex:aPara
|
|
705 |
] ifFalse:[
|
|
706 |
(what == #remove:) ifTrue:[
|
|
707 |
self removeIndex:aPara
|
|
708 |
] ifFalse:[
|
|
709 |
(what == #insertCollection:) ifTrue:[
|
|
710 |
start := aPara first.
|
|
711 |
size := aPara last.
|
|
712 |
|
|
713 |
size ~~ 0 ifTrue:[
|
|
714 |
size == 1 ifTrue:[
|
|
715 |
self add:(list at:start) beforeIndex:start
|
|
716 |
] ifFalse:[
|
|
717 |
stop := start + size - 1.
|
|
718 |
self addAll:(list copyFrom:start to:stop) beforeIndex:start
|
|
719 |
]
|
|
720 |
]
|
|
721 |
] ifFalse:[
|
|
722 |
self listHolder:chgObj
|
|
723 |
]
|
|
724 |
]
|
|
725 |
].
|
|
726 |
^ self
|
|
727 |
].
|
|
728 |
|
|
729 |
columns notNil ifTrue:[
|
|
730 |
(columns includesIdentical:chgObj) ifTrue:[
|
|
731 |
^ self columnChanged:what with:aPara from:chgObj
|
|
732 |
]
|
|
733 |
].
|
|
734 |
|
|
735 |
super update:what with:aPara from:chgObj
|
|
736 |
|
|
737 |
! !
|
|
738 |
|
|
739 |
!GraphColumnView methodsFor:'conversion'!
|
|
740 |
|
|
741 |
floatFrom:aValue onError:aBlock
|
749
|
742 |
"converts something to a float, on error the result of the block is returned
|
741
|
743 |
"
|
|
744 |
^ aValue isNumber ifTrue:[aValue asFloat] ifFalse:[aBlock value]
|
|
745 |
!
|
|
746 |
|
|
747 |
unsignedIntegerFrom:aValue onError:aBlock
|
749
|
748 |
"converts something to an unsigned integer, on error the result of the block is returned
|
741
|
749 |
"
|
|
750 |
|v|
|
|
751 |
|
|
752 |
aValue isNumber ifTrue:[
|
|
753 |
v := aValue isInteger ifTrue:[aValue] ifFalse:[(aValue asFloat) rounded]. "/ no fractions
|
|
754 |
|
|
755 |
v >= 0 ifTrue:[ ^ v ]
|
|
756 |
].
|
|
757 |
^ aBlock value
|
|
758 |
! !
|
|
759 |
|
|
760 |
!GraphColumnView methodsFor:'initialization'!
|
|
761 |
|
|
762 |
create
|
|
763 |
"set color on device
|
|
764 |
"
|
|
765 |
super create.
|
|
766 |
|
|
767 |
fgColor := (fgColor ? DefaultForegroundColor) on:device.
|
|
768 |
bgColor := (bgColor ? DefaultBackgroundColor) on:device.
|
|
769 |
gridColor := (gridColor ? DefaultGridColor) on:device.
|
|
770 |
vLinesColor := (vLinesColor ? DefaultVLinesColor) on:device.
|
|
771 |
|
|
772 |
!
|
|
773 |
|
|
774 |
destroy
|
|
775 |
"remove dependencies
|
|
776 |
"
|
|
777 |
super destroy.
|
|
778 |
|
749
|
779 |
listHolder removeDependent:self.
|
|
780 |
vLinesHolder removeDependent:self.
|
|
781 |
windowSizeHolder removeDependent:self.
|
|
782 |
zoomYHolder removeDependent:self.
|
|
783 |
graphOriginXHolder removeDependent:self.
|
741
|
784 |
|
|
785 |
columns notNil ifTrue:[
|
|
786 |
columns do:[:aCol| aCol removeDependent:self ]
|
|
787 |
].
|
|
788 |
|
|
789 |
!
|
|
790 |
|
|
791 |
initialize
|
|
792 |
"setup default values
|
|
793 |
"
|
|
794 |
super initialize.
|
|
795 |
|
|
796 |
DefaultGridColor isNil ifTrue:[
|
|
797 |
self class updateStyleCache
|
|
798 |
].
|
|
799 |
|
749
|
800 |
vLines := OrderedCollection new.
|
|
801 |
windowSize := 101.
|
|
802 |
showGrid := false.
|
|
803 |
zoomY := 1.
|
|
804 |
graphOriginX := 1.
|
|
805 |
scrollUpdatesOriginX := false.
|
741
|
806 |
! !
|
|
807 |
|
|
808 |
!GraphColumnView methodsFor:'menu & submenus'!
|
|
809 |
|
|
810 |
defaultMenu
|
749
|
811 |
"returns the default middle button menu provided by the graph
|
741
|
812 |
"
|
|
813 |
|menu|
|
|
814 |
|
|
815 |
menu := self class defaultMenu decodeAsLiteralArray.
|
749
|
816 |
|
741
|
817 |
menu notNil ifTrue:[
|
|
818 |
menu receiver:self
|
|
819 |
].
|
|
820 |
^ menu
|
|
821 |
|
|
822 |
|
|
823 |
!
|
|
824 |
|
|
825 |
doZoomY:aValue
|
749
|
826 |
"triggered by the default menu to change the current zoom Y factor;
|
|
827 |
on change, the corresponding model (zoomYHolder) is updated.
|
|
828 |
"
|
741
|
829 |
|old|
|
|
830 |
|
|
831 |
old := self zoomY.
|
|
832 |
self zoomY:aValue.
|
|
833 |
|
|
834 |
self zoomYHolder notNil ifTrue:[
|
|
835 |
zoomYHolder value:(self zoomY)
|
|
836 |
]
|
|
837 |
!
|
|
838 |
|
|
839 |
subMenuZoomY
|
749
|
840 |
"returns the submenu to configure the zoom Y factor
|
741
|
841 |
"
|
|
842 |
^ GraphColumn zoomMenuSelector:#doZoomY:
|
|
843 |
|
|
844 |
|
|
845 |
! !
|
|
846 |
|
|
847 |
!GraphColumnView methodsFor:'protocol'!
|
|
848 |
|
|
849 |
colorChanged:what
|
749
|
850 |
"called if any color changed; the argument to the change notification
|
|
851 |
specifies the color which has changed:
|
|
852 |
|
|
853 |
#foreground the foreground color
|
|
854 |
#background the background color
|
|
855 |
#grid the color of the grid
|
|
856 |
#vLines the color of the vertical lines
|
741
|
857 |
"
|
|
858 |
self recomputeWholeGraph
|
|
859 |
!
|
|
860 |
|
|
861 |
columnChanged:what with:aPara from:aColumn
|
749
|
862 |
"a column has changed one of its attributes; the arguments to the
|
|
863 |
notification are passed by the column.
|
741
|
864 |
"
|
|
865 |
self recomputeWholeGraph
|
|
866 |
|
|
867 |
|
|
868 |
!
|
|
869 |
|
749
|
870 |
graphOriginXChanged:deltaX
|
|
871 |
"scroll left or right n x-steps. A positive value scrolls to the right
|
|
872 |
a negative value to the left.
|
|
873 |
"
|
|
874 |
self recomputeWholeGraph
|
|
875 |
!
|
|
876 |
|
741
|
877 |
invalidateGraph
|
|
878 |
"called to redraw the graph
|
|
879 |
"
|
|
880 |
self recomputeWholeGraph
|
|
881 |
!
|
|
882 |
|
|
883 |
listSizeChanged:what from:aColumn
|
749
|
884 |
"called if a column description is inserted (#insert:) or removed (#remove:)
|
|
885 |
from the list of columns.
|
741
|
886 |
"
|
|
887 |
self recomputeWholeGraph
|
|
888 |
!
|
|
889 |
|
|
890 |
recomputeWholeGraph
|
|
891 |
"called if the whole graph should be recomputed
|
|
892 |
"
|
|
893 |
self subclassResponsibility
|
749
|
894 |
!
|
|
895 |
|
|
896 |
vLinesSizeChanged:what atX:aPhysX
|
|
897 |
"called if the list of vertical lines changed; a new lineIndex is inserted (#insert:)
|
|
898 |
or removed (#remove:) from the list
|
|
899 |
"
|
|
900 |
self recomputeWholeGraph
|
741
|
901 |
! !
|
|
902 |
|
|
903 |
!GraphColumnView methodsFor:'queries'!
|
|
904 |
|
|
905 |
numberOfVisibleColumns
|
749
|
906 |
"returns the number of visible Columns (shown is true)
|
741
|
907 |
"
|
|
908 |
|no|
|
|
909 |
|
|
910 |
no := 0.
|
|
911 |
|
|
912 |
columns notNil ifTrue:[
|
|
913 |
columns do:[:aCol| aCol shown ifTrue:[no := no + 1]]
|
|
914 |
].
|
|
915 |
^ no
|
|
916 |
! !
|
|
917 |
|
749
|
918 |
!GraphColumnView methodsFor:'scrolling'!
|
|
919 |
|
|
920 |
halfWindowSizeLeft
|
|
921 |
"scroll left half window size
|
|
922 |
"
|
|
923 |
self scrollLeft:(windowSize // 2)
|
|
924 |
|
|
925 |
!
|
|
926 |
|
|
927 |
halfWindowSizeRight
|
|
928 |
"scroll right half window size
|
|
929 |
"
|
|
930 |
self scrollRight:(windowSize // 2)
|
|
931 |
|
|
932 |
!
|
|
933 |
|
|
934 |
scroll:nIndices
|
|
935 |
"scroll left or right n x-steps. a positive value scrolls to the right
|
|
936 |
a negative value to the left.
|
|
937 |
"
|
|
938 |
|max|
|
|
939 |
|
|
940 |
nIndices ~~ 0 ifTrue:[
|
|
941 |
scrollUpdatesOriginX ifTrue:[
|
|
942 |
graphOriginX := graphOriginX - nIndices
|
|
943 |
].
|
|
944 |
|
|
945 |
shown ifTrue:[
|
|
946 |
max := 2 * (windowSize // 3).
|
|
947 |
|
|
948 |
(nIndices abs) > max ifTrue:[
|
|
949 |
self recomputeWholeGraph "/ full redraw
|
|
950 |
] ifFalse:[
|
|
951 |
self graphOriginXChanged:nIndices "/ scroll
|
|
952 |
]
|
|
953 |
]
|
|
954 |
].
|
|
955 |
!
|
|
956 |
|
|
957 |
scrollLeft:nIndices
|
|
958 |
"scroll n indices left
|
|
959 |
"
|
|
960 |
self scroll:(nIndices negated)
|
|
961 |
|
|
962 |
!
|
|
963 |
|
|
964 |
scrollRight:nIndices
|
|
965 |
"scroll n indices right
|
|
966 |
"
|
|
967 |
self scroll:nIndices
|
|
968 |
|
|
969 |
!
|
|
970 |
|
|
971 |
windowSizeLeft
|
|
972 |
"scroll left window size
|
|
973 |
"
|
|
974 |
self scrollLeft:windowSize
|
|
975 |
|
|
976 |
!
|
|
977 |
|
|
978 |
windowSizeRight
|
|
979 |
"scroll right window size
|
|
980 |
"
|
|
981 |
self scrollRight:windowSize
|
|
982 |
|
|
983 |
! !
|
|
984 |
|
741
|
985 |
!GraphColumnView class methodsFor:'documentation'!
|
|
986 |
|
|
987 |
version
|
749
|
988 |
^ '$Header: /cvs/stx/stx/libwidg2/GraphColumnView.st,v 1.2 1998-02-09 10:31:27 ca Exp $'
|
741
|
989 |
! !
|