1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.ximtec.igesture.core.jdom;
25
26 import org.jdom.Element;
27 import org.ximtec.igesture.core.Gesture;
28 import org.ximtec.igesture.core.GestureSample3D;
29 import org.ximtec.igesture.util.additions3d.RecordedGesture3D;
30 import org.ximtec.igesture.util.additions3d.jdom.JdomRecordedGesture3D;
31
32
33
34
35
36
37
38
39 public class JdomGestureSample3D extends Element {
40
41 public static final String ROOT_TAG = "sample";
42
43 public static final String NAME_ATTRIBUTE = "name";
44
45 public static final String UUID_ATTRIBUTE = "id";
46
47
48 public JdomGestureSample3D(Gesture<RecordedGesture3D> sample) {
49 super(ROOT_TAG);
50 setAttribute(NAME_ATTRIBUTE, sample.getName());
51 setAttribute(UUID_ATTRIBUTE, ((GestureSample3D)sample).getId());
52 addContent(new JdomRecordedGesture3D(sample.getGesture()));
53 }
54
55
56 public static Gesture<RecordedGesture3D> unmarshal(Element sample) {
57 RecordedGesture3D gesture = null;
58
59 if (sample.getChild(JdomRecordedGesture3D.ROOT_TAG) != null) {
60 gesture = JdomRecordedGesture3D.unmarshal(sample.getChild(JdomRecordedGesture3D.ROOT_TAG));
61 }
62
63 final String name = sample.getAttributeValue(NAME_ATTRIBUTE);
64 final String uuid = sample.getAttributeValue(UUID_ATTRIBUTE);
65 final GestureSample3D gestureSample = new GestureSample3D(name, gesture);
66 gestureSample.setId(uuid);
67 return gestureSample;
68
69 }
70
71 }