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.enlivening;
20
21 import java.util.Collections;
22 import java.util.List;
23
24 import net.sourceforge.jeuclid.elements.AbstractElementWithDelegates;
25 import net.sourceforge.jeuclid.layout.LayoutableNode;
26
27 import org.w3c.dom.Node;
28 import org.w3c.dom.mathml.MathMLActionElement;
29
30
31
32
33
34
35
36 public final class Maction extends AbstractElementWithDelegates implements
37 MathMLActionElement {
38
39
40
41
42 public static final String ELEMENT = "maction";
43
44 private static final String ATTR_ACTIONTYPE = "actiontype";
45
46 private static final String ATTR_SELECTION = "selection";
47
48 private static final long serialVersionUID = 1L;
49
50
51
52
53 public Maction() {
54 super();
55 this.setDefaultMathAttribute(Maction.ATTR_SELECTION, "1");
56 }
57
58
59 @Override
60 protected Node newNode() {
61 return new Maction();
62 }
63
64
65 public String getActiontype() {
66 return this.getMathAttribute(Maction.ATTR_ACTIONTYPE);
67 }
68
69
70 public String getSelection() {
71 return this.getMathAttribute(Maction.ATTR_SELECTION);
72 }
73
74
75 public void setActiontype(final String actiontype) {
76 this.setAttribute(Maction.ATTR_ACTIONTYPE, actiontype);
77 }
78
79
80 public void setSelection(final String selection) {
81 this.setAttribute(Maction.ATTR_SELECTION, selection);
82 }
83
84
85 @Override
86 protected List<LayoutableNode> createDelegates() {
87 LayoutableNode selectedElement;
88 try {
89 final int selected = Integer.parseInt(this.getSelection());
90 selectedElement = this.getMathElement(selected - 1);
91 } catch (final NumberFormatException nfe) {
92 selectedElement = null;
93 }
94
95 if (selectedElement == null) {
96 return Collections.emptyList();
97 } else {
98 return Collections.singletonList(selectedElement);
99 }
100 }
101
102 }