1 package fr.ove.openmath.jome.ctrlview.bidim;
2
3 import java.awt.*;
4 import fr.ove.openmath.jome.ctrlview.bidim.*;
5 import fr.ove.openmath.jome.ctrlview.bidim.selection.events.SelectionEvent;
6 import fr.ove.openmath.jome.model.*;
7 import fr.ove.openmath.jome.behaviour.*;
8
9
10
11 public class Function2Layout extends HorizontalLayout{
12
13 /***
14 * According to the operator, the layout manager has to add some components (e.g. brackets, ...)
15 * or has to perform some "re-oganisation" before rendering.<BR>
16 * As soon as the layout manager is set to the display, this mehtod MUST be called with the display laid out
17 * as parameter. This method serves as well as a registering method. So all sub-classes of the instance MUST
18 * call super.initDisplay(displayToLay).
19 * @param displayToLay the display laid by the instance
20 */
21 public void initDisplay(Display displayToLay) {
22 super.initDisplay(displayToLay);
23
24 }
25
26 /***
27 * Checks the validity of the selection.
28 */
29 public void validateSelection() {
30
31
32
33 Display display = displayToLay;
34 if (displayToLay.getParent() instanceof Display) {
35 display = (Display) displayToLay.getParent();
36 FormulaTreeStructure fts = (FormulaTreeStructure) display.getListener();
37 if (fts.getFather() != null)
38 ((DisplayLayout) display.getLayout()).validateSelection();
39 }
40
41
42 display.repaint();
43 }
44
45 /***
46 * Checks the validity of the deselection.
47 * @param display the display to deselect.
48 */
49 public void validateDeselection(Display display) {
50 Display father = displayToLay;
51 Display tmp;
52 SelectionEvent selEvt = new SelectionEvent(displayToLay);
53
54
55 if (father.isSelected()) {
56 father.setNotSelected();
57
58 selEvt.setAction(SelectionEvent.REMOVE, father);
59 father.fireSelectionEvent(selEvt);
60
61
62 if (father.getParent() instanceof Display) {
63 father = (Display) father.getParent();
64 FormulaTreeStructure fts = (FormulaTreeStructure) father.getListener();
65 if (fts.getFather() != null)
66 ((DisplayLayout) father.getLayout()).validateDeselection(displayToLay);
67 }
68
69
70
71
72 validateSelection();
73
74
75 father.repaint();
76 }
77
78 }
79
80 /***
81 * Computes the size of the display according to its children size (if any),
82 * and its different attributes.
83 * @return the size of the display.
84 */
85 public Dimension computeAttributes() {
86 Display display = null;
87
88 if (((Maskable) displayToLay.getListener()).isVisible()) {
89
90 ((Display) displayToLay.getComponent(0)).setShiftX(0);
91
92 Dimension dim = super.computeAttributes();
93
94
95
96
97
98
99
100 return dim;
101 }
102 else
103 return super.computeAttributes();
104 }
105
106 /***
107 * The display needs to be rebuilt. We do this.
108 */
109 public void rebuildDisplay() {
110
111
112 displayToLay.computeAncestorsAttributes();
113 }
114
115
116
117
118
119
120 }