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 package fr.ove.openmath.jome.ctrlview.bidim;
30
31 import java.awt.*;
32 import fr.ove.openmath.jome.ctrlview.bidim.*;
33 import fr.ove.openmath.jome.ctrlview.bidim.selection.events.SelectionEvent;
34 import fr.ove.openmath.jome.model.*;
35 import fr.ove.openmath.jome.behaviour.*;
36
37 /***
38 * A layout manager that lays components to be displayed between something.<BR>
39 * Obviously, what is called something will be parenthesis, braces, ....
40 *
41 * @author © 1999 DIRAT Laurent
42 * @version 2.0 13/12/1999
43 */
44 public class GroupLayout extends HorizontalLayout {
45
46
47 /***
48 * According to the operator, the layout manager has to add some components (e.g. brackets, ...)
49 * or has to perform some "re-oganisation" before rendering.<BR>
50 * As soon as the layout manager is set to the display, this mehtod MUST be called with the display laid out
51 * as parameter. This method serves as well as a registering method. So all sub-classes of the instance MUST
52 * call super.initDisplay(displayToLay).
53 * @param displayToLay the display laid by the instance
54 */
55 public void initDisplay(Display displayToLay) {
56 super.initDisplay(displayToLay);
57
58 }
59
60 /***
61 * Checks the validity of the selection.
62 */
63 public void validateSelection() {
64
65
66
67 Display display = displayToLay;
68 if (displayToLay.getParent() instanceof Display) {
69 display = (Display) displayToLay.getParent();
70 FormulaTreeStructure fts = (FormulaTreeStructure) display.getListener();
71 if (fts.getFather() != null)
72 ((DisplayLayout) display.getLayout()).validateSelection();
73 }
74
75
76 display.repaint();
77 }
78
79 /***
80 * Checks the validity of the deselection.
81 * @param display the display to deselect.
82 */
83 public void validateDeselection(Display display) {
84 Display father = displayToLay;
85 Display tmp;
86 SelectionEvent selEvt = new SelectionEvent(displayToLay);
87
88
89 if (father.isSelected()) {
90 father.setNotSelected();
91
92 selEvt.setAction(SelectionEvent.REMOVE, father);
93 father.fireSelectionEvent(selEvt);
94
95
96 if (father.getParent() instanceof Display) {
97 father = (Display) father.getParent();
98 FormulaTreeStructure fts = (FormulaTreeStructure) father.getListener();
99 if (fts.getFather() != null)
100 ((DisplayLayout) father.getLayout()).validateDeselection(displayToLay);
101 }
102
103
104
105
106 validateSelection();
107
108
109 father.repaint();
110 }
111
112 }
113
114 /***
115 * Computes the size of the display according to its children size (if any),
116 * and its different attributes.
117 * @return the size of the display.
118 */
119 public Dimension computeAttributes() {
120 Display display = null;
121
122 if (((Maskable) displayToLay.getListener()).isVisible()) {
123
124 ((Display) displayToLay.getComponent(0)).setShiftX(0);
125
126 Dimension dim = super.computeAttributes();
127
128
129
130
131
132
133
134 return dim;
135 }
136 else
137 return super.computeAttributes();
138 }
139
140 /***
141 * The display needs to be rebuilt. We do this.
142 */
143 public void rebuildDisplay() {
144
145
146 displayToLay.computeAncestorsAttributes();
147 }
148
149
150
151
152 }