0 CS 160: Design Process: Implement Event-based UI Programming, Model-View-Controller, and the Web Jeffrey Nichols IBM Almaden Research Center

Slides:



Advertisements
Similar presentations
Graphic User Interfaces Layout Managers Event Handling.
Advertisements

1 Chapter 7 Graphics and Event Handling. 2 Overview The java.awt and javax.swing packages and their subpackages support graphics and event handling. Many.
6/13/20151 CS 160: Lecture 13 Professor John Canny Fall 2004.
1 Model View Controller. 2 Outline Review Definitions of MVC Why do we need it? Administiriva Changing the display Event flow Dragging at interactive.
Graphical User Interface (GUI) Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Graphical User Interface (GUI) Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Object-Oriented Analysis and Design
Graphical User Interface (GUI) Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Stanford hci group / cs376 research topics in human-computer interaction UI Software Tools Scott Klemmer 27 October 2005.
Scripted, Tab Accessible Tree Control Hierarchical view of data via tree control. Keyboard Navigation from initially closed tree to view above with focus.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
Chapter 3 Working with Symbols and Interactivity.
MVC pattern and implementation in java
Software Tools.  It accomplishes an important task  (for better and for worse) You don’t have to make it yourself, and it abstracts a set of knowledge.
Model View Controller (MVC) Rick Mercer with a wide variety of others 1.
Welcome to CIS 083 ! Events CIS 068.
Lehigh University Introduction to Flash MX Sharmeen Mecklai.
Execution Environment for JavaScript " Java Script Window object represents the window in which the browser displays documents. " The Window object provides.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
© 2011 Delmar, Cengage Learning Chapter 3 Working with Symbols and Interactivity.
Java Swing, Events and MVC Optional Readings: Eckel’s Thinking in Java: Chap 14 (
Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
Chapter 8: Writing Graphical User Interfaces Visual Basic.NET Programming: From Problem Analysis to Program Design.
CompSci 230 S Software Construction Frameworks & GUI Programming.
GUI Widgets Jeff Offutt SWE 432 Design and Implementation of Software for the Web.
(c) University of Washington08-1 CSC 143 Models and Views Reading: Ch. 18.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Object Oriented Software Development 9. Creating Graphical User Interfaces.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
Automated GUI testing How to test an interactive application automatically?
Web Application Design Patterns. Large Scale Architectures Early systems were monolithic applications –Large and hard to maintain Then came the client-server.
3461 Model-View Controller Advanced GUI concepts.
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
MS Visual Basic 6 Walter Milner. VB 6 0 Introduction –background to VB, A hello World program 1 Core language 1 –Projects, data types, variables, forms,
Spring /6.831 User Interface Design and Implementation1 Lecture 9: UI Software Architecture RS1 (for 6.831G), PS1 (for 6.813U) released today,
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
CS160 Discussion Section Matthew Kam Apr 7, 2003.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
Object Oriented Programming.  Interface  Event Handling.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 – Graphical User Interfaces Java Foundations: Introduction to Programming.
Swing - 2 Session 13. Swing - 2 / 2 of 38 Objectives (1) Discuss trees and tables Discuss progress bars Discuss MVC architecture Describe menus.
Model-View-Controller Architecture. 2 Give someone a program, you frustrate them for a day; teach them how to program, you frustrate them for a lifetime.
Java Swing, Events Readings: Just Java 2: Chap 19 & 21, or Eckel’s Thinking in Java: Chap 14 Slide credits to CMPUT 301, Department of Computing Science.
1 Lecture 8: User Interface Components with Swing.
3461 Course Summary COSC 3461A Fall Intro to UI Design  Course plan: Implementation, Evaluation, Design  Human Computer Interaction is an.
12-Jun-16 Event loops. 2 Programming in prehistoric times Earliest programs were all “batch” processing There was no interaction with the user Input Output.
GUI and Web Programming CSE 403 (based on a lecture by James Fogarty)
Mobile Computing CSE 40814/60814 Spring 2017.
Event Loops and GUI Intro2CS – weeks
CompSci 230 S Software Construction
Chapter 8: Writing Graphical User Interfaces
Event loops 16-Jun-18.
Understand Windows Forms Applications and Console-based Applications
Event Driven Programming
Event loops.
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Professor John Canny Spring 2004 March 5
Event loops 8-Apr-19.
Professor John Canny Spring 2003 March 12
Event loops.
Event loops 19-Aug-19.
Presentation transcript:

0 CS 160: Design Process: Implement Event-based UI Programming, Model-View-Controller, and the Web Jeffrey Nichols IBM Almaden Research Center * based on the slides of Jeffrey Heer, Jake Wobbrock, and James Landay

1 How many of you… have implemented a command-line user interface?

2 How many of you… have implemented a graphical user interface? HTML/CSS Java Swing.NET Framework Mozilla’s XUL Mobile platform (Windows Mobile, Palm, Symbian, etc.) Something else?

3 What’s the difference? Command-line model (e.g., UNIX shell, DOS) Interaction controlled by system User queried when input is needed Event-driven model (e.g., GUIs) Interaction controlled by the user System waits for user actions and then reacts More complicated programming and architecture

4 What we’ll cover today: Building the “look” of a user interface Component/Container model Managing layout Building the “feel” of a user interface Event loop and dispatching Handling an event Model-View-Controller In a normal desktop application In a web application

5 Building the “Look”

6 What do we start with? (0,0) Bitmap (“Raster”) Display 2D, origin usually at top-left, units vary (often pixels) Graphics Context Device-independent drawing abstraction Clipping region Color Typefaces Stroke model Coordinate transforms Rendering methods Draw, fill shapes Draw text strings Draw images

7 Component/Container Model Component (aka widget, control, etc.) Encapsulation of an interactive element Drawn using the 2D graphics library Low-level input event processing Repaint management In OOP systems, each component is implemented as a sub-class of a base “Component” class

8 Name some components? Button Checkbox Radio button Text box Combo box (drop-down list) List box Scrollbar Slider Menu Menu item NumericPicker DateTimePicker more…

9 Java Swing Components

10.NET Framework Controls

11 HTML Form Controls

12 Component/Container Model Container Component that contains one or more other components Creates the structure of the user interface Manages child components Layout, painting, event dispatch Some have interactive features (e.g. tab panel)

13 Containment Structure LabelTextbox Buttons

14 Containment Structure LabelTextbox ButtonsPanels

15 Containment Structure Window Panel TextboxLabelPanel Button

16 Layout Window Panel TextboxLabelPanel Button Containers specify layout of their children

17 Layout Window Panel TextboxLabelPanel Button Containers specify layout of their children spring strut

18 Tree Structure Nearly every UI framework uses a tree containment structure Even HTML! DOM Inspector demo with google/Firefox

19 Building the “Feel”

20 Events User input is modeled as “events” that must be handled by the system Examples? Mouse button down, button up, button clicked, entered, exited, moved, dragged Keyboard key down, key up, key pressed Window movement, resizing

21 Anatomy of an Event An event encapsulates the information needed for handlers to react to the input Event type (mouse button down, key up, etc.) Event target (component in which event occurred) Timestamp Modifiers (Ctrl, Shift, Alt, etc.) Type-specific content Mouse: x,y coordinates, # clicks Keyboard: key code

22 Event Handlers Events are dispatched to components Application developers can specify code to be executed when the event occurs (callbacks) Built-in components will have code to handle most keyboard and mouse events Buttons handle mouse up/down to change graphic Text boxes update their contents on key press Built-in components often generate new “high-level” events from combinations of low-level events Text boxes generate “change” events when contents changes and focus is lost Sliders generate “change” events when thumb is dragged

23 Event Loop Event Queue mouse up (10,20) key down (‘h’) key up (‘h’) key down (‘i’) while(!done) { evt = dequeue_event(); dispatch_event(evt); repaint_screen(); } Input Devices Event Loop Exists in every application Usually handled for you by UI framework

24 Event Loop Event Queue mouse up (10,20) key down (‘h’) key up (‘h’) key down (‘i’) while(!done) { evt = dequeue_event(); dispatch_event(evt); repaint_screen(); } Input Devices Event Loop Blocks until an event arrives

25 Event Loop Event Queue mouse up (10,20) key down (‘h’) key up (‘h’) key down (‘i’) while(!done) { evt = dequeue_event(); dispatch_event(evt); repaint_screen(); } Input Devices Event Loop Most of the work happens here

26 Dispatching Events Window Panel TextboxLabelPanel Button mouse down (10,50) function onMouseDown(evt) { // do something... }

27 Dispatching Events Window Panel TextboxLabelPanel Button mouse down (10,50) function onMouseDown(evt) { // do something... }

28 Dispatching Events Window Panel TextboxLabelPanel Button mouse down (10,50) function onMouseDown(evt) { // do something... }

29 Dispatching Events Window Panel Textbox LabelPanel Button mouse down (10,50) function onMouseDown(evt) { // do something... }

30 Dispatching Events Window Panel Textbox LabelPanel Button mouse down (10,50) function onMouseDown(evt) { // do something... }

31 Events in the Web Browser Events are dispatched very much like this within the web browser DOM structure of HTML document is used Two-stage dispatch process: Capture phase Event is sent down the tree to target Bubbling phase Event goes back up the tree to the window

32 Demo of browser events Firefox web browser JavaScript Debugger (“venkman”)

33 Model-View-Controller

34 Model-View-Controller Architecture for interactive apps Introduced by Smalltalk developers at PARC Partitions application in a way that is Scalable Maintainable model view controller

35 Example Application

36 Model Information the app is trying to manipulate Representation of real world objects Circuit for a CAD program Shapes in a drawing program List of people in a contact management program model view controller

37 View Implements a visual display of the model May have multiple views E.g., shape view and numeric view model view controller

38 Multiple Views

39 View Implements a visual display of the model May have multiple views E.g., shape view and numeric view Any time the model is changed, each view must be notified so that it can update later model view controller

40 Controller Receives all input events from the user Decides what they mean and what to do Communicates with view to determine the objects being manipulated (e.g., selection) Calls model methods to make changes to objects model view controller

41 Controller

42 Controller

43 Controller Click!

44 Controller

45 Combining View & Controller View and controller are tightly intertwined Lots of communication between the two E.g. determine what was clicked on Almost always occur in pairs i.e., for each view, need a separate controller Many architectures combine into a single unit model view controller

46 Why MVC? Mixing all pieces in one place will not scale Model may have more than one view Each is different and needs update when model changes Separation eases maintenance and extensibility Easy to add a new view later Model can be extended, but old views still work Views can be changed later (e.g., add 3D)

47 Adding Views Later

48 Nesting MVC MVC is useful on both large and small scales For a whole application Within a complex widget Complex components need to store internal state (a model) that affects their drawing and event handling Simplifies internal implementation Allows for code re-use in other components Makes the most sense if you combine application’s View and Controller E.g., Many Java Swing components have an internal MVC architecture

49 MVC and the Web MVC is a very useful architectural style for the web model view controller

50 Review Building the “look” of a user interface Component/Container model Managing layout Building the “feel” of a user interface Event loop and dispatching Handling an event Model-View-Controller In a normal desktop application In a web application