1 /*
2 * @(#)$Id: Result.java 823 2010-05-26 22:35:09Z bpuype $
3 *
4 * Author : Ueli Kurmann, igesture@uelikurmann.ch
5 *
6 * Purpose : A single result of the recognition process.
7 *
8 * -----------------------------------------------------------------------
9 *
10 * Revision Information:
11 *
12 * Date Who Reason
13 *
14 * Dec 26, 2006 ukurmann Initial Release
15 * Feb 27, 2007 bsigner Cleanup
16 *
17 * -----------------------------------------------------------------------
18 *
19 * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20 *
21 * This software is the proprietary information of ETH Zurich.
22 * Use is subject to license terms.
23 *
24 */
25
26
27 package org.ximtec.igesture.core;
28
29 import org.sigtec.util.Constant;
30
31
32 /**
33 * A single result of the recognition process.
34 *
35 * @version 1.0, Dec 2006
36 * @author Ueli Kurmann, igesture@uelikurmann.ch
37 * @author Beat Signer, signer@inf.ethz.ch
38 */
39 public class Result {
40
41 private GestureClass gestureClass;
42
43 private double accuracy;
44
45 private Object userObject;
46
47
48 /**
49 * Constructs a new result.
50 *
51 * @param gestureClass the recognised gesture class.
52 * @param accuracy the accuracy for the recognised gesture class.
53 */
54 public Result(GestureClass gestureClass, double accuracy) {
55 this.gestureClass = gestureClass;
56 this.accuracy = accuracy;
57 }
58
59
60 /**
61 * Sets the accuracy for the gesture class of this result object.
62 *
63 * @param accuracy the accuracy for the gesture class of this result object.
64 */
65 public void setAccuracy(double accuracy) {
66 this.accuracy = accuracy;
67 } // setAccuracy
68
69
70 /**
71 * Returns the accuracy for the gesture class of this result object.
72 *
73 * @return the accuracy for the gesture class of this result object.
74 */
75 public double getAccuracy() {
76 return accuracy;
77 } // getAccuracy
78
79
80 /**
81 * Returns the result gesture class.
82 *
83 * @return the result gesture class.
84 */
85 public GestureClass getGestureClass() {
86 return gestureClass;
87 } // getGestureClass
88
89
90 /**
91 * @param gestureClass the gestureClass to set
92 */
93 public void setGestureClass(GestureClass gestureClass) {
94 this.gestureClass = gestureClass;
95 }
96
97
98 /**
99 * Sets a user object. A user object enables an algorithm to return an
100 * arbitrary object. However, the user is responsible for the correct handling
101 * since no explicit type information is available.
102 *
103 * @param userObject the user object to be set.
104 */
105 public void setUserObject(Object userObject) {
106 this.userObject = userObject;
107 } // setUserObject
108
109
110 /**
111 * Returns a user object. A user object enables an algorithm to return an
112 * arbitrary object. However, the user is responsible for the correct handling
113 * since no explicit type information is available.
114 *
115 * @return the user object.
116 */
117 public Object getUserObject() {
118 return userObject;
119 } // getUserObject
120
121
122 /**
123 * Returns the name of the gesture class represented by this result or an
124 * empty string if no gesture class is associated with this result object.
125 *
126 * @return the name of the gesture class represented by this result.
127 */
128 public String getGestureClassName() {
129 return (gestureClass != null & gestureClass.getName() != null)
130 ? gestureClass.getName() : Constant.EMPTY_STRING;
131 } // getGestureClassName
132
133
134 @Override
135 public String toString() {
136 return getGestureClassName() + Constant.COLON_BLANK + getAccuracy();
137 }
138
139 }