User Interface Summary Displayable ScreenCanvas FormAlertListTextbox Item DateFieldImageItemTextFieldStringItemGaugeChoiceGroup.

Slides:



Advertisements
Similar presentations
Chapter 13 Graphics classes Bjarne Stroustrup
Advertisements

Chapter 14 Graph class design Bjarne Stroustrup
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
1 More on Applets Overview l Changing Colors l Changing Fonts & Styles l Applet Life-Cycle l Input using Dialog Window l Input using HTML parameters l.
Cosc 5/4730 Blackberry Drawing. Screen size With Blackberry devices, they have a known screen size in pixels. If you are programming for specific device.
Chapter 14 Graph class design John Keyser’s Modifications of Slides by Bjarne Stroustrup
Building Java Programs Supplement 3G Graphics Copyright (c) Pearson All rights reserved.
Applets An applet is similar to a Java program, but it runs within a Web-browser on a client machine. For security, you cannot change anything on a client.
Cosc 4755 Low-level GUI APIs. Low-Level API Composed of Canvas and Graphics classes – GameCanvas will be covered later on Canvas is an abstract class,
Listener Interfaces  A mechanism for registering handlers that respond to external events  Motivation: Develop a Canvas class that:  supports drawing.
©2004 Brooks/Cole Applets Graphics & GUIs. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Graphical Programs Most applications these days are.
1 Lecture 06(Abstract Classes)Lecture 9 Abstract Classes Overview  Abstract Classes: A Definition.  Declaring Abstract Classes.  Abstract Methods: A.
A Simple Applet. Applets and applications An applet is a Java program that runs on a web page –Applets can be run from: Internet Explorer Netscape Navigator.
A Simple Applet.
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Java Applets What is an Applet? How do you create.
Chapter 13 Advanced GUIs and Graphics. Chapter Objectives Learn about applets Explore the class Graphics Learn about the class Font Explore the class.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
CSE 219 Computer Science III Images. HW1 Has been posted on Blackboard Making a Game of Life with limited options.
Java Applet Presented by Fitsum Okubu. Introduction Introduction Graphics Graphics Methods and Variables Methods and Variables Events Events Decision.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 13 lcdui and OXO Rob Pooley
tiled Map Case Study: Rendering with JPanel © Allan C. Milne v
CSC 205 Java Programming II Polymorphism. Topics Polymorphism The principle of substitution Dynamic binding Object type casting Abstract class The canonical.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved COS240 Object-Oriented Languages.
Applets & Graphics. Applets programs that run inside a browser Java platform-independence makes applets possible security restrictions: –cannot read or.
J McQuillan SE204: 2004/2005: Lecture 4slide 1 The Graphics Class Used when we need to draw to the screen Two graphics classes –Graphics –Graphics2D.
Canvas and Graphics CS 21a. 9/26/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L17: Canvas.
Applets Applet is java program that can be embedded into HTML pages. Java applets runs on the java enabled web browsers such as mozilla and internet explorer.
Graphics Copyright © 2015 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data.
Java Graphics. Review 3 kinds of elements in components API? Layout managers Events Extend vs. Implement.
1 Block1 – unit 2 (The Case study in Budd 5-6).  create a small application that uses the Abstract Windowing Toolkit (AWT)  Swing packages to simulate.
-Sai Phalgun Tatavarthy. Outline What is a “Graphing Calculator”? Graphics, Graphics2D classes Methods of Graphics object Custom Painting The paintComponent()
Creating Your Own Widgets CompSci 230 S Software Construction.
Lec 16 Adding Mouse and KeyEvent handlers to an Applet Class.
(C) 2010 Pearson Education, Inc. All rights reserved.  Class Graphics (from package java.awt) provides various methods for drawing text and shapes onto.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
עקרונות תכנות מונחה עצמים תרגול 6 - GUI. Outline  Game of Life  Painting.
Applets An applet is similar to a Java program, but it runs within a Web-browser on a client machine. For security, you cannot change anything on a client.
Georgia Institute of Technology Drawing in Java – part 3 Barb Ericson Georgia Institute of Technology September 2006.
1 A Simple Applet. 2 Applets and applications An applet is a Java program that runs on a web page Applets can be run within any modern browser To run.
CSI 3125, Preliminaries, page 1 AWT. CSI 3125, Preliminaries, page 2 AWT Java AWT (Abstract Windowing Toolkit) is an API to develop GUI or window-based.
Object Oriented Programming Lecture 3: Things OO.
Basic Graphics 03/03/16 & 03/07/16 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
CPCS 391 Computer Graphics Lab One. Computer Graphics Using Java What is Computer Graphics: Computer graphics are graphics created using computers and,
Graphics JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin, Gary Litvin, and Skylight.
Barb Ericson Georgia Institute of Technology September 2005
Creating Your Own Widgets
Object Oriented Programming
Building Java Programs
Android Layouts 24 July 2018 S.RENUKADEVI/AP/SCD/ANDROID LAYOUTS 1.
GUI Components Part II.
Building Java Programs
Building Java Programs
Topic 8 graphics "What makes the situation worse is that the highest level CS course I've ever taken is cs4, and quotes from the graphics group startup.
עקרונות תכנות מונחה עצמים
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Making a Smile Face Pepper.
Graphics Reading: Supplement 3G
Building Java Programs
Barb Ericson Georgia Institute of Technology September 2005
Presentation transcript:

User Interface Summary Displayable ScreenCanvas FormAlertListTextbox Item DateFieldImageItemTextFieldStringItemGaugeChoiceGroup

Canvas  A type of screen that allows drawing and capturing keypad input  Abstract class – need to inherit and implement specific behaviors

Canvas  A type of screen that allows drawing and capturing keypad input  Abstract class – need to inherit and implement specific behaviors void paint(Graphics g) – carry out the drawing

Canvas  A type of screen that allows drawing and capturing keypad input  Abstract class – need to inherit and implement specific behaviors void paint(Graphics g) – carry out the drawing void repaint() – invoke to redraw Canvas (calls paint())

Canvas  A type of screen that allows drawing and capturing keypad input  Abstract class – need to inherit and implement specific behaviors void paint(Graphics g) – carry out the drawing void repaint() – invoke to redraw Canvas (calls paint()) void keyPressed(int keyCode) – invoked when key is pressed

Canvas  A type of screen that allows drawing and capturing keypad input  Abstract class – need to inherit and implement specific behaviors void paint(Graphics g) – carry out the drawing void repaint() – invoke to redraw Canvas (calls paint()) void keyPressed(int keyCode) – invoked when key is pressed void keyReleased(int keyCode) – invoked when key is released

Canvas  A type of screen that allows drawing and capturing keypad input  Abstract class – need to inherit and implement specific behaviors void paint(Graphics g) – carry out the drawing void repaint() – invoke to redraw Canvas (calls paint()) void keyPressed(int keyCode) – invoked when key is pressed void keyReleased(int keyCode) – invoked when key is released Key codes: Canvas.KEY_NUM0... Canvas.KEY_NUM9 Canvas.KEY_STAR... Canvas.KEY_POUND Canvas.LEFT... Canvas.RIGHT

Canvas  Treat as a regular Form void addCommand(Command c) void setCommandListener(CommandListenr l) void setTitle(String text) void setTicker(String text) int getWidth() Int getHeight()

Canvas  Treat as a regular Form Canvas gameView = new MahjongCanvas(); Display.getDisplay(this).setCurrent(gameView);

Canvas  Drawing takes place in void paint(Grpahics g);  Graphics class provides capabilities for drawing lines, rectangles, images void paint(Graphics g) { int red = 0x00FF000000; g.setColor(red); g.drawLine(x1, y1, x2, y2); int green = 0x0000FF00; g.setColor(green); g.drawRect(x, y, width, height); g.fillRect(x, y, width, height); int blue = 0x000000FF; g.setColor(blue); g.drawString(text, x, y, anchor); }

Canvas  Drawing takes place in void paint(Grpahics g);  Graphics class provides capabilities for drawing lines, rectangles, images void paint(Graphics g) { for (int i = 0; i < shapes.size(); ++i) { Shape s = (Shape) shape.elmentAt(i); this.setColor( s.getColor() ); s.draw( g ); }

Canvas  Placement of Text and Images (Anchor Points)  BASELINE, TOP, BOTTOM, RIGHT, LEFT, HCENTER, VCENTER g.drawLine(this.getWidth()/2, 0, this.getWidth()/2, this.getHeight()); g.drawLine(0, 20, this.getWidth(), 20); g.drawString("Canvas Caption", this.getWidth()/2, 20, Graphics.BASELINE | Graphics.HCENTER); g.drawLine(0, 50, this.getWidth(), 50); g.drawString("Canvas Caption", this.getWidth()/2, 50, Graphics.BASELINE | Graphics.LEFT); g.drawLine(0, 80, this.getWidth(), 80); g.drawString("Canvas Caption", this.getWidth()/2, 80, Graphics.BASELINE | Graphics.RIGHT); g.drawLine(0, 110, this.getWidth(), 110); g.drawString("Canvas Caption", this.getWidth()/2, 110, Graphics.LEFT | Graphics.TOP); g.drawLine(0, 140, this.getWidth(), 140); g.drawString("Canvas Caption", this.getWidth()/2, 140, Graphics.LEFT | Graphics.BOTTOM);

Canvas  Placement of Text and Images (Anchor Points)  BASELINE, TOP, BOTTOM, RIGHT, LEFT, HCENTER, VCENTER g.drawLine(this.getWidth()/2, 0, this.getWidth()/2, this.getHeight()); g.drawLine(0, 20, this.getWidth(), 20); g.drawString("Canvas Caption", this.getWidth()/2, 20, Graphics.BASELINE | Graphics.HCENTER); g.drawLine(0, 50, this.getWidth(), 50); g.drawString("Canvas Caption", this.getWidth()/2, 50, Graphics.BASELINE | Graphics.LEFT); g.drawLine(0, 80, this.getWidth(), 80); g.drawString("Canvas Caption", this.getWidth()/2, 80, Graphics.BASELINE | Graphics.RIGHT); g.drawLine(0, 110, this.getWidth(), 110); g.drawString("Canvas Caption", this.getWidth()/2, 110, Graphics.LEFT | Graphics.TOP); g.drawLine(0, 140, this.getWidth(), 140); g.drawString("Canvas Caption", this.getWidth()/2, 140, Graphics.LEFT | Graphics.BOTTOM);

Canvas  Placement of Text and Images (Anchor Points)  BASELINE, TOP, BOTTOM, RIGHT, LEFT, HCENTER, VCENTER

Lab  Create a class Rectangle that represents a 2D rectangle data members: ulx, uly, width, height methods:constructor void draw(Graphics g) void move(int dx, int dy)  Create a class ShapesCanvas that extends Canvas data members: collection of Rectnagles methods:constructor void paint(Graphics g) <-- override: draw shapes void keyPressed(int keyCode) <-- override