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