1 package fr.ove.openmath.jome.ctrlview.bidim;
2
3 import java.awt.*;
4 import fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout;
5 import fr.ove.openmath.jome.ctrlview.bidim.Display;
6 import fr.ove.openmath.jome.ctrlview.bidim.StringDisplay;
7 import fr.ove.openmath.jome.ctrlview.bidim.selection.events.SelectionEvent;
8 import fr.ove.openmath.jome.model.*;
9
10 /***
11 * A layout manager that lays symbols.
12 *
13 * @author © 1999 DIRAT Laurent
14 * @version 2.0 09/07/1999
15 */
16 public class SymbolLayout extends DisplayLayout {
17 /***
18 * Checks the validity of the selection.
19 */
20 public void validateSelection() {
21 Display display = displayToLay;
22 if (display.getParent() instanceof Display) {
23 display = (Display) display.getParent();
24 FormulaTreeStructure fts = (FormulaTreeStructure) display.getListener();
25 if (fts.getFather() != null)
26 ((DisplayLayout) display.getLayout()).validateSelection();
27 }
28
29
30 display.repaint();
31 }
32
33 /***
34 * Checks the validity of the deselection.
35 * @param display the display to deselect.
36 */
37 public void validateDeselection(Display display) {
38 Display father = displayToLay;
39
40 if (father.isSelected()) {
41 father.setNotSelected();
42
43 SelectionEvent selEvt = new SelectionEvent(father);
44 selEvt.setAction(SelectionEvent.REMOVE, father);
45 father.fireSelectionEvent(selEvt);
46
47 if (father.getParent() instanceof Display) {
48 father = (Display) father.getParent();
49 FormulaTreeStructure fts = (FormulaTreeStructure) father.getListener();
50 if (fts.getFather() != null)
51 ((DisplayLayout) father.getLayout()).validateDeselection(displayToLay);
52 }
53 }
54 }
55
56 /***
57 * Computes the size of the display and its different attributes.
58 * @return the size of the display.
59 */
60 public Dimension computeAttributes() {
61 Displayable symbol = ((SymbolDisplay) displayToLay).getSymbol();
62 symbol.setGraphicContext(displayToLay.getGraphicContext());
63 Dimension dim = symbol.getPreferredSize();
64
65 displayToLay.setSize(dim);
66 displayToLay.setAscent(symbol.getAscent());
67 displayToLay.setDescent(symbol.getDescent());
68 displayToLay.setComputeAttributes(false);
69
70 return dim;
71 }
72
73 /***
74 * The display needs to be rebuilt. We do this.
75 */
76 public void rebuildDisplay() {
77
78 }
79
80
81
82
83
84
85
86
87
88
89
90
91 public void layoutContainer(Container parent) {
92 }
93
94
95
96
97 }