PC Design and Liveliness Sabin Tabirca.


154 views
Uploaded on:
Description
PC Representation and Movement Sabin Tabirca Email: s.tabirca@cs.ucc.ie Phone: (490) 3662 Office: Brighton Manors, Sight and sound Building, Second Floor Contact Hours: Monday 11-13. Point of the Course: To present some PC Illustrations ideas utilizing Java. Targets of the Course:
Transcripts
Slide 1

PC Graphics and Animation Sabin Tabirca Email: s.tabirca@cs.ucc.ie Phone: (490) 3662 Office: Brighton Villas, Multimedia Building, Second Floor Contact Hours: Monday 11-13. Point of the Course: To present some Computer Graphics ideas utilizing Java. Goals of the Course: -To give some negligible Java abilities for Multimedia Programming. - To present some Computer Graphics components. PC Graphics - Course 1.

Slide 2

Structure of the Course Introduction to Java Programming -Java essentials: information sorts, articulations, techniques, classes, … -The Java classes for Graphics: Graphics, Graphics2D, … -Elements of GUI configuration: awt/swing … Computer Graphics - Turtle Graphics and fractals -2D Graphics: Transformation s , 2D bends, … Animation and Games in Java Multimedia for Mobile gadgets Computer Graphics - Course 1.

Slide 3

References Java: Dietel & Dietel, Advanced/Java: How to Program, Prentince Hall, 2001. Steve Holzner, The Java Black Book, Coriolis Press, 2000. Throw Cavaness et. al , Using Java 2 Standard Edition,QUE Press, 2001 Graphics: V.D. Foley, Introduction to Computer Graphics, Addison-Wesley Publ. Dwindle Cooley, The embodiment of Computer Graphics, Prentice Hall Java + Graphics: J. Knudsen, Java 2D Graphics, O’Reilly Publ , 2000 . PC Graphics - Course 1.

Slide 4

Introduction to Java What is Java? It is more than a programming dialect. History: James Gosling 1990 - Green Project, Oak dialect 1993 - HotJava program Sun Microsystems: 1995 - Java 1.0, 1997 - Java 1.1, 1998 – Java 1.2 , 2002? Focal points [according to Sun Microsystems]: straightforward, article situated, WEB arranged , ordered, structural planning unbiased, multi-strung, waste gathered, strong, secure, and extensible . PC Graphics - Course 1.

Slide 5

JDK – Java Developers K it JDK is an accumulation of libraries and instruments. The Main Libraries: java.awt – realistic interfaces [java.awt.Graphics; java.awt.image, …] java.applet – applet java.io – info/yield java.math – science java.net – network java.sql – databases … Rule: Import the bundles you require. import java.awt.*; import java.applet.Applet; The primary devices: javac – compiler java – translator jre – runtime interpreter jdb – debugger javadoc – help producing appletviewer – execute an applet Computer Graphics - Course 1.

Slide 6

T he First Java Application Steps: Editing >> Compiling >> (Correcting Errors) >> Executing Step 1. Alter the java program FirstApplication (Notepad, Wordpad, Simple Text, …) Step 2. Gather the document FirstApplication.java (javac FirstApplication.java) Step 3. Execute the system (java FirstApplication.java) open class L1App1 { open static void fundamental( String args[] ){ System.out.println(“This is our first Java Application”) } } Rule : The record name ( L1App1 . j ava) and the class name ( L1App1 ) must be indistinguishable. PC Graphics - Course 1.

Slide 7

Computer Graphics - Course 1.

Slide 8

T he First Java Applet Steps: Editing >> Compiling >> (Correcting Errors) Editing the html document >> Executing the applet through a program (Internet Explorer …) Step 1. Alter the java applet FirstApplet.java (Notepad, Wordpad, Simple Text, …) Step 2. Aggregate the record FirstApplet.java (javac FirstApplet.java) Step 3. Alter the HTML document FirstApplet.html Step 4. Run the applet either by means of a program of appletviewer I mportant: The Java document name ( L1Appl1 . j ava) and the class name ( L1Appl1 ) must be indistinguishable . Brilliant Rule: Keep the same name for the HTML record. PC Graphics - Course 1.

Slide 9

Computer Graphics - Course 1.

Slide 10

The document L1Appl1 .java import java.applet.Applet; import java.awt.Graphics; open class L1Appl1 augments Applet{ open void paint( Graphics g){ g.drawString(“This is our first Java applet”, 30, 30); } The record L1Appl1 .html <HTLM> <BODY> <APPLET CODE= L1Appl1 .class, WIDTH=200, HEIGHT=200> </APPLET> </BODY> </HTLM> Computer Graphics - Course 1.

Slide 11

The Structure of a Java Applet 1. Import affirmation; import java.package.*;  import every one of the classes of bundle import java.package.Class;  import just the Class of bundle Golden Rule: Import every one of the bundles that the applet needs. 2. Develop the assemblage of MyApplet open class My Applet amplifies Applet{ open void paint( Graphics g){ … the assortment of strategy paint } Golden Rule of Names: classes  the first digit of words is top (e.g. MyApplet, Graphics, Applet, ..) variables, techniques  the first digit of words is top aside from the first word (e.g. paint, myOwnVariable, myOwnMethod,…) Computer Graphics - Course 1.

Slide 12

Applet 1. Draw a line Draw a line between (xInitial, yInitial) and (xFinal, yFinal). import java.applet.Applet; import java.awt.Graphics; open class L1Appl2 amplifies Applet { open void paint(Graphics g) { /announce and initialise the variables int xInitial,yInitial,xFinal,yFinal; xInitial=100; yInitial=100; xFinal=200; yFinal=200; g.drawString(“ T his is a line : “ , 50, 50); //lay down a meaningful boundary g.drawLine(xInitial,yInitial,xFinal,yFinal);/adhere to a meaningful boundary } }â  Remarks: drawString, drawLine are strategies for class Graphics. PC Graphics - Course 1.

Slide 13

Program 1. Total of 2 numbers. Discover the whole of two whole number numbers firstNr, secondNr. class SumT wo Num{ open static void principle( String args[] ){ int firstNr, secondNr, sumNrs ; //proclaim the numbers and total firstNr =1; secondNr =2; //instatement of the numbers sum Nrs = firstNr+secondNr ;/discover the aggregate System.out.println(“ whole = “ + total); } Remarks: String everything in “ ” is a string. String + Number = String System.out.println( str )  compose the string str and bounce another line. System.out.print (str )  compose the string str. Tenet: Declare and Initialise every variable of the applet. PC Graphics - Course 1.

Slide 14

Class Graphics is a bundle\'s piece awt ( a bstract w indow t oolkit). Design contains strategies: -to draw articles: drawString, drawRect, drawLine, drawOval, drawImage, … -to fill objects: fillRect, fillOval, fillPolygon. - get/set component of current Graphics: shading, textual style, … Find more data at http://java.sun.com/j2se/1.3/docs/programming interface/index.html . Go to awt + Graphics. In technique paint: -Declare the applet\'s variables. - Compute the applet\'s components. - Draw the objects of your applet. Class Graphics Computer Graphics - Course 1.

Slide 15

Applet 2. Draw a rectangle from (xInitial, yInitial) with (widthRect, heightRect) and discover data about its square and border. import java.applet.Applet; import java.awt.Graphics; open class L1Appl3 expands Applet { open void paint(Graphics g) { int xInitial,yInitial,widthRect,heightRect;/announce and instate the variables xInitial=100;yInitial=100; widthRect=200;heightRect=100; int perRect=2*widthRect+2*heightRect;/ascertain the edge and square int squareRect=widthRect*heightRect; g.drawString("The border is: "+perRect, 50, 50); g.drawString("The square is: "+squareRect, 50, 70); g.drawRect(xInitial,yInitial,widthRect,heightRect);/draw the rectangle } Draw a Rectangle Computer Graphics - Course 1.

Slide 16

Computer Graphics - Course 1.

Slide 17

Problems to Read: 1. Java Tutorial: The first roadster of Java. 2. Java by Example: Java Overview Applets to Write: Applet 1. Compose an applet to draw a String three times at (50,50), (50,100), (50, 150). Applet

Recommended
View more...