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

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/case_tool/eiffel_view/eiffel_world.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62171 - (show annotations)
Tue Aug 1 01:27:17 2006 UTC (13 years, 4 months ago) by larryl
File size: 37759 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description: "Objects that is a view for on EIFFEL_GRAPH"
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 author: ""
6 date: "$Date$"
7 revision: "$Revision$"
8
9 class
10 EIFFEL_WORLD
11
12 inherit
13 EG_FIGURE_WORLD
14 rename
15 nodes as classes,
16 flat_nodes as flat_classes
17 redefine
18 default_create,
19 figure_added,
20 scale,
21 on_pointer_button_press,
22 model,
23 xml_element,
24 set_with_xml_element,
25 xml_node_name,
26 store,
27 retrieve,
28 on_linkable_move,
29 update,
30 make_with_model_and_factory,
31 node_type
32 end
33
34 EB_CONSTANTS
35 undefine
36 default_create
37 end
38
39 EB_SHARED_PREFERENCES
40 undefine
41 default_create
42 end
43
44 create {EIFFEL_WORLD}
45 make_filled
46
47 feature {NONE} -- Initialization
48
49 default_create is
50 -- Create an EIFFEL_WORLD.
51 do
52 Precursor {EG_FIGURE_WORLD}
53 is_labels_shown := True
54 is_client_supplier_links_shown := True
55 is_inheritance_links_shown := True
56 is_high_quality := True
57 is_cluster_shown := True
58 current_view := default_view_name
59
60 create available_views.make
61 available_views.compare_objects
62 available_views.extend (current_view)
63
64 create cluster_legend.make_with_world (Current)
65 extend (cluster_legend)
66 cluster_legend.disable_sensitive
67 cluster_legend.hide
68 end
69
70 make_with_model_and_factory (a_model: like model; a_factory: like factory) is
71 -- Create a view for `a_model' using `a_factory'.
72 do
73 Precursor {EG_FIGURE_WORLD} (a_model, a_factory)
74 end
75
76 feature -- Status report
77
78 is_labels_shown: BOOLEAN
79 -- Are labels of client supplier links shown?
80
81 is_client_supplier_links_shown: BOOLEAN
82 -- Are client supplier links shown?
83
84 is_inheritance_links_shown: BOOLEAN
85 -- Are inheritance links shown?
86
87 is_high_quality: BOOLEAN
88 -- Is `Current' shown in high quality?
89
90 is_cluster_shown: BOOLEAN
91 -- Are cluster figures shown?
92
93 is_legend_shown: BOOLEAN
94 -- Is cluster legend shown?
95
96 is_right_angles: BOOLEAN
97 -- Are right angles used for links?
98
99 is_statistics: BOOLEAN is False
100 -- Is a statistic shown informing of draw and physics time?
101
102 is_uml: BOOLEAN
103 -- Is diagram shown as UML?
104
105 feature -- Access
106
107 context_editor: EB_DIAGRAM_TOOL
108 -- Context showing `Current'.
109
110 model: ES_GRAPH
111 -- Model for `Current'.
112
113 current_view: STRING
114 -- Name of Current view.
115
116 available_views: LINKED_LIST [STRING]
117 -- All the views described in `Current' ead file.
118
119 default_view_name: STRING is
120 -- Name for the default view.
121 do
122 Result := once "DEFAULT"
123 ensure
124 Result_not_Void: Result /= Void
125 end
126
127 uml_views (file_name: STRING): LIST [STRING] is
128 -- All views in `file_name' which are uml views.
129 require
130 file_name_not_void: file_name /= Void
131 local
132 diagram_input: XM_DOCUMENT
133 node: XM_ELEMENT
134 a_cursor: DS_LINKED_LIST_CURSOR [XM_NODE]
135 view_name: STRING
136 do
137 create {ARRAYED_LIST [STRING]} Result.make (0)
138 diagram_input := Xml_routines.deserialize_document (file_name)
139 if diagram_input /= Void then
140 check
141 valid_xml: diagram_input.root_element.name.is_equal (xml_node_name)
142 end
143 a_cursor := diagram_input.root_element.new_cursor
144 from
145 a_cursor.start
146 until
147 a_cursor.after
148 loop
149 node ?= a_cursor.item
150 if node /= Void then
151 if node.name.is_equal ("VIEW") then
152 view_name := node.attribute_by_name ("NAME").value
153 if node.attribute_by_name ("IS_UML").value.is_equal ("True") then
154 Result.extend (view_name)
155 end
156 end
157 end
158 a_cursor.forth
159 end
160 end
161 end
162
163 bon_views (file_name: STRING): LIST [STRING] is
164 -- All views in `file_name' which are bon views.
165 require
166 file_name_not_void: file_name /= Void
167 local
168 diagram_input: XM_DOCUMENT
169 node: XM_ELEMENT
170 a_cursor: DS_LINKED_LIST_CURSOR [XM_NODE]
171 view_name: STRING
172 do
173 create {ARRAYED_LIST [STRING]} Result.make (0)
174 diagram_input := Xml_routines.deserialize_document (file_name)
175 if diagram_input /= Void then
176 check
177 valid_xml: diagram_input.root_element.name.is_equal (xml_node_name)
178 end
179 a_cursor := diagram_input.root_element.new_cursor
180 from
181 a_cursor.start
182 until
183 a_cursor.after
184 loop
185 node ?= a_cursor.item
186 if node /= Void then
187 if node.name.is_equal (once "VIEW") then
188 view_name := node.attribute_by_name (once "NAME").value
189 if node.attribute_by_name (once "IS_UML").value.is_equal (once "False") then
190 Result.extend (view_name)
191 end
192 end
193 end
194 a_cursor.forth
195 end
196 end
197 end
198
199 feature -- Element change.
200
201 update is
202 -- Update.
203 local
204 l_background_color: like background_color
205 do
206 l_background_color := preferences.diagram_tool_data.diagram_background_color
207 if background_color /= l_background_color then
208 background_color := l_background_color
209 full_redraw
210 end
211 if is_statistics then
212 update_statistic
213 end
214 Precursor {EG_FIGURE_WORLD}
215 if is_cluster_shown then
216 update_fade
217 end
218 end
219
220 scale (a_scale: DOUBLE) is
221 -- Scale to x and y direction for `a_scale'.
222 local
223 val: DOUBLE
224 do
225 if cluster_legend /= Void then
226 prune_all (cluster_legend)
227 end
228
229 if not is_center_valid then
230 set_center
231 end
232 scale_factor := scale_factor * a_scale
233 val := -a_scale + 1
234 projection_matrix.put (a_scale, 1, 1)
235 internal_projection_matrix.put (0.0, 1, 2)
236 internal_projection_matrix.put (center.x_precise * val, 1, 3)
237 internal_projection_matrix.put (0.0, 2, 1)
238 internal_projection_matrix.put (a_scale, 2, 2)
239 internal_projection_matrix.put (center.y_precise * val, 2, 3)
240 internal_projection_matrix.put (0.0, 3, 1)
241 internal_projection_matrix.put (0.0, 3, 2)
242 internal_projection_matrix.put (1.0, 3, 3)
243
244 recursive_transform (internal_projection_matrix)
245 if is_in_group and then group.is_center_valid then
246 group.center_invalidate
247 end
248 if cluster_legend /= Void then
249 extend (cluster_legend)
250 end
251 if is_right_angles then
252 apply_right_angles
253 end
254 end
255
256 enable_high_quality is
257 -- Enable high quality.
258 do
259 is_high_quality := True
260 set_high_quality (True)
261 ensure
262 is_high_quality: is_high_quality
263 end
264
265 disable_high_quality is
266 -- Disable high qualtiy.
267 do
268 is_high_quality := False
269 set_high_quality (False)
270 ensure
271 is_low_quality: not is_high_quality
272 end
273
274 show_labels is
275 -- Show labels.
276 do
277 is_labels_shown := True
278 set_label_shown (True)
279 ensure
280 is_labels_shown: is_labels_shown
281 end
282
283 hide_labels is
284 -- Hide labels.
285 do
286 is_labels_shown := False
287 set_label_shown (False)
288 ensure
289 labels_hidden: not is_labels_shown
290 end
291
292 show_client_supplier_links is
293 -- Show client supplier links.
294 do
295 is_client_supplier_links_shown := True
296 set_client_supplier_links_shown (True)
297 if context_editor /= Void then
298 context_editor.restart_force_directed
299 end
300 ensure
301 client_supplier_links_shown: is_client_supplier_links_shown
302 end
303
304 hide_client_supplier_links is
305 -- Hide client supplier links.
306 do
307 is_client_supplier_links_shown := False
308 set_client_supplier_links_shown (False)
309 if context_editor /= Void then
310 context_editor.restart_force_directed
311 end
312 ensure
313 client_supplier_links_hidden: not is_client_supplier_links_shown
314 end
315
316 show_inheritance_links is
317 -- Show client supplier links.
318 do
319 is_inheritance_links_shown := True
320 set_inheritance_links_shown (True)
321 if context_editor /= Void then
322 context_editor.restart_force_directed
323 end
324 ensure
325 inheritance_links_shown: is_inheritance_links_shown
326 end
327
328 hide_inheritance_links is
329 -- Hide client supplier links.
330 do
331 is_inheritance_links_shown := False
332 set_inheritance_links_shown (False)
333 if context_editor /= Void then
334 context_editor.restart_force_directed
335 end
336 ensure
337 inheritance_links_hidden: not is_inheritance_links_shown
338 end
339
340 show_clusters is
341 -- Show cluster figures.
342 do
343 is_cluster_shown := True
344 set_is_cluster_shown (True)
345 update_fade
346 ensure
347 is_cluster_shown: is_cluster_shown
348 end
349
350 hide_clusters is
351 -- Hide cluster figures.
352 local
353 l_c_fig: EIFFEL_CLASS_FIGURE
354 l_linkables: like classes
355 i, nb: INTEGER
356 do
357 is_cluster_shown := False
358 set_is_cluster_shown (False)
359 from
360 l_linkables := classes
361 i := 1
362 nb := l_linkables.count
363 until
364 i > nb
365 loop
366 l_c_fig ?= l_linkables.i_th (i)
367 if l_c_fig /= Void then
368 l_c_fig.fade_in
369 end
370 i := i + 1
371 end
372 ensure
373 not_is_cluster_shown: not is_cluster_shown
374 end
375
376 show_legend is
377 -- Show legend of clusters and colors.
378 local
379 bbox: like bounding_box
380 do
381 cluster_legend.update
382 cluster_legend.hide
383 bbox := bounding_box
384 cluster_legend.set_point_position (bbox.left, bbox.top)
385 cluster_legend.show
386 cluster_legend.enable_sensitive
387 if not has (cluster_legend) then
388 extend (cluster_legend)
389 end
390 bring_to_front (cluster_legend)
391 is_legend_shown := True
392 ensure
393 legend_is_shown: is_legend_shown
394 end
395
396 hide_legend is
397 -- Hide legend of clusters and colors.
398 do
399 cluster_legend.hide
400 cluster_legend.disable_sensitive
401 is_legend_shown := False
402 ensure
403 legend_is_hidden: not is_legend_shown
404 end
405
406 enable_right_angles is
407 -- Set `is_right_angles' to True.
408 do
409 is_right_angles := True
410 ensure
411 set: is_right_angles
412 end
413
414 disable_right_angles is
415 -- Set `is_right_angles' to False.
416 do
417 is_right_angles := False
418 ensure
419 set: not is_right_angles
420 end
421
422 apply_right_angles is
423 -- Apply right angles to all LINK_FIGUREs in the world.
424 local
425 l_edges: ARRAYED_LIST [EG_LINK_FIGURE]
426 l_item: EIFFEL_LINK_FIGURE
427 i, nb: INTEGER
428 do
429 if context_editor = Void or else context_editor.force_directed_layout.is_stopped then
430 update
431 from
432 l_edges := links
433 i := 1
434 nb := l_edges.count
435 until
436 i > nb
437 loop
438 l_item ?= l_edges.i_th (i)
439 if l_item /= Void then
440 l_item.apply_right_angles
441 end
442 i := i + 1
443 end
444 end
445 end
446
447 remove_right_angles is
448 -- Remove all edges in links.
449 local
450 l_edges: ARRAYED_LIST [EG_LINK_FIGURE]
451 l_item: EIFFEL_LINK_FIGURE
452 i, nb: INTEGER
453 do
454 from
455 l_edges := links
456 i := 1
457 nb := l_edges.count
458 until
459 i > nb
460 loop
461 l_item ?= l_edges.i_th (i)
462 if l_item /= Void then
463 l_item.reset
464 end
465 i := i + 1
466 end
467 end
468
469 feature {EB_DIAGRAM_TOOL} -- Status settings
470
471 show_anchors is
472 -- Show all anchors of fixed linkable figures.
473 do
474 set_is_anchor_shown (True)
475 end
476
477 hide_anchors is
478 -- Hide all anchors of fixed linkable figures.
479 do
480 set_is_anchor_shown (False)
481 end
482
483 feature {EB_CHANGE_COLOR_COMMAND, EB_DELETE_FIGURE_COMMAND, EG_FIGURE} -- Cluster color legend.
484
485 update_cluster_legend is
486 --
487 do
488 if is_legend_shown then
489 cluster_legend.update
490 bring_to_front (cluster_legend)
491 end
492 end
493
494 feature {EB_DIAGRAM_TOOL} -- Legend
495
496 cluster_legend: EIFFEL_CLUSTER_LEGEND
497 -- Legend of clusters and colors.
498
499 feature -- Store/Retrive
500
501 remove_view (name: STRING) is
502 -- Remove any reference to view named `name' in the .xml file.
503 -- Switch to view default_view_name.
504 require
505 name_not_void: name /= Void
506 local
507 f: RAW_FILE
508 do
509 create f.make (context_editor.diagram_file_name (Current.model))
510 if f.exists then
511 f.open_read
512 else
513 f.open_write
514 end
515 remove_view_from_file (f, name)
516 available_views.prune_all (name)
517 f.close
518
519 current_view := default_view_name
520 create f.make (context_editor.diagram_file_name (Current.model))
521 if f.exists then
522 f.open_read
523 if f.readable then
524 retrieve (f)
525 end
526 end
527 context_editor.projector.full_project
528 ensure
529 default_view_restored: current_view.is_equal (default_view_name)
530 end
531
532 set_current_view (name: STRING) is
533 -- Set `current_view' to `name'.
534 require
535 name_not_void: name /= Void
536 do
537 current_view := name
538 if not available_views.has (name) then
539 available_views.extend (name)
540 end
541 ensure
542 set: current_view = name
543 name_is_available: available_views.has (name)
544 end
545
546 retrieve_view (name: STRING) is
547 -- Assign `name' to `current_view' and retrieve corresponding settings.
548 require
549 name_not_void: name /= Void
550 local
551 f: RAW_FILE
552 do
553 -- Save current view.
554 create f.make (context_editor.diagram_file_name (Current.model))
555 if f.exists then
556 f.open_read
557 else
558 f.open_write
559 end
560 store (f)
561 f.close
562 -- Restore view `name' if possible.
563 current_view := name
564 create f.make (context_editor.diagram_file_name (Current.model))
565 if f.exists then
566 f.open_read
567 if f.readable and then has_view_with_name (f, name) then
568 retrieve (f)
569 end
570 end
571 if not available_views.has (name) then
572 available_views.extend (name)
573 end
574 ensure
575 name_assigned: current_view.is_equal (name)
576 end
577
578 store (ptf: RAW_FILE) is
579 -- Freeze state of `Current'.
580 local
581 diagram_output: XM_DOCUMENT
582 view_output, node: XM_ELEMENT
583 a_cursor: DS_LINKED_LIST_CURSOR [XM_NODE]
584 root: XM_ELEMENT
585 l_view_str, l_name_str: STRING
586 do
587 if ptf.is_open_read then
588 -- Remove any previous save of `current_view'.
589 diagram_output := Xml_routines.deserialize_document (ptf.name)
590 else
591 -- Create a new view.
592 create diagram_output.make_with_root_named (xml_node_name,
593 create {XM_NAMESPACE}.make_default)
594 end
595 if diagram_output /= Void then
596 a_cursor := diagram_output.root_element.new_cursor
597 from
598 l_view_str := "VIEW"
599 l_name_str := "NAME"
600 a_cursor.start
601 until
602 a_cursor.after
603 loop
604 node ?= a_cursor.item
605 if
606 node /= Void and then
607 node.name.is_equal (l_view_str) and then
608 equal (node.attribute_by_name (l_name_str).value, current_view)
609 then
610 diagram_output.root_element.remove_at_cursor (a_cursor)
611 end
612 if not a_cursor.after then
613 a_cursor.forth
614 end
615 end
616 create root.make_root (create {XM_DOCUMENT}.make, "VIEW", xml_namespace)
617 root.add_attribute ("IS_UML", xml_namespace, is_uml.out)
618 view_output := xml_element (root)
619 diagram_output.root_element.force_first (view_output)
620 Xml_routines.save_xml_document (ptf.name, diagram_output)
621 end
622 end
623
624 load_available_views (f: RAW_FILE) is
625 -- Load avaiable views from `f' store it in `available_views.
626 require
627 f_exists: f /= Void
628 local
629 diagram_input: XM_DOCUMENT
630 node: XM_ELEMENT
631 a_cursor: DS_LINKED_LIST_CURSOR [XM_NODE]
632 view_name: STRING
633 do
634 available_views.wipe_out
635 diagram_input := Xml_routines.deserialize_document (f.name)
636 if diagram_input /= Void then
637 check
638 valid_xml: diagram_input.root_element.name.is_equal (xml_node_name)
639 end
640 a_cursor := diagram_input.root_element.new_cursor
641 from
642 a_cursor.start
643 until
644 a_cursor.after
645 loop
646 node ?= a_cursor.item
647 if node /= Void then
648 if node.name.is_equal ("VIEW") then
649 view_name := node.attribute_by_name ("NAME").value
650 available_views.extend (view_name)
651 end
652 end
653 a_cursor.forth
654 end
655 end
656 if not available_views.has (default_view_name) then
657 available_views.extend (default_view_name)
658 end
659 end
660
661 retrieve (f: RAW_FILE) is
662 -- Reload former state of `Current'.
663 local
664 diagram_input: XM_DOCUMENT
665 view_input, node: XM_ELEMENT
666 a_cursor: DS_LINKED_LIST_CURSOR [XM_NODE]
667 nb_of_tags: INTEGER
668 view_name: STRING
669 l_name_str, l_view_str: STRING
670 do
671 diagram_input := Xml_routines.deserialize_document (f.name)
672 if diagram_input /= Void then
673 check
674 valid_xml: diagram_input.root_element.name.is_equal (xml_node_name)
675 end
676 available_views.wipe_out
677 a_cursor := diagram_input.root_element.new_cursor
678 from
679 a_cursor.start
680 l_name_str := "NAME"
681 l_view_str := "VIEW"
682 until
683 a_cursor.after
684 loop
685 node ?= a_cursor.item
686 if node /= Void then
687 if node.name.is_equal (l_view_str) then
688 view_name := node.attribute_by_name (l_name_str).value
689 available_views.extend (view_name)
690 if view_input = Void or else node.attribute_by_name (l_name_str).value.is_equal (current_view) then
691 view_input := node
692 end
693 end
694 end
695 a_cursor.forth
696 end
697 if view_input /= Void then
698 current_view := view_input.attribute_by_name ("NAME").value
699 if view_input.attribute_by_name ("IS_UML").value.is_equal ("True") then
700 if not is_uml then
701 set_factory (create {UML_FACTORY})
702 is_uml := True
703 end
704 else
705 if is_uml then
706 set_factory (create {BON_FACTORY})
707 is_uml := False
708 end
709 end
710 if context_editor /= Void then
711 --context_editor.progress_dialog.start (0)
712 --context_editor.development_window.status_bar.progress_bar.reset_with_range (0 |..| 0)
713 nb_of_tags := xml_routines.number_of_tags (view_input)
714 --context_editor.progress_dialog.start (nb_of_tags)
715 context_editor.develop_window.status_bar.reset_progress_bar_with_range (0 |..| nb_of_tags)
716 --context_editor.progress_dialog.set_degree ("Loading:")
717 xml_routines.valid_tag_read_actions.extend (agent on_valid_tag_read)
718 end
719 wipe_out
720 model.wipe_out
721 view_input.start
722 view_input.forth
723 set_with_xml_element (view_input)
724 xml_routines.valid_tag_read_actions.wipe_out
725 end
726 end
727 end
728
729 xml_node_name: STRING is
730 -- Name of the node returned by `xml_element'.
731 do
732 Result := once "EIFFEL_WORLD"
733 end
734
735 xml_element (node: XM_ELEMENT): XM_ELEMENT is
736 -- Xml node representing `Current's state.
737 do
738 node.put_last (Xml_routines.xml_node (node, once "INHERITANCE_LINKS_DISPLAYED", is_inheritance_links_shown.out))
739 node.put_last (Xml_routines.xml_node (node, once "CLIENT_LINKS_DISPLAYED", is_client_supplier_links_shown.out))
740 node.put_last (Xml_routines.xml_node (node, once "LABELS_SHOWN", is_labels_shown.out))
741 node.put_last (Xml_routines.xml_node (node, once "CLUSTER_SHOWN", is_cluster_shown.out))
742 node.put_last (Xml_routines.xml_node (node, once "HIGH_QUALITY", is_high_quality.out))
743 node.put_last (Xml_routines.xml_node (node, once "LEGEND_SHOWN", is_legend_shown.out))
744 node.put_last (Xml_routines.xml_node (node, once "LEGEND_X_POS", cluster_legend.point_x.out))
745 node.put_last (Xml_routines.xml_node (node, once "LEGEND_Y_POS", cluster_legend.point_y.out))
746 node.put_last (xml_routines.xml_node (node, once "IS_RIGHT_ANGLES", is_right_angles.out))
747
748 Result := Precursor {EG_FIGURE_WORLD} (node)
749 end
750
751 set_with_xml_element (node: XM_ELEMENT) is
752 -- Retrive state from `node'.
753 local
754 ax, ay: INTEGER
755 do
756 if xml_routines.xml_boolean (node, once "INHERITANCE_LINKS_DISPLAYED") then
757 show_inheritance_links
758 else
759 hide_inheritance_links
760 end
761 if xml_routines.xml_boolean (node, once "CLIENT_LINKS_DISPLAYED") then
762 show_client_supplier_links
763 else
764 hide_client_supplier_links
765 end
766 if xml_routines.xml_boolean (node, once "LABELS_SHOWN") then
767 show_labels
768 else
769 hide_labels
770 end
771 if xml_routines.xml_boolean (node, once "CLUSTER_SHOWN") then
772 show_clusters
773 else
774 hide_clusters
775 end
776 if xml_routines.xml_boolean (node, once "HIGH_QUALITY") then
777 enable_high_quality
778 else
779 disable_high_quality
780 end
781 if xml_routines.xml_boolean (node, once "LEGEND_SHOWN") then
782 show_legend
783 ax := xml_routines.xml_integer (node, once "LEGEND_X_POS")
784 ay := xml_routines.xml_integer (node, once "LEGEND_Y_POS")
785 cluster_legend.set_point_position (ax, ay)
786 else
787 hide_legend
788 ax := xml_routines.xml_integer (node, once "LEGEND_X_POS")
789 ay := xml_routines.xml_integer (node, once "LEGEND_Y_POS")
790 cluster_legend.set_point_position (ax, ay)
791 end
792 if xml_routines.xml_boolean (node, once "IS_RIGHT_ANGLES") then
793 enable_right_angles
794 else
795 disable_right_angles
796 end
797
798 Precursor {EG_FIGURE_WORLD} (node)
799 end
800
801 feature {EB_DIAGRAM_TOOL} -- Statistic
802
803 set_last_draw_time (ms: INTEGER) is
804 -- Set time needed for draw.
805 do
806 if draw_count >= 1000 then
807 draw_count := 0
808 draw_sum := 0
809 end
810 draw_sum := draw_sum + ms
811 draw_count := draw_count + 1
812 nbOfDraws := nbOfDraws + 1
813 end
814
815 set_last_physics_time (ms: INTEGER) is
816 -- Set time needed for physics.
817 do
818 if physics_count >= 1000 then
819 physics_count := 0
820 physics_sum := 0
821 end
822 physics_sum := physics_sum + ms
823 physics_count := physics_count + 1
824 end
825
826 feature {NONE} -- Statistic
827
828 physics_count, draw_count: INTEGER
829
830 physics_sum, draw_sum: INTEGER
831 nbOfDraws: INTEGER
832
833 statistic_box: EV_MODEL_MOVE_HANDLE
834 txt: EV_MODEL_TEXT
835
836 update_statistic is
837 -- Update statistic
838 local
839 l_classes: like classes
840 l_node: EIFFEL_CLASS_FIGURE
841 l_clusters: like clusters
842 l_cluster: EIFFEL_CLUSTER_FIGURE
843 l_links: like links
844 l_cs_link: EIFFEL_CLIENT_SUPPLIER_FIGURE
845 l_i_link: EIFFEL_INHERITANCE_FIGURE
846 nr_of_classes: INTEGER
847 nr_of_clusters: INTEGER
848 nr_of_client_supplier_links: INTEGER
849 nr_of_inheritance_links: INTEGER
850 rec: EV_MODEL_RECTANGLE
851 l_speed: STRING
852 do
853 if statistic_box = Void then
854 create statistic_box
855 create txt.make_with_text ( "Classes: " + nr_of_classes.out + "%N" +
856 "CS_Links: " + nr_of_client_supplier_links.out + "%N" +
857 "I_Links: " + nr_of_inheritance_links.out + "%N" +
858 "Clusters: " + nr_of_clusters.out + "%N" +
859 "Physics ms: %NDraw ms: 0%NDraws: ")
860 txt.set_point_position (10, 10)
861 create rec.make_with_positions (0, 0, txt.width + 60, txt.height + 20)
862 rec.set_background_color (default_colors.white)
863 statistic_box.extend (rec)
864 statistic_box.extend (txt)
865 statistic_box.set_pointer_style (default_pixmaps.sizeall_cursor)
866 end
867 if not has (statistic_box) then
868 extend (statistic_box)
869 end
870 from
871 nr_of_classes := 0
872 l_classes := classes
873 l_classes.start
874 until
875 l_classes.after
876 loop
877 l_node ?= l_classes.item
878 if l_node /= Void and then l_node.is_show_requested then
879 nr_of_classes := nr_of_classes + 1
880 end
881 l_classes.forth
882 end
883 from
884 nr_of_clusters := 0
885 l_clusters := clusters
886 l_clusters.start
887 until
888 l_clusters.after
889 loop
890 l_cluster ?= l_clusters.item
891 if l_cluster /= Void and then l_cluster.is_show_requested then
892 nr_of_clusters := nr_of_clusters + 1
893 end
894 l_clusters.forth
895 end
896 from
897 nr_of_client_supplier_links := 0
898 nr_of_inheritance_links := 0
899 l_links := links
900 l_links.start
901 until
902 l_links.after
903 loop
904 l_i_link ?= l_links.item
905 if l_i_link /= Void and then l_i_link.is_show_requested then
906 nr_of_inheritance_links := nr_of_inheritance_links + 1
907 end
908 l_cs_link ?= l_links.item
909 if l_cs_link /= Void and then l_cs_link.is_show_requested then
910 nr_of_client_supplier_links := nr_of_client_supplier_links + 1
911 end
912 l_links.forth
913 end
914 if physics_count = 0 then
915 l_speed := "Physics ms: 0%N"
916 else
917 l_speed := "Physics ms: " + (physics_sum // physics_count).out + "%N"
918 end
919 if draw_count = 0 then
920 l_speed := l_speed + "Draw ms: ?"
921 else
922 l_speed := l_speed + "Draw ms: " + (draw_sum // draw_count).out
923 end
924 txt.set_text ( "Classes: " + nr_of_classes.out + "%N" +
925 "CS_Links: " + nr_of_client_supplier_links.out + "%N" +
926 "I_Links: " + nr_of_inheritance_links.out + "%N" +
927 "Clusters: " + nr_of_clusters.out + "%N" +
928 l_speed + "%NDraws: " + nbOfDraws.out)
929 bring_to_front (statistic_box)
930 end
931
932
933 feature {NONE} -- Implementation
934
935 remove_view_from_file (ptf: RAW_FILE; a_name: STRING) is
936 -- Remove view named `a_name' in `ptf'.
937 require
938 file_not_void: ptf /= Void
939 ptf_is_readable: ptf.is_open_read
940 a_name_exists: a_name /= Void
941 local
942 diagram_output: XM_DOCUMENT
943 node: XM_ELEMENT
944 a_cursor: DS_LINKED_LIST_CURSOR [XM_NODE]
945 do
946 diagram_output := Xml_routines.deserialize_document (ptf.name)
947 if diagram_output /= Void then
948 check
949 valid_xml: diagram_output.root_element.name.is_equal (xml_node_name)
950 end
951 a_cursor := diagram_output.root_element.new_cursor
952 from
953 a_cursor.start
954 until
955 a_cursor.after
956 loop
957 node ?= a_cursor.item
958 if
959 node /= Void and then
960 node.name.is_equal (once "VIEW") and then
961 equal (node.attribute_by_name (once "NAME").value, a_name)
962 then
963 diagram_output.root_element.remove_at_cursor (a_cursor)
964 end
965 if not a_cursor.after then
966 a_cursor.forth
967 end
968 end
969 Xml_routines.save_xml_document (ptf.name, diagram_output)
970 end
971 end
972
973 has_view_with_name (f: RAW_FILE; a_name: STRING): BOOLEAN is
974 -- Does `f' contain a view with name `a_name'?
975 local
976 diagram_input: XM_DOCUMENT
977 node: XM_ELEMENT
978 a_cursor: DS_LINKED_LIST_CURSOR [XM_NODE]
979 view_name: STRING
980 do
981 diagram_input := Xml_routines.deserialize_document (f.name)
982 if diagram_input /= Void then
983 check
984 valid_xml: diagram_input.root_element.name.is_equal (xml_node_name)
985 end
986 a_cursor := diagram_input.root_element.new_cursor
987 from
988 a_cursor.start
989 until
990 a_cursor.after or else Result
991 loop
992 node ?= a_cursor.item
993 if node /= Void then
994 if node.name.is_equal (once "VIEW") then
995 view_name := node.attribute_by_name (once "NAME").value
996 Result := view_name.is_equal (a_name)
997 end
998 end
999 a_cursor.forth
1000 end
1001 end
1002 end
1003
1004 figure_added (a_figure: EG_FIGURE) is
1005 -- `a_figure' was added to the view.
1006 local
1007 bon_fig: BON_FIGURE
1008 cs_fig: EIFFEL_CLIENT_SUPPLIER_FIGURE
1009 i_fig: EIFFEL_INHERITANCE_FIGURE
1010 c_fig: EIFFEL_CLUSTER_FIGURE
1011 bc_fig: EIFFEL_CLASS_FIGURE
1012 do
1013 Precursor {EG_FIGURE_WORLD} (a_figure)
1014 if not is_high_quality then
1015 bon_fig ?= a_figure
1016 if bon_fig /= Void then
1017 bon_fig.disable_high_quality
1018 end
1019 end
1020 cs_fig ?= a_figure
1021 if cs_fig /= Void then
1022 if not is_labels_shown then
1023 cs_fig.hide_label
1024 end
1025 if not is_client_supplier_links_shown then
1026 cs_fig.hide
1027 cs_fig.disable_sensitive
1028 end
1029 if is_right_angles then
1030 cs_fig.apply_right_angles
1031 end
1032 else
1033 i_fig ?= a_figure
1034 if i_fig /= Void then
1035 if not is_inheritance_links_shown then
1036 i_fig.hide
1037 i_fig.disable_sensitive
1038 end
1039 if is_right_angles then
1040 i_fig.apply_right_angles
1041 end
1042 else
1043 c_fig ?= a_figure
1044 if c_fig /= Void then
1045 if not is_cluster_shown then
1046 c_fig.disable_shown
1047 end
1048 else
1049 bc_fig ?= a_figure
1050 if is_legend_shown and then bc_fig /= Void then
1051 cluster_legend.update
1052 bring_to_front (cluster_legend)
1053 end
1054 end
1055 end
1056 end
1057 end
1058
1059 set_high_quality (b: BOOLEAN) is
1060 -- Set all BON_FIGUREs in `world' to high quality if `b', low quality otherwise.
1061 local
1062 bon_fig: BON_FIGURE
1063 figs: LIST [EG_FIGURE]
1064 do
1065 figs := clusters
1066 from
1067 figs.start
1068 until
1069 figs.after
1070 loop
1071 bon_fig ?= figs.item
1072 if bon_fig /= Void then
1073 if b then
1074 bon_fig.enable_high_quality
1075 else
1076 bon_fig.disable_high_quality
1077 end
1078 end
1079 figs.forth
1080 end
1081 figs := links
1082 from
1083 figs.start
1084 until
1085 figs.after
1086 loop
1087 bon_fig ?= figs.item
1088 if bon_fig /= Void then
1089 if b then
1090 bon_fig.enable_high_quality
1091 else
1092 bon_fig.disable_high_quality
1093 end
1094 end
1095 figs.forth
1096 end
1097 figs := classes
1098 from
1099 figs.start
1100 until
1101 figs.after
1102 loop
1103 bon_fig ?= figs.item
1104 if bon_fig /= Void then
1105 if b then
1106 bon_fig.enable_high_quality
1107 else
1108 bon_fig.disable_high_quality
1109 end
1110 end
1111 figs.forth
1112 end
1113 end
1114
1115 set_label_shown (b: BOOLEAN) is
1116 -- Show labels if `b', hide otherwise.
1117 local
1118 l_links: like links
1119 cs_link: EIFFEL_CLIENT_SUPPLIER_FIGURE
1120 do
1121 from
1122 l_links := links
1123 l_links.start
1124 until
1125 l_links.after
1126 loop
1127 cs_link ?= l_links.item
1128 if cs_link /= Void then
1129 if b then
1130 if not cs_link.is_label_shown then
1131 cs_link.show_label
1132 end
1133 else
1134 if cs_link.is_label_shown then
1135 cs_link.hide_label
1136 end
1137 end
1138 end
1139 l_links.forth
1140 end
1141 end
1142
1143 set_client_supplier_links_shown (b: BOOLEAN) is
1144 -- Show client supplier links in `links' if `b', hide otherwise.
1145 local
1146 l_links: like links
1147 cs_link: EIFFEL_CLIENT_SUPPLIER_FIGURE
1148 do
1149 from
1150 l_links := links
1151 l_links.start
1152 until
1153 l_links.after
1154 loop
1155 cs_link ?= l_links.item
1156 if cs_link /= Void and then cs_link.model.is_needed_on_diagram then
1157 if b then
1158 cs_link.show
1159 cs_link.enable_sensitive
1160 else
1161 cs_link.hide
1162 cs_link.disable_sensitive
1163 end
1164 end
1165 l_links.forth
1166 end
1167 end
1168
1169 set_inheritance_links_shown (b: BOOLEAN) is
1170 -- Show inheritance links in `links' if `b', hide otherwise.
1171 local
1172 l_links: like links
1173 i_link: EIFFEL_INHERITANCE_FIGURE
1174 do
1175 from
1176 l_links := links
1177 l_links.start
1178 until
1179 l_links.after
1180 loop
1181 i_link ?= l_links.item
1182 if i_link /= Void and then i_link.model.is_needed_on_diagram then
1183 if b then
1184 i_link.show
1185 i_link.enable_sensitive
1186 else
1187 i_link.hide
1188 i_link.disable_sensitive
1189 end
1190 end
1191 l_links.forth
1192 end
1193 end
1194
1195 set_is_cluster_shown (b: BOOLEAN) is
1196 -- Show clusters in `clusters' if `b', hide otherwise.
1197 local
1198 l_clusters: like clusters
1199 l_item: EIFFEL_CLUSTER_FIGURE
1200 do
1201 from
1202 l_clusters := clusters
1203 l_clusters.start
1204 until
1205 l_clusters.after
1206 loop
1207 l_item ?= l_clusters.item
1208 if l_item /= Void then
1209 if b then
1210 l_item.enable_shown
1211 else
1212 l_item.disable_shown
1213 end
1214 end
1215 l_clusters.forth
1216 end
1217 end
1218
1219 set_is_anchor_shown (b: BOOLEAN) is
1220 -- Show all anchors of linkable figures if `b'.
1221 local
1222 bcf: BON_CLASS_FIGURE
1223 l_classes: like classes
1224 do
1225 from
1226 l_classes := classes
1227 l_classes.start
1228 until
1229 l_classes.after
1230 loop
1231 bcf ?= l_classes.item
1232 if bcf /= Void then
1233 if b then
1234 bcf.show_anchor
1235 else
1236 bcf.hide_anchor
1237 end
1238 end
1239 l_classes.forth
1240 end
1241 end
1242
1243 feature {EB_DELETE_FIGURE_COMMAND} -- UndoRedo delete
1244
1245 reinclude_class (a_class: EIFFEL_CLASS_FIGURE; a_links: LIST [ES_ITEM]; ax, ay: INTEGER) is
1246 -- Reinclude `a_class' and all links in `a_links' that has been removed by `disable_needed_on_diagram'
1247 -- and set the corresponding figures port position to (`ax',`ay').
1248 require
1249 a_class_not_void: a_class /= Void
1250 a_class_not_needed_on_diagram: not a_class.model.is_needed_on_diagram
1251 do
1252 a_class.model.enable_needed_on_diagram
1253 from
1254 a_links.start
1255 until
1256 a_links.after
1257 loop
1258 a_links.item.enable_needed_on_diagram
1259 a_links.forth
1260 end
1261 a_class.set_port_position (ax, ay)
1262 ensure
1263 a_class_needed_on_diagram: a_class.model.is_needed_on_diagram
1264 end
1265
1266 remove_class_virtual (a_class: EIFFEL_CLASS_FIGURE; a_links: LIST [ES_ITEM]) is
1267 -- Remove `a_class' and all links in `a_links' from diagram
1268 -- by disable `is_needed_on_diagram'
1269 do
1270 a_class.model.disable_needed_on_diagram
1271 from
1272 a_links.start
1273 until
1274 a_links.after
1275 loop
1276 a_links.item.disable_needed_on_diagram
1277 a_links.forth
1278 end
1279 end
1280
1281 remove_cluster_virtual (cluster_figure: EIFFEL_CLUSTER_FIGURE; a_links: LIST [ES_ITEM]; a_classes: LIST [TUPLE [EIFFEL_CLASS_FIGURE, INTEGER, INTEGER]]) is
1282 -- Remove `cluster_figure' all links in `a_links' and all classes in `a_classes' at position in TUPLE by
1283 -- disable `is_needed_on_diagram'.
1284 local
1285 empty_list: ARRAYED_LIST [ES_ITEM]
1286 l_class_figure: EIFFEL_CLASS_FIGURE
1287 do
1288 cluster_figure.model.disable_needed_on_diagram
1289 from
1290 create empty_list.make (0)
1291 a_classes.start
1292 until
1293 a_classes.after
1294 loop
1295 l_class_figure ?= a_classes.item.item (1)
1296 remove_class_virtual (l_class_figure, empty_list)
1297 a_classes.forth
1298 end
1299 from
1300 a_links.start
1301 until
1302 a_links.after
1303 loop
1304 a_links.item.disable_needed_on_diagram
1305 a_links.forth
1306 end
1307 end
1308
1309 reinclude_cluster (cluster_figure: EIFFEL_CLUSTER_FIGURE; a_links: LIST [ES_ITEM]; a_classes: LIST [TUPLE [EIFFEL_CLASS_FIGURE, INTEGER, INTEGER]]) is
1310 -- Reinclude `cluster_figure', all links in `a_links' and all classes in `a_classes' at position in TUPLE
1311 -- by enable `is_needed_on_diagram'.
1312 local
1313 empty_list: ARRAYED_LIST [ES_ITEM]
1314 l_class_figure: EIFFEL_CLASS_FIGURE
1315 ax, ay: INTEGER
1316 do
1317 cluster_figure.model.enable_needed_on_diagram
1318 from
1319 create empty_list.make (0)
1320 a_classes.start
1321 until
1322 a_classes.after
1323 loop
1324 l_class_figure ?= a_classes.item.item (1)
1325 ax := a_classes.item.integer_item (2)
1326 ay := a_classes.item.integer_item (3)
1327 reinclude_class (l_class_figure, empty_list, ax, ay)
1328 a_classes.forth
1329 end
1330 from
1331 a_links.start
1332 until
1333 a_links.after
1334 loop
1335 a_links.item.enable_needed_on_diagram
1336 a_links.forth
1337 end
1338 end
1339
1340 feature {NONE} -- Implementation
1341
1342 enable_all_links (a_linkable: EG_LINKABLE) is
1343 -- Enable is_neede_on_diagram for all links in `a_linkable'.
1344 local
1345 l_links: LIST [EG_LINK]
1346 eiffel_item: ES_ITEM
1347 e_source, e_target: ES_ITEM
1348 do
1349 from
1350 l_links := a_linkable.links
1351 l_links.start
1352 until
1353 l_links.after
1354 loop
1355 eiffel_item ?= l_links.item
1356 e_source ?= l_links.item.source
1357 e_target ?= l_links.item.target
1358 if
1359 eiffel_item /= Void and then
1360 not eiffel_item.is_needed_on_diagram and then
1361 (e_source = Void or else e_source.is_needed_on_diagram) and then
1362 (e_target = Void or else e_target.is_needed_on_diagram)
1363 then
1364 eiffel_item.enable_needed_on_diagram
1365 end
1366 l_links.forth
1367 end
1368 end
1369
1370 on_pointer_button_press (figure: EG_LINKABLE_FIGURE; ax, ay, button: INTEGER; x_tilt, y_tilt, pressure: DOUBLE; screen_x, screen_y: INTEGER) is
1371 -- Pointer button was pressed on `figure'.
1372 do
1373 Precursor {EG_FIGURE_WORLD} (figure, ax, ay, button, x_tilt, y_tilt, pressure, screen_x, screen_y)
1374 bring_to_front (cluster_legend)
1375 end
1376
1377 on_linkable_move (figure: EG_LINKABLE_FIGURE; ax, ay: INTEGER; x_tilt, y_tilt, pressure: DOUBLE; screen_x, screen_y: INTEGER) is
1378 -- `figure' was moved for `ax' `ay'.
1379 -- | Move all `selected_figures' as well.
1380 local
1381 l_selected_figures: like selected_figures
1382 l_item: EG_FIGURE
1383 i, nb: INTEGER
1384 cf: EG_CLUSTER_FIGURE
1385 l_linkable: EG_LINKABLE_FIGURE
1386 e_c_fig: EIFFEL_CLASS_FIGURE
1387 do
1388 cf ?= figure
1389 if cf = Void and then not selected_figures.is_empty then
1390 check
1391 when_figures_selected_move_only_a_selected_figure: selected_figures.has (figure)
1392 end
1393 from
1394 l_selected_figures := selected_figures
1395 i := 1
1396 nb := l_selected_figures.count
1397 until
1398 i > nb
1399 loop
1400 l_item := l_selected_figures.i_th (i)
1401 if l_item /= figure then
1402 l_item.set_point_position (l_item.point_x + ax, l_item.point_y + ay)
1403 l_linkable ?= l_item
1404 if l_linkable /= Void then
1405 l_linkable.set_is_fixed (True)
1406 end
1407 end
1408 e_c_fig ?= l_item
1409 if e_c_fig /= Void then
1410 if is_right_angles and not context_editor.is_force_directed_used then
1411 e_c_fig.apply_right_angles
1412 end
1413 end
1414 i := i + 1
1415 end
1416 else
1417 if is_right_angles and not context_editor.is_force_directed_used then
1418 e_c_fig ?= figure
1419 if e_c_fig /= Void then
1420 e_c_fig.apply_right_angles
1421 end
1422 end
1423 end
1424 end
1425
1426 on_valid_tag_read is
1427 -- A valid tag was read through xml routines.
1428 local
1429 lpd: EB_PERCENT_PROGRESS_BAR
1430 do
1431 lpd := context_editor.develop_window.status_bar.progress_bar
1432 if lpd /= Void then
1433 if lpd.value < lpd.range.upper then
1434 lpd.set_value (lpd.value + 1)
1435 end
1436 end
1437 end
1438
1439 update_fade is
1440 -- Fade out classes with cluster on top fade in otherwise.
1441 local
1442 l_c_fig: EIFFEL_CLASS_FIGURE
1443 l_linkables: like classes
1444 i, nb: INTEGER
1445 do
1446 from
1447 l_linkables := classes
1448 i := 1
1449 nb := l_linkables.count
1450 until
1451 i > nb
1452 loop
1453 l_c_fig ?= l_linkables.i_th (i)
1454 if l_c_fig /= Void then
1455 l_c_fig.update_fade
1456 end
1457 i := i + 1
1458 end
1459 end
1460
1461 feature {NONE} -- Implementation
1462
1463 node_type: ES_CLASS is
1464 -- Type for nodes.
1465 do
1466 end
1467
1468 invariant
1469 scale_factor_larger_zero: scale_factor > 0.0
1470 current_view_not_void: current_view /= Void
1471 available_views_not_void: available_views /= Void
1472 available_views_compare_objects: available_views.object_comparison
1473
1474 indexing
1475 copyright: "Copyright (c) 1984-2006, Eiffel Software"
1476 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
1477 licensing_options: "http://www.eiffel.com/licensing"
1478 copying: "[
1479 This file is part of Eiffel Software's Eiffel Development Environment.
1480
1481 Eiffel Software's Eiffel Development Environment is free
1482 software; you can redistribute it and/or modify it under
1483 the terms of the GNU General Public License as published
1484 by the Free Software Foundation, version 2 of the License
1485 (available at the URL listed under "license" above).
1486
1487 Eiffel Software's Eiffel Development Environment is
1488 distributed in the hope that it will be useful, but
1489 WITHOUT ANY WARRANTY; without even the implied warranty
1490 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1491 See the GNU General Public License for more details.
1492
1493 You should have received a copy of the GNU General Public
1494 License along with Eiffel Software's Eiffel Development
1495 Environment; if not, write to the Free Software Foundation,
1496 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1497 ]"
1498 source: "[
1499 Eiffel Software
1500 356 Storke Road, Goleta, CA 93117 USA
1501 Telephone 805-685-1006, Fax 805-685-6869
1502 Website http://www.eiffel.com
1503 Customer support http://support.eiffel.com
1504 ]"
1505
1506 end -- class EIFFEL_WORLD

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23