1 package fr.ove.openmath.jome.ctrlview.bidim;
2
3 import java.awt.*;
4 import java.util.*;
5 import fr.ove.openmath.jome.ctrlview.bidim.Display;
6 import fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout;
7 import fr.ove.openmath.jome.ctrlview.bidim.selection.events.SelectionEvent;
8 import fr.ove.openmath.jome.model.*;
9
10 /***
11 * Layout manager for horizontal list operator.<BR>
12 * If the list operator is set as as visible list, curly brackets are displayed on both
13 * sides of the list elements.
14 *
15 * @author © 1999 DIRAT Laurent
16 * @version 2.0 15/12/1999
17 */
18 public class HorizontalListLayout extends CurlyLayout {
19 /***
20 * According to the operator, the layout manager has to add some components (e.g. brackets, ...)
21 * or has to perform some "re-oganisation" before rendering.<BR>
22 * As soon as the layout manager is set to the display, this mehtod MUST be called with the display laid out
23 * as parameter. This method serves as well as a registering method. So all sub-classes of the instance MUST
24 * call super.initDisplay(displayToLay).
25 * @param displayToLay the display laid by the instance
26 */
27 public void initDisplay(Display displayToLay) {
28 super.initDisplay(displayToLay);
29
30
31
32
33 Display elementsDisplay = new BidimDisplay(displayToLay.getGraphicContext());
34
35
36
37
38
39
40
41
42 elementsDisplay.addControlListener((FormulaTreeStructure) displayToLay.getListener());
43
44 SeparatorOperatorLayout layout = new SeparatorOperatorLayout();
45 layout.initDisplay(elementsDisplay);
46 elementsDisplay.setLayout(layout);
47
48
49 this.displayToLay.add(elementsDisplay);
50 }
51
52 /***
53 * Computes the size of the display according to its children size (if any),
54 * and its different attributes.
55 * @return the size of the display.
56 */
57 public Dimension computeAttributes() {
58 updateLevel(displayToLay.getLevel());
59
60 if (displayToLay.getComponentCount() > 3) {
61
62
63
64 Display elementsDisplay = (Display) displayToLay.getComponent(2);
65 Display d;
66 for (int i = 3; i < displayToLay.getComponentCount(); ) {
67 d = (Display) displayToLay.getComponent(i);
68
69
70
71 d.setDoRemoveFromListListeners(false);
72 elementsDisplay.add(d);
73
74 d.setDoRemoveFromListListeners(true);
75 }
76 }
77
78 return super.computeAttributes();
79 }
80 }