Beyond Console Programs

Slides:



Advertisements
Similar presentations
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.
Advertisements

Chapter 2—Programming by Example The Art and Science of An Introduction to Computer Science ERIC S. ROBERTS Java Programming by Example C H A P T E R 2.
Made with love, by Zachary Langley Applets The Graphics Presentation.
Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
LAB SESSION 7 Graphical user interface Applet fundamentals Methods in applets Execution of an applet Graphics class.
Chapter 2 Programming by Example. A Holistic Perspective Three sections separated by blank lines. Program comment File: FileName.java
Copyright 2008 by Pearson Education Building Java Programs Graphics Reading: Supplement 3G.
ObjectDraw and Objects Early Chris Nevison Barbara Wells.
Slide Transitions Slide Show, Slide Transition opens Slide Transition task pane Practice each option setting to select the transition style, its speed,
Chapter 9—Object-oriented Graphics
CSE 219 Computer Science III Images. HW1 Has been posted on Blackboard Making a Game of Life with limited options.
How To Use This Template
Graphical Structures Eric Roberts CS 106A January 29, 2010.
Graphics Concepts CS 2302, Fall /3/20142 Drawing Paths.
Hello, little turtles. Hello, little turtles! There are many modules in Python that provide very powerful feature that we can use in our own program.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
(C) 2010 Pearson Education, Inc. All rights reserved.  Class Graphics (from package java.awt) provides various methods for drawing text and shapes onto.
CSC 1010 Programming for All Lecture 7 Input, Output & Graphics.
Introduction to Graphics. Graphical objects To draw pictures, we will use three classes of objects: –DrawingPanel : A window on the screen. –Graphics.
Graphical Structures Eric Roberts CS 106A January 27, 2016.
Simple Java Eric Roberts CS 106A January 11, 2016.
Interactive Graphics Eric Roberts CS 106A January 25, 2016.
Object Oriented Programming Lecture 3: Things OO.
CS 115 Lecture 7 Graphics – coordinate systems, Text, Entry, aliases Taken from notes by Dr. Neil Moore.
Five-Minute Review 1.What steps do we distinguish in solving a problem by computer? 2.What are essential properties of an algorithm? 3.What is a definition.
Five-Minute Review 1.What are enumerated types? How can we represent enumerations in Java? 2.What is character arithmetic? 3.What is a string, conceptually?
LEARN TO FORMAT TABLES Unit 10: Lessons What is a Table? ◦ A table is an arrangement of data (words and/or numbers) in rows and columns. ◦ A table.
Five-Minute Review What steps do we distinguish in solving a problem by computer? What are essential properties of an algorithm? What is a definition of.
What is a Function Expression?
Five-Minute Review What are enumerated types? How can we represent enumerations in Java? What is character arithmetic? What is a string, conceptually?
Area of a Triangle.
Jerry Cain and Eric Roberts
Computer Science 209 Graphics and GUIs.
Review.
Animation & Games Module
PHP Image Manipulation
Basic Graphics Chapter 5 3/19/15 Thursday Section Only
CS106A, Stanford University
Five-Minute Review What are enumerated types? How can we represent enumerations in Java? What is character arithmetic? What is a string, conceptually?
reading: Art & Science of Java,
CS 106A, Lecture 15 Events and Memory
CS 106A, Lecture 24 Interactors and NameSurfer
CS 115 Lecture Graphics II – coordinate systems, Text, Entry, aliases
reading: Art & Science of Java, Ch. 9
CS 106A, Lecture 12 More Graphics
CS 106A, Lecture 28 Final Exam Review 2
CS106A, Stanford University
CS 106A, Lecture 14 Events and Instance Variables
CS 106A, Lecture 22 More Classes
CS106A, Stanford University
4.14 GUI and Graphics Case Study: Creating Simple Drawings (Cont.)
Chapter 9—Object-oriented Graphics
Chapter 2—Programming by Example
CS 115 Lecture Graphics II – coordinate systems, Text, Entry, aliases
SSEA Computer Science: Track A
CS106A, Stanford University
Graphics.
CS106A, Stanford University
Extend Text Editor to Draw shapes
Interactive Graphics Jerry Cain and Ryan Eberhardt CS 106AJ
CSE 142 Lecture Notes Graphics with DrawingPanel Chapter 3
Simple Graphics Package
Chapter 2—Programming by Example
Millennium High School Agenda Calendar
Building Java Programs
Graphics Reading: Supplement 3G
Spell your name using word art from above
Introduction to Computer Science and Object-Oriented Programming
Presentation transcript:

Beyond Console Programs

GRect GRect is a variable that stores a rectangle. As an example, the following run method displays a rectangle public void run() { Grect rect = new GRect(200, 200); rect.setFilled(true); rect.setColor(Color.BLUE); add(rect, 50, 50); } LargestOval

Graphics Coordinates 0,0 40,20 120,40 getHeight(); 40,120 getWidth();

GLabel A variable that represents text. public class HelloProgram extends GraphicsProgram { public void run() { GLabel label = new GLabel("hello, world", 100, 75); label.setFont("SansSerif-36"); label.setColor(Color.RED); add(label); } HelloProgram

GLabel A variable that represents text. public class HelloProgram extends GraphicsProgram { public void run() { GLabel label = new GLabel("hello, world", 100, 75); label.setFont("SansSerif-36"); label.setColor(Color.RED); add(label); } HelloProgram

GLabel A variable that represents text. public class HelloProgram extends GraphicsProgram { public void run() { GLabel label = new GLabel("hello, world", 100, 75); label.setFont("SansSerif-36"); label.setColor(Color.RED); add(label); } HelloProgram

GLabel A variable that represents text. public class HelloProgram extends GraphicsProgram { public void run() { GLabel label = new GLabel("hello, world", 100, 75); label.setFont("SansSerif-36"); label.setColor(Color.RED); add(label); } HelloProgram

GLabel hello, world A variable that represents text. public class HelloProgram extends GraphicsProgram { public void run() { GLabel label = new GLabel("hello, world", 100, 75); label.setFont("SansSerif-36"); label.setColor(Color.RED); add(label); } HelloProgram hello, world

GOval The GOval class represents an elliptical shape defined by the boundaries of its enclosing rectangle. As an example, the following run method creates the largest oval that fits within the canvas: public void run() { GOval oval = new GOval(getWidth(), getHeight()); oval.setFilled(true); oval.setColor(Color.GREEN); add(oval, 0, 0); } LargestOval

Karel’s Grandpa

Graphics Methods Adds the object to the canvas at the front of the stack Moves the object to (x, y) and then adds it to the canvas Removes the object from the canvas Removes all objects from the canvas Returns the frontmost object at (x, y), or null if none Returns the width in pixels of the entire canvas Returns the height in pixels of the entire canvas Sets the background color of the canvas to c. add(object) add(object, x, y) remove(object) removeAll() getElementAt(x, y) getWidth() getHeight() setBackground(c) Pauses the program for the specified time in milliseconds Suspends the program until the user clicks the mouse pause(milliseconds) waitForClick()

Graphics Methods Adds the object to the canvas at the front of the stack Moves the object to (x, y) and then adds it to the canvas Removes the object from the canvas Removes all objects from the canvas Returns the frontmost object at (x, y), or null if none Returns the width in pixels of the entire canvas Returns the height in pixels of the entire canvas Sets the background color of the canvas to c. add(object) add(object, x, y) remove(object) removeAll() getElementAt(x, y) getWidth() getHeight() setBackground(c) Pauses the program for the specified time in milliseconds Suspends the program until the user clicks the mouse pause(milliseconds) waitForClick()

Reference Sheet