talx x1.0.5

constraint
Class LayeredConstraint

java.lang.Object
  extended byconstraint.LayeredConstraint
All Implemented Interfaces:
Constraint, ConstraintConstants, StateConstants
Direct Known Subclasses:
AutoFingerFirstUserTextError, AutoFingerInstruction, AutoFingerInstruction, AutoFingerLastTargetTextError, AutoFingerLastUserTextError, AutoFingerUserHighlight, AutoFingerUserTextCaret, AutoHighlightFirstTargetTextError, AutoHighlightFirstUserTextError, AutoHighlightLastTargetTextError, AutoHighlightLastUserTextError, AutoHighlightTargetTextError, AutoHighlightUserTextError, AutoKeymapFingerFirstError, AutoKeymapFingerLastError, AutoKeymapFingerToPosition, AutoKeymapFirstError, AutoKeymapLastError, AutoKeymapToPosition, AutoSelectFirstUserTextError, ChangeStateOnScrollText, ChangeStateOnText, FailOnError, PassOnCaretChangePosition, PassOnCaretPosition, PassOnCaretRange, PassOnLogicalCaretPosition, PassOnLooseText, PassOnSameText, PassOnThisText, SucceedOnAutowrap, SucceedOnMultiwrap

public abstract class LayeredConstraint
extends java.lang.Object
implements Constraint, ConstraintConstants, StateConstants

Skeleton class for Constraint implementations. Implementation classes for constraints can extend this class and override only the getLevel, doAction and getMonitoredEvents methods. Each time an action is performed that might affect a child constraint, this class begins the firing sequence. Any action event will trigger the firing sequence and any key or mouse event that is in some constraint's m onitored events list will trigger the firing sequence. When the sequence fires, it uses the controller's event queue to coordinate calling doAction on all level one constraints, then on all level two constraints, then level three, and finally level four. If some other event is discovered in the controller queue, the firing sequence begins again. Thus, level one constraints, on the other hand, are guaranteed to be activated once for each triggering event. During heavy user usage, however, level two, three and four constraints may not act as frequently as level one constraints.
Constraints that act directly on user input, or simulate user input should implement ConstraintAdapter instead of this class.


Field Summary
 
Fields inherited from interface constraint.ConstraintConstants
ACTION_COMMAND_KEY, ACTION_TYPE_SOUND_FINISHED, COMPONENT_FINGER_POSITION, COMPONENT_FINGER_PRESS_POSITION, COMPONENT_HORIZONTAL_ARROW_POSITION, COMPONENT_INSTRUCTION_BACKGROUND_COLOR, COMPONENT_INSTRUCTION_TEXT, COMPONENT_INSTRUCTION_TEXT_ATTRIBUTES, COMPONENT_INSTRUCTION_TEXT_COLOR, COMPONENT_INSTRUCTION_TEXT_FONT_FACE, COMPONENT_INSTRUCTION_TEXT_SIZE, COMPONENT_MOUSE_FINGER_POSITION, COMPONENT_SOUND, COMPONENT_SOUND_IS_PLAYING, COMPONENT_SOUND_QUIT, COMPONENT_TIMER, COMPONENT_VERTICAL_ARROW_POSITION, DIALOG, HIDE_BULLSEYE, LESSON_STOP_ACTION, MOUSE_BULLSEYE, MOUSE_FINGER_IMAGE, NO_TOKEN, PREVIOUS_TASK_COMPLETION_REASON, PROGRESS_PANEL_VISIBLITY, SHOW_BULLSEYE, SKIP_TASK_ACTION, TAL_DIALOG, TASK_FAIL_COUNT, TASK_STATUS, TASK_SUCCEED_COUNT, YES_TOKEN
 
Fields inherited from interface controller.StateConstants
ACTION, ACTION_TYPE_CONTINUE, ACTION_TYPE_GOTO, ACTION_TYPE_IGNORE, ACTION_TYPE_PANIC, ACTION_TYPE_QUIT, ACTION_TYPE_RESTART, ACTION_TYPE_REVIEW, ACTION_TYPE_SKIP_DRILL, ACTION_TYPE_SKIP_SKILL, ACTION_TYPE_SKIP_TASK, ACTION_TYPE_TASK_STARTED, ACTION_TYPE_TRAIN, CALLBACK_COMMAND, FIRST_CALLBACK, FOURTH_CALLBACK, SECOND_CALLBACK, THIRD_CALLBACK
 
Constructor Summary
LayeredConstraint()
           
 
Method Summary
abstract  void doAction(TaskProperties tp)
          Performs the constraint's action.
 int getIntValue()
          Returns the value converted to an int, or zero if the conversion fails.
abstract  int getLevel()
          Returns the level of callback for this constraint.
 int[] getMonitoredKeyEvents()
          Returns an array of KeyEvent ids that will generate a callback.
 int[] getMonitoredMouseEvents()
          Returns an array of MouseEvent ids that will generate a callback.
 java.lang.String getType()
           
 java.lang.String getValue()
           
 void process(EventWrapper ev, TaskProperties tp)
          Manages callback levels and event processing.
 void processInit(TaskProperties tp)
          Called at the beginning of a task.
 void setValue(java.lang.String value, java.lang.String type, TaskProperties tp)
          Performs task initialization code.
 java.lang.String toString()
          Returns the fully qualified pathname of the constraint.
protected  boolean valueContains(java.lang.String token)
          Performs case-insensitive search for token in the value of this constraint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LayeredConstraint

public LayeredConstraint()
Method Detail

process

public void process(EventWrapper ev,
                    TaskProperties tp)
Manages callback levels and event processing.

Specified by:
process in interface Constraint

getMonitoredMouseEvents

public int[] getMonitoredMouseEvents()
Returns an array of MouseEvent ids that will generate a callback. The default behavior is to return an empty array.


getMonitoredKeyEvents

public int[] getMonitoredKeyEvents()
Returns an array of KeyEvent ids that will generate a callback. The default behavior is to return an empty array.


getLevel

public abstract int getLevel()
Returns the level of callback for this constraint. The available callback levels are:
  1. Used for constraints that react to interface changes.
  2. Used for constraints that react to changes made by level 1 constraints.
  3. Used for constraints that react to changes made by level 1 and 2 constraints. Constraints at this level should not make changes to apparati that other constraints may be monitoring.
  4. Used for constraints that require considerable overhead during callback. Constraints at this level are likely to not have their callbacks activated during heavy user input. Thus, this level can be used by constraints that only want to update during idle time.
A return value of less than 1 is interpreted as level one. A return value of more than 4 is interpreted as level four.


doAction

public abstract void doAction(TaskProperties tp)
Performs the constraint's action. When a monitored event is seen, and the constraint's callback level is reached, this method is called.


processInit

public void processInit(TaskProperties tp)
Called at the beginning of a task. Subclasses can override this method to initialize task property variables, etc. The default behavior does nothing.


setValue

public void setValue(java.lang.String value,
                     java.lang.String type,
                     TaskProperties tp)
Performs task initialization code. This sets up the internal state to support subsequent calls to getValue. Subclasses should override the processInit method rather than this one.

Specified by:
setValue in interface Constraint

getValue

public java.lang.String getValue()
Specified by:
getValue in interface Constraint

getIntValue

public int getIntValue()
Returns the value converted to an int, or zero if the conversion fails.


valueContains

protected boolean valueContains(java.lang.String token)
Performs case-insensitive search for token in the value of this constraint.


getType

public java.lang.String getType()
Specified by:
getType in interface Constraint

toString

public java.lang.String toString()
Returns the fully qualified pathname of the constraint.


talx x1.0.5

© 2001-2005 University of Oregon.
Eugene OR 97403, U.S.A. All Rights Reserved.