Đang chuẩn bị liên kết để tải về tài liệu:
Introduction to Java: 2- Simple Graphics
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'introduction to java: 2- simple graphics', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 2 In this chapter Graphics Point Dimension Shape Rectangle Polygon Image MediaTracker Simple Graphics This chapter digs into the meat of the AWT classes. After completing this chapter you will be able to draw strings images and shapes via the Graphics class in your Java programs. We discuss geometry-related classes Polygon Rectangle Point and Dimension and the Shape interface you will see these throughout the remaining AWT objects. You will also learn several ways to do smooth animation by using double buffering and the MediaTracker. After reading this chapter you should be able to do simple animation and image manipulation with AWT. For most applications this should be sufficient. If you want to look at AWT s more advanced graphics capabilities be sure to take a look at Chapter 12 Image Processing. 2.1 Graphics The Graphics class is an abstract class that provides the means to access different graphics devices. It is the class that lets you draw on the screen display images and so forth. Graphics is an abstract class because working with graphics requires detailed knowledge of the platform on which the program runs. The actual work is done by concrete classes that are closely tied to a particular platform. Your Java Virtual Machine vendor provides the necessary concrete classes for your environment. You never need to worry about the platform-specific classes once you have a Graphics object you can call all the methods of the Graphics class confident that the platform-specific classes will work correctly wherever your program runs. You rarely need to create a Graphics object yourself its constructor is protected and is only called by the subclasses that extend Graphics. How then do you get a 20 2.1 Graphics 21 Graphics object to work with The sole parameter of the Component.paint and Component.update methods is the current graphics context. Therefore a Graphics object is always available when you override a component s paint and update methods. You can ask for the