Presentation is loading. Please wait.

Presentation is loading. Please wait.

UMass Lowell Computer Science 91.460 Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 14 Java Fundamentals 2D Graphics Wed. 10/11/00.

Similar presentations


Presentation on theme: "UMass Lowell Computer Science 91.460 Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 14 Java Fundamentals 2D Graphics Wed. 10/11/00."— Presentation transcript:

1 UMass Lowell Computer Science 91.460 Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 14 Java Fundamentals 2D Graphics Wed. 10/11/00

2 Homework #4 1 Fri, 9/8 Fri, 9/15 Part 1 Mon, 9/18 Part 2 Mon, 9/18 Part 2 2Fri, 9/15 Fri, 9/22 Part 1 & Part 2 3Fri, 9/22 Fri, 9/29Part 1 & Part 2 4Fri, 10/6Fri, 10/13Part 1 & Part 2 HW# Assigned Due Content We’ll discuss any questions about HW#4 at end of lecture.

3 Exam 1: To be returned today

4 2D Graphics

5 Some Java Graphics Class Libraries (partial taxonomy) javax.swing JApplet JOptionPane  java.awt  Component Graphics JLabel JButton JFrame Graphics2D abstract Component  JColorChooser

6 Graphics Context ä Can draw from within an applet or application ä Graphics context: allows drawing on screen ä contains state of graphics drawing environment ä drawing color, “pen position”, window size, etc.

7 Java Abstract Windowing Toolkit Some Graphics Methods (from java.awt package) ä java.awt.Graphics (see list on p. 530-531) ä Given an object g of Graphics class: ä g.setColor( Color.red ); // Sets current drawing color to red ä g.drawString(“hello”, 200, 25); // Draws String starting at (200,25) ä g.drawLine(20, 28, 40, 10 ); // Draws line from (20,28) to (40,10) ä g.fillRect(100, 5, 20, 15); // Draws filled rectangle whose upper left // corner is at (100, 5). Width = 20. Height = 15 // corner is at (100, 5). Width = 20. Height = 15 ä g.drawOval(60, 9, 20, 13); // Draws oval whose bounding box upper left // corner is at (60, 9). Width = 20. Height = 13 // corner is at (60, 9). Width = 20. Height = 13 (0,0)x y hello usescurrentcolor

8 Drawing Arcs ä Given an object g of Graphics class: ä g.drawArc( x, y, width, height, startAngle, arcAngle ); ä // Arc is part of an oval ä // Arc sweeps starting at startAngle (0 degrees is at +x 90 is at +y). ä // ArcAngle is amount of sweep in degrees (CCW is positive CW is negative). ä // Arc’s bounding box has top-left corner at (x,y) and has width, height (0,0)xy width height (x,y)

9 Java Color Model ä RGB model is additive ä RGB unit cube: Magenta= (1,0,1) Black = (0,0,0) White = (1,1,1) Shades of gray Blue= (0,0,1) Red= (1,0,0) Green= (0,1,0)Cyan= (0,1,1) Yellow= (1,1,0)

10 Java Color Model (continued) ä Perceptual Term ä Hue ä distinguishes among colors such as red, green, blue, yellow... ä Saturation ä distance from gray of equal intensity ä Brightness ä perceived intensity of s self- luminous object Source: Foley & van Dam, 2nd edition ä Colorimetry (physics) ä Dominant wavelength ä Excitation purity ä Luminance

11 Graphics Demos Deitel Code (Chapter 11)

12 Graphics (appletviewer) Demos - jdk1.2.2\demo\jfc\Java2D - jdk1.2.2\demo\applets\GraphicsTest

13 Graphics Demos Random (multi-threaded) Waves

14 HW#4 Demo Program Mobile Communications Class & Interface Hierarchy Any questions?

15 Mobile Communications Class & Interface Hierarchy

16 Exam 1: Return Graded Exams & Solution


Download ppt "UMass Lowell Computer Science 91.460 Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 14 Java Fundamentals 2D Graphics Wed. 10/11/00."

Similar presentations


Ads by Google