author | Jan Vrany <jan.vrany@labware.com> |
Thu, 09 Feb 2023 14:03:49 +0000 | |
branch | jv |
changeset 6265 | 09ae5bbed69e |
parent 4770 | 6634b540fea2 |
permissions | -rw-r--r-- |
3150 | 1 |
"{ Package: 'stx:libwidg2' }" |
2 |
||
4770
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3150
diff
changeset
|
3 |
"{ NameSpace: Smalltalk }" |
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3150
diff
changeset
|
4 |
|
741 | 5 |
Model subclass:#GraphColumn |
6 |
instanceVariableNames:'aspects functionYblock' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'Views-Graphs' |
|
10 |
! |
|
11 |
||
748 | 12 |
!GraphColumn class methodsFor:'documentation'! |
13 |
||
14 |
documentation |
|
15 |
" |
|
16 |
a model, which keeps all the information to describe a graph column as used by |
|
17 |
the GraphColumnView. Each change of an attribute will raise a change notification |
|
18 |
and immediately take affect in the graphs |
|
19 |
||
20 |
||
21 |
[author:] |
|
3150 | 22 |
Claus Atzkern |
748 | 23 |
|
24 |
[see also:] |
|
3150 | 25 |
GraphColumnView |
26 |
GraphColumnView2D |
|
27 |
GraphColumnView3D |
|
748 | 28 |
" |
29 |
||
30 |
! ! |
|
741 | 31 |
|
32 |
!GraphColumn class methodsFor:'instance creation'! |
|
33 |
||
34 |
name:aName |
|
35 |
^ self new name:aName |
|
36 |
! |
|
37 |
||
38 |
new |
|
39 |
^ super basicNew initialize |
|
40 |
! ! |
|
41 |
||
755 | 42 |
!GraphColumn class methodsFor:'constants'! |
43 |
||
44 |
lineStyleFor:aStyle |
|
45 |
"returns the valid style for a style; supported styles |
|
46 |
are: |
|
3150 | 47 |
#dashed and #solid |
755 | 48 |
" |
49 |
^ aStyle == #dashed ifFalse:[#solid] ifTrue:[#dashed] |
|
50 |
||
51 |
! ! |
|
52 |
||
741 | 53 |
!GraphColumn class methodsFor:'menu definitions'! |
54 |
||
55 |
colorMenuSelector:aSelector |
|
56 |
"specification used to build the Menu |
|
57 |
" |
|
58 |
^ ColorMenu colorMenu:true value:aSelector. |
|
59 |
! |
|
60 |
||
61 |
middleButtonMenu |
|
62 |
"this window spec was automatically generated by the ST/X MenuEditor" |
|
63 |
||
64 |
"do not manually edit this - the builder may not be able to |
|
65 |
handle the specification if its corrupted." |
|
66 |
||
67 |
" |
|
68 |
MenuEditor new openOnClass:GraphColumn andSelector:#middleButtonMenu |
|
69 |
(Menu new fromLiteralArrayEncoding:(GraphColumn middleButtonMenu)) startUp |
|
70 |
" |
|
71 |
||
72 |
<resource: #menu> |
|
73 |
||
74 |
^ |
|
3150 | 75 |
|
741 | 76 |
#(#Menu |
3150 | 77 |
|
78 |
#( |
|
79 |
#(#MenuItem |
|
80 |
#'label:' 'Style' |
|
81 |
#'argument:' #'lineStyle:' |
|
82 |
#'submenuChannel:' #'styleMenuSelector:' |
|
83 |
) |
|
84 |
#(#MenuItem |
|
85 |
#'label:' 'Size' |
|
86 |
#'argument:' #'lineWidth:' |
|
87 |
#'submenuChannel:' #'widthMenuSelector:' |
|
88 |
) |
|
89 |
#(#MenuItem |
|
90 |
#'label:' 'Color' |
|
91 |
#'argument:' #'foregroundColor:' |
|
92 |
#'submenuChannel:' #'colorMenuSelector:' |
|
93 |
) |
|
94 |
#(#MenuItem |
|
95 |
#'label:' 'Zoom Y' |
|
96 |
#'argument:' #'zoomY:' |
|
97 |
#'submenuChannel:' #'zoomMenuSelector:' |
|
98 |
) |
|
99 |
) nil |
|
100 |
nil |
|
741 | 101 |
) |
102 |
! |
|
103 |
||
104 |
styleMenuSelector:aSelector |
|
105 |
|menu width height item bitmap| |
|
106 |
||
107 |
menu := Menu new. |
|
108 |
width := 40. |
|
109 |
height := 10. |
|
110 |
||
111 |
#( #solid #dashed ) do:[:style| |
|
3150 | 112 |
bitmap := Form width:width height:height depth:1. |
113 |
bitmap paint:(Color colorId:1). |
|
114 |
bitmap fillRectangleX:0 y:0 width:width height:height. |
|
741 | 115 |
|
3150 | 116 |
bitmap paint:(Color colorId:0). |
117 |
bitmap fillRectangleX:0 y:0 width:width height:height. |
|
118 |
bitmap paint:(Color colorId:1). |
|
119 |
bitmap lineWidth:2. |
|
120 |
bitmap lineStyle:style. |
|
121 |
bitmap displayLineFromX:2 y:(height // 2) toX:width-2 y:(height // 2). |
|
122 |
item := MenuItem labeled:bitmap. |
|
123 |
item value:aSelector. |
|
124 |
item argument:style. |
|
125 |
menu addItem:item. |
|
741 | 126 |
]. |
127 |
^ menu |
|
128 |
||
129 |
" |
|
130 |
(self styleMenuSelector:#lineStyle) startUp |
|
131 |
" |
|
132 |
||
133 |
! |
|
134 |
||
135 |
widthMenuSelector:aSelector |
|
136 |
|menu width item bitmap| |
|
137 |
||
138 |
menu := Menu new. |
|
139 |
width := 40. |
|
140 |
||
141 |
#( 1 2 3 4 5 6 ) do:[:height| |
|
3150 | 142 |
bitmap := Form width:width height:height depth:1. |
143 |
bitmap paint:(Color colorId:1). |
|
144 |
bitmap fillRectangleX:0 y:0 width:width height:height. |
|
741 | 145 |
|
3150 | 146 |
item := MenuItem labeled:bitmap. |
147 |
item value:aSelector. |
|
148 |
item argument:height. |
|
149 |
menu addItem:item. |
|
741 | 150 |
]. |
151 |
item := MenuItem labeled:'other ..'. |
|
152 |
item value:[:arg :panel||n| |
|
3150 | 153 |
n := Number fromString:(Dialog request:'size:') onError:nil. |
741 | 154 |
|
3150 | 155 |
n notNil ifTrue:[ |
156 |
panel receiver perform:aSelector with:n |
|
157 |
] |
|
741 | 158 |
]. |
159 |
menu addItem:item. |
|
160 |
^ menu |
|
161 |
||
162 |
" |
|
163 |
(self widthMenuSelector:#lineWidth) startUp |
|
164 |
" |
|
165 |
||
166 |
! |
|
167 |
||
168 |
zoomMenuSelector:aSelector |
|
169 |
"specification used to build the Menu |
|
170 |
" |
|
171 |
|menu width item bitmap| |
|
172 |
||
173 |
menu := Menu new. |
|
174 |
width := 40. |
|
175 |
||
176 |
#( 25 50 75 nil 100 nil 150 200 nil ) do:[:zY| |
|
3150 | 177 |
zY notNil ifTrue:[ |
178 |
item := MenuItem labeled:(zY printString, ' %' ). |
|
179 |
item value:aSelector. |
|
180 |
item argument:(zY / 100). |
|
181 |
] ifFalse:[ |
|
182 |
item := MenuItem labeled:'-'. |
|
183 |
]. |
|
184 |
menu addItem:item. |
|
741 | 185 |
]. |
186 |
item := MenuItem labeled:'other ..'. |
|
187 |
item value:[:arg :panel||n| |
|
3150 | 188 |
n := Number fromString:(Dialog request:'zoom %:') onError:nil. |
741 | 189 |
|
3150 | 190 |
n notNil ifTrue:[ |
191 |
panel receiver perform:aSelector with:(n / 100) |
|
192 |
] |
|
741 | 193 |
]. |
194 |
menu addItem:item. |
|
195 |
^ menu |
|
196 |
||
197 |
" |
|
198 |
(self zoomMenuSelector:#zoomY) startUp |
|
199 |
" |
|
200 |
||
201 |
! ! |
|
202 |
||
203 |
!GraphColumn methodsFor:'accessing'! |
|
204 |
||
205 |
name |
|
206 |
"get the name of the column |
|
207 |
" |
|
208 |
^ aspects at:#name ifAbsent:nil |
|
209 |
! |
|
210 |
||
211 |
name:aName |
|
212 |
"set the name of the column |
|
213 |
" |
|
214 |
self aspectAt:#name put:aName |
|
215 |
! |
|
216 |
||
217 |
relativeXaxis |
|
748 | 218 |
"returns the relative X-axis (y == 0) into the graph view; staring at top (0.0) to |
219 |
bottom (1.0). Thus a relative X axis of 0.5 means the graph is centered in the view. |
|
741 | 220 |
" |
221 |
^ aspects at:#relativeXaxis ifAbsent:0.5 |
|
222 |
||
223 |
||
224 |
! |
|
225 |
||
755 | 226 |
relativeXaxis:aValue |
748 | 227 |
"sets the relative X-axis (y == 0) into the graph view; staring at top (0.0) to |
228 |
bottom (1.0). Thus a relative X axis of 0.5 means the graph is centered in the view. |
|
229 |
In case that the value is not a valid number, the relative X axis is set to 0.5. |
|
741 | 230 |
" |
231 |
|x| |
|
232 |
||
755 | 233 |
self aspectAt:#relativeXaxis put:(self numberFrom:aValue onError:[0.5]) |
741 | 234 |
|
235 |
! |
|
236 |
||
237 |
scaleY |
|
748 | 238 |
"returns the current y-scale of the column (~~ 0); this value should be set once |
755 | 239 |
dependent on the maximum and minimum Y value. To zoom the graph vertical use |
748 | 240 |
insteat #zoomY:. |
741 | 241 |
" |
242 |
^ aspects at:#scaleY ifAbsent:1 |
|
243 |
! |
|
244 |
||
755 | 245 |
scaleY:aFactor |
748 | 246 |
"set the current y-scale of the column (~~ 0); this value should be set once |
755 | 247 |
dependent on the maximum and minimum Y value. To zoom the graph vertical use |
748 | 248 |
insteat #zoomY:. |
249 |
In case that the value is not a valid number or less equal zero, the scale Y |
|
250 |
factor is set to its default value (1). |
|
741 | 251 |
" |
252 |
|y| |
|
253 |
||
755 | 254 |
(y := self numberFrom:aFactor onError:[1]) > 0 ifFalse:[ y := 1 ]. |
741 | 255 |
self aspectAt:#scaleY put:y |
256 |
! |
|
257 |
||
258 |
shown |
|
748 | 259 |
"returns true if the column is shown otherwise false |
741 | 260 |
" |
261 |
^ aspects at:#shown ifAbsent:true |
|
262 |
! |
|
263 |
||
264 |
shown:aState |
|
748 | 265 |
"set the visibility state of the column |
741 | 266 |
" |
267 |
self aspectAt:#shown put:aState |
|
268 |
! |
|
269 |
||
270 |
transY |
|
748 | 271 |
"get the current y-transition of the column; the default is 0 |
741 | 272 |
" |
273 |
^ aspects at:#transY ifAbsent:0 |
|
274 |
! |
|
275 |
||
755 | 276 |
transY:aValue |
741 | 277 |
"set the current y-transition of the column to an integer or nil (== 0). |
278 |
" |
|
755 | 279 |
self aspectAt:#transY put:(self integerFrom:aValue onError:[0]) |
741 | 280 |
! |
281 |
||
282 |
zoomY |
|
748 | 283 |
"returns the current y-zoom factor of the column excluding the scale Y factor |
741 | 284 |
" |
285 |
^ aspects at:#zoomY ifAbsent:1 |
|
286 |
! |
|
287 |
||
288 |
zoomY:aFactor |
|
748 | 289 |
"set the current y-zoom factor of the column. The graph and its |
290 |
horizontal lines are vertical zoomed relative to its center defined |
|
291 |
by the relativeXaxis. |
|
292 |
In case that the value is not a valid number or less equal zero, the zoom Y |
|
293 |
factor is set to its default value (1). |
|
741 | 294 |
" |
295 |
|y| |
|
296 |
||
755 | 297 |
(y := self numberFrom:aFactor onError:[1]) > 0 ifFalse:[ y := 1 ]. |
741 | 298 |
self aspectAt:#zoomY put:y |
299 |
! ! |
|
300 |
||
301 |
!GraphColumn methodsFor:'accessing Y function'! |
|
302 |
||
303 |
functionYblock |
|
304 |
"get the two arguments block which is used to access Y values from |
|
305 |
start into an array. The block should return the collection of y |
|
306 |
values; see method: #from:into: |
|
307 |
" |
|
308 |
^ functionYblock |
|
309 |
! |
|
310 |
||
311 |
functionYblock:something |
|
312 |
"set the two arguments block which is used to access Y values from |
|
313 |
start into an array. The block should return the collection of y |
|
314 |
values; see method: #from:into: |
|
315 |
" |
|
316 |
functionYblock := something. |
|
317 |
self changed. |
|
318 |
! ! |
|
319 |
||
320 |
!GraphColumn methodsFor:'accessing Y values'! |
|
321 |
||
322 |
yValueAt:anIndex |
|
748 | 323 |
"returns the Y value at an index |
741 | 324 |
" |
325 |
^ (self yValuesStartAt:anIndex into:(Array new:1)) at:1 |
|
326 |
! |
|
327 |
||
328 |
yValuesStartAt:start into:anArray |
|
748 | 329 |
"returns the Y values from start upto an array size. The collection of Y |
330 |
values should be returned. |
|
331 |
You can use the argument anArray, to store the Y values or a new array. |
|
332 |
The functionYblock is obligated to return the array used |
|
741 | 333 |
" |
334 |
^ functionYblock value:start value:anArray |
|
335 |
! ! |
|
336 |
||
337 |
!GraphColumn methodsFor:'accessing graph'! |
|
338 |
||
339 |
foregroundColor |
|
748 | 340 |
"returns the color of the graph; if the color is nil the default foreground color |
341 |
of the graph is used which derives from the style sheet. |
|
741 | 342 |
" |
343 |
^ aspects at:#foregroundColor ifAbsent:nil |
|
344 |
||
345 |
! |
|
346 |
||
347 |
foregroundColor:aColor |
|
748 | 348 |
"set the color of the graph; if the color is nil the default foreground color |
349 |
of the graph is used which derives from the style sheet. |
|
741 | 350 |
" |
351 |
self aspectAt:#foregroundColor put:aColor |
|
352 |
||
353 |
! |
|
354 |
||
355 |
lineStyle |
|
748 | 356 |
"returns the style in which the graph is drawn; if no style is defined, the |
357 |
default style is used (#solid). |
|
358 |
||
755 | 359 |
Supported styles are: |
3150 | 360 |
#solid or #dashed |
741 | 361 |
" |
362 |
^ aspects at:#lineStyle ifAbsent:#solid |
|
363 |
! |
|
364 |
||
365 |
lineStyle:aStyle |
|
748 | 366 |
"set the style in which the graph is drawn; if no style is defined or |
367 |
in case of a non valid style, the default style is used (#solid). |
|
368 |
||
755 | 369 |
Supported styles are: |
3150 | 370 |
#solid or #dashed |
741 | 371 |
" |
755 | 372 |
self aspectAt:#lineStyle put:(self class lineStyleFor:aStyle) |
741 | 373 |
! |
374 |
||
375 |
lineWidth |
|
748 | 376 |
"returns the width of the graph line |
741 | 377 |
" |
378 |
^ aspects at:#lineWidth ifAbsent:1 |
|
379 |
! |
|
380 |
||
381 |
lineWidth:anInteger |
|
748 | 382 |
"set the width of the graph line; if the width is not defined or |
383 |
not a valid number, the default value is set (1). |
|
741 | 384 |
" |
385 |
self aspectAt:#lineWidth put:(anInteger ? 1) |
|
386 |
! ! |
|
387 |
||
388 |
!GraphColumn methodsFor:'accessing hLines'! |
|
389 |
||
390 |
hLineFgColor |
|
748 | 391 |
"returns the color of the horizontal lines; if the color is nil the default foreground |
392 |
color of the graph is used which derives from the style sheet. |
|
741 | 393 |
" |
394 |
^ aspects at:#hLineFgColor ifAbsent:nil |
|
395 |
! |
|
396 |
||
397 |
hLineFgColor:aColor |
|
748 | 398 |
"set the color of the horizontal lines; if the color is nil the default foreground |
399 |
color of the graph is used which derives from the style sheet. |
|
741 | 400 |
" |
401 |
self aspectAt:#hLineFgColor put:aColor |
|
402 |
! |
|
403 |
||
404 |
hLineList |
|
748 | 405 |
"returns the list of horizontal lines or nil |
741 | 406 |
" |
407 |
^ aspects at:#hLineList ifAbsent:nil |
|
408 |
! |
|
409 |
||
410 |
hLineList:aCollection |
|
748 | 411 |
"set the list of horizontal lines to be drawn |
741 | 412 |
" |
413 |
|col| |
|
414 |
||
755 | 415 |
col := (aCollection size ~~ 0) ifTrue:[aCollection] |
3150 | 416 |
ifFalse:[nil]. |
741 | 417 |
|
418 |
self aspectAt:#hLineList put:col |
|
419 |
! |
|
420 |
||
421 |
hLineStyle |
|
748 | 422 |
"returns the style in which the horizontal lines are drawn; if no style is |
423 |
defined, the default style is used (#solid). |
|
424 |
||
755 | 425 |
Supported styles are: |
3150 | 426 |
#solid or #dashed |
741 | 427 |
" |
428 |
^ aspects at:#hLineStyle ifAbsent:#solid |
|
429 |
! |
|
430 |
||
431 |
hLineStyle:aStyle |
|
748 | 432 |
"set the style in which the horizontal lines are drawn; if no style is defined |
433 |
or in case of a non valid style, the default style is used (#solid). |
|
434 |
||
755 | 435 |
Supported styles are: |
3150 | 436 |
#solid or #dashed. |
741 | 437 |
" |
755 | 438 |
self aspectAt:#hLineStyle put:(self class lineStyleFor:aStyle) |
748 | 439 |
|
741 | 440 |
! |
441 |
||
442 |
hLineWidth |
|
748 | 443 |
"returns the width of the horizontal lines |
741 | 444 |
" |
445 |
^ aspects at:#hLineWidth ifAbsent:1 |
|
446 |
||
447 |
! |
|
448 |
||
449 |
hLineWidth:anInteger |
|
748 | 450 |
"set the width of the horizontal lines; if the width is not defined or |
451 |
not a valid number, the default value is set (1). |
|
741 | 452 |
" |
453 |
self aspectAt:#hLineWidth put:(anInteger ? 1) |
|
454 |
||
455 |
||
456 |
! ! |
|
457 |
||
458 |
!GraphColumn methodsFor:'accessing menu'! |
|
459 |
||
460 |
middleButtonMenu |
|
748 | 461 |
"returns the default middle button menu of a column |
462 |
" |
|
741 | 463 |
|menu| |
464 |
||
465 |
menu := Menu new fromLiteralArrayEncoding:(self class middleButtonMenu). |
|
466 |
menu receiver:self. |
|
467 |
^ menu |
|
468 |
||
469 |
||
470 |
! ! |
|
471 |
||
755 | 472 |
!GraphColumn methodsFor:'accessing without notify'! |
473 |
||
474 |
setForegroundColor:aColor |
|
475 |
"set the color of the graph; if the color is nil the default foreground color |
|
476 |
of the graph is used which derives from the style sheet. |
|
477 |
No change notification is raised |
|
478 |
" |
|
479 |
self withoutNotificationAspectAt:#foregroundColor put:aColor |
|
480 |
||
481 |
! |
|
482 |
||
483 |
setHLineFgColor:aColor |
|
484 |
"set the color of the horizontal lines; if the color is nil the default foreground |
|
485 |
color of the graph is used which derives from the style sheet. |
|
486 |
No change notification is raised |
|
487 |
" |
|
488 |
self withoutNotificationAspectAt:#hLineFgColor put:aColor |
|
489 |
! |
|
490 |
||
491 |
setHLineList:aCollection |
|
492 |
"set the list of horizontal lines to be drawn; no |
|
493 |
change notification is raised |
|
494 |
" |
|
495 |
|col| |
|
496 |
||
497 |
col := (aCollection size ~~ 0) ifTrue:[aCollection] |
|
3150 | 498 |
ifFalse:[nil]. |
755 | 499 |
|
500 |
self withoutNotificationAspectAt:#hLineList put:col |
|
501 |
! |
|
502 |
||
503 |
setHLineStyle:aStyle |
|
504 |
"set the style in which the horizontal lines are drawn; if no style is defined |
|
505 |
or in case of a non valid style, the default style is used (#solid). |
|
506 |
No change notification is raised. |
|
507 |
||
508 |
Supported styles are: |
|
3150 | 509 |
#solid or #dashed. |
755 | 510 |
" |
511 |
self withoutNotificationAspectAt:#hLineStyle put:(self class lineStyleFor:aStyle) |
|
512 |
||
513 |
! |
|
514 |
||
515 |
setHLineWidth:anInteger |
|
516 |
"set the width of the horizontal lines; if the width is not defined or |
|
517 |
not a valid number, the default value is set (1). |
|
518 |
No change notification is raised. |
|
519 |
" |
|
520 |
self withoutNotificationAspectAt:#hLineWidth put:(anInteger ? 1) |
|
521 |
||
522 |
||
523 |
! |
|
524 |
||
525 |
setLineStyle:aStyle |
|
526 |
"set the style in which the graph is drawn; if no style is defined or |
|
527 |
in case of a non valid style, the default style is used (#solid). |
|
528 |
No change notification is raised. |
|
529 |
||
530 |
Supported styles are: |
|
3150 | 531 |
#solid or #dashed |
755 | 532 |
" |
533 |
self withoutNotificationAspectAt:#lineStyle put:(self class lineStyleFor:aStyle) |
|
534 |
||
535 |
! |
|
536 |
||
537 |
setLineWidth:anInteger |
|
538 |
"set the width of the graph line; if the width is not defined or |
|
539 |
not a valid number, the default value is set (1). |
|
540 |
No change notification is raised |
|
541 |
" |
|
542 |
self withoutNotificationAspectAt:#lineWidth put:(anInteger ? 1) |
|
543 |
! |
|
544 |
||
545 |
setName:aName |
|
546 |
"set the name of the column; no change notification is raised |
|
547 |
" |
|
548 |
self withoutNotificationAspectAt:#name put:aName |
|
549 |
! |
|
550 |
||
551 |
setRelativeXaxis:aValue |
|
552 |
"sets the relative X-axis (y == 0) into the graph view; staring at top (0.0) to |
|
553 |
bottom (1.0). Thus a relative X axis of 0.5 means the graph is centered in the view. |
|
554 |
In case that the value is not a valid number, the relative X axis is set to 0.5. |
|
555 |
No change notification is raised. |
|
556 |
" |
|
557 |
self withoutNotificationAspectAt:#relativeXaxis |
|
3150 | 558 |
put:(self numberFrom:aValue onError:[0.5]) |
755 | 559 |
|
560 |
! |
|
561 |
||
562 |
setScaleY:aFactor |
|
563 |
"set the current y-scale of the column (~~ 0); this value should be set once |
|
564 |
dependent on the maximum and minimum Y value. To zoom the graph vertical use |
|
565 |
insteat #zoomY:. |
|
566 |
In case that the value is not a valid number or less equal zero, the scale Y |
|
567 |
factor is set to its default value (1). |
|
568 |
No change notification is raised. |
|
569 |
" |
|
570 |
|y| |
|
571 |
||
572 |
(y := self numberFrom:aFactor onError:[1]) > 0 ifFalse:[ y := 1 ]. |
|
573 |
self withoutNotificationAspectAt:#scaleY put:y |
|
574 |
! |
|
575 |
||
576 |
setShown:aState |
|
3150 | 577 |
"set the visibility state of the column; |
755 | 578 |
no notification is raised |
579 |
" |
|
580 |
self withoutNotificationAspectAt:#shown put:aState |
|
581 |
! |
|
582 |
||
583 |
setTransY:aValue |
|
584 |
"set the current y-transition of the column to an integer or nil (== 0). |
|
585 |
no notification is raised |
|
586 |
" |
|
587 |
self withoutNotificationAspectAt:#transY |
|
3150 | 588 |
put:(self integerFrom:aValue onError:[0]) |
755 | 589 |
! |
590 |
||
591 |
setZoomY:aFactor |
|
592 |
"set the current y-zoom factor of the column. The graph and its |
|
593 |
horizontal lines are vertical zoomed relative to its center defined |
|
594 |
by the relativeXaxis. |
|
595 |
In case that the value is not a valid number or less equal zero, the zoom Y |
|
596 |
factor is set to its default value (1). |
|
597 |
No change notification is raised. |
|
598 |
" |
|
599 |
|y| |
|
600 |
||
601 |
(y := self numberFrom:aFactor onError:[1]) > 0 ifFalse:[ y := 1 ]. |
|
602 |
self withoutNotificationAspectAt:#zoomY put:y |
|
603 |
! ! |
|
604 |
||
741 | 605 |
!GraphColumn methodsFor:'aspects'! |
606 |
||
607 |
aspect |
|
608 |
"returns current aspects |
|
609 |
" |
|
610 |
^ aspects |
|
611 |
! |
|
612 |
||
613 |
aspectAt:aKey put:aValue |
|
748 | 614 |
"set an aspect; if the aspect changed its value, a notification will |
615 |
be raised. The arguments to the change notifications is the key of |
|
616 |
the aspect (selector) and the old value of the aspect. |
|
617 |
" |
|
741 | 618 |
|oldValue| |
619 |
||
620 |
oldValue := aspects at:aKey ifAbsent:nil. |
|
621 |
||
622 |
oldValue ~= aValue ifTrue:[ |
|
3150 | 623 |
aValue isNil ifTrue:[aspects removeKey:aKey] |
624 |
ifFalse:[aspects at:aKey put:aValue]. |
|
741 | 625 |
|
3150 | 626 |
self changed:aKey with:oldValue |
741 | 627 |
] |
628 |
! |
|
629 |
||
630 |
aspects:aDictionaryOrNil |
|
631 |
"change aspects; raise a change notification when changed. If the argument is |
|
632 |
nil, the default aspects are set |
|
633 |
" |
|
634 |
|oldAspects| |
|
635 |
||
636 |
aDictionaryOrNil == aspects ifFalse:[ |
|
3150 | 637 |
oldAspects := aspects. |
638 |
self setAspects:aDictionaryOrNil. |
|
639 |
self changed:#aspects with:oldAspects. |
|
741 | 640 |
] |
641 |
! |
|
642 |
||
643 |
setAspects:aDictionaryOrNil |
|
644 |
"change aspects; raise no notification. If the argument is |
|
645 |
nil, the default aspects are set |
|
646 |
" |
|
647 |
aDictionaryOrNil isNil ifTrue:[ |
|
3150 | 648 |
aspects := IdentityDictionary new. |
741 | 649 |
|
3150 | 650 |
aspects at:#hLineWidth put:1. |
651 |
aspects at:#lineWidth put:1. |
|
652 |
aspects at:#scaleY put:1. |
|
653 |
aspects at:#zoomY put:1. |
|
654 |
aspects at:#transY put:0. |
|
655 |
aspects at:#relativeXaxis put:0.5. |
|
741 | 656 |
] ifFalse:[ |
3150 | 657 |
aspects := aDictionaryOrNil |
741 | 658 |
] |
755 | 659 |
! |
660 |
||
661 |
withoutNotificationAspectAt:aKey put:aValue |
|
662 |
"set an aspect without a change notification |
|
663 |
" |
|
664 |
aValue notNil ifTrue:[ aspects at:aKey put:aValue ] |
|
3150 | 665 |
ifFalse:[ aspects removeKey:aKey ifAbsent:nil ] |
755 | 666 |
! ! |
667 |
||
668 |
!GraphColumn methodsFor:'conversion'! |
|
669 |
||
670 |
integerFrom:aValue onError:aBlock |
|
671 |
"converts something to an integer, on error the result of the block is returned |
|
672 |
" |
|
673 |
|v| |
|
674 |
||
675 |
aValue isNumber ifTrue:[ |
|
3150 | 676 |
^ aValue isInteger ifTrue:[aValue] |
677 |
ifFalse:[(aValue asFloat) rounded] "/ no fractions |
|
755 | 678 |
]. |
679 |
^ aBlock value |
|
680 |
||
681 |
||
682 |
! |
|
683 |
||
684 |
numberFrom:aValue onError:aBlock |
|
685 |
"converts something to a number (no fractions); on error |
|
686 |
the result of the block is returned |
|
687 |
" |
|
688 |
aValue isNumber ifTrue:[ |
|
3150 | 689 |
^ aValue isInteger ifTrue:[aValue] |
690 |
ifFalse:[aValue asFloat] "/ no fractions |
|
755 | 691 |
]. |
692 |
^ aBlock value |
|
741 | 693 |
! ! |
694 |
||
695 |
!GraphColumn methodsFor:'initialization'! |
|
696 |
||
697 |
initialize |
|
698 |
"setup default values |
|
699 |
" |
|
700 |
super initialize. |
|
701 |
self setAspects:nil. |
|
702 |
! ! |
|
703 |
||
704 |
!GraphColumn methodsFor:'printing'! |
|
705 |
||
706 |
printString |
|
707 |
"returns my printable string |
|
708 |
" |
|
709 |
|name| |
|
710 |
||
711 |
^ (name := self name) notNil ifTrue:[name printString] ifFalse:[''] |
|
712 |
! ! |
|
713 |
||
714 |
!GraphColumn methodsFor:'queries'! |
|
715 |
||
716 |
centerGraphMaxY:maxY minY:minY |
|
755 | 717 |
"set the transition Y for the graph dependent on the current scaleY, the maximum |
748 | 718 |
and minimum Y value; the graph is centered to its relative X-Axis. |
741 | 719 |
" |
720 |
self transY:(((maxY + minY) / 2) * self scaleY) |
|
721 |
! |
|
722 |
||
723 |
scaleToHeight:aHeight maxY:maxY minY:minY |
|
755 | 724 |
"set the scale Y value dependent on the maximum and minimum Y value to fit into |
741 | 725 |
a height >= 1 |
726 |
" |
|
727 |
|dltY| |
|
728 |
||
729 |
(dltY := (maxY - minY) abs) = 0 ifTrue:[dltY := 1]. |
|
730 |
self scaleY:((aHeight max:1) / dltY) |
|
731 |
! ! |
|
732 |
||
733 |
!GraphColumn class methodsFor:'documentation'! |
|
734 |
||
735 |
version |
|
3150 | 736 |
^ '$Header: /cvs/stx/stx/libwidg2/GraphColumn.st,v 1.4 2006-11-13 16:11:29 cg Exp $' |
741 | 737 |
! ! |
4770
6634b540fea2
Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3150
diff
changeset
|
738 |