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
9 /***
10 * A layout manager that lays strings.
11 *
12 * @author © 1998 DIRAT Laurent
13 * @version 1.0 23/06/98
14 */
15 public abstract class AbstractStringLayout extends DisplayLayout {
16 /***
17 * Updates the level of the display that is layed out.<BR>
18 * @param level the level put to the display
19 */
20 public void updateLevel(int level) {
21 if (displayToLay.getUpdateLevel()) {
22 displayToLay.setLevel(level);
23 displayToLay.scaleDisplay();
24 displayToLay.setUpdateLevel(false);
25 displayToLay.setSize(computeAttributes());
26 }
27 }
28
29 /***
30 * Computes the size of the display and its different attributes.
31 * @return the size of the display.
32 */
33 public Dimension computeAttributes() {
34 FontMetrics fm = displayToLay.getFontMetrics(displayToLay.getFont());
35
36 displayToLay.setAscent(fm.getAscent());
37 displayToLay.setDescent(fm.getDescent());
38
39 int width = fm.stringWidth(((AbstractStringDisplay) displayToLay).getString()) + 2;
40 int height = displayToLay.getAscent() + displayToLay.getDescent();
41
42 displayToLay.setSize(width, height);
43 displayToLay.setComputeAttributes(false);
44
45 return new Dimension(width, height);
46 }
47
48
49
50
51
52 public void layoutContainer(Container parent) {
53 return;
54 }
55
56
57 /***
58 * The display needs to be rebuilt. We do this.
59 */
60 public void rebuildDisplay() {
61
62 }
63
64 }