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
27 package org.ximtec.igesture.algorithm.rubinebd;
28
29 import java.math.BigDecimal;
30 import java.util.logging.Level;
31 import java.util.logging.Logger;
32
33 import org.sigtec.ink.Note;
34 import org.ximtec.igesture.algorithm.feature.FeatureException;
35 import org.ximtec.igesture.util.BigDecimalVector;
36
37
38
39
40
41
42
43 public class GestureSampleHelper {
44
45 private static final Logger LOGGER = Logger.getLogger(GestureSampleHelper.class
46 .getName());
47
48 private Note note;
49 private RubineConfiguration config;
50 private BigDecimalVector featureVector;
51
52
53 public GestureSampleHelper(Note note, RubineConfiguration config) {
54 this.note = note;
55 this.config = config;
56 LOGGER.setLevel(Level.SEVERE);
57 }
58
59
60
61
62
63
64
65
66
67
68 private BigDecimalVector computeFeatureVector()
69 throws FeatureException {
70
71
72
73
74 Note clonedNote = (Note)note.clone();
75 clonedNote.scaleTo(200, 200);
76
77
78 clonedNote.filter(config.getMinDistance());
79
80
81 BigDecimalVector featureVector = new BigDecimalVector(config.getNumberOfFeatures());
82
83 for (int i = 0; i < config.getNumberOfFeatures(); i++) {
84
85
86 featureVector.set(i, new BigDecimal(config.getFeatureList()[i].compute(clonedNote)));
87 }
88 System.out.println(featureVector.toString());
89 LOGGER.info(featureVector.toString());
90 return featureVector;
91 }
92
93
94 public BigDecimalVector getFeatureVector() throws FeatureException {
95 if(featureVector == null){
96 featureVector = computeFeatureVector();
97 }
98 return featureVector;
99 }
100
101 }