UI Software Organization

Similar documents
Organization of User Interface Software

GUI Software Architecture

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

UI Software Organization IAT351

Graphical User Interface (GUI)

PIC 20A GUI with swing

Input (part 2: input models)

Advanced Effects in Java Desktop Applications

Bringing Life to Swing Desktop Applications

Fall UI Design and Implementation 1

Java: Graphical User Interfaces (GUI)

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

2IS45 Programming

Windows and Events. created originally by Brian Bailey

More UI Output Tasks: Damage Management & Layout

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

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

AP CS Unit 11: Graphics and Events

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

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

G51PRG: Introduction to Programming Second semester Applets and graphics

CSE 331 Software Design & Implementation

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

Event Dispatch. Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch. Event Architecture. A pipeline: Event Capture

Graphic Interface Programming II Using Swing and OOP more advanced issues. Uppsala universitet

Event Dispatch. Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch. 2.4 Event Dispatch 1

Graphic User Interfaces. - GUI concepts - Swing - AWT

Graphical User Interfaces (GUIs)

Class 16: The Swing Event Model

Graphical User Interface (GUI)

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

We will talk about Alt-Tab from the usability perspective. Think about: - Is it learnable? - Is it efficient? - What about errors and safety?

CS 251 Intermediate Programming GUIs: Components and Layout

CSSE 220. Event Based Programming. Check out EventBasedProgramming from SVN

Graphics programming. COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson)

CSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing

COMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) )

Fall UI Design and Implementation 1

Design patterns for graphical user interface applications

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

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011

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

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

GUI Implementation Support

Programming Languages and Techniques (CIS120)

Event Dispatch. Dispatching events to windows and widgets.

Lecture 3: Java Graphics & Events

MOBILE COMPUTING 1/20/18. How many of you. CSE 40814/60814 Spring have implemented a command-line user interface?

Programming Languages and Techniques (CIS120)

Introduction to the JAVA UI classes Advanced HCI IAT351

Graphic Interface Programming II Events and Threads. Uppsala universitet

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!

Design Case Study: GUI with Swing (2)

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

Assignment 2. Application Development

What is Widget Layout? COSC 3461 User Interfaces. Hierarchical Widget Layout. Resizing a Window. Module 5 Laying Out Components

CS11 Java. Fall Lecture 4

Lecture 5: Java Graphics

Page 1. Human-computer interaction. Lecture 2: Design & Implementation. Building user interfaces. Users and limitations

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

Lecture 19 GUI Events

(Incomplete) History of GUIs

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

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

CS11 Java. Fall Lecture 3

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

User interfaces and Swing

CSE 331 Software Design & Implementation

Programming graphics

Object-Oriented Programming Design. Topic : Graphics Programming GUI Part I

CS 251 Intermediate Programming GUIs: Event Listeners

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

Unit 7: Event driven programming

Widget Toolkits CS MVC

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

IT101. Graphical User Interface

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS

Design Case Study: GUI with Swing

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

Lecture 9: UI Software Architecture. Fall UI Design and Implementation 1

CS260. UI Toolkits. Björn Hartmann University of California, Berkeley EECS, Computer Science Division Fall 2010

Window Interfaces Using Swing Objects

CSE 331 Software Design and Implementation. Lecture 19 GUI Events

AP CS Unit 12: Drawing and Mouse Events

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java

CSE 331 Software Design & Implementation

Jonathan Aldrich Charlie Garrod

CS2110 Fall 2015 Assignment A5: Treemaps 1

Inheritance Systems. Merchandise. Television Camcorder Shirt Shoe Dress 9.1.1

WIMP Elements. GUI goo. What is WIMP?

Computer Science 210: Data Structures. Intro to Java Graphics

Lecture 18 Java Graphics and GUIs

Graphics and Painting

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

Welcome to CIS 068! 1. GUIs: JAVA Swing 2. (Streams and Files we ll not cover this in this semester, just a review) CIS 068

Packages: Putting Classes Together

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

Review sheet for Final Exam (List of objectives for this course)

Java Programming. Computer Science 112

Transcription:

UI Software Organization

The user interface From previous class: Generally want to think of the UI as only one component of the system Deals with the user Separate from the functional core (AKA, the app ) 2

Separation of Concerns There are good software engineering reasons to do this Keep UI code separate from app code Isolate changes More modular implementation Different expertise needed Don t want to iterate the whole thing 3

In practice, very hard to do... More and more interactive programs are tightly coupled to the UI Programs structured around UI concepts/flow UI structure sneaks into application Not always bad... Tight coupling can offer better feedback/performance 4

Separation of concerns is a central theme of UI organization A continual challenge A continual tension and tradeoff Real separation of UI from application is almost a lost cause 5

Conceptual Overview of the UI Input UI Core App Interface App Output UI Toolkit 6

Basic UI Flow Input UI Core App Interface App Output UI Toolkit 7

How would you architect this? Tempting to architect systems around these boxes One module for input, one for output, etc. Has been tried ( Seeheim model ) Didn t work well 8

Why Big Box architectures don t work well Modern ( direct manipulation ) interfaces tend to be collections of quasi-independent agents Each interactor ( object of interest on the screen) is separable Example: an on-screen button Produces button-like output Acts on input in a button-like way Etc. 9

Leads to object-based architectures Each on-screen interactor corresponds to an object instance Common methods for Drawing output (button-like appearance) Handling input (what happens when I click) Classes are organized into a subclassing hierarchy Typically a top-level Component or Widget class that describes basic interactor capabilities Leaf-node classes for the things you actually see on the screen (buttons, scrollbars, etc.) Intermediate classes for common behaviors (text or mouse processing) Objects are organized hierarchically at runtime Normally reflecting spatial containment relationships NOTE: different than class hierarchy created at development time Interactor trees 10

Challenge: maintaining separation of concerns Trick is coming up with a separation that works quickly, simply, and extensibly Even a single button may be hopelessly complex (pluggable looks-andfeels anyone?) Needs to be extensible to new interactors What s the right factoring for all this stuff? Will see some strategies later Basically: common O-O patterns to manage complexity 11

UI Toolkits System to provide development-time and runtime support for UIs Core functionality Input & output handling Connecting to the application Also: specific interaction techniques Library of interactors Look and feel (sometimes pluggable) 12

Categories of users Consumer End-user, albeit indirectly Programmers Interface designer Application builder Toolkit implementer/maintainer Interactor writer Tool builder Expert end-user (through scripting) 13

Toolkit functionality in detail (Roadmap of topics) Core functions Hierarchy management Create, maintain, tear down tree of interactor objects Geometry management Dealing with coordinate systems On-screen bounds of interactors Interactor status/information management Is this interactor visible? Is it active? 14

Toolkit functionality in detail Output Layout Establishing the size and position of each object Both initially, and after a resize (Re)drawing Damage management Knowing what needs to be redrawn Localization and customization We won t talk much about this... 15

Toolkit functionality in detail Input Picking Figuring out what interactors are under a given screen point Event dispatch, translation, handling This is where a lot of the work goes 16

Toolkit functionality in detail Application interface How the UI system connects with application code... Callbacks Command objects Undo models 17

Example: Java Swing All functions of interactors encapsulated in base class javax.swing.jcomponent All objects on-screen inherit from this class Terminology: interactor, widget, component, control,... 18

Standard object-oriented approach Base class (or interface) defines the set of things that every interactor must do e.g., public void paintcomponent(graphics g); Subclasses provide specific specialized implementations Do the right drawing, input, etc., to be a button vs. a slider vs.... 19

JComponent API defines methods for Hierarchy management Geometry management Object status management Layout (Re)drawing Damage management Picking 20

In subclasses and other parts of the toolkit: Input dispatch and handling Application interface Pluggable looks and feels Undo support Accessibility 21

Hierarchy Management Swing interfaces are trees of components To make something appear, you must add it to the tree Swing takes care of many of the details from there Screen redraw Input dispatch JFrame JPanel JButton JButton JButton 22

Hierarchy Management Lots of methods for manipulating the tree add(), remove(), removeall(), getcomponents(), getcomponentcount(), isancestorof(),... Common mistake If nothing shows up on the screen, make sure you ve added it! 23

Geometry Management Every component maintains its own geometry: Bounding box: getx(), gety(), getwidth(), getheight() X,Y are relative to parent i.e., 0,0 is at parent s top left corner Other operations: setsize(), setlocation(), setbounds(), getsize(), getlocation(), getbounds() All drawing happens within that box System clips to bounding box Including output of children! Drawing is relative to top-left corner Each component has its own coordinate system 24

Object Status Each component maintains information about its state isenabled(), setenabled() isvisible(), setvisible() Lots of other methods of lesser importance 25

Each component handles: Layout (we ll talk about this later...) Drawing Each component knows how to (re)create its appearance based on its current state Responsible for painting three items, in order: 1. Component 2. Borders 3. Children paintcomponent(), paintborder(), paintchildren() These are the only places to draw on the screen!!! Automatically called by JComponent s paint() method, which is itself called by the Swing RepaintManager (figures out damaged regions) 26

Damage Management Damage: areas of a component that need to be redrawn Sometimes: computed automatically by Swing RepaintManager e.g., if another window is dragged over your component, or your component is resized Other times: you need to flag damage yourself to tell the system that something in your internal state has changes and your on-screen image may not be correct e.g., your component needs to change the color of a displayed label Managing damage yourself: repaint(rectangle r) Puts the indicated rectangle on the RepaintManager s queue of regions to be redrawn Terminology: damage is not a Swing term; generic 27

Picking Determine if a point is inside a component contains(int x, int y) Is the point inside the bounding box of this component (uses local coordinate system of component) Terminology: likewise, picking is not a Swing term 28

Other stuff Input (we ll talk about this later...) Application interface Glue between component and application functionality Not directly in component, but there is a convention for how to associate your functionality with a component Callbacks: you register code with a component to say call this code when something happens Terminology: Swing uses the term listener for a piece of application code that will be called back in response to something happening The code listens for something happening 29

Listeners Any given component may have multiple situations in which it invokes a listener Button pressed, list scrolled, list item selected Different types of listeners representing different types of things happening Therefore, each component has a list of listeners for each situation Standardized names for accessing these lists addpropertychangelistener(), getpropertychangelisteners(), removepropertychangelistener() addactionlistener(), getactionlisteners(), removeactionlistener() 30

More on listeners There is generally a separate interface for each type of listener PropertyChangeListener ActionListener Your code must implement the appropriate listener interface and be registered with the list of appropriate list of listeners on the appropriate component Example: button press causes listeners on the button s ActionListener list to be called Define your code so that it implements ActionListener Register it with the button using addactionlistener() 31

Events Most listener interfaces define methods that take an event object that describes what just happened Separate classes of events for each listener interface ActionListener: ActionEvent MouseListener: MouseEvent Passed as a parameter containing details of what happened e.g., MouseListener: mouse coordinates, whether it was pressed, released, etc. 32