320 likes | 348 Views
CMPUT 301: Lecture 30 Dialog Notations and Design. Ken Wong Department of Computing Science University of Alberta 2001-11-21. Textual Notations. Selected kinds: grammars production rules. Example. Creating a polyline: select line item from palette click first point
E N D
CMPUT 301: Lecture 30Dialog Notations and Design Ken Wong Department of Computing Science University of Alberta 2001-11-21
Textual Notations • Selected kinds: • grammars • production rules
Example • Creating a polyline: • select line item from palette • click first point • click a second point • … • double click last point
Grammars • BNF: • Backus-Naur Form • a notation that specifies a grammar or syntax for a language • e.g., valid command lines • e.g., valid source code • e.g., valid user/computer dialogs
Grammars • BNF: • non-terminals • terminals (lowest-level symbols) • metacharacters ::= is defined as (can be replaced by) + sequence (or use space) | choice • left-hand-side ::= right-hand-side
Grammars • BNF • recursive definitions for iteration some-things ::= thing | thing some-things • EBNF • extended BNF (for readability) some-things ::= thing+
EBNF notation: () grouping | alternate * zero or more occurrences + one or more occurrences {} list of alternates [] optional items zero or one occurrences Grammars
Grammars • BNF for creating a polyline: • draw-line ::= select-line choose-points last-pointselect-line ::= position-mouse CLICK-MOUSEchoose-points ::= choose-one | choose-one choose-pointschoose-one ::= position-mouse CLICK-MOUSElast-point ::= position-mouse DBL-CLICK-MOUSEposition-mouse ::= empty | MOVE-MOUSE position-mouse
Grammars • EBNF for creating a polyline: • draw-line ::= select-line choose-one+ last-pointselect-line ::= position-mouse CLICK-MOUSEchoose-one ::= position-mouse CLICK-MOUSElast-point ::= position-mouse DBL-CLICK-MOUSEposition-mouse ::= MOVE-MOUSE*
EBNF • Interaction: • select line item from palette • MOVE-MOUSE, CLICK-MOUSE • click first point • MOVE-MOUSE, CLICK-MOUSE • click a second point • MOVE-MOUSE, CLICK-MOUSE • double click last point • MOVE-MOUSE, DBL-CLICK-MOUSE
EBNF • Creating a polyline: • draw-line ::= select-line choose-one+ last-pointselect-line ::= MOVE-MOUSE* CLICK-MOUSEchoose-one ::= MOVE-MOUSE* CLICK-MOUSElast-point ::= MOVE-MOUSE* DBL-CLICK-MOUSE
EBNF • Derivation: • draw-line • select-linechoose-one+last-point • MOVE-MOUSE* CLICK-MOUSEchoose-one+last-point • MOVE-MOUSE CLICK-MOUSEchoose-one+last-point • MOVE-MOUSE CLICK-MOUSEchoose-onechoose-onelast-point
EBNF • Derivation: • MOVE-MOUSE CLICK-MOUSEMOVE-MOUSE* CLICK-MOUSEchoose-onelast-point • MOVE-MOUSE CLICK-MOUSEMOVE-MOUSE CLICK-MOUSEchoose-onelast-point • MOVE-MOUSE CLICK-MOUSEMOVE-MOUSE CLICK-MOUSEMOVE-MOUSE* CLICK-MOUSElast-point • MOVE-MOUSE CLICK-MOUSEMOVE-MOUSE CLICK-MOUSEMOVE-MOUSE CLICK-MOUSElast-point
EBNF • Derivation: • MOVE-MOUSE CLICK-MOUSEMOVE-MOUSE CLICK-MOUSEMOVE-MOUSE CLICK-MOUSEMOVE-MOUSE* DBL-CLICK-MOUSE • MOVE-MOUSE CLICK-MOUSEMOVE-MOUSE CLICK-MOUSEMOVE-MOUSE CLICK-MOUSEMOVE-MOUSE DBL-CLICK-MOUSE
Grammars • Regular expressions: • specifies the structure of lexical elements • e.g., valid Java identifiers • less expressive than BNF • e.g., cannot express matching brackets (of arbitrary depth of nesting) • can be implemented using a finite state machine • e.g., use lex tool • not “wildcard” expressions
A regexp notation: () grouping | alternates * zero or more + one or more . any character ^ beginning of line $ end of line [] range \ escape Regular Expressions
Regular Expressions • Examples: • a postal code [A-Z][0-9][A-Z] [0-9][A-Z][0-9] • a positive integer (unlimited digits) [0-9]+ • a Java identifier [_a-zA-Z][_a-zA-Z0-9]* • sometimes useful at low-level dialogs select-line click click* double-click
Production Rules • Notation: • if condition then action • condition action • condition: action
Production Rules • How: • conditions of all rules are matched against occurring events and/or current state (user and/or system) • any and all matching rules fire to execute the corresponding actions • foundation of rule-based systems
Event-Oriented Production Rules • Events: • user • e.g., user clicking mouse • internal • e.g., for keeping track of dialog state • system response • e.g., visible or audible system feedback
Event-Oriented Production Rules • Creating a polyline: • Select-line start-line <highlight ‘line’>C-point start-line rest-line <rubber band on>C-point rest-line rest-line <draw line>D-point rest-line <draw line> <rubber band off> • Event notation: • User-event • internal-event • <system response>
Event-Oriented Production Rules • User events: • select line item from palette • Select-line • click first point • C-point • click a second point • C-point • double click last point • D-point
Event-Oriented Production Rules • System response events: • select line item from palette • <highlight ‘line’> • click first point • <rubber band on> • click a second point • <draw line> • double click last point • <draw line> <rubber band off>
Event-Oriented Production Rules • Creating a polyline: • Select-linestart-line <highlight ‘line’>C-point start-linerest-line <rubber band on>C-point rest-linerest-line <draw line>D-point rest-line<draw line> <rubber band off> • Note: • system events are removed once processed
Event-Oriented Production Rules • Memory of events: • Select-line • start-line <highlight ‘line’> • start-line • start-line C-point • rest-line <rubber band on> • rest-line • rest-line C-point • rest-line <draw line> • rest-line • rest-line D-point • <draw line> <rubber band off>
State-Oriented Production Rules • Attributes and states: • Mouse:{ mouse-off, select-line, click-point, double-click } • Line-state:{ menu, start-line, rest-line } • Rubber-band:{ rubber-band-off, rubber-band-on } • Draw:{ draw-nothing, draw-line }
State-Oriented Production Rules • Creating a polyline: • select-linemouse-off start-lineclick-point start-linemouse-off rest-line rubber-band-onclick-point rest-linemouse-off draw-linedouble-click rest-linemouse-off menu draw-line rubber-band-off • Note: • attribute values are removed when a new value is set
State-Oriented Production Rules • Memory of state: • mouse-off menu draw-nothing rubber-band-off • select-line menu draw-nothing rubber-band-off • mouse-off start-line draw-nothing rubber-band-off • click-point start-line draw-nothing rubber-band-off • mouse-off rest-line draw-nothing rubber-band-on • click-point rest-line draw-nothing rubber-band-on • mouse-off rest-line draw-line rubber-band-on • double-clickrest-line draw-line rubber-band-on • mouse-off menu draw-line draw-line rubber-band-off
Production Rules • Mixing events and state: • event: condition action • Note: • the event must occur and the condition must be true for the rule to fire
Production Rules • State: • Bold: { off, on } • Italic: { off, on } • Underline: { off, on } • Events and conditions: • click-bold: Bold=off Bold=onclick-bold: Bold=on Bold=offclick-italic: Italic=off Italic=onclick-italic: Italic=on Italic=offclick-underline: Underline=off Underline=onclick-underline: Underline=on Underline=off
Production Rules • Issues: • better able to handle concurrency • somewhat awkward at handling sequential dialogs • start-line, rest-line
Human-Computer Interaction A. Dix et al. Prentice Hall, 1998 [d8] References