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