1 Lecture 3: Other Output Models: Structured Graphics; Object-Oriented Techniques Brad Myers 05-830 Advanced User Interface Software © 2013 - Brad Myers.

Slides:



Advertisements
Similar presentations
Object-Oriented Programming Python. OO Paradigm - Review Three Characteristics of OO Languages –Inheritance It isn’t necessary to build every class from.
Advertisements

Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Lecture 10: Part 1: OO Issues CS 540 George Mason University.
Chapter 3: Modules, Hierarchy Charts, and Documentation
Portability and Safety Mahdi Milani Fard Dec, 2006 Java.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 3 Advanced Object-Oriented Concepts.
1 Lecture 9: Software Organization: Lexical-Syntax- Semantics, Seeheim Model, MVC, Object-Oriented Programming for UIs Brad Myers Advanced User.
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
Programming Language Paradigms: summary. Object-oriented programming Objects are the fundamental building blocks of a program. Interaction is structured.
1 Lecture 5: Other Output Models: Structured Graphics; Object-Oriented Techniques Brad Myers Advanced User Interface Software.
The Procedure Abstraction Part IV: Run-time Structures for OOLs Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students.
Object-Oriented Databases
Context-sensitive Analysis, II Ad-hoc syntax-directed translation, Symbol Tables, andTypes.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
The Composite Pattern.. Composite Pattern Intent –Compose objects into tree structures to represent part-whole hierarchies. –Composite lets clients treat.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
1 Lecture 4: Output Models, Structured Graphics & Display PostScript Brad Myers Advanced User Interface Software.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
Abstraction: Polymorphism, pt. 1 Abstracting Objects.
CSCI-383 Object-Oriented Programming & Design Lecture 15.
CSSE501 Object-Oriented Development
1 Lecture 9: Deep Dive: Selecting and Creating Objects across Different Kinds of Views Brad Myers A/05-499A: Interaction Techniques Spring, 2014.
Written by Liron Blecher
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
A First Program Using C#
C++ Programming. Table of Contents History What is C++? Development of C++ Standardized C++ What are the features of C++? What is Object Orientation?
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
Chapter 8: Writing Graphical User Interfaces
11.10 Human Computer Interface www. ICT-Teacher.com.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
CSCI-383 Object-Oriented Programming & Design Lecture 13.
The Procedure Abstraction, Part V: Support for OOLs Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 7.
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers Advanced User Interface Software 1© 2013.
1 Lecture 2: Overview of UI Software and Tools Brad Myers Advanced User Interface Software.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
Chapter 5 Introduction to Defining Classes
Chapter 12 Support for Object-Oriented Programming.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
(1) ICS 313: Programming Language Theory Chapter 12: Object Oriented Programming.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
Copyright © 2005 Elsevier Object-Oriented Programming Control or PROCESS abstraction is a very old idea (subroutines!), though few languages provide it.
1 Lecture 5: Interactive Tools: Prototypers (HyperCard, Director, Visual Basic), Interface Builders Brad Myers Advanced User Interface Software.
Creating a Java Application and Applet
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Basic Organization of UI Software. 2 The User Interface n Typically want to think of “UI” as only one component of an overall system – The part that “deals.
Polymorphism and Inheritance (CS-319 Supplementary Notes)
CSCI-383 Object-Oriented Programming & Design Lecture 17.
CSCI 383 Object-Oriented Programming & Design Lecture 15 Martin van Bommel.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Brad Myers Advanced User Interface Software, 2017
Andy Wang Object Oriented Programming in C++ COP 3330
Inheritance, Polymorphism and the Object Memory Model
Computer Programming.
Design Patterns A Case Study: Designing a Document Editor
The Procedure Abstraction Part V: Run-time Structures for OOLs
Support for Object-Oriented Programming
Brad Myers : Interaction Techniques Spring, 2019
Presentation transcript:

1 Lecture 3: Other Output Models: Structured Graphics; Object-Oriented Techniques Brad Myers Advanced User Interface Software © Brad Myers

OK to post the PDFs of evaluations on-line? With your names on it? Do you want to feedback from classmates? With names? Not easy – 3 week assignment on purpose How TestOutlineRect should look Redraw vs. main event loop Reminder: no copying or collaborating Will be checking Homework 1 © Brad Myers2 Homework 2

Interesting issue java.awt.Rectangle – (x, y, width, height) java.awt.Rectangle My BoundaryRectangle class based on this android.graphics.Rect – (left, top, right, bottom) android.graphics.Rect Doesn’t say whether inclusive or exclusive!! Rect r = new Rect(2,2,4,5); What is r.width() and r.height()? © Brad Myers3

4 Structured Graphics Saves a list of all the graphical objects Edit the screen by editing the saved list Also called "display list" or "retained object model" Provided by many toolkits and graphics packages early vector displays CORE (~1977), GKS (1985), PHIGS (1988) Optional in InterViews, CLIM, etc. Required in Amulet, Garnet, Rendezvous, etc. HTML document object model (DOM) Display tree © Brad Myers

5 Structured Graphics, cont. Advantages: Simpler to program with: don't call "draw" and "erase" Automatic refresh of windows when uncovered, etc. Automatic redisplay of objects when change and also of other overlapping objects BeforeAfter © Brad Myers

6 Structured Graphics Can Support Ability to support: high-level behaviors like move, grow, cut/copy/paste, etc. high-level widgets like selection handles constraints among objects automatic layout grouping: "Groups" in Garnet automatic printing tutors and monitors external scripting,... accessibility © Brad Myers

7 Structured Graphics Disadvantages Disadvantages: Significant space penalties objects take up to 1000 bytes each imagine a scene with 40,000 dots (200x200 fat bits) Time penalties Redisplay doesn't take advantage of special properties of data:  regularity  non-overlapping © Brad Myers

Redisplay Algorithms Redisplay everything each time Most appropriate for small numbers of objects, and if drawing is really quick compared to computation Used on the Macintosh and many others Used by Amulet Used by homework 2 May add clipping region and/or double-buffering 8© Brad Myers

Redisplay only the affected areas of the screen Requires computing what areas are affected Garnet: keep track of objects that change any "interesting" slot compute the bounding box of all these changed objects in their old and new locations assert this as the clipping region (must not self-intersect; Garnet uses 2 regions) erase the area go through objects from top-to-bottom, back to front draw those which overlap the bounding box for step 4: goes through all top level aggregates, and any children of the aggregates that intersect (recursively) Other techniques: quad trees 9© Brad Myers

Issue: Anti-Aliasing and special effects Drop shadows, highlights, other special effects Can’t assume clipping regions will work Can draw outside of the bounding boxes Mac OS X uses anti-aliasing and seems to redraw lots of windows 10© Brad Myers

11 Optimizing Redraw Special additions in Garnet; not in Amulet "Fast-redraws" declared by the programmer objects drawn with XOR on top of other objects those that have a solid color behind them (nothing in front) so can be erased with a rectangle or by redrawing with the background color When change, have to be erased using old values No bounding boxes, no intersections, etc. "Virtual aggregates" only pretend to allocate storage for elements provide table and arbitrary layouts © Brad Myers

12 Optimizing Redraw “Glyphs” in InterViews Calder, P.R. and Linton, M.A. “Glyphs: Flyweight Objects for User Interfaces,” in Proceedings UIST'90: ACM SIGGRAPH Symposium on User Interface Software and Technology Snowbird, Utah: pp Don't include position information, etc. so very small Much of the layout retained by the aggregate (computed as needed) Object can be reused in many places: e.g.: the letter "a" Used for a text editor Issue: why is location special? What about red vs. blue "a"s? © Brad Myers

13 Object-Oriented Techniques Motivation Became popular along with GUIs, Direct Manipulation Icons, graphics seem like objects: have internal state, persistance OO was originally developed (SmallTalk) and became popular (C++) mostly due to GUIs. © Brad Myers

14 Object Oriented As a UI technique: Same as GUI, Direct Manipulation = icons, graphical objects, widgets Here, as a programming paradigm (often in a language) A form of "data abstraction" "Classes" describe the basic structure of the data Also, the methods that can be called Usually no direct access to the data, only the methods © Brad Myers

15 OO Create "instances" of the classes local copy of data may also be class data -- all instances share the same value shares all methods "Inheritance": create a new class "like" the superclass by default has all the same methods and data can add new data and methods and re-program inherited methods Example: graphical_object.draw... circle.draw © Brad Myers

16 OO New style of programming; thinking about the problem Many books about how to do it right. OO design; getting the classes and protocols right So subclasses don't have extra, wasted data space Methods make sense to all sub-classes So external classes don't need to know inside description. Also OO databases, etc. Implementation: object in memory, starts with pointer to table of methods, etc. lots of tricks and extra declarations in C++, Java etc. to avoid overhead of lookups at run-time ("virtual", "pure virtual") © Brad Myers

17 Multiple inheritance Class has multiple parent classes Combine all the methods and data of all Special rules for when conflict (same method, same name of data with different types, etc.) Example: circle inherits from graphical-object and moveable-object Complex so often not used even when available Amulet uses constraints to provide flexible copying of values instead Java, etc. use “interfaces” No inheritance of implementations, but ability to have arbitrary “mix-ins” No confusion about which superclass to inherit from © Brad Myers

18 Prototype-Instance model Instead of the class-instance model All objects are instances Can use any object as a prototype for other objects Inherits all slots it doesn't override (= instance variables, member variables, fields, attributes). Methods are just a value in a slot Dynamic changing of methods Easy to implement using structures. Usually, changing prototype data also changes all instances that do not override it. Now used by JavaScript, ActionScript (Flash) Older uses: SELF, NewtonScript, © Brad Myers

19 Prototype-Instance model © Brad Myers

20 Prototype-Instance model May provide adding and removing of slots dynamically to any instance Simpler model, easy to implement More dynamic But much less efficient Can't usually compile slot accesses into structure access; may need a search Type checking on slots Methods looked up at run-time Space for names of slots, extra pointers, etc. © Brad Myers

21 Examples of OO Systems OO in SmallTalk First "pure" example Everything is an object (numbers, strings, etc.) Single inheritance Methods dispatched on a single parameter 3 + "4.5" different from "4.5" + 3 Dynamic method lookup at run-time => "Message not understood" Smalltalk 72 had strange syntax with special characters Whole environment (windows, browsers, MVC, etc.) © Brad Myers

22 Examples of OO Systems OO in C++ Numbers, strings, etc. not objects Lots of mess to make it fit with C Statically (compile-time) determine types, methods Originally a pre-processor (new syntax) Multiple-inheritance © Brad Myers

23 Examples of OO Systems OO in CLOS (Common-Lisp Object System) Add-on to language Special feature: method dispatch on all parameters +(int int) +(int str) +(str int) +(str str) Methods not as tightly coupled with objects © Brad Myers

24 Examples of OO Systems OO in MacApp (approx – 1994) Because OO so natural for UIs, invented their own language: Object Pascal with help from Niklaus Werth (inventor of Pascal) Used in MacApp SmallTalk model, but more compile-time checkable Eventually abandoned in favor of Objective C (NeXT) Third-party company by Brad Cox Now supported directly by Apple © Brad Myers

25 Examples of OO Systems OO in Andrew and Motif GUI systems for X Window System on Unix in the late 1980’s Invented their own object systems in C Similar to GTK+ and Qt from homework 1 presentations Before C++ was popular, available "Intrinsics" Mainly is a method and inheritance protocol Andrew: (ATK) pre-processor for header files single inheritance "_" = new syntax: class_method(xxx) dynamic loading of object implementations querying an object's class at run-time Andrew converted to C++ Now defunct Motif just a set of conventions; no preprocessor not "real" inheritance, overriding

26 Examples of OO Systems Amulet provides a prototype-instance object system embedded in C++ Java C# Objective C Javascript & ActionScript © Brad Myers

Design Issues: Hierarchies & Inheritance How many hierarchies for OO graphics systems? Inheritance (class-instance or prototype-instance) Components / Groups Display tree Where do properties come from? Color, size, shape Issue: changing type of object – rectangle  polygon Windows widget properties Size, color scheme, transparency, … © Brad Myers27

28 Amulet and Garnet Videos Brad A. Myers, Dario Giuse, Andrew Mickish, Brad Vander Zanden, David Kosbie, Richard McDaniel, James Landay, Matthew Goldberg, and Rajan Parthasarathy. “The Garnet User Interface Development Environment.” Technical Video Program of the CHI'94 conference. SIGGRAPH Video Review, Issue 97, no. 13. ACM, ISBN Brad A. Myers, Richard G. McDaniel, Robert C. Miller, Alan Ferrency, Ellen Borison, Andrew Faulring, Andy Mickish, Patrick Doane, and Alex Klimovitski, “The Amulet User Interface Development Environment”. 8 minute video. Technical Video Program of the CHI'97 conference. ACM, OpenVideo version © Brad Myers 1996, 8:45 min