View Javadoc

1   /**
2    * 
3    */
4   package org.ximtec.igesture.core.composite;
5   
6   import java.util.Calendar;
7   import java.util.List;
8   import java.util.Set;
9   import java.util.Map;
10  
11  import org.ximtec.igesture.core.Gesture;
12  import org.ximtec.igesture.io.IDeviceManager;
13  
14  /**
15   * Constraint for a composite gesture.
16   * 
17   * If a composite gesture contains two or more times the same simple gestures, you MUST call the necessary 
18   * add methods for one simple after each other to get correct results.
19   * 
20   * @author Bjorn Puype, bpuype@gmail.com
21   *
22   */
23  public interface Constraint {
24  	
25  	/**
26  	 * Add a gesture class to the composite gesture.
27  	 * Note: All users and devices are allowed to perform the gesture.
28  	 */
29  	public void addGestureClass(String gestureClass) throws IllegalArgumentException;
30  	/**
31  	 * Add a gesture class to the composite gesture and specify the user that performs it.
32  	 * Note: All devices are allowed to perform the gesture.
33  	 */
34  	public void addGestureClass(String gestureClass, int user) throws IllegalArgumentException;
35  	/**
36  	 * Add a gesture class to the composite gesture and specify the device type used to perform it.
37  	 * Note: all users are allowed to perform to gesture. If devices is null, all devices of type deviceType are
38  	 * allowed to perform the gesture.
39  	 */
40  	public void addGestureClass(String gestureClass, String deviceType, Set<String> devices) throws IllegalArgumentException;
41  	/**
42  	 * Add a gesture class to the composite gesture and specify the user and the device type used to perform it.
43  	 * Note: if devices is null, all devices of type deviceType are allowed to perform the gesture.
44  	 */
45  	public void addGestureClass(String gestureClass, int user, String deviceType, Set<String> devices) throws IllegalArgumentException;
46  	/**
47  	 * Removes the specified gesture class from the composite.
48  	 */
49  	public void removeGestureClass(DefaultConstraintEntry entry);
50  	/**
51  	 * Remove all gesture classes from the composite.
52  	 */
53  	public void removeAllGestureClasses();
54  	
55  	/** Get all the names of the gesture classes that compose this composite gesture */
56  	public List<String> getGestureClasses();
57  	/** Get the disctinct gesture classes that compose this composite gesture */
58  	public Set<String> getDistinctGestureClasses();
59  	/** Get the number of composing gestures */
60  	public int getNumberOfGestures();
61  	/**
62  	 * Get all gesture entries.
63  	 */
64  	public List<DefaultConstraintEntry> getGestureEntries();
65  	/**
66  	 * Validate the constraint conditions.
67  	 * @param gestures	Gestures that possibly compose the composite gesture.
68  	 * @param manager	Device manager to check the associated users.
69  	 * @return
70  	 */
71  	public boolean validateConditions(List<Gesture<?>> gestures, IDeviceManager manager);
72  	
73  	/**
74  	 * Generate all possible string patterns that represent the composite gesture.
75  	 * @param charMapping Mapping between the gesture class name and the character representation
76  	 */
77  	public Set<String> generatePatterns(Map<String, String> charMapping);
78  	/**
79  	 * Determine the time window for each composing gesture.
80  	 * @return Mapping between the gesture name and the corresponding time window.
81  	 */
82  	public Map<String, Calendar> determineTimeWindows();
83  	
84  	/**
85   	 * Returns an array of containing the constraint parameters.
86  	 * 
87  	 * @return the constraint parameters.
88  	 */
89  	public Map<String, String> getParameters();
90  	
91  	public String getParameter(String property);
92  	
93  	public void setParameter(String property, String value);
94  	
95  	public String toString();
96  }