GUI Software Architecture

Similar documents
GUI Implementation Support

10/16/2008. CSG 170 Round 5. Prof. Timothy Bickmore. User Analysis Task Analysis (6) Problem Scenarios (3)

Human-Computer Interaction IS4300

Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science

UI Software Organization

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

COMPSCI 230. Software Design and Construction. Swing

GUI Event Handling 11. GUI Event Handling. Objectives. What is an Event? Hierarchical Model (JDK1.0) Delegation Model (JDK1.1)

Advanced Java Programming (17625) Event Handling. 20 Marks

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo

Human-Computer Interaction IS4300

Java: Graphical User Interfaces (GUI)

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011

SD Module-1 Advanced JAVA

Graphical User Interface (GUI)

SD Module-1 Advanced JAVA. Assignment No. 4

Widget. Widget is a generic name for parts of an interface that have their own behaviour. e.g., buttons, progress bars, sliders, drop-down

Introduction to concurrency and GUIs

Introduction to GUIs. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2014

Organization of User Interface Software

CSE 331 Software Design & Implementation

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

CS 251 Intermediate Programming GUIs: Event Listeners

Widgets. Widgets Widget Toolkits. 2.3 Widgets 1

Lecture 19 GUI Events

11/7/12. Discussion of Roulette Assignment. Objectives. Compiler s Names of Classes. GUI Review. Window Events

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

Event Driven Programming

Swing. By Iqtidar Ali

CSE 331 Software Design and Implementation. Lecture 19 GUI Events

CompSci 125 Lecture 17. GUI: Graphics, Check Boxes, Radio Buttons

Chapter 6: Graphical User Interfaces

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User

Graphical User Interfaces (GUIs)

CS111: PROGRAMMING LANGUAGE II

Cheng, CSE870. More Frameworks. Overview. Recap on OOP. Acknowledgements:

Programming Languages and Techniques (CIS120)

Jonathan Aldrich Charlie Garrod

What does JFC stand for?

Dr. Hikmat A. M. AbdelJaber

All the Swing components start with J. The hierarchy diagram is shown below. JComponent is the base class.

Graphical User Interfaces. Comp 152

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Java & Graphical User Interface II. Wang Yang wyang AT njnet.edu.cn

KF5008 Program Design & Development. Lecture 1 Usability GUI Design and Implementation

Widgets. Widgets Widget Toolkits. User Interface Widget

Programming graphics

Input: Interaction Techniques

Windows and Events. created originally by Brian Bailey

Java GUI Design: the Basics

Input part 3: Interaction Techniques

Widget Toolkits CS MVC

Introduction to Graphical Interface Programming in Java. Introduction to AWT and Swing

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

Method Of Key Event Key Listener must implement three methods, keypressed(), keyreleased() & keytyped(). 1) keypressed() : will run whenever a key is

GUI Event Handlers (Part I)

Starting Out with Java: From Control Structures Through Objects Sixth Edition

2010 가을학기부산대학교정보컴퓨터공학부 OVERVIEW OF GUI PROGRAMMING

Lecture 5: Java Graphics


To gain experience using GUI components and listeners.

Class 16: The Swing Event Model

(Incomplete) History of GUIs

Inheritance. One class inherits from another if it describes a specialized subset of objects Terminology:

Table of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7...

PIC 20A GUI with swing

GUI 4.1 GUI GUI MouseTest.java import javax.swing.*; import java.awt.*; import java.awt.event.*; /* 1 */

Virtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4.

Java Programming Lecture 6

Java Event Handling -- 1

implementation support

Introduction to the JAVA UI classes Advanced HCI IAT351

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

Input (part 2: input models)

The AWT Event Model 9

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

Course Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski

Model-View-Controller

Packages: Putting Classes Together

Human Computer Interaction Lecture 08 [ Implementation Support ] Implementation support

GUI Programming: Swing and Event Handling

CSC207 Week 4. Larry Zhang

Sri Vidya College of Engineering & Technology

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages.

Programming Languages 2nd edition Tucker and Noonan"

12/22/11. Copyright by Pearson Education, Inc. All Rights Reserved.

CS415 Human Computer Interaction

Prototyping a Swing Interface with the Netbeans IDE GUI Editor

BASICS OF GRAPHICAL APPS

CS11 Java. Fall Lecture 3

G51PRG: Introduction to Programming Second semester Applets and graphics

Graphical interfaces & event-driven programming

Chapter 17 Creating User Interfaces

Software Tools. Scott Klemmer Autumn 2009

TYPES OF INTERACTORS Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill

This page intentionally left blank

Transcription:

GUI Software Architecture

P2: Requirements Analysis User Analysis Task Analysis Problem Scenarios Usability Criteria

Scenario Your engineers just developed a new desktop computer. They give you the following primitives: drawpixel(x,y,color) readmousex(), readmousey(), readmousebutton(), readkey() They ask you to implement this:

Levels of Abstraction in UI Software Windowing systems Central environment for programmer and user Supports separate user-system threads simultaneously. Interaction toolkits Abstract away physical separation of input and output Programmer can describe behaviors of objects at a level similar to how the user perceives them.

Levels of Abstraction in UI Software User interface management systems Designer and programmer controls relationship between toolkit presentation objects with functional semantics Application

Levels of Abstraction

Hierarchy of Windows Most UIs described as a collection of hierarchically ordered windows or elements ( interactors or widgets ) Top of tree or root is whole display Geometric relationships (containment, overlap) are important Eg Windows, ios, Android

Output and the Interactor Tree Output is organized around the tree structure Each object has own behaviors & states can draw itself can do other tasks knows own capabilities and those of children Generic tasks are specialized to specific subclasses

UI Toolkit Programming Paradigm 1: Read-Evaluation Loop

Notification Based Application / Notifier

Read-eval loop vs. Notifications Pros and cons for each

Using Interactive Toolkits Interaction objects Input and output intrinsically linked Toolkits provide this level of abstraction Programming with interaction objects Consistency and generalizability through look & feel Amenable to object-oriented programming

Objects and the UI Why are they so well suited? Natural metaphor (direct manipulation) Encapsulation (info hiding) Class-instance Subclassing Message passing

Standard UI Widgets: "The Macintosh 7" 1. Button 2. Slider 3. Pulldown menu 4. Check box 5. Radio buttons 6. Text entry fields 7. File pick/save

Influence on Today's GUIs Large part of the WIMP GUI The Macintosh 7 have become standard (common) interaction techniques MFC as an example Sure enough, inside the Swing toolkit as well

The Good and the Bad Collection of good interaction techniques that work well uniformity is good for usability Significant stagnation Failing to customize interaction techniques to tasks (although this is general issue)

Example of a non-standard widget: Pie Menus Circular pop-up menu with dead area at center basically only angle counts What are Fitts law properties?*** minimum distance to travel minimum required accuracy (dependent on # of options) Very fast (dependent on # of options)

Pie Menus How many of you have seen these before? Reasons why we don t see these used? Just not known Hard to implement (draw labels) Don t scale (variations support hierarchy) Other?

Monolithic Layered Architectures (non-oo) Don't Work Here Because... Modern interfaces: set of quasi-independent agents Each object of interest is separate e.g. a button produces button-like output acts on input in a button-like way etc. Each object does its tasks based on What it is What its current state is Context from prior interaction or application

Object Based Solutions Interactor objects AKA components, controls, widgets Each object implements each aspect In a way that reflects what it is Objects organized hierarchically Normally reflecting spatial containment relationships Interactor trees

Discussion How to minimize complexity of individual objects? Three general approaches Inheritance Composition Aggregation

Inheritance All concerns in one object/class inherit / override them separately works best with multiple inheritance example: draggable_icon inherit appearance from icon output aspects only inherit behavior from draggable input aspects only

Inheritance: JButton http://docs.oracle. com/javase/7/docs/api/javax/swing/jbutton. html

Composition Put together interactive objects at larger scale than interactors Container objects e.g., row and column layout objects e.g. Image Button Containers can also add input & output behavior to things they contain

Composition

Aggregation Different concerns in separate objects Treat collection as the interactor Classic architecture: model-viewcontroller (MVC)

MVC Motivation The UI of an application is subject to many changes: Change of UI for different users Same info can be shown in different windows Changes to underlying data should be reflected quickly everywhere Changes to UI should be easy, even at runtime Different look and feel should not affect functional core So separate processing, output, and input

MVC MVC divides application into: Model of core functionality and data Views displaying information to user Controllers handling user input Views and Controllers comprise UI Change-propagation mechanism ensures consistency between Model and UI...it is rarely this clean.

Continue Here... Due Today: P2 Due Soon: Programming assignment (I4) I3 Commentary A ton of work is due soon (7 / 5 classes)

MVC Architecture What's the advantage?

Model Encapsulates application-specific data and functionality, providing: methods to edit data, which Controller can call methods to access state, which View and Controller can request Maintains registry of dependent Views and Controllers to be notified about data changes

Model Examples text editor: model is a text string slider: model is an integer + range spreadsheet: collection of values related by functional constraints

View Mechanism needed to map model data to rendition (view / display) When Model changes, View is informed View requests relevant model information View arranges to update screen Declare damaged areas Redraw when requested

View Example Slider: text-field(x3), line, & thumb Spreadsheet: Tabular representation Bar chart Histogram

Controller Accepts user input events Translates events into methods invoked on Model Activates/Deactivates UI elements (graying)...sorta

Controller Examples Keyboard / Textual commands Mouse (point and click) commands Touch events No input

MVC Dynamics 1. User input event routed by Window System to appropriate Controller. 2. Controller may require View to pick object of focus for event.

MVC Dynamics 3. Controller requests method of Model to change its state: set 4. Model changes its internal state

MVC Dynamics 5.Model notifies all dependent Views that data has changed. 6.View requests from Model current data values.

MVC Dynamics 7. Model notifies all dependent Controllers that data has changed. 8. Controller requests from Model current data values.

MVC Dynamics 9. Controller informs View if elements are disabled (maybe). 10. View requests redraw

MVC: Pros and Cons Pros: Multiple views of same model Synchronized views Pluggable V & C and look and feel Cons: Complexity for simple interactors Potentially excessive updates/messages Tight coupling, in practice (V-C, VC-M) Lack of portability Some toolkits make MVC framework hard

Swing's Modified MVC Architecture ("Model-Delegate") Collapse View & Controller Hard to write these independently Allows pluggable look and feel e.g. JButton

Interactive Toolkit Example...in a second. Java Swing is a great example but first let's look at UIMSs

User Interface Management Systems (UIMS) Specify complete UI behavior by declarative specification Techniques for dialogue controller menu networks state transition diagrams grammar notations event languages declarative languages constraints graphical specification I never used these (from what I can tell)

LabView

Swing and Netbeans AWT: The original now mostly obsolete as a toolkit (event handling mechanism still used in Swing) Swing: The current standard. SWT (Standard Widget Toolkit) Open source widget toolkit. JavaFX: (maybe) Becoming new standard UI toolkit, but not as many components available yet, can t customize look-and-feel (yet).

AWT vs. Swing AWT used heavy weight components Uses native widget & processes Swing uses light weight components Uses native window for top-level frame, but Swing provides its own windowing system within the frame Even draws its own menus Thus, Can have pluggable look-and-feel Can be deployed on any device (with req d libs) Many more (non-native) widgets

Pluggable Look-and-Feel

Buttons & Combo Boxes

Menus, Text Fields, & Labels

Tool Tips & Embedded Panels

Additional Widgets

JFrame See Oracle documentation http://docs.oracle. com/javase/tutorial/uiswing/components/frame. html

Netbeans or Eclipse <brief demos of each?> Building test applications: resources

Swing Events Swing is notification based: class MyActionHandler implements ActionListener { public void actionperformed( ActionEvent event) { System.out.println("Somebody pushed me!"; } } Button button1 = new Button("Push Me"); button1.addactionlistener(new MyActionHandler());

Event Model Swing events are a subclass of java.awt. AWTEvent getsource() -> who produced it.

Events by Component

Event Action Adjustment Listener Methods actionperformed() adjustmentvaluechanged() Event Types Component Container Focus Item Key Mouse Text componenthidden(), componentmoved(), componentresized(), componentshown() componentadded(), componentremoved() focusgained(), focuslost() itemstatechanged() keypressed(), keyreleased(), keytyped() MouseListener / MouseAdapter: mouseclicked(), mouseentered(), mouseexited(), mousepressed(), MouseMotionListener / MouseMotionAdapter:... textvaluechanged()

Some Event Methods ItemEvent KeyEvent MouseEvent getstatechange() //SELECTED or Deselected getkeychar(), getkeycode() getx(), gety(), getclickcount()

Swing Homework I4: Create a Restaurant Ordering App 2 JLabels, one with an icon. 2 JButtons, one with an icon. 1 JButtonGroup with at least 3 JRadioButton options (with toggling between buttons functional). 2 JCheckBoxes. 1 JComboBox with 2 items. 1 JTextField 1 JPanel with a titled border enclosing at least one other component. 1 tool tip on one component. 1 Menu with at least two options.

To Do Read Design I (Benyon Ch 5 & 9; Rosson Ch 3). Due next: P2 Requirements Analysis Start Homework I4 Swing & Netbeans