1
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
186
|
3 |
All Rights Reserved
|
1
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
356
|
13 |
Geometric subclass:#Rectangle
|
1
|
14 |
instanceVariableNames:'left top width height'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
308
|
17 |
category:'Graphics-Geometry'
|
1
|
18 |
!
|
|
19 |
|
|
20 |
Rectangle comment:'
|
5
|
21 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
186
|
22 |
All Rights Reserved
|
93
|
23 |
|
362
|
24 |
$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.23 1995-07-22 19:24:16 claus Exp $
|
1
|
25 |
'!
|
|
26 |
|
77
|
27 |
!Rectangle class methodsFor:'documentation'!
|
|
28 |
|
88
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
186
|
32 |
All Rights Reserved
|
88
|
33 |
|
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
362
|
45 |
$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.23 1995-07-22 19:24:16 claus Exp $
|
88
|
46 |
"
|
|
47 |
!
|
|
48 |
|
77
|
49 |
documentation
|
|
50 |
"
|
|
51 |
Rectangles represent a rectangular area in 2D space.
|
|
52 |
|
|
53 |
notice, my implementation does not use origin/corner as instance objects
|
|
54 |
but left/top/width/height to save space and allocations. This means, that my
|
|
55 |
Rectangles cannot be used to represent Rectangles in a higher than 2D
|
|
56 |
space. (i.e. only valid if origin/corner are 2D Points)
|
|
57 |
|
|
58 |
(aside from that, you will not see any difference from the outside)
|
|
59 |
|
|
60 |
Instance variables:
|
|
61 |
|
186
|
62 |
left <Number> the left coordinate (i.e origin x)
|
|
63 |
top <Number> the top coordinate (i.e origin y)
|
|
64 |
width <Number> the width of the rectangle
|
|
65 |
height <Number> the height of the rectangle
|
77
|
66 |
|
|
67 |
I am not certain, if implementing Rectangle different was a good idea -
|
|
68 |
subclasses may expect things to be different ...
|
|
69 |
Therefore, this may change.
|
|
70 |
"
|
|
71 |
! !
|
|
72 |
|
1
|
73 |
!Rectangle class methodsFor:'instance creation'!
|
|
74 |
|
|
75 |
origin:origin corner:corner
|
|
76 |
"create and return a new Rectangle giving top-left and bottom-right points"
|
|
77 |
|
|
78 |
^ (self basicNew) origin:origin corner:corner
|
|
79 |
!
|
|
80 |
|
|
81 |
origin:origin extent:extent
|
|
82 |
"create and return a new Rectangle giving top-left point and extent point"
|
|
83 |
|
|
84 |
%{ /* NOCONTEXT */
|
59
|
85 |
REGISTER OBJ newRect;
|
1
|
86 |
extern OBJ Point;
|
293
|
87 |
OBJ t;
|
|
88 |
int spc;
|
1
|
89 |
|
|
90 |
/* short cut - rectangles are created so often ... */
|
|
91 |
if (_CanDoQuickNew(OHDR_SIZE + 4*sizeof(OBJ))) {
|
186
|
92 |
if (self == Rectangle) {
|
|
93 |
if (__isPoint(origin) && __isPoint(extent)) {
|
|
94 |
_qCheckedAlignedNew(newRect, OHDR_SIZE + 4*sizeof(OBJ));
|
|
95 |
_InstPtr(newRect)->o_class = Rectangle;
|
325
|
96 |
spc = __qSpace(newRect);
|
59
|
97 |
|
325
|
98 |
t = _PointInstPtr(origin)->p_x;
|
293
|
99 |
_InstPtr(newRect)->i_instvars[0] = t;
|
|
100 |
__STORE_SPC(newRect, t, spc);
|
|
101 |
|
325
|
102 |
t = _PointInstPtr(origin)->p_y;
|
293
|
103 |
_InstPtr(newRect)->i_instvars[1] = t;
|
|
104 |
__STORE_SPC(newRect, t, spc);
|
59
|
105 |
|
325
|
106 |
t = _PointInstPtr(extent)->p_x;
|
293
|
107 |
_InstPtr(newRect)->i_instvars[2] = t;
|
|
108 |
__STORE_SPC(newRect, t, spc);
|
|
109 |
|
325
|
110 |
t = _PointInstPtr(extent)->p_y;
|
293
|
111 |
_InstPtr(newRect)->i_instvars[3] = t;
|
|
112 |
__STORE_SPC(newRect, t, spc);
|
186
|
113 |
RETURN ( newRect );
|
|
114 |
}
|
|
115 |
}
|
1
|
116 |
}
|
|
117 |
%}
|
|
118 |
.
|
|
119 |
^ (self basicNew) origin:origin extent:extent
|
|
120 |
!
|
|
121 |
|
|
122 |
left:left top:top width:w height:h
|
|
123 |
"create and return a new Rectangle giving left and top coordinates
|
|
124 |
and width, height"
|
|
125 |
|
|
126 |
%{ /* NOCONTEXT */
|
59
|
127 |
REGISTER OBJ newRect;
|
293
|
128 |
OBJ t;
|
|
129 |
int spc;
|
1
|
130 |
|
|
131 |
if (_CanDoQuickNew(OHDR_SIZE + 4*sizeof(OBJ))) {
|
308
|
132 |
if (self == Rectangle) {
|
186
|
133 |
/* short cut - rectangles are created so often ... */
|
|
134 |
_qCheckedAlignedNew(newRect, OHDR_SIZE + 4*sizeof(OBJ));
|
293
|
135 |
|
186
|
136 |
_InstPtr(newRect)->o_class = Rectangle;
|
|
137 |
_InstPtr(newRect)->i_instvars[0] = left;
|
|
138 |
_InstPtr(newRect)->i_instvars[1] = top;
|
|
139 |
_InstPtr(newRect)->i_instvars[2] = w;
|
|
140 |
_InstPtr(newRect)->i_instvars[3] = h;
|
308
|
141 |
|
|
142 |
if (! (__bothSmallInteger(left, top) &&
|
|
143 |
__bothSmallInteger(w, h))) {
|
325
|
144 |
spc = __qSpace(newRect);
|
308
|
145 |
__STORE_SPC(newRect, left, spc);
|
|
146 |
__STORE_SPC(newRect, top, spc);
|
|
147 |
__STORE_SPC(newRect, w, spc);
|
|
148 |
__STORE_SPC(newRect, h, spc);
|
|
149 |
}
|
59
|
150 |
|
186
|
151 |
RETURN ( newRect );
|
|
152 |
}
|
1
|
153 |
}
|
|
154 |
%}
|
|
155 |
.
|
|
156 |
^ (self basicNew) left:left top:top width:w height:h
|
|
157 |
!
|
|
158 |
|
|
159 |
left:left right:right top:top bottom:bottom
|
|
160 |
"create and return a new Rectangle giving left, top, right and bottom coordinates"
|
|
161 |
|
|
162 |
^ (self basicNew) left:left right:right top:top bottom:bottom
|
|
163 |
!
|
|
164 |
|
|
165 |
left:left top:top right:right bottom:bottom
|
|
166 |
"create and return a new Rectangle giving left, top, right and bottom coordinates"
|
|
167 |
|
|
168 |
^ (self basicNew) left:left top:top right:right bottom:bottom
|
32
|
169 |
!
|
|
170 |
|
|
171 |
fromUser
|
|
172 |
"let user specify a rectangle on the screen, return it"
|
|
173 |
|
359
|
174 |
^ Screen current rectangleFromUser
|
32
|
175 |
|
356
|
176 |
"
|
|
177 |
Rectangle fromUser
|
|
178 |
"
|
1
|
179 |
! !
|
|
180 |
|
|
181 |
!Rectangle methodsFor:'accessing'!
|
|
182 |
|
|
183 |
left:newLeft right:right top:newTop bottom:bottom
|
77
|
184 |
"set the rectangle given left, top, right and bottom coordinates."
|
1
|
185 |
|
|
186 |
left := newLeft.
|
|
187 |
top := newTop.
|
|
188 |
width := right - left.
|
|
189 |
height := bottom - top
|
|
190 |
!
|
|
191 |
|
|
192 |
left:newLeft top:newTop right:right bottom:bottom
|
|
193 |
"set the rectangle given left, top, right and bottom coordinates"
|
|
194 |
|
|
195 |
left := newLeft.
|
|
196 |
top := newTop.
|
|
197 |
width := right - left.
|
|
198 |
height := bottom - top
|
|
199 |
!
|
|
200 |
|
|
201 |
left:newLeft top:newTop width:newWidth height:newHeight
|
|
202 |
"set the rectangle given left, top coordinates and width, height"
|
|
203 |
|
|
204 |
left := newLeft.
|
|
205 |
top := newTop.
|
|
206 |
width := newWidth.
|
|
207 |
height := newHeight
|
|
208 |
!
|
|
209 |
|
|
210 |
origin:aPoint
|
77
|
211 |
"set the top-left origin. The corner remains unchanged."
|
|
212 |
|
|
213 |
|newTop newLeft|
|
1
|
214 |
|
77
|
215 |
newTop := aPoint y.
|
|
216 |
newLeft := aPoint x.
|
|
217 |
height := height + (top - newTop).
|
|
218 |
width := width + (left - newLeft).
|
|
219 |
left := newLeft.
|
|
220 |
top := newTop
|
1
|
221 |
!
|
|
222 |
|
|
223 |
corner:aPoint
|
|
224 |
"set the bottom-right corner"
|
|
225 |
|
|
226 |
width := aPoint x - left.
|
|
227 |
height := aPoint y - top
|
|
228 |
!
|
|
229 |
|
|
230 |
top:aNumber
|
|
231 |
"set the top edge"
|
|
232 |
|
|
233 |
height := height + (top - aNumber).
|
|
234 |
top := aNumber
|
|
235 |
!
|
|
236 |
|
|
237 |
bottom:aNumber
|
|
238 |
"set the bottom edge"
|
|
239 |
|
|
240 |
height := aNumber - top
|
|
241 |
!
|
|
242 |
|
77
|
243 |
left:aNumber
|
|
244 |
"set the left edge"
|
|
245 |
|
|
246 |
width := width + (left - aNumber).
|
|
247 |
left := aNumber
|
|
248 |
!
|
|
249 |
|
|
250 |
right:aNumber
|
|
251 |
"set the right edge"
|
|
252 |
|
|
253 |
width := aNumber - left
|
|
254 |
!
|
|
255 |
|
|
256 |
topLeft:aPoint
|
|
257 |
"Set the top and left edges.
|
|
258 |
The bottom right remains unchanged."
|
|
259 |
|
|
260 |
|newTop|
|
|
261 |
|
|
262 |
newTop := aPoint y.
|
|
263 |
height := height + (top - newTop).
|
|
264 |
top := newTop.
|
|
265 |
width := aPoint x - left
|
|
266 |
!
|
|
267 |
|
|
268 |
topRight:aPoint
|
|
269 |
"Set the top and right edges.
|
|
270 |
The bottom left remains unchanged."
|
|
271 |
|
|
272 |
|newTop|
|
|
273 |
|
|
274 |
newTop := aPoint y.
|
|
275 |
height := height + (top - newTop).
|
|
276 |
top := newTop.
|
|
277 |
width := aPoint x - left
|
|
278 |
!
|
|
279 |
|
1
|
280 |
origin:origin corner:corner
|
|
281 |
"set both origin and corner"
|
|
282 |
|
|
283 |
left := origin x.
|
|
284 |
top := origin y.
|
|
285 |
width := corner x - left.
|
|
286 |
height := corner y - top
|
|
287 |
!
|
|
288 |
|
|
289 |
extent:aPoint
|
|
290 |
"set the extent from the argument, aPoint with width taken from aPoint x
|
|
291 |
and height taken from aPoint y"
|
|
292 |
|
|
293 |
width := aPoint x.
|
|
294 |
height := aPoint y
|
|
295 |
!
|
|
296 |
|
|
297 |
origin:origin extent:extent
|
|
298 |
"set both origin and extent"
|
|
299 |
|
|
300 |
left := origin x.
|
|
301 |
top := origin y.
|
|
302 |
width := extent x.
|
|
303 |
height := extent y
|
|
304 |
!
|
|
305 |
|
|
306 |
origin
|
|
307 |
"return the origin"
|
|
308 |
|
77
|
309 |
^ left @ top
|
1
|
310 |
!
|
|
311 |
|
|
312 |
corner
|
|
313 |
"return the corner"
|
|
314 |
|
77
|
315 |
^ (left + width) @ (top + height)
|
|
316 |
!
|
|
317 |
|
|
318 |
width
|
|
319 |
"return the width of the rectangle"
|
|
320 |
|
|
321 |
^ width
|
|
322 |
!
|
|
323 |
|
|
324 |
height
|
|
325 |
"return the height of the rectangle"
|
|
326 |
|
|
327 |
^ height
|
1
|
328 |
!
|
|
329 |
|
|
330 |
extent
|
|
331 |
"return the extent"
|
|
332 |
|
77
|
333 |
^ width @ height
|
|
334 |
!
|
|
335 |
|
|
336 |
left
|
|
337 |
"return the x-coordinate of the top-left origin"
|
|
338 |
|
|
339 |
^ left
|
|
340 |
!
|
|
341 |
|
|
342 |
leftCenter
|
|
343 |
"return the left center point"
|
|
344 |
|
|
345 |
^ left @ (top + (height // 2))
|
|
346 |
!
|
|
347 |
|
|
348 |
top
|
|
349 |
"return the y-coordinate of the top-left"
|
|
350 |
|
|
351 |
^ top
|
1
|
352 |
!
|
|
353 |
|
|
354 |
topLeft
|
77
|
355 |
"return the top-left point - the same as origin"
|
1
|
356 |
|
77
|
357 |
^ left @ top
|
1
|
358 |
!
|
|
359 |
|
|
360 |
topRight
|
|
361 |
"return the top-right point"
|
|
362 |
|
77
|
363 |
^ (left + width) @ top
|
1
|
364 |
!
|
|
365 |
|
77
|
366 |
topCenter
|
|
367 |
"return the top center point"
|
1
|
368 |
|
77
|
369 |
^ (left + (width // 2)) @ top
|
1
|
370 |
!
|
|
371 |
|
|
372 |
bottom
|
|
373 |
"return the y coordinate of the bottom"
|
|
374 |
|
|
375 |
^ (top + height)
|
|
376 |
!
|
|
377 |
|
77
|
378 |
bottomLeft
|
|
379 |
"return the bottom-left point"
|
|
380 |
|
|
381 |
^ left @ (top + height)
|
|
382 |
!
|
|
383 |
|
|
384 |
bottomRight
|
|
385 |
"return the bottom-right point"
|
|
386 |
|
|
387 |
^ (left + width) @ (top + height)
|
|
388 |
!
|
|
389 |
|
|
390 |
bottomCenter
|
|
391 |
"return the bottom center point"
|
|
392 |
|
|
393 |
^ (left + (width // 2)) @ (top + height)
|
|
394 |
!
|
|
395 |
|
1
|
396 |
right
|
|
397 |
"return the x coordinate of the right"
|
|
398 |
|
|
399 |
^ (left + width)
|
|
400 |
!
|
|
401 |
|
77
|
402 |
rightCenter
|
|
403 |
"return the right center point"
|
|
404 |
|
|
405 |
^ (left + width) @ (top + (height // 2))
|
|
406 |
!
|
|
407 |
|
1
|
408 |
center
|
|
409 |
"return the point in the center of the receiver"
|
|
410 |
|
77
|
411 |
^ (left + (width // 2)) @ (top + (height // 2))
|
1
|
412 |
!
|
|
413 |
|
|
414 |
area
|
77
|
415 |
"return the area
|
|
416 |
- for screen Rectangles this is the number of pixels"
|
1
|
417 |
|
|
418 |
^ width * height
|
|
419 |
! !
|
|
420 |
|
|
421 |
!Rectangle methodsFor:'comparing'!
|
|
422 |
|
|
423 |
= aRectangle
|
|
424 |
"return true, if the argument aRectangle represents the same
|
|
425 |
rectangle as the receiver"
|
|
426 |
|
|
427 |
%{ /* NOCONTEXT */
|
59
|
428 |
/*
|
|
429 |
* handle the common case quickly
|
|
430 |
*/
|
329
|
431 |
if (__isNonNilObject(aRectangle)
|
|
432 |
&& __qClass(aRectangle) == Rectangle) {
|
325
|
433 |
if ((_InstPtr(self)->i_instvars[0] == _InstPtr(aRectangle)->i_instvars[0])
|
|
434 |
&& (_InstPtr(self)->i_instvars[1] == _InstPtr(aRectangle)->i_instvars[1])
|
|
435 |
&& (_InstPtr(self)->i_instvars[2] == _InstPtr(aRectangle)->i_instvars[2])
|
|
436 |
&& (_InstPtr(self)->i_instvars[3] == _InstPtr(aRectangle)->i_instvars[3])) {
|
186
|
437 |
RETURN ( true );
|
|
438 |
}
|
325
|
439 |
if (__bothSmallInteger(_InstPtr(self)->i_instvars[0], _InstPtr(aRectangle)->i_instvars[0])
|
|
440 |
&& __bothSmallInteger(_InstPtr(self)->i_instvars[1], _InstPtr(aRectangle)->i_instvars[1])
|
|
441 |
&& __bothSmallInteger(_InstPtr(self)->i_instvars[2], _InstPtr(aRectangle)->i_instvars[2])
|
|
442 |
&& __bothSmallInteger(_InstPtr(self)->i_instvars[3], _InstPtr(aRectangle)->i_instvars[3])) {
|
|
443 |
RETURN ( false );
|
|
444 |
}
|
1
|
445 |
}
|
|
446 |
%}
|
|
447 |
.
|
259
|
448 |
(aRectangle species ~~ self species) ifTrue:[^ false].
|
1
|
449 |
|
|
450 |
left = aRectangle left ifFalse:[^ false].
|
|
451 |
top = aRectangle top ifFalse:[^ false].
|
|
452 |
width = aRectangle width ifFalse:[^ false].
|
|
453 |
height = aRectangle height ifFalse:[^ false].
|
|
454 |
^ true
|
59
|
455 |
!
|
|
456 |
|
|
457 |
hash
|
|
458 |
"return an integer useful for hashing -
|
|
459 |
redefined since = is redefined here"
|
|
460 |
|
|
461 |
^ ((left hash bitShift:16) bitXor:(top hash bitShift:16))
|
|
462 |
+ ((width hash) bitXor:(height hash))
|
1
|
463 |
! !
|
|
464 |
|
356
|
465 |
!Rectangle methodsFor:'converting'!
|
|
466 |
|
|
467 |
asFractionalLayout
|
|
468 |
"return a layoutFrame in which fractions (top, left, bottom, right)
|
|
469 |
are taken from corresponding edges of the receiver.
|
|
470 |
You have to make certain that those are in 0..1."
|
|
471 |
|
|
472 |
|l|
|
|
473 |
|
|
474 |
l := LayoutFrame new.
|
|
475 |
l
|
|
476 |
leftFraction:(self left);
|
|
477 |
rightFraction:(self right);
|
|
478 |
topFraction:(self top);
|
|
479 |
bottomFraction:(self bottom).
|
|
480 |
^ l
|
|
481 |
|
|
482 |
"
|
|
483 |
(0.5@0.5 corner:0.75@0.75) asFractionalLayout
|
|
484 |
(0.5@0.5 corner:0.75@0.75) asOffsetLayout
|
|
485 |
(0.5@0.5 corner:0.75@0.75) asLayout
|
|
486 |
"
|
|
487 |
!
|
|
488 |
|
|
489 |
asOffsetLayout
|
|
490 |
"return a layoutFrame in which offsets (top, left, bottom, right)
|
|
491 |
are taken from corresponding edges of the receiver.
|
|
492 |
You have to make certain that those are in 0..1."
|
|
493 |
|
|
494 |
|l|
|
|
495 |
|
|
496 |
l := LayoutFrame new.
|
|
497 |
l
|
|
498 |
leftOffset:(self left);
|
|
499 |
rightFraction:0 offset:(self right);
|
|
500 |
topOffset:(self top);
|
|
501 |
bottomFraction:0 offset:(self bottom).
|
|
502 |
^ l
|
|
503 |
|
|
504 |
"
|
|
505 |
(0.5@0.5 corner:0.75@0.75) asFractionalLayout
|
|
506 |
(0.5@0.5 corner:0.75@0.75) asOffsetLayout
|
|
507 |
(0.5@0.5 corner:0.75@0.75) asLayout
|
|
508 |
|
|
509 |
(10@10 corner:20@20) asFractionalLayout
|
|
510 |
(10@10 corner:20@20) asOffsetLayout
|
|
511 |
(10@10 corner:20@20) asLayout
|
|
512 |
"
|
|
513 |
|
|
514 |
!
|
|
515 |
|
|
516 |
asLayout
|
|
517 |
"return a layoutFrame in which offsets (top, left, bottom, right)
|
|
518 |
are taken from corresponding edges of the receiver.
|
|
519 |
If all values are between 0..1, a fractionalLayout is created,
|
|
520 |
otherwise, an offsetLayout"
|
|
521 |
|
|
522 |
|l left right top bot|
|
|
523 |
|
|
524 |
l := LayoutFrame new.
|
|
525 |
left := (self left).
|
|
526 |
right := (self right).
|
|
527 |
top := (self top).
|
|
528 |
bot := (self bottom).
|
|
529 |
((left between:0 and:1)
|
|
530 |
and:[(right between:0 and:1)
|
|
531 |
and:[(top between:0 and:1)
|
|
532 |
and:[(bot between:0 and:1)]]]) ifTrue:[
|
|
533 |
l
|
|
534 |
leftFraction:left;
|
|
535 |
rightFraction:right;
|
|
536 |
topFraction:top;
|
|
537 |
bottomFraction:bot.
|
|
538 |
] ifFalse:[
|
|
539 |
l
|
|
540 |
leftOffset:left;
|
|
541 |
rightFraction:0 offset:right;
|
|
542 |
topOffset:top;
|
|
543 |
bottomFraction:0 offset:bot.
|
|
544 |
].
|
|
545 |
^ l
|
|
546 |
|
|
547 |
"
|
|
548 |
(0.5@0.5 corner:0.75@0.75) asFractionalLayout
|
|
549 |
(0.5@0.5 corner:0.75@0.75) asOffsetLayout
|
|
550 |
(0.5@0.5 corner:0.75@0.75) asLayout
|
|
551 |
(0@0 corner:1@1) asLayout
|
|
552 |
(0@0 corner:1@1) asFractionalLayout
|
|
553 |
(0@0 corner:1@1) asOffsetLayout
|
|
554 |
"
|
|
555 |
!
|
|
556 |
|
|
557 |
asPointArray
|
|
558 |
"return an array containing my corners (clockwise) and
|
|
559 |
the origin again as 5th element. Can be used to convert
|
|
560 |
a rectangle into a polygon."
|
|
561 |
|
|
562 |
|org|
|
|
563 |
|
|
564 |
^ Array with:(org := self origin)
|
|
565 |
with:self topRight
|
|
566 |
with:self corner
|
|
567 |
with:self bottomLeft
|
|
568 |
with:org
|
|
569 |
|
|
570 |
"
|
|
571 |
(10@10 corner:100@100) asPointArray
|
|
572 |
"
|
|
573 |
!
|
|
574 |
|
|
575 |
rectangleRelativeTo:aRectangle preferred:prefRect
|
|
576 |
"compute a displayRectangle, treating the receiver like a
|
|
577 |
layoutorigin. This allows point to be used interchangable with
|
|
578 |
LayoutOrigins."
|
|
579 |
|
|
580 |
^ (self asLayout) rectangleRelativeTo:aRectangle preferred:prefRect
|
|
581 |
|
|
582 |
"
|
|
583 |
(10@20 corner:20@30) rectangleRelativeTo:(0@0 corner:100@100) preferred:(0@0 corner:50@50)
|
|
584 |
|
|
585 |
(0.5@0.5) rectangleRelativeTo:(0@0 corner:100@100) preferred:(0@0 corner:50@50)
|
|
586 |
"
|
|
587 |
! !
|
|
588 |
|
77
|
589 |
!Rectangle methodsFor:'queries'!
|
|
590 |
|
|
591 |
isRectangle
|
|
592 |
"return true, if the receiver is some kind of rectangle"
|
|
593 |
|
|
594 |
^ true
|
|
595 |
! !
|
|
596 |
|
1
|
597 |
!Rectangle methodsFor:'testing'!
|
|
598 |
|
|
599 |
containsPoint:aPoint
|
|
600 |
"return true, if the argument, aPoint is contained in the receiver"
|
|
601 |
|
|
602 |
|px py|
|
|
603 |
|
|
604 |
px := aPoint x.
|
|
605 |
(px < left) ifTrue:[^ false].
|
|
606 |
(px > (left + width)) ifTrue:[^ false].
|
|
607 |
py := aPoint y.
|
|
608 |
(py < top) ifTrue:[^ false].
|
|
609 |
(py > (top + height)) ifTrue:[^ false].
|
|
610 |
^ true
|
|
611 |
!
|
|
612 |
|
208
|
613 |
containsPointX:x y:y
|
|
614 |
"return true, if the point defined by x@y is contained in the receiver.
|
|
615 |
This is the same as containsPoint:, but can be used if the coordinates
|
|
616 |
are already available as separate numbers to avoid useless creation of a
|
|
617 |
temporary point."
|
|
618 |
|
|
619 |
(x < left) ifTrue:[^ false].
|
|
620 |
(x > (left + width)) ifTrue:[^ false].
|
|
621 |
(y < top) ifTrue:[^ false].
|
|
622 |
(y > (top + height)) ifTrue:[^ false].
|
|
623 |
^ true
|
|
624 |
!
|
|
625 |
|
1
|
626 |
intersects:aRectangle
|
|
627 |
"return true, if the intersection between the argument, aRectangle
|
|
628 |
and the receiver is not empty"
|
|
629 |
|
|
630 |
|b r|
|
|
631 |
|
|
632 |
(aRectangle right) < left ifTrue:[^ false].
|
|
633 |
(aRectangle bottom) < top ifTrue:[^ false].
|
|
634 |
r := left + width.
|
|
635 |
(aRectangle left) > r ifTrue:[^ false].
|
|
636 |
b := top + height.
|
|
637 |
(aRectangle top) > b ifTrue:[^ false].
|
|
638 |
^ true
|
|
639 |
!
|
|
640 |
|
|
641 |
contains:aRectangle
|
|
642 |
"return true, if the argument, aRectangle is equal to or
|
|
643 |
is contained fully within the receiver"
|
|
644 |
|
|
645 |
(left <= aRectangle left) ifTrue:[
|
|
646 |
((left + width) >= aRectangle right) ifTrue:[
|
186
|
647 |
(top <= aRectangle top) ifTrue:[
|
|
648 |
((top + height) >= aRectangle bottom) ifTrue:[
|
|
649 |
^ true
|
|
650 |
]
|
|
651 |
]
|
1
|
652 |
]
|
|
653 |
].
|
|
654 |
^ false
|
|
655 |
!
|
|
656 |
|
|
657 |
isContainedIn:aRectangle
|
|
658 |
"return true, if the receiver is fully contained within
|
|
659 |
the argument, aRectangle"
|
|
660 |
|
|
661 |
(aRectangle left <= left) ifTrue:[
|
|
662 |
(aRectangle right >= (left + width)) ifTrue:[
|
186
|
663 |
(aRectangle top <= top) ifTrue:[
|
|
664 |
(aRectangle bottom >= (top + height)) ifTrue:[
|
|
665 |
^ true
|
|
666 |
]
|
|
667 |
]
|
1
|
668 |
]
|
|
669 |
].
|
|
670 |
^ false
|
|
671 |
! !
|
|
672 |
|
186
|
673 |
!Rectangle methodsFor:'destructive rectangle operations'!
|
|
674 |
|
|
675 |
translateBy:amount
|
|
676 |
"translate (i.e. move) the receiver rectangle
|
|
677 |
by amount, a Point or Number.
|
|
678 |
This is destructive (modifies the receiver, not a copy) and
|
|
679 |
should only be used if you know, that you are the exclusive owner
|
217
|
680 |
of the receiver. (use translatedBy if in doubt)"
|
186
|
681 |
|
|
682 |
|amountPoint|
|
|
683 |
|
|
684 |
(amount isMemberOf:Point) ifTrue:[ "type hint to stc"
|
|
685 |
left := left + amount x.
|
|
686 |
top := top + amount y
|
|
687 |
] ifFalse:[
|
|
688 |
amountPoint := amount asPoint.
|
|
689 |
left := left + amountPoint x.
|
|
690 |
top := top + amountPoint y
|
|
691 |
]
|
|
692 |
|
|
693 |
"
|
|
694 |
(Rectangle origin:10@10 corner:50@50) translateBy:10
|
|
695 |
"
|
|
696 |
|
|
697 |
"its destructive:"
|
|
698 |
"
|
|
699 |
|r1 r2|
|
|
700 |
|
|
701 |
r1 := Rectangle origin:10@10 corner:50@50.
|
|
702 |
r2 := r1 translateBy:10.
|
|
703 |
r1
|
|
704 |
"
|
|
705 |
!
|
|
706 |
|
|
707 |
scaleBy:scale
|
|
708 |
"scale the receiver rectangle by scale (a Number or Point).
|
|
709 |
This is destructive (modifies the receiver, not a copy) and
|
|
710 |
should only be used if you know, that you are the exclusive owner
|
217
|
711 |
of the receiver. (use scaledBy if in doubt)"
|
186
|
712 |
|
217
|
713 |
|scalePoint sx sy|
|
186
|
714 |
|
|
715 |
(scale isMemberOf:Point) ifTrue:[ "type hint to stc"
|
217
|
716 |
sx := scale x.
|
|
717 |
sy := scale y
|
186
|
718 |
] ifFalse:[
|
|
719 |
scalePoint := scale asPoint.
|
217
|
720 |
sx := scalePoint x.
|
|
721 |
sy := scalePoint y
|
|
722 |
].
|
|
723 |
width := width * sx.
|
|
724 |
height := height * sy.
|
|
725 |
left := left * sx.
|
|
726 |
top := top * sy
|
|
727 |
|
186
|
728 |
"
|
|
729 |
(Rectangle origin:10@10 corner:50@50) scaleBy:2
|
|
730 |
"
|
|
731 |
|
|
732 |
"its destructive:"
|
|
733 |
"
|
|
734 |
|r1 r2|
|
|
735 |
|
|
736 |
r1 := Rectangle origin:10@10 corner:50@50.
|
|
737 |
r2 := r1 scaleBy:2.
|
|
738 |
r1
|
|
739 |
"
|
|
740 |
!
|
|
741 |
|
|
742 |
moveTo:aPoint
|
|
743 |
"destructively translate the rectangle to have its origin at aPoint."
|
|
744 |
|
|
745 |
|diff|
|
|
746 |
|
|
747 |
diff := aPoint - self origin.
|
|
748 |
self origin:aPoint corner:self corner + diff
|
|
749 |
!
|
|
750 |
|
|
751 |
moveBy:aPoint
|
|
752 |
"destructively translate the rectangle by some distance.
|
|
753 |
sorry for the name inconsistency - but GNU-ST named it that way"
|
|
754 |
|
|
755 |
left := left + aPoint x.
|
|
756 |
top := top + aPoint y
|
356
|
757 |
!
|
|
758 |
|
|
759 |
expandBy:delta
|
|
760 |
"destructively expanded the receiver in all directions
|
|
761 |
by amount, a Point, Rectangle or Number.
|
|
762 |
Warning: this is a destructive operation, modifying the receiver
|
|
763 |
NOT returning a copy. You have to be certain to be the exclusive
|
|
764 |
owner of the receiver to avoid side effects. See also: #expandedBy:"
|
|
765 |
|
|
766 |
|amountPoint deltaLeft deltaTop deltaWidth deltaHeight|
|
|
767 |
|
|
768 |
delta isNumber ifTrue:[
|
|
769 |
deltaLeft := deltaTop := delta.
|
|
770 |
deltaWidth := deltaHeight := delta * 2.
|
|
771 |
] ifFalse:[
|
|
772 |
delta isRectangle ifTrue:[
|
|
773 |
deltaLeft := delta left.
|
|
774 |
deltaTop := delta top.
|
|
775 |
deltaWidth := deltaLeft + delta right.
|
|
776 |
deltaHeight := deltaTop + delta bottom
|
|
777 |
] ifFalse:[
|
|
778 |
amountPoint := delta asPoint.
|
|
779 |
deltaLeft := amountPoint x.
|
|
780 |
deltaTop := amountPoint y.
|
|
781 |
deltaWidth := deltaLeft * 2.
|
|
782 |
deltaHeight := deltaTop * 2.
|
|
783 |
]
|
|
784 |
].
|
|
785 |
|
|
786 |
left := (left - deltaLeft).
|
|
787 |
top := (top - deltaTop).
|
|
788 |
width := (width + deltaWidth).
|
|
789 |
height := (height + deltaHeight).
|
|
790 |
|
|
791 |
"
|
|
792 |
|r|
|
|
793 |
r := Rectangle origin:10@10 corner:100@100.
|
|
794 |
r expandBy:5.
|
|
795 |
|
|
796 |
r := Rectangle origin:10@10 corner:100@100.
|
|
797 |
r expandBy:(5 @ 0).
|
|
798 |
|
|
799 |
r := Rectangle origin:10@10 corner:100@100.
|
|
800 |
r expandBy:(10 @ 10).
|
|
801 |
|
|
802 |
r := Rectangle origin:10@10 corner:100@100.
|
|
803 |
r expandBy:( 10@10 corner:20@20 )
|
|
804 |
"
|
186
|
805 |
! !
|
|
806 |
|
1
|
807 |
!Rectangle methodsFor:'rectangle operations'!
|
|
808 |
|
|
809 |
intersect:aRectangle
|
|
810 |
"return a new rectangle covering the intersection of the receiver
|
|
811 |
and the argument, aRectangle.
|
|
812 |
the rectangles must intersect for a valid return"
|
|
813 |
|
|
814 |
^ Rectangle left:(left max:(aRectangle left))
|
186
|
815 |
right:((left + width) min:(aRectangle right))
|
|
816 |
top:(top max:(aRectangle top))
|
|
817 |
bottom:((top + height) min:(aRectangle bottom))
|
208
|
818 |
|
|
819 |
"
|
|
820 |
|r1 r2|
|
|
821 |
|
|
822 |
r1 := Rectangle origin:10@10 corner:100@100.
|
|
823 |
r2 := Rectangle origin:50@50 corner:150@75.
|
|
824 |
r1 intersect:r2
|
|
825 |
"
|
1
|
826 |
!
|
|
827 |
|
|
828 |
merge:aRectangle
|
|
829 |
"return a new rectangle covering both the receiver
|
|
830 |
and the argument, aRectangle"
|
|
831 |
|
|
832 |
^ Rectangle left:(left min:(aRectangle left))
|
186
|
833 |
right:((left + width) max:(aRectangle right))
|
|
834 |
top:(top min:(aRectangle top))
|
|
835 |
bottom:((top + height) max:(aRectangle bottom))
|
1
|
836 |
!
|
|
837 |
|
|
838 |
+ aPoint
|
356
|
839 |
"return a new rectangle with same extent as receiver but
|
1
|
840 |
origin translated by the argument, aPoint"
|
|
841 |
|
217
|
842 |
|amountPoint|
|
|
843 |
|
|
844 |
amountPoint := aPoint asPoint.
|
|
845 |
^ Rectangle left:(left + amountPoint x)
|
|
846 |
top:(top + amountPoint y)
|
|
847 |
width:width
|
|
848 |
height:height
|
1
|
849 |
!
|
|
850 |
|
|
851 |
rounded
|
356
|
852 |
"return a copy of the receiver with rounded coordinates"
|
|
853 |
|
217
|
854 |
^ Rectangle left:(left rounded)
|
|
855 |
top:(top rounded)
|
|
856 |
width:(width rounded)
|
|
857 |
height:(height rounded)
|
1
|
858 |
!
|
|
859 |
|
356
|
860 |
expandedBy:delta
|
1
|
861 |
"return a new rectangle which is expanded in all directions
|
77
|
862 |
by amount, a Point, Rectangle or Number"
|
|
863 |
|
356
|
864 |
^ self copy expandBy:delta
|
77
|
865 |
|
|
866 |
"
|
|
867 |
|r|
|
|
868 |
r := Rectangle origin:10@10 corner:100@100.
|
356
|
869 |
r expandedBy:5.
|
|
870 |
r expandedBy:(5 @ 0).
|
|
871 |
r expandedBy:(10 @ 10).
|
|
872 |
r expandedBy:( 10@10 corner:20@20 )
|
77
|
873 |
"
|
1
|
874 |
!
|
|
875 |
|
|
876 |
insetBy: delta
|
|
877 |
"return a new rectangle which is inset in all directions
|
77
|
878 |
by delta, a Point, Rectangle or Number"
|
1
|
879 |
|
77
|
880 |
|amountPoint deltaLeft deltaTop deltaWidth deltaHeight|
|
1
|
881 |
|
77
|
882 |
delta isNumber ifTrue:[
|
186
|
883 |
deltaLeft := deltaTop := delta.
|
|
884 |
deltaWidth := deltaHeight := delta * 2.
|
77
|
885 |
] ifFalse:[
|
186
|
886 |
delta isRectangle ifTrue:[
|
|
887 |
deltaLeft := delta left.
|
|
888 |
deltaTop := delta top.
|
|
889 |
deltaWidth := deltaLeft + delta right.
|
|
890 |
deltaHeight := deltaTop + delta bottom
|
|
891 |
] ifFalse:[
|
|
892 |
amountPoint := delta asPoint.
|
|
893 |
deltaLeft := amountPoint x.
|
|
894 |
deltaTop := amountPoint y.
|
|
895 |
deltaWidth := deltaLeft * 2.
|
|
896 |
deltaHeight := deltaTop * 2.
|
|
897 |
]
|
77
|
898 |
].
|
|
899 |
|
|
900 |
^ Rectangle left:(left + deltaLeft)
|
186
|
901 |
top:(top + deltaTop)
|
|
902 |
width:(width - deltaWidth)
|
|
903 |
height:(height - deltaHeight)
|
77
|
904 |
"
|
|
905 |
|r|
|
|
906 |
r := Rectangle origin:10@10 corner:100@100.
|
|
907 |
r insetBy:5.
|
|
908 |
r insetBy:(5 @ 0).
|
|
909 |
r insetBy:(10 @ 10).
|
|
910 |
r insetBy:( 10@10 corner:20@20 )
|
|
911 |
"
|
1
|
912 |
!
|
|
913 |
|
362
|
914 |
insetOriginBy:originDelta cornerBy:cornerDelta
|
|
915 |
"return a new rectangle which is inset by originDelta
|
|
916 |
and cornerDelta; both may be instances of Point or Number"
|
|
917 |
|
|
918 |
|amountPoint deltaLeft deltaTop deltaWidth deltaHeight|
|
|
919 |
|
|
920 |
^ Rectangle
|
|
921 |
origin:(left @ top) + originDelta asPoint
|
|
922 |
corner:(self corner - cornerDelta asPoint)
|
|
923 |
"
|
|
924 |
|r|
|
|
925 |
r := Rectangle origin:10@10 corner:100@100.
|
|
926 |
r insetOriginBy:5 cornerBy:10.
|
|
927 |
r insetOriginBy:10@5 cornerBy:10.
|
|
928 |
r insetOriginBy:10 cornerBy:10@5.
|
|
929 |
r insetOriginBy:10@10 cornerBy:20@20.
|
|
930 |
"
|
|
931 |
!
|
|
932 |
|
3
|
933 |
translatedBy:amount
|
1
|
934 |
"return a new rectangle which is translated (i.e. moved)
|
|
935 |
by amount, aPoint or Number"
|
|
936 |
|
|
937 |
|amountPoint|
|
|
938 |
|
|
939 |
amountPoint := amount asPoint.
|
59
|
940 |
^ Rectangle left:(left + amountPoint x)
|
186
|
941 |
top:(top + amountPoint y)
|
|
942 |
width:width
|
|
943 |
height:height
|
|
944 |
"
|
|
945 |
(Rectangle origin:10@10 corner:50@50) translatedBy:10
|
|
946 |
"
|
1
|
947 |
|
186
|
948 |
"its NOT destructive:"
|
|
949 |
"
|
|
950 |
|r1 r2|
|
1
|
951 |
|
186
|
952 |
r1 := Rectangle origin:10@10 corner:50@50.
|
|
953 |
r2 := r1 translatedBy:10.
|
|
954 |
r1
|
|
955 |
"
|
1
|
956 |
!
|
|
957 |
|
|
958 |
scaledBy:scale
|
|
959 |
"return a new rectangle which is the receiver
|
|
960 |
scaled by scale"
|
|
961 |
|
217
|
962 |
|scalePoint sx sy|
|
1
|
963 |
|
|
964 |
scalePoint := scale asPoint.
|
217
|
965 |
sx := scalePoint x.
|
|
966 |
sy := scalePoint y.
|
|
967 |
^ Rectangle left:left * sx
|
|
968 |
top:top * sy
|
|
969 |
width:(width * sx)
|
|
970 |
height:(height * sy)
|
186
|
971 |
"
|
217
|
972 |
(Rectangle origin:10@10 corner:50@50) scaledBy:2
|
186
|
973 |
"
|
|
974 |
|
|
975 |
"its NOT destructive:"
|
|
976 |
"
|
|
977 |
|r1 r2|
|
|
978 |
|
|
979 |
r1 := Rectangle origin:10@10 corner:50@50.
|
217
|
980 |
r2 := r1 scaledBy:2.
|
|
981 |
r1
|
186
|
982 |
"
|
1
|
983 |
!
|
|
984 |
|
326
|
985 |
align:offset with:someCoordinate
|
|
986 |
"return a new rectangle which is translated (i.e. moved)
|
|
987 |
such that the point offset in mySelf is placed on someCoordinate."
|
|
988 |
|
|
989 |
^ Rectangle origin:(someCoordinate - offset + self origin)
|
|
990 |
extent:(self extent)
|
|
991 |
"
|
|
992 |
|r|
|
|
993 |
|
|
994 |
r := Rectangle origin:10@10 corner:50@50.
|
|
995 |
r align:(r center) with:100@100.
|
|
996 |
"
|
|
997 |
!
|
|
998 |
|
1
|
999 |
amountToTranslateWithin: aRectangle
|
|
1000 |
"for GNU-ST compatibility"
|
|
1001 |
|
|
1002 |
^(aRectangle origin) - self origin
|
|
1003 |
!
|
|
1004 |
|
|
1005 |
areasOutside: aRectangle
|
|
1006 |
"----------------------------------------------------------------
|
|
1007 |
| added for GNU-ST compatibility
|
|
1008 |
|
|
|
1009 |
| author: Doug McCallum <uunet!!ico.isc.com!!dougm>
|
|
1010 |
|
|
|
1011 |
|areasOutside: aRectangle
|
|
1012 |
| most complicated of the Rectangle primitives
|
|
1013 |
| The basic methodology is to first determine that there is an
|
|
1014 |
| intersection by finding the overlapping rectangle. From the
|
|
1015 |
| overlapping rectangle, first determine if it runs along an edge.
|
|
1016 |
| If it doesn't, extend the rectangle up to the top edge and add
|
|
1017 |
| the new rectangle to the collection and start the rest of the
|
|
1018 |
| process. If the left edge does not touch the left edge of self,
|
|
1019 |
| extend it to the edge saving the new rectangle. Then do the
|
|
1020 |
| same to the right edge. Then check top and bottom edges. Most
|
|
1021 |
| of the time only 2 or 3 rectangles get formed, occasionally 4.
|
|
1022 |
| It should be possible to never get more than 3 but requires more
|
|
1023 |
| work.
|
|
1024 |
----------------------------------------------------------------"
|
|
1025 |
|
|
1026 |
| collect iRect tmp |
|
360
|
1027 |
iRect := self intersect: aRectangle.
|
1
|
1028 |
(iRect = nil) ifTrue: [^nil]. "case of no intersection"
|
186
|
1029 |
"the collect collection gathers Rectangles"
|
360
|
1030 |
collect := OrderedCollection new: 4.
|
186
|
1031 |
"is it floating or on the edge?"
|
1
|
1032 |
(((((iRect top) ~= self top)
|
186
|
1033 |
and: [ (iRect bottom) ~= self bottom ])
|
|
1034 |
and: [ (iRect left) ~= self left ])
|
|
1035 |
and: [ (iRect right) ~= self right ] )
|
|
1036 |
ifTrue: "entirely in the center."
|
360
|
1037 |
[tmp := Rectangle origin: (Point x: iRect left y: self top)
|
|
1038 |
corner: iRect bottomRight.
|
186
|
1039 |
collect add: tmp.
|
360
|
1040 |
iRect := iRect merge: tmp].
|
1
|
1041 |
((iRect left) ~= self left)
|
186
|
1042 |
ifTrue: "doesn't touch left edge so make it touch"
|
360
|
1043 |
[tmp := Rectangle origin: (Point x: self left y: iRect top)
|
|
1044 |
corner: iRect bottomLeft.
|
186
|
1045 |
collect add: tmp.
|
|
1046 |
"merge new (tmp) with overlap to keep track"
|
360
|
1047 |
iRect := iRect merge: tmp].
|
1
|
1048 |
((iRect right) ~= self right)
|
186
|
1049 |
ifTrue: "doesn't touch right edge so extend it"
|
360
|
1050 |
[tmp := Rectangle origin: iRect topRight
|
|
1051 |
corner: (Point x: self right y: iRect bottom).
|
186
|
1052 |
collect add: tmp.
|
360
|
1053 |
iRect := iRect merge: tmp].
|
77
|
1054 |
(((iRect left) ~= self left) or: [(iRect top) ~= self top])
|
186
|
1055 |
ifTrue: "whole top part can be taken now"
|
360
|
1056 |
[tmp := Rectangle origin: self origin corner: iRect topRight.
|
186
|
1057 |
collect add: tmp].
|
77
|
1058 |
(((iRect right) ~= self right) or: [(iRect bottom) ~= self bottom])
|
186
|
1059 |
ifTrue: "whole bottom open and can be taken"
|
360
|
1060 |
[tmp := Rectangle origin: iRect bottomLeft corner: self corner.
|
186
|
1061 |
collect add: tmp].
|
1
|
1062 |
^collect
|
77
|
1063 |
!
|
1
|
1064 |
|
77
|
1065 |
nonIntersections:aRectangle
|
|
1066 |
"this is the same as areasOutside: - for ST/V compatibility only"
|
|
1067 |
|
|
1068 |
^ self areasOutside:aRectangle
|
1
|
1069 |
! !
|
|
1070 |
|
356
|
1071 |
!Rectangle methodsFor:'displaying'!
|
|
1072 |
|
|
1073 |
displayStrokedOn:aGC
|
|
1074 |
aGC displayRectangleX:left y:top width:width height:height
|
|
1075 |
|
|
1076 |
"
|
|
1077 |
|v|
|
|
1078 |
|
|
1079 |
v := View new open.
|
|
1080 |
[v shown] whileFalse:[Processor yield].
|
|
1081 |
|
|
1082 |
(Rectangle origin:10@10 corner:50@50) displayStrokedOn:v
|
|
1083 |
"
|
|
1084 |
!
|
|
1085 |
|
|
1086 |
displayFilledOn:aGC
|
|
1087 |
aGC fillRectangleX:left y:top width:width height:height
|
|
1088 |
|
|
1089 |
"
|
|
1090 |
|v|
|
|
1091 |
|
|
1092 |
v := View new open.
|
|
1093 |
[v shown] whileFalse:[Processor yield].
|
|
1094 |
|
|
1095 |
(Rectangle origin:10@10 corner:50@50) displayFilledOn:v
|
|
1096 |
"
|
|
1097 |
! !
|
|
1098 |
|
93
|
1099 |
!Rectangle methodsFor:'printing & storing'!
|
1
|
1100 |
|
|
1101 |
printOn:aStream
|
|
1102 |
"print the receiver on aStream"
|
|
1103 |
|
59
|
1104 |
aStream nextPutAll:(self class name).
|
|
1105 |
aStream nextPutAll:' origin:'.
|
1
|
1106 |
(self origin) printOn:aStream.
|
|
1107 |
aStream nextPutAll:' corner:'.
|
|
1108 |
(self corner) printOn:aStream
|
|
1109 |
!
|
|
1110 |
|
|
1111 |
storeOn:aStream
|
|
1112 |
"store the receiver on aStream; i.e. print an expression which will
|
|
1113 |
reconstruct the receiver"
|
|
1114 |
|
59
|
1115 |
aStream nextPut:$(.
|
1
|
1116 |
aStream nextPutAll:(self class name).
|
59
|
1117 |
aStream nextPutAll:' origin:'.
|
|
1118 |
(self origin) storeOn:aStream.
|
1
|
1119 |
aStream nextPutAll:' corner:'.
|
59
|
1120 |
(self corner) storeOn:aStream.
|
|
1121 |
aStream nextPut:$)
|
1
|
1122 |
! !
|