© 2006-2007 ETH Zurich

org.ximtec.igesture.core.composite
Class DefaultConstraint

java.lang.Object
  extended by org.ximtec.igesture.core.DefaultPropertyChangeNotifier
      extended by org.ximtec.igesture.core.DefaultDataObject
          extended by org.ximtec.igesture.core.composite.DefaultConstraint
All Implemented Interfaces:
Serializable, Constraint, DataObject, PropertyChangeNotifier
Direct Known Subclasses:
ConcurrencyConstraint, IntervalConstraint, SequenceConstraint

public abstract class DefaultConstraint
extends DefaultDataObject
implements Constraint

Author:
Bjorn Puype, bpuype@gmail.com
See Also:
Serialized Form

Nested Class Summary
static class DefaultConstraint.Config
           
 
Field Summary
protected  Map<String,String> DEFAULT_CONFIGURATION
           
protected  SimpleDateFormat df
           
protected  List<DefaultConstraintEntry> gestures
           
protected  Calendar gestureTime
           
protected  Calendar processingTime
           
static String PROPERTY_GESTURES
           
protected  Map<String,String> setterMapping
           
 
Fields inherited from class org.ximtec.igesture.core.DefaultDataObject
PROPERTY_ID
 
Fields inherited from class org.ximtec.igesture.core.DefaultPropertyChangeNotifier
propertyChangeSupport
 
Constructor Summary
DefaultConstraint()
           
 
Method Summary
 void addGestureClass(String gestureClass)
          Add a gesture class to the composite gesture.
 void addGestureClass(String gestureClass, int user)
          Add a gesture class to the composite gesture and specify the user that performs it.
 void addGestureClass(String gestureClass, int user, String deviceType, Set<String> devices)
          Add a gesture class to the composite gesture and specify the user and the device type used to perform it.
 void addGestureClass(String gestureClass, String deviceType, Set<String> devices)
          Add a gesture class to the composite gesture and specify the device type used to perform it.
abstract  Map<String,Calendar> determineTimeWindows()
          Determine the time window for each composing gesture.
abstract  Set<String> generatePatterns(Map<String,String> charMapping)
          Generate all possible string patterns that represent the composite gesture.
 Set<String> getDistinctGestureClasses()
          Get the disctinct gesture classes that compose this composite gesture
 List<String> getGestureClasses()
          Get all the names of the gesture classes that compose this composite gesture
 List<DefaultConstraintEntry> getGestureEntries()
          Get all gesture entries.
 Calendar getGestureTime()
           
 int getNumberOfGestures()
          Get the number of composing gestures
 String getParameter(String property)
           
 Map<String,String> getParameters()
          Returns an array of containing the constraint parameters.
protected  long getTimeStamp(Gesture<?> gesture, boolean start)
          Get the start or end timestamp of a gesture.
 void removeAllGestureClasses()
          Remove all gesture classes from the composite.
 void removeGestureClass(DefaultConstraintEntry entry)
          Removes the specified gesture class from the composite.
 void setGestureTime(String time)
           
 void setParameter(String property, String value)
           
 String toString()
           
 boolean validateConditions(List<Gesture<?>> gestures, IDeviceManager manager)
          Validate the constraint conditions.
 
Methods inherited from class org.ximtec.igesture.core.DefaultDataObject
accept, getId, setId
 
Methods inherited from class org.ximtec.igesture.core.DefaultPropertyChangeNotifier
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ximtec.igesture.core.PropertyChangeNotifier
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener
 

Field Detail

DEFAULT_CONFIGURATION

protected Map<String,String> DEFAULT_CONFIGURATION

setterMapping

protected Map<String,String> setterMapping

gestures

protected List<DefaultConstraintEntry> gestures

PROPERTY_GESTURES

public static final String PROPERTY_GESTURES
See Also:
Constant Field Values

df

protected SimpleDateFormat df

gestureTime

protected Calendar gestureTime

processingTime

protected Calendar processingTime
Constructor Detail

DefaultConstraint

public DefaultConstraint()
Method Detail

addGestureClass

public void addGestureClass(String gestureClass)
Description copied from interface: Constraint
Add a gesture class to the composite gesture. Note: All users and devices are allowed to perform the gesture.

Specified by:
addGestureClass in interface Constraint

addGestureClass

public void addGestureClass(String gestureClass,
                            int user)
Description copied from interface: Constraint
Add a gesture class to the composite gesture and specify the user that performs it. Note: All devices are allowed to perform the gesture.

Specified by:
addGestureClass in interface Constraint

addGestureClass

public void addGestureClass(String gestureClass,
                            String deviceType,
                            Set<String> devices)
Description copied from interface: Constraint
Add a gesture class to the composite gesture and specify the device type used to perform it. Note: all users are allowed to perform to gesture. If devices is null, all devices of type deviceType are allowed to perform the gesture.

Specified by:
addGestureClass in interface Constraint

addGestureClass

public void addGestureClass(String gestureClass,
                            int user,
                            String deviceType,
                            Set<String> devices)
Description copied from interface: Constraint
Add a gesture class to the composite gesture and specify the user and the device type used to perform it. Note: if devices is null, all devices of type deviceType are allowed to perform the gesture.

Specified by:
addGestureClass in interface Constraint

getGestureClasses

public List<String> getGestureClasses()
Description copied from interface: Constraint
Get all the names of the gesture classes that compose this composite gesture

Specified by:
getGestureClasses in interface Constraint

getDistinctGestureClasses

public Set<String> getDistinctGestureClasses()
Description copied from interface: Constraint
Get the disctinct gesture classes that compose this composite gesture

Specified by:
getDistinctGestureClasses in interface Constraint

getNumberOfGestures

public int getNumberOfGestures()
Description copied from interface: Constraint
Get the number of composing gestures

Specified by:
getNumberOfGestures in interface Constraint

setGestureTime

public void setGestureTime(String time)
                    throws ParseException
Throws:
ParseException

getGestureTime

public Calendar getGestureTime()

generatePatterns

public abstract Set<String> generatePatterns(Map<String,String> charMapping)
Description copied from interface: Constraint
Generate all possible string patterns that represent the composite gesture.

Specified by:
generatePatterns in interface Constraint
Parameters:
charMapping - Mapping between the gesture class name and the character representation

validateConditions

public boolean validateConditions(List<Gesture<?>> gestures,
                                  IDeviceManager manager)
Description copied from interface: Constraint
Validate the constraint conditions.

Specified by:
validateConditions in interface Constraint
Parameters:
gestures - Gestures that possibly compose the composite gesture.
manager - Device manager to check the associated users.
Returns:

determineTimeWindows

public abstract Map<String,Calendar> determineTimeWindows()
Description copied from interface: Constraint
Determine the time window for each composing gesture.

Specified by:
determineTimeWindows in interface Constraint
Returns:
Mapping between the gesture name and the corresponding time window.

getTimeStamp

protected long getTimeStamp(Gesture<?> gesture,
                            boolean start)
Get the start or end timestamp of a gesture.

Parameters:
gesture - the gesture from which to get the timestamp
start - true to get the start timestamp, false to get the end timestamp
Returns:
timestamp

toString

public String toString()
Specified by:
toString in interface Constraint
Overrides:
toString in class Object

getParameters

public Map<String,String> getParameters()
Description copied from interface: Constraint
Returns an array of containing the constraint parameters.

Specified by:
getParameters in interface Constraint
Returns:
the constraint parameters.

getParameter

public String getParameter(String property)
Specified by:
getParameter in interface Constraint

setParameter

public void setParameter(String property,
                         String value)
Specified by:
setParameter in interface Constraint

removeAllGestureClasses

public void removeAllGestureClasses()
Description copied from interface: Constraint
Remove all gesture classes from the composite.

Specified by:
removeAllGestureClasses in interface Constraint

removeGestureClass

public void removeGestureClass(DefaultConstraintEntry entry)
Description copied from interface: Constraint
Removes the specified gesture class from the composite.

Specified by:
removeGestureClass in interface Constraint

getGestureEntries

public List<DefaultConstraintEntry> getGestureEntries()
Description copied from interface: Constraint
Get all gesture entries.

Specified by:
getGestureEntries in interface Constraint

© 2006-2007 ETH Zurich

Copyright © 2007-2010 Global Information Systems Group, ETH Zurich. All Rights Reserved.