Corporate identity through graphic design - DiVA - Simple search
Lecture 3 A First Graphic Program. Features of a simple graphic program.
-
Upload
spencer-thrift -
Category
Documents
-
view
214 -
download
0
Transcript of Lecture 3 A First Graphic Program. Features of a simple graphic program.
![Page 1: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/1.jpg)
Lecture 3A First Graphic Program
![Page 2: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/2.jpg)
Features of a simple graphic program
![Page 3: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/3.jpg)
Features of a simple graphic program• Gapp and Gcanvas are ours – Are New
Developed.• Inherited from JFrame and panel which are part of
the Java Foundation Classes - in particular they are part of the swing” GUI components.
• when a Gapp object is created, a new GUI window appears on the screen.
![Page 4: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/4.jpg)
Features of a simple graphic program• A Gcanvas/JPanel is simply something we can
draw on, but it isn’t allowed to be on screen by itself, it must be part of a JFrame. So what we actually need is an instance of Gapp with an instance of Gcanvas “inside” it (Figure 23).
![Page 5: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/5.jpg)
simple graphic program – Main()• Main() The main entry point for the system is in
class Gapp.
![Page 6: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/6.jpg)
simple graphic program- initComponents() • sets the window’s screen position and size • (lines 22,23), sets up some Java apparatus to allow the
program to shut down cleanly.• (lines 27-31) and creates an instance of a Gcanvas (graphics
canvas) .• line 25. This GCanvas object is “added” to the Gapp object
and hence becomes part of that window.
![Page 7: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/7.jpg)
simple graphic program- Paintcomponent()• it is passed a Graphics object (“g”) - line 12. • drawLine() which is a member of the Graphics class. • The Graphics class is part of the standard Java class library
and its member functions are termed “graphics primitives”.• There exist a whole range of methods for drawing and
coloring in a variety of shapes (boxes, polygons, ovals etc.) • Take a look at the Java API documentation for full details.
![Page 8: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/8.jpg)
simple graphic program- Paintcomponent()
The drawLine() method takes 4 parameters, x1, y1, x2, y2 which represent the start and end points of the line you wish to draw.
![Page 9: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/9.jpg)
First Program
![Page 10: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/10.jpg)
First Program
![Page 11: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/11.jpg)
First Program
![Page 12: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/12.jpg)
First Program
![Page 13: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/13.jpg)
First Program - Running
![Page 14: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/14.jpg)
Graphics Primitives• A graphics primitive is a drawing function which the
system makes available to the applications programmer. Example is the Java “drawLine()” method.
![Page 15: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/15.jpg)
Graphics Primitives
![Page 16: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/16.jpg)
Graphics Primitives
![Page 17: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/17.jpg)
Graphics Primitives
![Page 18: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/18.jpg)
Graphics Primitives
![Page 19: Lecture 3 A First Graphic Program. Features of a simple graphic program.](https://reader036.fdocuments.in/reader036/viewer/2022062511/551bba1a550346be588b4606/html5/thumbnails/19.jpg)