1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package org.ximtec.igesture.util.additions3d.jdom;
27
28 import java.util.List;
29
30 import org.jdom.Element;
31 import org.ximtec.igesture.util.additions3d.Point3D;
32 import org.ximtec.igesture.util.additions3d.RecordedGesture3D;
33 import org.ximtec.igesture.util.additions3d.jdom.JdomAccelerations;
34
35
36
37
38
39
40
41 public class JdomRecordedGesture3D extends Element {
42
43 public static final String ROOT_TAG = "recordedGesture3D";
44
45
46 public JdomRecordedGesture3D(RecordedGesture3D gesture) {
47 super(ROOT_TAG);
48
49 for (Point3D point : gesture.getPoints()) {
50 addContent(new JdomPoint3D(point));
51 }
52
53 addContent(new JdomAccelerations(gesture.getAccelerations()));
54 }
55
56
57 @SuppressWarnings("unchecked")
58 public static RecordedGesture3D unmarshal(Element gesture) {
59 RecordedGesture3D newGesture = new RecordedGesture3D();
60
61 for (Element point : (List<Element>)gesture.getChildren(JdomPoint3D.ROOT_TAG)) {
62 newGesture.add(JdomPoint3D.unmarshal(point));
63 }
64
65 Element acc = gesture.getChild(JdomAccelerations.ROOT_TAG);
66 newGesture.setAccelerations(JdomAccelerations.unmarshal(acc));
67
68 return newGesture;
69 }
70
71 }