Introductory Graphics Chapter Three. Computer Graphics §Full motion pictures (“Star Wars”) l animated films §Virtual reality §Games §Simulators (air craft.

Slides:



Advertisements
Similar presentations
Applets and Graphics.
Advertisements

Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
Graphics Chapter 16.  If you want to draw shapes such as a bar chart, a clock, or a stop sign, how do you do it?
PHY-102 SAPIntroductory GraphicsSlide 1 Introductory Graphics In this section we will learn how about how to draw graphics on the screen in Java:  Drawing.
LAB SESSION 7 Graphical user interface Applet fundamentals Methods in applets Execution of an applet Graphics class.
CSC1401 Drawing in Java - 2. Reminder from last class How do you save your modified picture? String filename = …; Picture stevePicture = new Picture(filename);
Java Graphics Section 1 - Multi-File Graphics Programs Section 2 - The Coordinate System and Graphics Context g Section 3 - The Java Drawing and Painting.
Building Java Programs Supplement 3G Graphics Copyright (c) Pearson All rights reserved.
Building Java Programs Supplement 3G Graphics Copyright (c) Pearson All rights reserved.
GUI and Swing, part 2 The illustrated edition. Scroll bars As we have previously seen, a JTextArea has a fixed size, but the amount of text that can be.
1 A Simple Applet. 2 Applets and applications An application is an “ordinary” program Examples: Notepad, MS Word, Firefox, Halo, etc. An applet is a Java.
Copyright 2008 by Pearson Education Building Java Programs Graphics Reading: Supplement 3G.
©2004 Brooks/Cole Applets Graphics & GUIs. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Graphical Programs Most applications these days are.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Introduction to Java Applets Outline 3.1 Introduction 3.2 Sample Applets from the Java 2.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Topics  Applets  Classes used for graphics Graphics Point Dimension.
1 L37 Graphics and Java 2D™ (2). 2 OBJECTIVES To use methods of class Graphics to draw lines,  rectangles,  rectangles with rounded corners,  three-dimensional.
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
Copyright 2008 by Pearson Education Building Java Programs Graphics reading: Supplement 3G videos: Ch. 3G #1-2.
Java Applets. Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets –Introduce inheritance –Introduce the.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 5 Java Graphics Applets.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 5 Applets and Graphics.
Copyright 2008 by Pearson Education Building Java Programs Graphics reading: Supplement 3G videos: Ch. 3G #1-2.
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.
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
A Simple Applet.
1 Drawing Shapes and Text With Applets. 2 Drawing in the paint method import java.awt.*;// access the Graphics object import javax.swing.*;// access to.
1 Graphical objects We will draw graphics in Java using 3 kinds of objects: DrawingPanel : A window on the screen. Not part of Java; provided by the authors.
©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.
Agenda For Feb Discussion (Assignments & Rubric) 2. PowerPoint Presentation (Drawing Basic Shapes). 4.Read Unit 3 carefully (pages ) then.
Agenda For Feb Finish up Unit 3 Exercises on page Unit 4 Exercises on page 33. Question #2 3. Create a Happy Face Java Applet (due next class).
Java Software Solutions Lewis and Loftus Chapter 7 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphics -- Introduction The.
Java On The Web Session 15. Memory Upload JAVA Applets Colors Fonts Drawing Methods Posting your Applet.
Object Oriented Programming one of the main reasons we now teach Java instead of C++. C++ was designed to be backwardly compatible with the original (non-OOP)
Copyright 2010 by Pearson Education Building Java Programs Graphics reading: Supplement 3G.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 14 Java Fundamentals 2D Graphics Wed. 10/11/00.
Exposure Java-A 2006 Chapter 4 Slides Using Methods and Parameters
Applets & Graphics. Applets programs that run inside a browser Java platform-independence makes applets possible security restrictions: –cannot read or.
Chapter 7 Graphics. © Daly and Wrigley Objectives Use Graphic Components: ▫ Strings ▫ Lines ▫ Rectangles ▫ Ovals ▫ Arcs Change the color and font of elements.
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.
1 A Simple Applet. 2 Applets and applications An application is an “ordinary” program Examples: Notepad, MS Word, Firefox, Halo, etc. An applet is a Java.
Graphics & Applets CSC 1051 – Data Structures and Algorithms I
1 Building Java Programs Supplement 3G: Graphics These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold,
Drawing rectangles and ovals in the Applet window Displaying Text in the Java Console Window Demo of the HelloAgain program Arithmetic expressions Examples.
(C) 2010 Pearson Education, Inc. All rights reserved.  Class Graphics (from package java.awt) provides various methods for drawing text and shapes onto.
Painting (Chapter 12) Java Certification Study Group January 25, 1999 Mark Roth.
(c)2006 E.S.Boese All Rights Reserved.1 Drawing Shapes and Text Chapter 2 – Lecture Slides.
Chapter 2: Graphics In Java Basics of classes –instance variables –methods –overriding methods Graphics class (drawing routines) Other classes –Color –Font.
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.
1 Graphics, Fonts and Color Chapter 9. 2 What is in this chapter: l Graphics class and coordinates l graphics primitives (lines,rectangles,ovals and arcs)
Building Java Programs Graphics Reading: Supplement 3G.
Introduction to Graphics. Graphical objects To draw pictures, we will use three classes of objects: –DrawingPanel : A window on the screen. –Graphics.
Copyright 2008 by Pearson Education Building Java Programs Graphics reading: Supplement 3G videos: Ch. 3G #1-2.
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,
The 4 Stages of Program Design  Cryptic Programming Stage  Unstructured, Spaghetti-Programming Stage  Structured Programming Stage  Object Oriented.
Graphics JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin, Gary Litvin, and Skylight.
The 4 Stages of Program Design  Cryptic Programming Stage  Unstructured, Spaghetti-Programming Stage  Structured Programming Stage  Object Oriented.
Graphics Drawing Things With Java. Today's Topics Course Updates Java Graphics –Java 1.1 versus Java 1.2 (Java 2) Drawing Lines Drawing Shapes.
Intro to Graphics from Chapter 2 of Java Software Solutions
12 Graphics and Java 2D™.
Chapter 8 Graphics.
Chapter 10 Graphics.
4.14 GUI and Graphics Case Study: Creating Simple Drawings (Cont.)
Graphics -- Introduction
Chapter 8 Graphics.
Building Java Programs
Building Java Programs
Presentation transcript:

Introductory Graphics Chapter Three

Computer Graphics §Full motion pictures (“Star Wars”) l animated films §Virtual reality §Games §Simulators (air craft etc.)

“A first Picture” §import java.awt.*; §import java.applet.Applet; §public class FirstLine extends Applet { l public void paint (Graphics g) { g.drawLine (0,0,100,100); }

Alter old HTML or Write New One §<applet “code = FirstLine.class” l can use same width and height…..> 0,0 0, ,0 100, ,330 START ENDING G.drawLine(0,0,100,100);

g.drawLine(0,0,100,100) “parameters” §doSomething( ); No parameters

The Paint Method §“Signiture Line” l public void paint (Graphics g) { security return Method name type Variable name

§Security = who can “see” modify method §void = return “nothing” this time… §paint = name of method (could be anything) §(Graphics = type variable g = name of particular variable) { begin/start of content of method

Methods for Drawing §Rectangles, ovals, arcs, polygons l 3D rectangles l filled shapes l polygons l rounded corners §drawArc( ) or drawOval, Rect,Line

drawArc ( 6 parameters) §X position §Y position §Width §Height §Starting point (360 degree of Clock) §Total Angle of Arc

0 degree (3:00 o’clock position 90 degree (12:00 o’clock) degree or 6:00 o’clock position 100,200,200,150,180,90 G.drawArc() 90

COLORS STANDARD 13 §256 * 256 * 256 (Lots of possible) l blackbluecyan darkgray l graygreenlightgray magenta l orangepinkredwhite l yellow

§ g.setBackground(Color.lightgray) ; §g.setColor.red; l SOLID FIGURES §fillRect §fillArc §fillOval

Sequence of “Graphics” Applet §Import java.awt.*; §import java applet.Applet; l public class FirstShapes extends Applet { public void paint (Graphics g) { g.drawRect (30,30,80,40); g.drawOval(120,30,50,50); setColor(Color.black); fillRect(30,100,80,40);

§drawLine (30,160,130,170); §drawArc (30,180,50,50,60,40); §fillArc(120,180,50,50,60,40); §} }

Add some text… §G.drawString (“ Hello World “, 30, 40); Horizontal X Y position

Concatenation + operator §G.drawString(“Hi” + “There” + “Mike”,100,100);

Comments (Types) §// single line comments §/* This is l an example of a multi line comment */ l /** Special JDK comment used for manuals not in J++ JBuilder */

Some comments are required for this class (All programs) §Your name §What function of program §The course you are in §Other comments as needed to help explain logic of program OR add needed detail l // draws a stickman // head //legs //arms