CSC 308 – Design Programming.

Uploaded on:
Category: Animals / Pets
CSC 308 – Representation Programming Say Howdy to Illustrations i.e.: An initially, straightforward design program Dr. Paige H. Meeker Software engineering Presbyterian School, Clinton, SC Address 2: Making Straightforward Representation in Java* Homework
Slide 1

CSC 308 – Graphics Programming Say Hi to Graphics i.e.: A to begin with, basic illustrations program Dr. Paige H. Meeker Computer Science Presbyterian College, Clinton, SC

Slide 2

Lecture 2: Creating Simple Graphics in Java* Homework * Material altered from “ Computer Graphics by means of Java ” by Ian Ferguson – online digital book and a pleasant download)

Slide 3

Features Main window Graphics canvas Some lines drawn

Slide 4

Let’s Say “Hi!”

Slide 5

Java’s Machinery with a specific end goal to draw things on screen (which is the thing that this is about) you need to have a lot of Java “machinery” set up before you can begin.

Slide 6

Gapp and Gcanvas are our own – we’re creating them. JFrame and JPanel from which they acquire, are a Java\'s piece Foundation Classes - specifically they are a piece of the “swing” GUI parts. The class Gapp acquires from JFrame so when a Gapp item is made, another GUI window shows up on the screen. A Gcanvas/JPanel is basically something we can draw on, however it isn’t permitted to be on screen without anyone else, it must be a piece of a JFrame. So what we really need is an occurrence of Gapp with a case of Gcanvas “inside” it

Slide 7

Gapp – fundamental() static open void main(String[] args) { //Main section point try { Gapp myGapp = new Gapp(); myGapp.initComponents(); myGapp.setVisible(true); } catch (Exception e) { e.printStackTrace(); } }//end primary

Slide 8

Gapp – initComponents() open void initComponents() tosses Exception { setLocation(new java.awt.Point(0, 30)); setSize(new java.awt.Dimension(350, 400)); setTitle("Graphics Application"); getContentPane().add(new Gcanvas()); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { thisWindowClosing(e); } }); }//end - initComponents

Slide 9

open void paintComponent(Graphics g) { g.drawLine(100,50,100,150); g.drawLine(100,100,150,100); g.drawLine(150,100,150,150); g.drawLine(200,150,200,100); g.drawLine(200,50,200,60); }

Slide 10

Upon Closer Examination… you may be asking, this system doesn’t really appear to call the paintComponent technique and where does it get “g” the Graphics object from? You are correct, it doesn’t. paintComponent is what is known as a “callback” strategy. It’s really called by the framework everytime the JPanel object it fits in with should be shown on screen and moreover the framework passes us the baffling “g” to give those helpful capacities - we don’t need to stress over it.

Slide 11

So, Our system “hi” is really a basic drawing of 5 lines, each with its own particular begin and end point. To draw utilizing this procedure, it’s most straightforward to make a matrix, mark it, and plot your focuses.

Slide 12

Graphics Primitives A representation primitive can be approximately characterized as a drawing capacity which the framework makes accessible to the applications software engineer. Java actualizes a far reaching arrangement of representation primitives. Let’s investigate their description…

Slide 13

Java Graphics Class API interface/

Slide 14

Homework: Due Wednesday, 8/30/06 Modify the code to draw a square. Make from this a “Swirling Square” as seen underneath.

Slide 15

Homework “Hint” This fundamentally draws a square, then a second square inside the initially diminished in size by 0.1 and somewhat pivoted. This proceeds for 4

View more...