View Javadoc

1   /**
2    * 
3    */
4   package org.ximtec.igesture.util;
5   
6   import java.util.HashMap;
7   import java.util.Map;
8   
9   import com.sun.jna.TypeMapper;
10  
11  /**
12   * @author Bjorn Puype, bpuype@gmail.com
13   *
14   */
15  public class Constant {
16  	
17  	private static final Map<Integer, String> toDeviceTypeTextMapping = new HashMap<Integer, String>();
18  	private static final Map<String, Integer> toDeviceTypeValueMapping = new HashMap<String, Integer>();
19  	
20  	private static final Map<Integer, String> toConnectionTypeTextMapping = new HashMap<Integer, String>();
21  	private static final Map<String, Integer> toConnectionTypeValueMapping = new HashMap<String, Integer>();
22  	
23  	public static final String TYPE_2D_TEXT = "2D";
24  	public static final String TYPE_3D_TEXT = "3D";
25  	public static final String TYPE_VOICE_TEXT = "voice";
26  	
27  	public static final int TYPE_2D = 0;
28  	public static final int TYPE_3D = 1;
29  	public static final int TYPE_VOICE = 2;
30  	
31  	public static final int CONNECTION_BLUETOOTH = 0;
32  	public static final int CONNECTION_TUIO = 1;
33  	public static final int CONNECTION_USB = 2;
34  	
35  	public static final String CONNECTION_BLUETOOTH_TEXT = "Bluetooth";
36  	public static final String CONNECTION_TUIO_TEXT = "TUIO";
37  	public static final String CONNECTION_USB_TEXT = "USB";
38  	
39  	
40  	static{
41  		toDeviceTypeTextMapping.put(TYPE_2D, TYPE_2D_TEXT);
42  		toDeviceTypeTextMapping.put(TYPE_3D, TYPE_3D_TEXT);
43  		toDeviceTypeTextMapping.put(TYPE_VOICE, TYPE_VOICE_TEXT);
44  		
45  		toDeviceTypeValueMapping.put(TYPE_2D_TEXT, TYPE_2D);
46  		toDeviceTypeValueMapping.put(TYPE_3D_TEXT, TYPE_3D);
47  		toDeviceTypeValueMapping.put(TYPE_VOICE_TEXT, TYPE_VOICE);
48  		
49  		toConnectionTypeTextMapping.put(CONNECTION_BLUETOOTH, CONNECTION_BLUETOOTH_TEXT);
50  		toConnectionTypeTextMapping.put(CONNECTION_USB, CONNECTION_USB_TEXT);
51  		toConnectionTypeTextMapping.put(CONNECTION_TUIO, CONNECTION_TUIO_TEXT);
52  		
53  		toConnectionTypeValueMapping.put(CONNECTION_BLUETOOTH_TEXT, CONNECTION_BLUETOOTH);
54  		toConnectionTypeValueMapping.put(CONNECTION_USB_TEXT, CONNECTION_USB);
55  		toConnectionTypeValueMapping.put(CONNECTION_TUIO_TEXT, CONNECTION_TUIO);
56  	}
57  	
58  	public static String getDeviceTypeName(int type)
59  	{
60  		return toDeviceTypeTextMapping.get(type);
61  	}
62  	
63  	public static int getDeviceTypeValue(String type)
64  	{
65  		return toDeviceTypeValueMapping.get(type);
66  	}
67  	
68  	public static String getConnectionTypeName(int type)
69  	{
70  		return toConnectionTypeTextMapping.get(type);
71  	}
72  	
73  	public static int getConnectionTypeValue(String type)
74  	{
75  		return toConnectionTypeValueMapping.get(type);
76  	}
77  
78  	public static final String M = "m";
79  	public static final String CM = "cm"; 
80  	public static final String MM = "mm";
81  	public static final String KM = "km";
82  	
83  	public static final int MUL_M = 1000;
84  	public static final int MUL_CM = 10;
85  	public static final int MUL_KM = 1000000;
86  }