/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/case_tool/eiffel_view/cluster_figure.e
ViewVC logotype

Annotation of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/case_tool/eiffel_view/cluster_figure.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 26913 - (hide annotations)
Sun Aug 12 23:50:20 2001 UTC (18 years, 5 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/case_tool/bon/cluster_figure.e
File size: 13432 byte(s)
Merged branch `dev46_manu' to the trunc.

1 manus 26913 indexing
2     description:
3     "Graphical representations of clusters without%N%
4     %commitment to any notation."
5     date: "$Date$"
6     revision: "$Revision$"
7    
8     deferred class
9     CLUSTER_FIGURE
10    
11     inherit
12     LINKABLE_FIGURE
13     undefine
14     position_on_figure
15     redefine
16     set_origin,
17     world,
18     cluster_figure
19     end
20    
21     LINKABLE_FIGURE_GROUP
22     rename
23     cluster_figures as subclusters,
24     class_figures as classes
25     undefine
26     default_create,
27     is_equal
28     end
29    
30     feature {NONE} -- Initialization
31    
32     make_with_cluster (lace_cluster: CLUSTER_I) is
33     -- Initialize `Current' with lace_cluster.
34     require
35     lace_cluster_not_void: lace_cluster /= Void
36     do
37     default_create
38     create layout
39     create subclusters.make
40     create classes.make
41     create saved_subclusters.make
42     create saved_classes.make
43     cluster_i := lace_cluster
44     set_name (cluster_i.name_in_upper)
45     initialize
46     create {CLUSTER_FIGURE_STONE} pebble.make (Current)
47     set_accept_cursor (Cursors.cur_Cluster)
48     build_figure
49     end
50    
51     initialize is
52     deferred
53     end
54    
55     feature -- Access
56    
57     parent: LINKABLE_FIGURE_GROUP
58     -- Figure group containing `Current'.
59    
60     world: CLUSTER_DIAGRAM is
61     -- World `Current' belongs to.
62     do
63     Result ?= Precursor
64     end
65    
66     cluster_i: CLUSTER_I
67     -- Cluster this figure is a representation of.
68    
69     resizer_bottom_right: EV_MOVE_HANDLE is
70     -- Mover of `Current'.
71     deferred
72     end
73    
74     resizer_top_left: EV_MOVE_HANDLE is
75     -- Mover of `Current'.
76     deferred
77     end
78    
79     resizer_top_right: EV_MOVE_HANDLE is
80     -- Mover of `Current'.
81     deferred
82     end
83    
84     resizer_bottom_left: EV_MOVE_HANDLE is
85     -- Mover of `Current'.
86     deferred
87     end
88    
89     name_mover: EV_MOVE_HANDLE is
90     -- Mover of `Current' name.
91     deferred
92     end
93    
94     center_point: EV_RELATIVE_POINT is
95     -- Point at the center of `body', origin of `name_mover'.
96     deferred
97     end
98    
99     cluster_figure: CLUSTER_FIGURE is
100     -- Cluster figure `Current' is in directly.
101     -- Void if none or more than one.
102     do
103     Result ?= parent
104     end
105    
106     feature -- Element change
107    
108     add_class (a_class: CLASS_FIGURE) is
109     -- Add `a_class' to `classes'.
110     require
111     a_class_not_void: a_class /= Void
112     do
113     classes.extend (a_class)
114     a_class.set_cluster (Current)
115     a_class.set_origin (point)
116     ensure
117     a_class_added: classes.has (a_class)
118     end
119    
120     remove_class (a_class: CLASS_FIGURE) is
121     -- Remove `a_class' from `classes'.
122     require
123     a_class_not_void: a_class /= Void
124     do
125     classes.prune_all (a_class)
126     ensure
127     a_class_removed: not classes.has (a_class)
128     end
129    
130     add_all_classes is
131     -- Add class figures representing all items
132     -- in `cluster_i'.
133     do
134     world.include_classes_of_cluster (Current, True)
135     end
136    
137     add_subcluster (a_cluster: CLUSTER_FIGURE) is
138     -- Add `a_cluster' to `subclusters'.
139     require
140     a_cluster_not_void: a_cluster /= Void
141     do
142     if not subclusters.has (a_cluster) then
143     subclusters.extend (a_cluster)
144     a_cluster.set_parent (Current)
145     -- EA: a_cluster.point.set_origin (point)
146     a_cluster.point.change_origin (point)
147     end
148     ensure
149     a_cluster_added: subclusters.has (a_cluster)
150     end
151    
152     remove_subcluster (a_cluster: CLUSTER_FIGURE) is
153     -- Remove `a_cluster' from `subclusters'.
154     require
155     a_cluster_not_void: a_cluster /= Void
156     do
157     subclusters.prune_all (a_cluster)
158     a_cluster.set_parent (Void)
159     ensure
160     a_cluster_removed: not subclusters.has (a_cluster)
161     end
162    
163     set_parent (p: LINKABLE_FIGURE_GROUP) is
164     -- Assign `p' to `parent'.
165     -- `p' can be Void if `Current' is a top-level cluster in diagram.
166     do
167     parent := p
168     if p = Void and then world /= Void then
169     point.set_origin (world.point)
170     end
171     ensure
172     parent_assigned: parent = p
173     end
174    
175     remove_from_diagram (exclude_needed: BOOLEAN) is
176     -- Remove `Current' from its diagram, exclude it if `exclude_needed'.
177     local
178     d: CLUSTER_DIAGRAM
179     saved_cursor: CURSOR
180     cf: CLASS_FIGURE
181     do
182     d := world
183     if d.center_cluster /= Current then
184     saved_subclusters.wipe_out
185     saved_classes.wipe_out
186    
187     from
188     classes.start
189     until
190     classes.after
191     loop
192     cf := classes.item
193     classes.forth
194     saved_cursor := classes.cursor
195     saved_classes.extend (cf)
196     cf.remove_from_diagram (exclude_needed)
197     classes.go_to (saved_cursor)
198     end
199    
200     if exclude_needed then
201     d.exclude_cluster (cluster_i)
202     else
203     d.remove_cluster (cluster_i)
204     end
205     end
206     end
207    
208     recursive_remove_from_diagram (exclude_needed: BOOLEAN) is
209     -- Remove `Current' from its diagram, exclude it if `exclude_needed',
210     -- and remove subclusters as well.
211     local
212     d: CLUSTER_DIAGRAM
213     saved_cursor: CURSOR
214     cf: CLASS_FIGURE
215     clf: CLUSTER_FIGURE
216     do
217     d := world
218     if d.center_cluster /= Current then
219     saved_subclusters.wipe_out
220     saved_classes.wipe_out
221    
222     from
223     subclusters.start
224     until
225     subclusters.after
226     loop
227     clf := subclusters.item
228     subclusters.forth
229     saved_cursor := subclusters.cursor
230     saved_subclusters.extend (clf)
231     clf.recursive_remove_from_diagram (exclude_needed)
232     subclusters.go_to (saved_cursor)
233     end
234    
235     from
236     classes.start
237     until
238     classes.after
239     loop
240     cf := classes.item
241     classes.forth
242     saved_cursor := classes.cursor
243     saved_classes.extend (cf)
244     cf.remove_from_diagram (exclude_needed)
245     classes.go_to (saved_cursor)
246     end
247    
248     if exclude_needed then
249     d.exclude_cluster (cluster_i)
250     else
251     d.remove_cluster (cluster_i)
252     end
253     end
254     end
255    
256     put_back_on_diagram (d: CONTEXT_DIAGRAM) is
257     -- Put `Current' back on `d'.
258     local
259     cd: CLUSTER_DIAGRAM
260     do
261     cd ?= d
262     if cd /= Void then
263     cd.add_cluster_figure (Current, False)
264    
265     from
266     saved_subclusters.start
267     until
268     saved_subclusters.after
269     loop
270     saved_subclusters.item.put_back_on_diagram (d)
271     saved_subclusters.forth
272     end
273    
274     from
275     saved_classes.start
276     until
277     saved_classes.after
278     loop
279     saved_classes.item.put_back_on_diagram (d)
280     saved_classes.forth
281     end
282     end
283     end
284    
285     change_origin (new_origin: EV_RELATIVE_POINT) is
286     -- Set the point this figure is relative to.
287     -- Do not change absolute coordinates.
288     do
289     point.change_origin (new_origin)
290     end
291    
292     feature -- Status report
293    
294     iconified: BOOLEAN
295     -- Is `Current' iconified?
296    
297     is_subcluster_of (other: CLUSTER_FIGURE): BOOLEAN is
298     -- Is Current a subcluster of `other' (directly or not)?
299     require
300     other_not_void: other /= Void
301     local
302     tmp: CLUSTER_FIGURE
303     do
304     Result := other = Current
305     from
306     tmp := cluster_figure
307     until
308     Result = True or tmp = Void
309     loop
310     if other = tmp then
311     Result := True
312     end
313     tmp := tmp.cluster_figure
314     end
315     end
316    
317     recursive_has_class (a_class: CLASS_FIGURE): BOOLEAN is
318     -- Does `a_class' belong to `Current' or to one of its subclusters?
319     require
320     a_class_not_void: a_class /= Void
321     do
322     Result := classes.has (a_class)
323     from
324     subclusters.start
325     until
326     Result or else subclusters.after
327     loop
328     Result := subclusters.item.recursive_has_class (a_class)
329     subclusters.forth
330     end
331     end
332    
333     position_strictly_on_figure (x, y: INTEGER): BOOLEAN is
334     -- Is the point on (`x', `y') on this figure?
335     -- (excluding its subclusters).
336     deferred
337     end
338    
339     feature -- Status setting
340    
341     set_origin (a_point: EV_RELATIVE_POINT) is
342     -- Assign `a_point' to the origin of all
343     -- figures related to `Current'.
344     do
345     point.change_origin (a_point)
346     end
347    
348     update is
349     -- `Current' has just been moved/resized.
350     do
351     from
352     subclusters.start
353     until
354     subclusters.after
355     loop
356     subclusters.item.update
357     subclusters.item.move_to_front
358     subclusters.forth
359     end
360     from
361     classes.start
362     until
363     classes.after
364     loop
365     classes.item.update
366     classes.forth
367     end
368     end
369    
370     set_size (a_width, a_height: INTEGER) is
371     -- Resize `Current' to `a_width', `a_height'.
372     require
373     a_width_non_negative: a_width >= 0
374     a_height_non_negative: a_height >= 0
375     deferred
376     end
377    
378     set_minimum_bounds (a_left, a_top, a_right, a_bottom: INTEGER) is
379     -- Assign minimum bounds.
380     deferred
381     end
382    
383     update_minimum_size is
384     -- Figures have been added/removed in `Current',
385     -- minimum size should change.
386     local
387     rec: EV_RECTANGLE
388     l, t, r, b: INTEGER
389     new_left, new_top, new_right, new_bottom: INTEGER
390     resize_needed: BOOLEAN
391     clf: CLUSTER_FIGURE
392     do
393     if world /= Void then
394     resize_needed := False
395     new_left := left
396     new_top := top
397     new_right := right
398     new_bottom := bottom
399     rec := bounds
400     l := rec.x
401     t := rec.y
402     r := rec.width + l
403     b := rec.height + t
404     if r > right then
405     new_right := r
406     resize_needed := True
407     end
408     if b > bottom then
409     new_bottom := b
410     resize_needed := True
411     end
412     if l < left then
413     new_left := l
414     resize_needed := True
415     end
416     if t < top then
417     new_top := t
418     resize_needed := True
419     end
420     if resize_needed then
421     set_bounds (new_left, new_top, new_right, new_bottom)
422     end
423     set_minimum_bounds (l, t, r, b)
424    
425     clf ?= parent
426     if clf /= Void then
427     clf.update_minimum_size
428     end
429     end
430     end
431    
432     set_bounds (a_left, a_top, a_right, a_bottom: INTEGER) is
433     -- Assign bounds.
434     deferred
435     end
436    
437     set_relative_position_and_size (a_x, a_y, a_width, a_height: INTEGER) is
438     -- Assign bounds.
439     deferred
440     end
441    
442     iconify is
443     -- Iconify `Current'.
444     deferred
445     ensure
446     is_iconified: iconified
447     end
448    
449     deiconify is
450     -- Deiconify `Current'.
451     deferred
452     ensure
453     is_not_iconified: not iconified
454     end
455    
456     mask is
457     -- `Current' no longer needs to be displayed.
458     deferred
459     end
460    
461     unmask is
462     -- `Current' needs to be displayed again.
463     deferred
464     end
465    
466     feature {LINKABLE_FIGURE_GROUP} -- XML
467    
468     xml_element (a_parent: XML_ELEMENT): XML_ELEMENT is
469     -- XML representation.
470     do
471     create Result.make (a_parent, "CLUSTER_FIGURE")
472     Result.attributes.add_attribute (create {XML_ATTRIBUTE}.make ("NAME", cluster_i.cluster_name))
473     Result.put_last (xml_node (Result, "ICONIFIED", iconified.out))
474     Result.put_last (xml_node (Result, "X_POS", point.x.out))
475     Result.put_last (xml_node (Result, "Y_POS", point.y.out))
476     if iconified then
477     Result.put_last (xml_node (Result, "WIDTH", old_width.out))
478     Result.put_last (xml_node (Result, "HEIGHT", old_height.out))
479     else
480     Result.put_last (xml_node (Result, "WIDTH", width.out))
481     Result.put_last (xml_node (Result, "HEIGHT", height.out))
482     end
483     end
484    
485     set_with_xml_element (an_element: XML_ELEMENT) is
486     -- Set attributes from XML element.
487     require else
488     an_element_is_cluster_figure: an_element.name.is_equal ("CLUSTER_FIGURE")
489     an_element_has_name_attribute: an_element.attributes.has ("NAME")
490     an_element_name_is_cluster_name:
491     an_element.attributes.item ("NAME").value.is_equal (cluster_i.cluster_name)
492     local
493     x_pos, y_pos, w, h: INTEGER
494     was_iconified: BOOLEAN
495     do
496     reset_valid_tags
497     was_iconified := xml_boolean (an_element, "ICONIFIED")
498     if was_iconified then
499     iconify
500     else
501     deiconify
502     end
503     x_pos := xml_integer (an_element, "X_POS")
504     y_pos := xml_integer (an_element, "Y_POS")
505     w := xml_integer (an_element, "WIDTH")
506     h := xml_integer (an_element, "HEIGHT")
507     set_relative_position_and_size (x_pos, y_pos, w, h)
508     end
509    
510     feature {CLUSTER_FIGURE} -- Events
511    
512     move_to_front is
513     -- Make `Current' appear in front of its peers.
514     deferred
515     end
516    
517     feature {NONE} -- Implementation
518    
519     external_client_links: LINKED_LIST [CLIENT_SUPPLIER_FIGURE] is
520     -- Client figures which `supplier' is a figure inside `Current',
521     -- and `client' is a figure outside `Current'.
522     local
523     class_client_links: LINKED_LIST [CLIENT_SUPPLIER_FIGURE]
524     do
525     from
526     classes.start
527     until
528     classes.after
529     loop
530     class_client_links := classes.item.client_figures
531     from
532     class_client_links.start
533     until
534     class_client_links.after
535     loop
536     if class_client_links.item.client.cluster_figure /= Current then
537     Result.extend (class_client_links.item)
538     end
539     class_client_links.forth
540     end
541     classes.forth
542     end
543     --| FIXME: take subclusters into account as well.
544     end
545    
546     external_supplier_links: LINKED_LIST [CLIENT_SUPPLIER_FIGURE] is
547     -- Client figures which `client' is a figure inside `Current',
548     -- and `supplier' is a figure outside `Current'.
549     local
550     class_supplier_links: LINKED_LIST [CLIENT_SUPPLIER_FIGURE]
551     do
552     from
553     classes.start
554     until
555     classes.after
556     loop
557     class_supplier_links := classes.item.supplier_figures
558     from
559     class_supplier_links.start
560     until
561     class_supplier_links.after
562     loop
563     if class_supplier_links.item.supplier.cluster_figure /= Current then
564     Result.extend (class_supplier_links.item)
565     end
566     class_supplier_links.forth
567     end
568     classes.forth
569     end
570     --| FIXME: take subclusters into account as well.
571     end
572    
573     saved_subclusters: LINKED_LIST [CLUSTER_FIGURE]
574     -- Subclusters backup to undo delete command.
575    
576     saved_classes: LINKED_LIST [CLASS_FIGURE]
577     -- Classes backup to undo delete command.
578    
579     on_pebble_request: ANY is
580     -- New CLUSTER_STONE with `Current' as source.
581     do
582     create {CLUSTER_FIGURE_STONE} Result.make (Current)
583     end
584    
585     old_width: INTEGER is
586     -- Backup of `width' for iconifying.
587     deferred
588     end
589    
590     old_height: INTEGER is
591     -- Backup of `height' for iconifying.
592     deferred
593     end
594    
595     end -- class CLUSTER_FIGURE
596    
597    
598    
599    

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23