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

Similar documents
WYSIWIS AND SHARED WINDOWS. Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill

Graphical User Interface (GUI)

H212 Introduction to Software Systems Honors

Distributed Collaboration - Assignment 1: Multi-View 1-User IM

UI Software Organization

Lecture 9. Lecture

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in

Graphical User Interface (GUI)

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

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

Windows and Events. created originally by Brian Bailey

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

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

Graphical User Interfaces 2

MVC and User-Interface Toolkits

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

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

Graphical User Interfaces. Comp 152

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

Introduction to the JAVA UI classes Advanced HCI IAT351

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!

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

Jonathan Aldrich Charlie Garrod

G51PRG: Introduction to Programming Second semester Applets and graphics

Graphical User Interfaces (GUIs)

OOP Assignment V. For example, the scrolling text (moving banner) problem without a thread looks like:

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

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

Computer Science 210: Data Structures. Intro to Java Graphics

Graphic User Interfaces. - GUI concepts - Swing - AWT

Model-view-controller View hierarchy Observer

Java: Graphical User Interfaces (GUI)

GUI in Java TalentHome Solutions

(Incomplete) History of GUIs

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

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

Introduction to concurrency and GUIs

Block I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1

Event Dispatch. Dispatching events to windows and widgets.

Sri Vidya College of Engineering & Technology

CS11 Java. Fall Lecture 4

Java Programming Lecture 6

Programming Languages and Techniques (CIS120)

CSC207H: Software Design Lecture 11

CSC 161 SPRING 17 LAB 2-1 BORDERLAYOUT, GRIDLAYOUT, AND EVENT HANDLING

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

Event-driven Programming: GUIs

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011

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

2IS45 Programming

User interfaces and Swing

GUI Software Architecture

GUI Event Handlers (Part II)

Java Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1

CS 251 Intermediate Programming GUIs: Components and Layout

Window Interfaces Using Swing Objects

GUI (Graphic User Interface) Programming. Part 2 (Chapter 8) Chapter Goals. Events, Event Sources, and Event Listeners. Listeners

IT101. Graphical User Interface

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

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

GUI and its COmponent Textfield, Button & Label. By Iqtidar Ali

Graphical User Interface (Part-1) Supplementary Material for CPSC 233

Lecture 3: Java Graphics & Events

COMPSCI 230. Software Design and Construction. Swing

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling

Programming graphics

GUI Forms and Events, Part II

Example: Building a Java GUI

Lecture 5: Java Graphics

GUI Implementation Support

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

Building a Java First-Person Shooter

Example: Building a Java GUI

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

Java. GUI building with the AWT

Part 3: Graphical User Interface (GUI) & Java Applets

EPITA Première Année Cycle Ingénieur. Atelier Java - J5

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

COMP 401 FACTORIES. Instructor: Prasun Dewan

CS11 Java. Fall Lecture 3

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

Graphical User Interfaces 2

GUI Event Handlers (Part I)

+! Today. Lecture 3: ArrayList & Standard Java Graphics 1/26/14! n Reading. n Objectives. n Reminders. n Standard Java Graphics (on course webpage)

WIMP Elements. GUI goo. What is WIMP?

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

TRACEABLE ALGORITHMS Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill

SELF-STUDY. Glossary

Outline. More on the Swing API Graphics: double buffering and timers Model - View - Controller paradigm Applets

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

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13

Chris9an Kästner Charlie Garrod

What is Widget Layout? Laying Out Components. Resizing a Window. Hierarchical Widget Layout. Interior Design for GUIs

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

Graphical User Interfaces 2

Implementing Graphical User Interfaces

BASICS OF GRAPHICAL APPS

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.

Transcription:

TYPES OF INTERACTORS Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill dewan@cs.unc.edu Code available at: https://github.com/pdewan/colabteaching

PRE-REQUISITES Model- Separation 2

INTERACTOR TYPES UI Code Types of interactors? Computation Code Model 3

TYPES OF INTERACTORS Console-based UI GUI Graphics Three levels of abstraction 4

ABSTRACTION LAYERS Console-based Inetractor Console Text Component Toolkit-based (GUI) Widgets (Text Component, Button, Slider) Windowbased (Graphics) Windows Flexibility vs. Automation Tradeoff in Abstraction Design 5

ABSTRACTION LAYERS (REVIEW) Console-based Inetractor Console Text Component Toolkit-based (GUI) Widgets (Text Component, Button, Slider) Windowbased (Graphics) Windows Flexibility vs. Automation Tradeoff in Abstraction Design 6

RELATIONSHIP BETWEEN INTERACTOR AND DIFFERENT KINDS OF OBJECTS /Editor/ View Helper UI- Specific Objects Model Helper objects can be at varying levels of abstraction 7

WINDOWS a ^, w1, x, y Window Client Window are untyped rectangular screen areas in which each point is a pixel Input indicates keyboard and/or mouse operations Output draws text, shapes draw a, w1, x, y Window System user presses a User draws a at cursor position 8

EXAMPLE Draws the last character entered at the last position at which the mouse was clicked Draws a carat next to the character and a circle around it 9

USING JAVA WINDOW TO DEFINE A WIDGET public class ACircledCharacterDrawer extends JFrame implements MouseListener, KeyListener { Widget = Window + Window reusable functionality // called when an enqueued paint event for this component is dequeued public void paint (Graphics g) { super.paint(g); // clears the window // better to use FontMetrics to center circle g.drawoval(charx - X_OFFSET, chary - Y_OFFSET, DIAMETER, DIAMETER); g.drawline(charx, chary, charx, chary - CARAT_LENGTH); g.drawstring("" + lastchar, charx, chary); } public void keytyped(keyevent event) { setchar(event.getkeychar()); } public void setchar(char newvalue) { lastchar = newvalue; repaint();// enqueues a paint event } public void mousepressed(mouseevent event) { charx = event.getx(); chary = event.gety(); repaint(); // enqueues a paint event } This subclass of a window is listening to its own window events (registration methods in constructor not shown) Input notification method Reusable functionality Output painter In Java >= 1.1 input is provided through the observer pattern Notification method called by a lower-level abstraction == callback 10

WIDGETS AND TOOLKIT Widget Client Widgets are typed windows textentered() gettext() settext() Widget Input callbacks are widget specific (e.g. slider moved, text changed, text inserted) Output and other calls are widget specific (change text or slider position) Toolkit = Set of all Widgets User enter a line of text User Updates text e.g. AWT, Swing 11

WIDGET USE EXAMPLE JTextField jtextfield = new JTextField("JTextField: Edit me"); AJTextFieldListener jtextfieldlistener = new AJTextFieldListener(jTextField); jtextfield.addactionlistener(jtextfieldlistener); jtextfield.getdocument().adddocumentlistener(jtextfieldlistener); Widget creation and observer registration public class AJTextFieldListener implements ActionListener, DocumentListener{ JTextField jtextfield; public AJTextFieldListener(JTextField ajtextfield) { jtextfield = ajtextfield; } public void actionperformed(actionevent e) { System.out.println("New text entered:" + jtextfield.gettext()); } public void insertupdate(documentevent e) { int newpos = e.getoffset(); Notification of new line entered Notification of new character insertion char newchar = jtextfield.gettext().charat(newpos); System.out.println("Character " + newchar + " inserted at " + newpos); } 12

ATOMIC VS COMPOSITE WIDGETS/WINDOWS Atomic window (JFrame) Atomic component of a widget/window tree JFrame JTextField Root component is topspecial level window (Frame or JFrame) Top-level window manipulated by (customizable) window manager which puts border and provides operations to move, resize, iconify it 13

CREATING, LAYING-OUT AND DISPLAYING A HIERARCHY JFrame frame = new JFrame(theTitle); frame.setlayout(new GridLayout(5, 2)); JTextField jtextfield = new JTextField("JTextField: Edit me"); frame.add(jtextfield); Link creation frame.setsize(300, 300); frame.setvisible(true); Display Tree Parent node (Sub)tree layout Child node Here child created independent of parent and can be re-parented In some systems a child is created as part of a parent: parent specified when child created 14

DIFFERENT KINDS OF (PREDEFINED) HELPER UI ABSTRACTIONS System.out, System.in parses input unparses output Widget Hierarchies creates widget hierarchies, defines widget callbacks and invokes widget calls Window Hierarchies creates windows hierarchies, processes mouse and key events, and draws shapes Additional programmer-defined objects can and should be defined (e.g. different classes of widget listeners) 15

INTERACTOR-UI ABSTRACTION DECOUPLING System.out, System.in Widget Hierarchies Window Hierarchies An interactor can be bound to different kinds of UI abstractions A UI abstraction can be bound to different kinds of interactors 16

SEPARATION IN CONSOLE-BASED UIS System.out, System.in Eclipse Custom interactor for launching multiple processes 17

INTERACTORS CAN BE STRUCTURED When user interfaces are composed Subinteractors can intract directly with models or through parent interactoes 18

SUMMARY OF CONCEPTS IN INTERACTORS Window, Widget, and Console Layers Calls (callbacks) invoked by higher (lower) layer on lower (higher) layer Window: Rectangular Area Input (callbacks): Key, Mouse Events Output (calls) : shape draw calls (drawline, ) Widget: Window embellished with higher-level behavior Input (calls): arbitrary (e.g. new text changed) Output (callbacks): arbitrary (e.g. change text) Console: a text widget used to enter and display text lines Window/Widget Hierarchies: Trees associated with layouts Usually made visible after they have been created An interactor uses one of more of the UI abstractions above as helper objects and the UI abstraction objects are decoupled System.in, System.out used in different kinds of interactors 19

MODEL/INTERACTOR PATTERN UI Code Types of interactors? Computation Code Model Types of models? 20