Download Software Visualization in Prolog

Transcript
CHAPTER 3. A MODEL OF INFORMATION VISUALIZATION
51
The predicate action/3,
action(Action, ActionContext, Reaction)
A
implements the binary relation !a between Action and Reaction, for a given action context
ActionContext. Interactive behaviour is implemented by adding clauses to the predicate action/3.
Every time a user input occurs (such as a mouse move), the predicate action/3 is called to
determine the reaction. The graphical objects in the view contain identifiers (specified in the
graphical constraints) that are used to identify objects beneath the mouse cursor.
Example 19. The following actions are used in SVT:
Action
click(Object, Buttons,
Times)
drag(From, To, Buttons)
key(Object, Key)
linger(Object)
menu(Menu, Text)
move(Object, Buttons)
Description
The mouse has been clicked Times times over object
Object, with the mouse buttons Buttons.
A mouse drag from object From to an object To,
with mouse buttons Buttons.
A key Key has been pressed over object Object.
The mouse has stopped over object Object.
The menu Menu has item Text selected.
The mouse has been moved over object Object, with
mouse buttons Buttons.
Example 20. The action relation
action(click(Person, [on, _, _, _], _), a,
navigate_to(personal_details(Person))) :person(Person).
declares that the reaction to a mouse press with the left mouse button over a person Person
in action context a is navigate to(personal details(Person)). The underscores are wild-cards, or
unnamed variables.
Example 21. The action relation
action(menu(actions(File), ’Delete file’), a,
delete_file(File)) :file(File).
declares that the reaction to the menu selection in action context a is delete file(File), if File
is a file.
3.8.2
Reactions
Reactions execute the system’s response, in Prolog. To allow different implementations of reactions, each implementation is given a reaction context to identify it.
Definition 14 (Reaction context). Let
be the reaction context.
Definition 15 (Reaction relation). Let
T RC
T be the set of reaction contexts. Let r 2 TRC
R! be a relation between T and T .
R
RC
The reaction relation implements the response in Prolog. The predicate reaction/2
reaction(Reaction, ReactionContext)
is used, where Reaction is the term denoting the reaction, and ReactionContext is the reaction
context. Reactions are implemented by adding rules to the reaction/2 predicate that have sideeffects to perform the required task. The reaction term from action/3 is passed immediately to
A R
reaction/2 for execution. Interaction is the combined relation !a !.
The action and reaction contexts, and terms denoting actions and reactions, T A and TR , are
implementation defined. The action terms used by SVT are given in Section B.7.