Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 4 2D Graphics: Advanced Topics.

Slides:



Advertisements
Similar presentations
Engr 691 Special Topics in Engineering Science Software Architecture Spring Semester 2004 Lecture Notes.
Advertisements

STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Made with love, by Zachary Langley Applets The Graphics Presentation.
Examples. // A simple Frame with Rectangle Inside import java.awt.*; import javax.swing.*; import java.awt.geom.*; // For Shapes class rectComponent extends.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 2 2D Graphics: Basics.
Chapter 4 (Horstmann’s Book) Interface Types and Polymorphism: Graphics, Timer, Animation Hwajung Lee.
Multithreading : animation. slide 5.2 Animation Animation shows different objects moving or changing as time progresses. Thread programming is useful.
Chapter 5 Programming Graphics. Chapter Goals To be able to write applications with simple graphical user interfaces To display graphical shapes such.
More Java Drawing in 2D Animations with Timer. Drawing Review A simple two-dimensional coordinate system exists for each graphics context or drawing surface.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. Multithreading Example from Liang textbook.
Chapter 2: Using Objects Part 1. To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about.
UID – Swing and Graphics Boriana Koleva
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L19 (Chapter 24) Multithreading.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 47 Red Black Trees.
Slides prepared by Rose Williams, Binghamton University Chapter 20 Java Never Ends.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L01 (Chapter 13) Graphics.
1 Chapter 4 2D Graphics: Advanced Topics  To construct custom shape primitives  To apply basic image processing techniques  To create fractal images.
1 L38 Graphics and Java 2D™ (3). 2 OBJECTIVES In this chapter you will learn:  To understand graphics contexts and graphics objects.  To understand.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 2 2D Graphics: Basics F The architecture.
Manipulating and Displaying Images in Java Lihang Ying Department of Computing Science University of Alberta, Canada
Chapter 1 Overview of Computers and Programming. Copyright ©2004 Pearson Addison-Wesley. All rights reserved.1-2 Figure 1.3 Components of a Computer.
Overview of Computer Graphics Chapter 1. Bird’s Eye View  Overview of Computer Graphics –Basic concept of computer graphics, system, programming platforms,
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Overview of Computer Graphics.
Chapter 6: Graphical User Interface (GUI) and Object-Oriented Design (OOD) J ava P rogramming: Program Design Including Data Structures Program Design.
Java: Animation Chris North cs3724: HCI. Animation? Changing graphics over time Examples: cartoons Clippy, agents/assistants Hour glass Save dohicky Progress.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 2 Elementary Programming.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 6 Graphics Contents.
Chapter 15 Multithreading F Threads Concept  Creating Threads by Extending the Thread class  Creating Threads by Implementing the Runnable Interface.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 12 Additional 3D Topics.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 28 - Java Graphics and Java2D Outline 28.1Introduction.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Advanced User Interfaces with Java SD’98 - Session 3206 Ted Faison Faison Computing Inc.
2D Graphics Basics Chapter 2. Bird’s Eye View  Overview of Computer Graphics  2D Graphics: Basics –Basic 2D graphics, rendering pipeline, geometry,
Review Recursion Call Stack. Two-dimensional Arrays Visualized as a grid int[][] grays = {{0, 20, 40}, {60, 80, 100}, {120, 140, 160}, {180, 200, 220}};
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 3 2D Graphics: Rendering Details.
Chapter 2: Java Fundamentals
2D Graphics: Advanced Topics Chapter 4. Bird’s Eye View  Overview of Computer Graphics  2D Graphics: Basics  2D Graphics: Rendering Details  2D Graphics:
CSE 219 Computer Science III Image Manipulation. HW 1 Has been posted on Blackboard Making a Game of Life with limited.
Creating Your Own Widgets CompSci 230 S Software Construction.
Assignment An assignment statement changes the value of a variable The assignment operator is the = sign total = 55; Copyright © 2012 Pearson Education,
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 27 JavaBeans and.
Advanced Programming Rabie A. Ramadan vpro/ Lecture 4.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Java Dynamic Graphics.
Graphics and Java2D Chapter Java Coordinate System Origin is in _____________ corner –Behind title bar of window X values increase to the ________.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 9 Lighting and Texturing.
Practical Session 10: Animation. Animation kinds There are three basic kinds of animation: 1. Moving object 2. Changing pictures 3. Combination of 1 and.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 11 Animation.
Object-Oriented Software Engineering Using Threads and simple Animation.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 5 Basic 3D Graphics.
עקרונות תכנות מונחה עצמים תרגול 7: אנימציה. בשבוע שעבר  paint  Graphics  repaint.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Java Graphics Chris North cs3724: HCI. Presentations peter hou Vote: UI Hall of Fame/Shame?
JAVA: An Introduction to Problem Solving & Programming, 7 th Ed. By Walter Savitch ISBN © 2015 Pearson Education, Inc., Upper Saddle River,
Chapter 13: Multithreading The Thread class The Thread class The Runnable Interface The Runnable Interface Thread States Thread States Thread Priority.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Java 2D Image Manipulation A Brief Overview Ziv Yaniv.
Advanced Java Screen Update Techniques SD’98 - Session 4406 Ted Faison Faison Computing Inc.
10/20/2005week71 Graphics, mouse and mouse motion events, KeyEvent Agenda Classes in AWT for graphics Example java programs –Graphics –Mouse events –Mouse.
Chapter 13: Multithreading
ITEC324 Principle of CS III
Operator Overloading; Class string
Explicit and Implicit Type Changes
null, true, and false are also reserved.
עקרונות תכנות מונחה עצמים תרגול 7: אנימציה
Drawing in Java.
Chapter 49 Java 2D.
Chapter 15 Multithreading
עקרונות תכנות מונחה עצמים תרגול 7: אנימציה
ITEC324 Principle of CS III
Presentation transcript:

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 4 2D Graphics: Advanced Topics

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 2 Objectives F To understand B-spline curves F To construct custom shape primitives F To apply basic image processing techniques F To create fractal images F To create 2D animation F To perform graphics printing

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 3 General Bezier Curve Bernstein basis

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 4 B-Spline Curve Normalized B-spline blending functions

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 5 B-Spline to Bezier Conversion Source Run

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 6 Shape Interface public boolean contains(Rectangle2D rect) public boolean contains(Point2D point) public boolean contains(double x, double y) public boolean contains(double x, double y, double w, double h) public Rectangle getBounds() public Rectangle2D getBounds2D() public PathIterator getPathIterator(AffineTransform at) public PathIterator getPathIterator(AffineTransform at, double flatness) public boolean intersects(Rectangle2D rect) public boolean intersects(double x, double y, double w, double h)

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 7 A Custom Primitive F Cannot extend the final class GeneralPath F Wrap a GeneralPath Source Run public class Heart implements Shape { GeneralPath path; public Heart(float x, float y, float w, float h) { path = new GeneralPath(); …

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 8 Image Processing F AWT – push model F Java 2D – immediate model F JAI – pull model

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 9 BufferedImage BufferedImage bi = new BufferedImage(300, 400, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = (Graphics2D)(bi.createGraphics()); g2.drawImage(image, 0, 0, new Component() {}); BufferedImage bi = ImageIO.read(file); Create Read Display

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 10 Operators Source Run

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 11 Raster and WritableRaster int[] getPixel(int x, int y, int[] data) float[] getPixel(int x, int y, float[] data) double[] getPixel(int x, int y, double[] data) int[] getPixels(int x, int y, int w, int h, int[] data) float[] getPixels(int x, int y, int w, int h, float[] data) double[] getPixels(int x, int y, int w, int h, double[] data) void setPixel(int x, int y, int[] data) void setPixel(int x, int y, float[] data) void setPixel(int x, int y, double[] data) void setPixels(int x, int y, int w, int h, int[] data) void setPixels(int x, int y, int w, int h, float[] data) void setPixels(int x, int y, int w, int h, double[] data)

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 12 Mandelbrot Set Source Run Iterations on the complex plane

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 13 Animation: Multi-threading Source Outline of a typical multi-threading animation Run public void paintComponent(Graphics g) { } public void run() { while(true) { repaint(); try { Thread.sleep(sleepTime); } catch (InterruptedException ex) {} }

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 14 Animation: Timer SourceRun Timer timer = new Timer(period, listener); timer.start(); public void actionPerformed(ActionEvent event) { } Outline of an animation with Timer

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 15 Cellular Automata SourceRun The iteration of the system proceeds by assigning the next state of each cell based on the previous configuration. Each cell follows the same set of rules and the new state depends only upon the current states of the same cell and its neighbors. Example: A cell is black if exactly one of its neighbors in the current configuration is black

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 16 Printing F PrintJob –getPrintJob –printDialog –setPrintable –print F Printable –Print F PageFormat –getOrientation –getWidth –getHeight –getImageableX –getImageableY –getImageableWidth –getImageableHeight SourceRun