FrameworksFrameworks chap8. Framework Set of cooperating classes Structures the essential mechanisms of a problem domain Framework != design pattern Typical.

Slides:



Advertisements
Similar presentations
Copyright  Oracle Corporation, All rights reserved. 1 Creating an Application: The AppBuilder for Java IDE.
Advertisements

Frameworks and Collections Horstmann ch QUIZ What is the difference between a program library and a framework? 1.There is no difference 2.When.
Object Oriented Programming with Java (150704).   Applet  AWT (Abstract Window Toolkit)  Japplet  Swing Types of Applet.
© by Pearson Education, Inc. All Rights Reserved.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
Lecture 24 Applets. Introduction to Applets Applets should NOT have main method but rather init, stop, paint etc They should be run through javac compiler.
Review of Java Applets Vijayan Sugumaran Decision and Information Sciences Oakland University.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 16 Applets.
1 Applets Chapter 1 To understand:  why applets are used to extend the capabilities of Web pages  how an applet is executed and know about the restrictions.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 14 Applets, Images,
CS 112 GUI 06 May 2008 Bilkent. Java GUI API Containers: ◦ contain other GUI components. E.g, Window, Panel, Applet, Frame Dialog. Components: ◦ Buttons,
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Design patterns Observer,Strategi, Composite,Template (Chap 5, 6)
1 Frameworks Part 2. 2 Collections Framework Java API contains library of useful data structures Collections library also serves as framework for adding.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L05 (Chapter 16) Applets.
Applets  The Applet Class  The HTML Tag F Passing Parameters to Applets.
Applets Java API.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 16: Java Applets & AWT Fundamentals of Web Programming.
Chapter 12 Applets and Advanced Graphics  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets.
Chapter 13 Advanced GUIs and Graphics. Chapter Objectives Learn about applets Explore the class Graphics Learn about the class Font Explore the class.
Software Construction Lecture 10 Frameworks
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
JAPPLET.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
Chapter 17: Applets, Images, and Sound. Objectives Learn about applets Write an HTML document to host an applet Use the init() method Work with JApplet.
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
ISP666 MVC & Design Patterns. Outline Review Event Programming Model Model-View-Controller Revisit Simple Calculator Break Design Patterns Exercise.
Java Applets. 2 Introduction to Java Applet Programs  Applications are stand alone programs executed with Java interpreter executed with Java interpreter.
Chapter 12 Applets and Advanced GUI  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets F.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Event Driven Programming, The.
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
1 Programming Fundamentals AITI-GP. 2 Introduction to Programming.
Web 2.0 Tools SMART Notebook Math Tools By Joanna Snyder.
Chapter 10: Applets and Advanced Graphics The Applet Class The Applet Class The HTML Tag The HTML Tag Passing Parameters to Applets Passing Parameters.
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.
– Advanced Programming P ROGRAMMING IN Lecture 21 Introduction to Swing.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
CSC 205 – Java Programming II Applet. Types of Java Programs Applets Applications Console applications Graphics applications Applications are stand-alone.
1 Object Oriented Programming Lecture XI An abstract function plotter, using the Template and the Strategy design patterns.
Applets and Frames. Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L14: GUI Slide 2 Applets Usually.
Frameworks CompSci 230 S Software Construction.
Prototype pattern Participants Prototype (Graphic) – declared an interface for cloning itself ConcretePrototype (EditBox, Slider) – implements an operation.
Chapter 10: Applets and Advanced Graphics The Applet Class The Applet Class The HTML Tag The HTML Tag Passing Parameters to Applets Passing Parameters.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Chapter 14 Applets and Advanced GUI  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets F.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
Review Class Inheritance, Abstract, Interfaces, Polymorphism, GUI (MVC)
Chapter 8 (Horstmann’s Book) Frameworks Hwajung Lee.
1 Applets are small applications that are accessed on an Internet server, transported over the internet, automatically installed and run as a part of web.
Chapter 8 Frameworks. Frameworks Framework is a set of cooperating classes and interface types that structures the essential mechanisms of a particular.
Applets, Images, and Audio Chapter 14 CSCI CSCI 1302 – Applets, Images, and Audio2 Outline Introduction The Applet Class –The init Method –The start.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 16 Event-Driven Programming Of all men’s miseries.
Sections Inheritance and Abstract Classes
Applets.
Lecture 09 Applets.
Introduction to Event-Driven Programming
Chapter 13: Advanced GUIs and Graphics
EE 422C Java FX.
UNIT-5.
Java Applets.
11.1 Applets & graphics.
JAVA APPLET PREPARED BY Mr. Jahanzaib Ahmed
ITEC324 Principle of CS III
Advanced GUIs and Graphics
Chapter 7 Java Object Model
Presentation transcript:

FrameworksFrameworks chap8

Framework Set of cooperating classes Structures the essential mechanisms of a problem domain Framework != design pattern Typical framework uses multiple design patterns Example: Swing is a GUI framework

Application Frameworks Implements services common to a type of applications Programmer forms subclasses of framework classes Result is an application Inversion of control: framework controls execution flow

Applets as a simple Framework Applet: Java program that runs in a web browser Programmer forms subclass of Applet or JApplet Overwrites init/destroy start/stop paint

Applets as a Framework Interacts with ambient browser getParameter showDocument HTML page contains applet tag and parameters Ch8/applet/BannerApplet.java

Applets as a Framework Applet programmer uses inheritance Applet class deals with generic behavior (browser interaction) Inversion of control: applet calls init, start,stop,destroy

Graph Editor Framework Problem domain: interactive editing of graphs Graph consists of nodes and edges Class diagram: nodes are rectangles edges are arrows Electronic circuit diagram: nodes are transistors, resistors edges are wires

Graph Editor Framework Traditional approach: programmer starts from scratch for every editor type Framework approach: Programmer extends graph, node, edge classes Framework handles UI, handling commands and mouse events....

Graph Editor Framework User Interface Toolbar on top Grabber button for selecting nodes/edges Buttons for current node/edge type Menu Drawing area Mouse Operations Click on empty space: current node inserted Click on node or edge: select it Drag node when current tool an edge: connect nodes Drag node when current tool not an edge: move node

Division of Responsibility Divide code between –framework –specific application Rendering is app specific (e.g. transistor) Hit testing is app specific (odd node shapes) Framework draws toolbar, the buttons Framework does mouse listening

Framework Classes Framework programmer implements Node/Edge interfaces draw draws node/edge getBounds returns enclosing rectangle (to compute total graph size for scrolling) Edge.getStart, getEnd yield start/end nodes Node.getConnectionPoint computes attachment point on shape boundary Edge.getConnectionPoints yields start/end coordinates (for grabbers) clone overridden to be public AbstractEdge class for convenience Ch8/graphed/Node.java Ch8/graphed/Edge.java Ch8/graphed/AbstractEdge.java Programmer implements Node/Edge type or extends AbstractEdge

Framework Classes Graph collects nodes and edges Subclasses override methods public abstract Node[] getNodePrototypes() public abstract Edge[] getEdgePrototypes() Ch8/graphed/Graph.java

Adding Nodes and Edges Objects are more flexible than classes new CircleNode(Color.BLACK) new CircleNode(Color.WHITE) When user inserts new node, the toolbar node is cloned Node prototype = node of currently selected toolbar button; Node newNode = (Node) prototype.clone(); Point2D mousePoint = current mouse position; graph.add(newNode, mousePoint); Example of PROTOTYPE pattern GraphPanel.java.htmlGraphPanel.java.html

PROTOTYPE Pattern Context A system instantiates objects of classes that are not known when the system is built. You do not want to require a separate class for each kind of object. You want to avoid a separate hierarchy of classes whose responsibility it is to create the objects. Solution Define a prototype interface type that is common to all created objects. Supply a prototype object for each kind of object that the system creates. Clone the prototype object whenever a new object of the given kind is required. GraphPanel.java.html

The application