1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sourceforge.jeuclid.elements.presentation.token;
20
21 import net.sourceforge.jeuclid.Constants;
22 import net.sourceforge.jeuclid.LayoutContext;
23 import net.sourceforge.jeuclid.elements.AbstractJEuclidElement;
24 import net.sourceforge.jeuclid.elements.support.attributes.AttributesHelper;
25 import net.sourceforge.jeuclid.layout.LayoutInfo;
26 import net.sourceforge.jeuclid.layout.LayoutStage;
27 import net.sourceforge.jeuclid.layout.LayoutView;
28
29 import org.apache.batik.dom.AbstractDocument;
30 import org.w3c.dom.Node;
31 import org.w3c.dom.mathml.MathMLSpaceElement;
32
33
34
35
36
37
38
39
40
41 public final class Mspace extends AbstractJEuclidElement implements
42 MathMLSpaceElement {
43
44
45
46
47 public static final String ELEMENT = "mspace";
48
49
50 public static final String ATTR_WIDTH = "width";
51
52
53 public static final String ATTR_HEIGHT = "height";
54
55
56 public static final String ATTR_DEPTH = "depth";
57
58
59 public static final String ATTR_LINEBREAK = "linebreak";
60
61 private static final long serialVersionUID = 1L;
62
63
64
65
66
67
68
69
70
71 public Mspace(final String qname, final AbstractDocument odoc) {
72 super(qname, odoc);
73
74 this.setDefaultMathAttribute(Mspace.ATTR_DEPTH, Constants.ZERO);
75 this.setDefaultMathAttribute(Mspace.ATTR_HEIGHT, Constants.ZERO);
76 this.setDefaultMathAttribute(Mspace.ATTR_WIDTH, Constants.ZERO);
77 this.setDefaultMathAttribute(Mspace.ATTR_LINEBREAK, "auto");
78 }
79
80
81 @Override
82 protected Node newNode() {
83 return new Mspace(this.nodeName, this.ownerDocument);
84 }
85
86
87
88
89 public String getWidth() {
90 return this.getMathAttribute(Mspace.ATTR_WIDTH);
91 }
92
93
94
95
96
97 public void setWidth(final String width) {
98 this.setAttribute(Mspace.ATTR_WIDTH, width);
99 }
100
101
102
103
104 public String getHeight() {
105 return this.getMathAttribute(Mspace.ATTR_HEIGHT);
106 }
107
108
109
110
111
112 public void setHeight(final String height) {
113 this.setAttribute(Mspace.ATTR_HEIGHT, height);
114 }
115
116
117
118
119 public String getDepth() {
120 return this.getMathAttribute(Mspace.ATTR_DEPTH);
121 }
122
123
124
125
126
127 public void setDepth(final String depth) {
128 this.setAttribute(Mspace.ATTR_DEPTH, depth);
129 }
130
131
132 @Override
133 protected void layoutStageInvariant(final LayoutView view,
134 final LayoutInfo info, final LayoutStage stage,
135 final LayoutContext context) {
136 final LayoutContext now = this.applyLocalAttributesToContext(context);
137 info.setAscentHeight(AttributesHelper.convertSizeToPt(this.getHeight(),
138 now, AttributesHelper.PT), stage);
139 info.setDescentHeight(AttributesHelper.convertSizeToPt(this.getDepth(),
140 now, AttributesHelper.PT), stage);
141 info.setWidth(AttributesHelper.convertSizeToPt(this.getWidth(), now,
142 AttributesHelper.PT), stage);
143 }
144
145
146 public String getLinebreak() {
147 return this.getMathAttribute(Mspace.ATTR_LINEBREAK);
148 }
149
150
151 public void setLinebreak(final String linebreak) {
152 this.setAttribute(Mspace.ATTR_LINEBREAK, linebreak);
153 }
154 }