-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHotDraw Animated Examples.pst
1635 lines (1326 loc) · 52.6 KB
/
HotDraw Animated Examples.pst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0"?>
<st-source>
<!--
Name: HotDraw Animated Examples
Notice: Copyright 1993 - 2013 John Brant
This utility is made available to use under the MIT license, as detailed below.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
DbIdentifier: psql_public_cst_2007
DbTrace: 87403
DbUsername: niallr
DbVersion: 1.8
DevelopmentPrerequisites: #(#(#any 'HotDraw Animation Framework' ''))
PackageName: HotDraw Animated Examples
Parcel: #('HotDraw Animated Examples')
ParcelName: HotDraw Animated Examples
PrerequisiteParcels: #(#('HotDraw Animation Framework' ''))
PrintStringCache: (1.8,niallr)
Version: 1.8
Post-Load Block:
[:parcel | Refactory.HotDraw.MovingDrawingEditor postLoadActionFor: parcel]
Date: 3:02:52 PM April 5, 2013
-->
<time-stamp>From VisualWorks®, Pre-Release 7.10 (mar13.4) of 22 March 2013 on 5 April 2013 at 15:02:52</time-stamp>
<do-it>(Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.']</do-it>
<class>
<name>ObjectWorldDrawing</name>
<environment>Refactory.HotDraw</environment>
<super>Refactory.HotDraw.AnimatedDrawing</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>HotDraw-ObjectWorld</category>
<attributes>
<package>HotDraw Animated Examples</package>
</attributes>
</class>
<comment>
<class-id>Refactory.HotDraw.ObjectWorldDrawing</class-id>
<body>I am a Drawing (from HotDraw) that provides a number of instance methods for ObjectWorld animation control.</body>
</comment>
<class>
<name>ObjectWorldFigureModel</name>
<environment>Refactory.HotDraw</environment>
<super>UI.Model</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>figure name animationMethods model pause stayVisible </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>HotDraw-ObjectWorld</category>
<attributes>
<package>HotDraw Animated Examples</package>
</attributes>
</class>
<comment>
<class-id>Refactory.HotDraw.ObjectWorldFigureModel</class-id>
<body>a MetaFigure for the ObjectWorld application.
=========================
Assumes that a figure must implement :
rotateBy: Rotate the figure by the given angle.
Instance Variables:
name <String>
The name of the figure in the ObjectWorld. This is the string associated with the figure by the user.
animationMethods <Collection>
A collection of the method the figure should apply to itself to perform a step in its animation.
model <ObjectParser>
The ObjectWorld that the figure belongs to.
pause <Boolean>
Indicator for the figure as to whether or not it will perform its animation step. This allows each figure to control whether or not it wants to perform a step in its
animation.
stayVisible <Boolean>
Indicator telling the figure if it should stay within the visible bounds given to it as part of an animation step.
Class Variables:
DebugFlag <Boolean>
Indicator telling the figure to perform debug operations.
DefaultGrow <Integer>
Amount to grow a figure when the grow or shrink message is sent to a figure.
DefaultRotate <Float>
Angle to rotate a figure when the turnRight or turnLeft message is sent to a figure.
DefaultMovement <Integer>
Amount to move a figure when it is sent the moveLeft, moveRight, moveUp, or moveDown messages are sent to it.
DefaultOrbit <Float>
Angle to rotate the figure around the object it is orbiting.
DefaultSize <Integer>
Size in pixels to create the initial figure.</body>
</comment>
<class>
<name>NetworkEditor</name>
<environment>Refactory.HotDraw</environment>
<super>Refactory.HotDraw.DrawingEditor</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nodes edgeWeights nodeList2 nodeList1 textEditor </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>HotDraw-Network Drawing</category>
<attributes>
<package>HotDraw Animated Examples</package>
</attributes>
</class>
<comment>
<class-id>Refactory.HotDraw.NetworkEditor</class-id>
<body>Network editors are a good example of embedding HotDraw in a larger
MVC application, and of how to do animation in HotDraw. The idea
is that you create a set of nodes and can assign weights to the edges
between the nodes. An edge with weight zero doesn''t exist. The
drawing rearranges itself so that edges act like springs, and nodes
with high-weight edges are closer together than nodes with low-weight
edges.
nodes <Collection of: NetworkNode>
edgeWeights <Dictionary from: Figure to: Number>
node1, node2 <NetworkNode> the selected nodes
NetworkEditor open</body>
</comment>
<class>
<name>WorkspaceCompiler</name>
<environment>Refactory.HotDraw</environment>
<super>Kernel.Compiler</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>workspaceDictionary </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>HotDraw-ObjectWorld</category>
<attributes>
<package>HotDraw Animated Examples</package>
</attributes>
</class>
<comment>
<class-id>Refactory.HotDraw.WorkspaceCompiler</class-id>
<body>I am a compiler for an object that is a workspace, i.e. it has its own
set of variables that can be named by the code I evaluate. You should
only use me to evaluate strings using my public access protocol. My
inherited public access protocol has not been tested and probably
does not work.</body>
</comment>
<class>
<name>ObjectWorld</name>
<environment>Refactory.HotDraw</environment>
<super>Refactory.HotDraw.DrawingEditor</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>parser commandText </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>HotDraw-ObjectWorld</category>
<attributes>
<package>HotDraw Animated Examples</package>
</attributes>
</class>
<comment>
<class-id>Refactory.HotDraw.ObjectWorld</class-id>
<body>I am the model in an ObjectWorld application. I am like a subclass of both ValueHolder and DrawingEditor, because one of my views is a ComposedTextView and the other one is a DrawingView. However, I copy code from DrawingEditor and am a subclass of ValueHolder.
In ObejctWorld, if a user types ''self doSomething'' the message gets sent to me. Things users are allowed to do are all contained in my ''public'' protocol. Special commands are trapped in the ''private'' protocol (i.e. ''self remove'' which does *not* remove ObjectWorld).
ObjectParser and ObjectWorldMetaFigure are the other important classes of the ObjectWorld application. ObjectParser is the controller of the text pane, and it parses user input and directs messages to the ObjectWorld, to the drawing, and to the individual figures in the drawing. ObjectWorldMetaFigure implements ObjectWorld-specific protocol for figures.
Instance variables:
parser :-
The object parsing ObjectWorld commands is also the controller of our text pane.
drawingView The view of our drawing, needed for flashing, etc.
drawing The ObjectWorldDrawing.
tools, currentTool, fileName: variables from DrawingEditor</body>
</comment>
<class>
<name>MovingDrawingEditor</name>
<environment>Refactory.HotDraw</environment>
<super>Refactory.HotDraw.DrawingEditor</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>HotDraw-Moving Drawing</category>
<attributes>
<package>HotDraw Animated Examples</package>
</attributes>
</class>
<comment>
<class-id>Refactory.HotDraw.MovingDrawingEditor</class-id>
<body>A MovingDrawing is one of the simplest examples of how to do animation.
It simulates objects in orbit around each other, i.e. the n-body
problem.
MovingDrawingEditor open</body>
</comment>
<class>
<name>ObjectParser</name>
<environment>Refactory.HotDraw</environment>
<super>UI.TextEditorController</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>bindings drawingEditor </inst-vars>
<class-inst-vars></class-inst-vars>
<imports>
private TextConstants.*
</imports>
<category>HotDraw-ObjectWorld</category>
<attributes>
<package>HotDraw Animated Examples</package>
</attributes>
</class>
<comment>
<class-id>Refactory.HotDraw.ObjectParser</class-id>
<body>This is the parser and controller for the StringHolder part of ObjectWorld. Hacks have been added to ''access'' and doItProcessing to allow user''s to enter text such as ''fred moveRight!!'' and have the ''!!'' cause a doIt.
Instance Variables
bindings :-
A dictionary of all of the named objects that we currently know about. This dictionary always contains a binding to map ''self'' to our model (i.e. an ObjectWorld object)
</body>
</comment>
<class>
<name>NetworkDrawing</name>
<environment>Refactory.HotDraw</environment>
<super>Refactory.HotDraw.AnimatedDrawing</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>nodes edgeWeights forces </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>HotDraw-Network Drawing</category>
<attributes>
<package>HotDraw Animated Examples</package>
</attributes>
</class>
<class>
<name>MovingFigure</name>
<environment>Refactory.HotDraw</environment>
<super>Refactory.HotDraw.RectangleFigure</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>velocity </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>HotDraw-Moving Drawing</category>
<attributes>
<package>HotDraw Animated Examples</package>
</attributes>
</class>
<comment>
<class-id>Refactory.HotDraw.MovingFigure</class-id>
<body>A RectangleFigure with a velocity.
The only instance variable, velocity, is a point that represents the
velocity vector.</body>
</comment>
<class>
<name>MovingDrawing</name>
<environment>Refactory.HotDraw</environment>
<super>Refactory.HotDraw.AnimatedDrawing</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>HotDraw-Moving Drawing</category>
<attributes>
<package>HotDraw Animated Examples</package>
</attributes>
</class>
<comment>
<class-id>Refactory.HotDraw.MovingDrawing</class-id>
<body>MovingDrawing is a simple drawing that shows animation.
</body>
</comment>
<class>
<name>NetworkNode</name>
<environment>Refactory.HotDraw</environment>
<super>Refactory.HotDraw.CachedFigure</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>name </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>HotDraw-Network Drawing</category>
<attributes>
<package>HotDraw Animated Examples</package>
</attributes>
</class>
<shared-variable>
<name>DebugFlag</name>
<environment>Refactory.HotDraw.ObjectWorldFigureModel</environment>
<private>true</private>
<constant>false</constant>
<category>As yet unclassified</category>
<initializer>false</initializer>
<attributes>
<package>HotDraw Animated Examples</package>
</attributes>
</shared-variable>
<shared-variable>
<name>DefaultOrbit</name>
<environment>Refactory.HotDraw.ObjectWorldFigureModel</environment>
<private>true</private>
<constant>false</constant>
<category>As yet unclassified</category>
<initializer>0.0872665</initializer>
<attributes>
<package>HotDraw Animated Examples</package>
</attributes>
</shared-variable>
<shared-variable>
<name>DefaultMovement</name>
<environment>Refactory.HotDraw.ObjectWorldFigureModel</environment>
<private>true</private>
<constant>false</constant>
<category>As yet unclassified</category>
<initializer>10</initializer>
<attributes>
<package>HotDraw Animated Examples</package>
</attributes>
</shared-variable>
<methods>
<class-id>Refactory.HotDraw.ObjectWorldDrawing</class-id> <category>animating</category>
<body package="HotDraw Animated Examples">pause
"Pause the animation on all Figures in the receiving Drawing."
self components do: [:each | each model notNil ifTrue: [each model pause]]</body>
<body package="HotDraw Animated Examples">resume
"Resume animation on all Figures in the receiving Drawing.
(This is the opposite of pause.)"
self components
do: [:each | each model notNil ifTrue: [each model resume]]</body>
<body package="HotDraw Animated Examples">step
"Tell each Figure in the receiving Drawing to perform
one step in its animation sequence (if any)."
self components
do: [:each | each model notNil ifTrue: [each model stepIn: self bounds]]</body>
<body package="HotDraw Animated Examples">stopAll
"Shut off animation and delete the list of animation steps for
all Figures in the receiving Drawing."
self components do: [:each | each model notNil ifTrue: [each model stop]]</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorldDrawing</class-id> <category>adding</category>
<body package="HotDraw Animated Examples">add: aFigure
ObjectWorldFigureModel on: aFigure.
aFigure model model: self model.
^super add: aFigure</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorldFigureModel</class-id> <category>figure</category>
<body package="HotDraw Animated Examples">bounds
^figure bounds</body>
<body package="HotDraw Animated Examples">center
^figure center</body>
<body package="HotDraw Animated Examples">changed
^figure changed</body>
<body package="HotDraw Animated Examples">damage
^figure damage</body>
<body package="HotDraw Animated Examples">number
^figure number</body>
<body package="HotDraw Animated Examples">number: aNumber
^figure number: aNumber</body>
<body package="HotDraw Animated Examples">translateBy: aPoint
^figure translateBy: aPoint</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorldFigureModel</class-id> <category>animating</category>
<body package="HotDraw Animated Examples">animate: aMethod
"Add aMethod to the list of methods to invoke for animation on this
figure. aMethod is either a block or the name of a message to send."
| block |
block := aMethod isSymbol
ifTrue:
[(self respondsTo: aMethod)
ifTrue: [[:fig | fig perform: aMethod]]
ifFalse: [^self error: aMethod , ' is an illegal message']]
ifFalse: [aMethod].
animationMethods addFirst: block</body>
<body package="HotDraw Animated Examples">checkVisible: drawingBounds oldBounds: oldBounds
| newBox xDirection yDirection |
stayVisible ifFalse: [^self].
newBox := self bounds.
xDirection := newBox left - oldBounds left.
yDirection := newBox top - oldBounds top.
xDirection < 0 & (newBox right < drawingBounds left)
ifTrue: [self translateBy: (drawingBounds width + newBox width) @ 0].
xDirection > 0 & (newBox left > drawingBounds right)
ifTrue: [self translateBy: (drawingBounds width + newBox width) negated @ 0].
yDirection < 0 & (newBox bottom < drawingBounds top)
ifTrue: [self translateBy: 0 @ (drawingBounds height + newBox height)].
yDirection > 0 & (newBox top > drawingBounds bottom)
ifTrue: [self translateBy: 0 @ (drawingBounds height + newBox height) negated]</body>
<body package="HotDraw Animated Examples">home
"Tell this Figure to move to the center of the visible part of the view. "
| newCenter bounds |
bounds := model drawing bounds.
newCenter := bounds center - self center.
figure translateBy: newCenter</body>
<body package="HotDraw Animated Examples">pause
"Suspend animation for this Figure."
pause := true</body>
<body package="HotDraw Animated Examples">resume
"Begin animation for this Figure."
pause := false</body>
<body package="HotDraw Animated Examples">stayVisible
"Require that this Figure stay within the visible part of the view."
stayVisible := true</body>
<body package="HotDraw Animated Examples">stepIn: drawingBounds
"Perform all the methods in the animation list on this Figure. This is
meant to move the figure one step through its animation. If the pause
indicator is set, skip animation for this figure. If animation is to occur,
then once it has moved through one step, see if the figure is supposed
to stay within the visible bounds of drawing that were passed in. If so,
make sure the user can still see the figure, if not, move it to the opposite
side of the drawing based on the direction the figure is traveling in."
| oldBounds |
oldBounds := self bounds.
pause ifTrue: [^self].
animationMethods do: [:method | method value: self].
self checkVisible: drawingBounds oldBounds: oldBounds</body>
<body package="HotDraw Animated Examples">stop
"Stop all the methods in the animation list on this Figure. This is an
ObjectWorld extension. This method is intended to be invoked
by the ObjectWorld user."
[animationMethods isEmpty] whileFalse: [animationMethods removeFirst]</body>
<body package="HotDraw Animated Examples">stop: aMethod
"Stop the given method from the animation list for the figure.
This is an ObjectWorld extension. This method is intended to be invoked
by the ObjectWorld user."
| methodSymbol |
methodSymbol := aMethod asSymbol.
(animationMethods includes: methodSymbol)
ifTrue: [animationMethods remove: methodSymbol ifAbsent: []]</body>
<body package="HotDraw Animated Examples">unbounded
stayVisible := false</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorldFigureModel</class-id> <category>accessing</category>
<body package="HotDraw Animated Examples">menu
| mb |
mb := MenuBuilder new.
mb add: 'Rename...' -> #rename.
^mb menu</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorldFigureModel</class-id> <category>transforming</category>
<body package="HotDraw Animated Examples">moveDown
"Move the receiving Figure downwards the default distance."
self moveDown: self class defaultMovement</body>
<body package="HotDraw Animated Examples">moveDown: anInteger
"Move the receiving Figure downwards the specified distance.
Intended for the ObjectWorld user."
self translateBy: 0 @ anInteger</body>
<body package="HotDraw Animated Examples">moveLeft
"Move the receiving Figure left the default distance.
Intended for the ObjectWorld user."
self moveLeft: self class defaultMovement</body>
<body package="HotDraw Animated Examples">moveLeft: anInteger
"Move the receiving Figure left the specified distance.
Intended for the ObjectWorld user."
self translateBy: anInteger negated @ 0</body>
<body package="HotDraw Animated Examples">moveRight
"Move the receiving Figure right the default distance.
Intended for the ObjectWorld user."
self moveRight: self class defaultMovement</body>
<body package="HotDraw Animated Examples">moveRight: anInteger
"Move the receiving Figure right the specified distance.
Intended for the ObjectWorld user."
self translateBy: anInteger @ 0</body>
<body package="HotDraw Animated Examples">moveUp
"Move the receiving Figure upwards the default distance.
Intended for the ObjectWorld user."
self moveUp: self class defaultMovement</body>
<body package="HotDraw Animated Examples">moveUp: anInteger
"Move the receiving Figure upwards the specified distance.
Intended for the ObjectWorld user."
self translateBy: 0 @ anInteger negated</body>
<body package="HotDraw Animated Examples">orbit: aFigure
"Make the receiving Figure move in an 'orbit' around aFigure.
To do this, we rotate the receiver about the center of aFigure.
This is an ObjectWorld user method."
| deltaX deltaY sin cos newX newY |
deltaX := (self center x - aFigure center x) asDouble.
deltaY := (self center y - aFigure center y) asDouble.
sin := self class defaultOrbit sin.
cos := self class defaultOrbit cos.
newX := aFigure center x + (deltaX * cos) - (deltaY * sin) - self center x.
newY := aFigure center y + (deltaY * cos) + (deltaX * sin) - self center y.
figure translateBy: newX @ newY</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorldFigureModel</class-id> <category>private</category>
<body package="HotDraw Animated Examples">doesNotUnderstand: aMessage
"Override the same method in the Object class to allow us to
signal the user that they made an error by flashing the view,
rather than by raising an exception and popping up a window."
self class debugFlag
ifTrue: [^super doesNotUnderstand: aMessage]
ifFalse: [model parser view flash]</body>
<body package="HotDraw Animated Examples">rename
"Let the ObjectWorld user change the name of the receiver with a dialogue."
| newname defaultName |
defaultName := name isNil ifTrue: [''] ifFalse: [name].
newname := Dialog request: 'Enter name of object:'
initialAnswer: defaultName.
self name: newname</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorldFigureModel</class-id> <category>initialize-release</category>
<body package="HotDraw Animated Examples">figure
^figure</body>
<body package="HotDraw Animated Examples">figure: aFigure
figure := aFigure</body>
<body package="HotDraw Animated Examples">initialize
"Create the animation list, start the figure out with pausing turned off
and let it roam outside the visible part of the drawing. "
animationMethods := OrderedCollection new.
pause := false.
stayVisible := false</body>
<body package="HotDraw Animated Examples">model: aModel
model := aModel</body>
<body package="HotDraw Animated Examples">name
"Return the name of the figure."
^name</body>
<body package="HotDraw Animated Examples">name: aString
"Register the receiver with the local model. Check if the receiver has been registered
before (i.e. if the receiver already has a non-null name), in which case the receiver
must unregister itself before re-registering under the new name."
name isNil ifFalse: [model unregister: self].
model register: self as: aString.
name := aString</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorldFigureModel</class-id> <category>removing</category>
<body package="HotDraw Animated Examples">remove
"Remove the receiving Figure from its Drawing."
figure changed.
self unregister.
model drawing remove: self</body>
<body package="HotDraw Animated Examples">unregister
"Remove the receiving Figure from its Drawing."
model unregister: self</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorldFigureModel class</class-id> <category>accessing</category>
<body package="HotDraw Animated Examples">debugFlag
^DebugFlag</body>
<body package="HotDraw Animated Examples">debugFlag: aBoolean
"Control the class' DebugFlag: if true, then handle doesNotUnderstand
messages in the usual way, i.e. raise an exception. If false (the default),
then override doesNotUnderstand: to just flash the view to signal the
error to the user."
DebugFlag := aBoolean</body>
<body package="HotDraw Animated Examples">defaultMovement
"Return the default amount of movement for a figure"
^DefaultMovement</body>
<body package="HotDraw Animated Examples">defaultMovement: anInteger
"Set the default amount of movement for a figure to anInteger"
DefaultMovement := anInteger</body>
<body package="HotDraw Animated Examples">defaultOrbit
^DefaultOrbit</body>
<body package="HotDraw Animated Examples">defaultOrbit: aFloat
DefaultOrbit := aFloat</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorldFigureModel class</class-id> <category>instance creation</category>
<body package="HotDraw Animated Examples">new
^super new initialize</body>
<body package="HotDraw Animated Examples">on: aFigure
| model |
model := self new.
model figure: aFigure.
aFigure model: model</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.NetworkEditor</class-id> <category>weights</category>
<body package="HotDraw Animated Examples">acceptText: aString from: what
self weight: aString asNumber.
^true</body>
<body package="HotDraw Animated Examples">node1
^self nodeList1 selection</body>
<body package="HotDraw Animated Examples">node2
^self nodeList2 selection</body>
<body package="HotDraw Animated Examples">textMenu
"Answer a Menu for the node list panes."
^Menu
labels: 'again\undo\copy\cut\paste\accept\cancel' withCRs
lines: #(2 5 )
values: #(#again #undo #copySelection #cut #paste #acceptText:from: #cancel )</body>
<body package="HotDraw Animated Examples">weight
^(edgeWeights at: self node1 ifAbsent: [^0])
at: self node2 ifAbsent: [0]</body>
<body package="HotDraw Animated Examples">weight: number
| node1 node2 |
node1 := self node1.
node2 := self node2.
node1 isNil | node2 isNil ifTrue: [^self].
(self getTableFor: node1)
at: node2 put: number.
(self getTableFor: node2)
at: node1 put: number.
drawing
edgeWeight: number
from: node1
to: node2</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.NetworkEditor</class-id> <category>private</category>
<body package="HotDraw Animated Examples">getTableFor: name
^edgeWeights at: name ifAbsentPut: [Dictionary new]</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.NetworkEditor</class-id> <category>nodes</category>
<body package="HotDraw Animated Examples">addNode
"Get name of node from user."
| name |
name := Dialog request: 'enter name of new node'.
name isNil ifTrue: [^nil].
nodes add: name.
drawing addNode: name.
self updateLists</body>
<body package="HotDraw Animated Examples">deleteNode1
self node1 isNil ifTrue: [^self].
nodes remove: self node1 ifAbsent: [].
drawing removeNode: self node1.
self updateLists</body>
<body package="HotDraw Animated Examples">deleteNode2
self node2 isNil ifTrue: [^self].
nodes remove: self node2 ifAbsent: [].
drawing removeNode: self node2.
self updateLists</body>
<body package="HotDraw Animated Examples">nodeMenu1
"Answer a Menu for the node list panes."
^Menu
labels: 'add node\delete node' withCRs
lines: #( )
values: #(#addNode #deleteNode1 )</body>
<body package="HotDraw Animated Examples">nodeMenu2
"Answer a Menu for the node list panes."
^Menu
labels: 'add node\delete node' withCRs
lines: #( )
values: #(#addNode #deleteNode2 )</body>
<body package="HotDraw Animated Examples">updateLists
| selection |
selection := self nodeList1 selection.
self nodeList1 list: nodes asList.
self nodeList1 selection: selection.
selection := self nodeList2 selection.
self nodeList2 list: nodes asList.
self nodeList2 selection: selection</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.NetworkEditor</class-id> <category>aspects</category>
<body package="HotDraw Animated Examples">nodeList1
"This method was generated by UIDefiner. Any edits made here
may be lost whenever methods are automatically defined. The
initialization provided below may have been preempted by an
initialize method."
^nodeList1 isNil
ifTrue:
[nodeList1 := SelectionInList new]
ifFalse:
[nodeList1]</body>
<body package="HotDraw Animated Examples">nodeList2
"This method was generated by UIDefiner. Any edits made here
may be lost whenever methods are automatically defined. The
initialization provided below may have been preempted by an
initialize method."
^nodeList2 isNil
ifTrue:
[nodeList2 := SelectionInList new]
ifFalse:
[nodeList2]</body>
<body package="HotDraw Animated Examples">textEditor
"This method was generated by UIDefiner. Any edits made here
may be lost whenever methods are automatically defined. The
initialization provided below may have been preempted by an
initialize method."
^textEditor isNil
ifTrue:
[textEditor := String new asValue]
ifFalse:
[textEditor]</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.NetworkEditor</class-id> <category>initialize-release</category>
<body package="HotDraw Animated Examples">initialize
super initialize.
nodes := SortedCollection new.
edgeWeights := Dictionary new.
self updateLists</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.NetworkEditor</class-id> <category>updating</category>
<body package="HotDraw Animated Examples">changedNode
textEditor value: self weight printString</body>
<body package="HotDraw Animated Examples">update: anAspectSymbol with: aParameter from: aSender
anAspectSymbol == #removeNode
ifTrue:
[nodes remove: aParameter ifAbsent: [].
edgeWeights removeKey: aParameter ifAbsent: [].
edgeWeights values do: [:value | value removeKey: aParameter ifAbsent: []].
self updateLists].
^super
update: anAspectSymbol
with: aParameter
from: aSender</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.NetworkEditor</class-id> <category>drawing description</category>
<body package="HotDraw Animated Examples">drawingClass
^NetworkDrawing</body>
<body package="HotDraw Animated Examples">windowName
^'Network Editor'</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.WorkspaceCompiler</class-id> <category>public access</category>
<body package="HotDraw Animated Examples">evaluate: textOrStream inWorkspace: aDict receiver: receiver notifying: aRequestor ifFail: failBlock
"Evaluate an expression binding the receiver to self and using aDict as a global dictionary of names.
The idea is that aDict is a workspace context of some sort, and receiver
might be the workspace."
workspaceDictionary := aDict.
^self
evaluate: textOrStream
in: nil
receiver: receiver
notifying: aRequestor
ifFail: failBlock</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.WorkspaceCompiler</class-id> <category>private</category>
<body package="HotDraw Animated Examples">scopeForClass
"Return a scope for the workspace. This is a carefully placed hack."
| scope |
scope := StaticScope variables: workspaceDictionary.
scope outerScope: (NameScope forEnvironment: Smalltalk).
^scope</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorld</class-id> <category>public</category>
<body package="HotDraw Animated Examples">clearAnimation
"Clear list of figures being animated"
drawing stopAll</body>
<body package="HotDraw Animated Examples">pause
"Temporarily pause animation"
drawing pause</body>
<body package="HotDraw Animated Examples">refresh
"If the screen has gotten out of sync refresh it"
drawing repairDamage</body>
<body package="HotDraw Animated Examples">resume
"Restart animation"
drawing resume</body>
<body package="HotDraw Animated Examples">setFont: aFontSize
"set a new font for everything in the Universe"
TextAttributes setDefaultTo: aFontSize asSymbol.
TextAttributes resetViews</body>
<body package="HotDraw Animated Examples">who
"Show the objects we know about"
| mb |
mb := MenuBuilder new.
parser keys do: [:each | mb add: each -> each].
mb menu startUp</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorld</class-id> <category>ObjectParser protocol</category>
<body package="HotDraw Animated Examples">register: anObject as: aString
parser register: anObject as: aString</body>
<body package="HotDraw Animated Examples">unregister: anObject
parser unregister: anObject</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorld</class-id> <category>user interface</category>
<body package="HotDraw Animated Examples">browse
"Browse only the methods users are allowed to see"
((#{Refactory.Browser.BrowserEnvironment}
valueOrDo: [^self error: 'No Browser Loaded']) new
forClass: self class
protocols: #(#public)) openEditor</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorld</class-id> <category>drawing description</category>
<body package="HotDraw Animated Examples">drawingClass
^ObjectWorldDrawing</body>
<body package="HotDraw Animated Examples">windowName
^'Object World'</body>
</methods>
<methods>
<class-id>Refactory.HotDraw.ObjectWorld</class-id> <category>aspects</category>
<body package="HotDraw Animated Examples">commandText
"This method was generated by UIDefiner. Any edits made here
may be lost whenever methods are automatically defined. The
initialization provided below may have been preempted by an
initialize method."
^commandText isNil
ifTrue:
[commandText := String new asValue]
ifFalse:
[commandText]</body>