Java 2D Graphics For example, you might place
Java 2D Graphics coordinates into 1 physical inch. Let’s say, for example, that you create a rectangle that is 144 User Space coordinates wide and 72 User Space coordinates high. The default transformation into Device Space for a monitor will map User Space directly to Device Space. Since monitors have (more or less) 72 pixels per inch, the rectangle will be 2 inches wide and 1 inch high. If you draw the same rectangle on a 300 DPI printer, the default transformation will convert the rectangle into a 600 by 300 pixel rectangle. The end result will still be a rectangle that is 2 inches wide and 1 inch high. In general, you don’t ever have to worry about the details of a particular device. Your applications live in User Space. As long as you remember that User Space, by default, has 72 coordinates per inch, Java 2D will ensure that everything is the right size on your output devices. Chapter 3. Geometry Java 2D allows you to represent any shape as a combination of straight and curved line segments. This chapter describes the Java 2D classes that represent geometric shapes. You’ll learn about the following topics: classes that represent points the two central interfaces for geometric shapes: Shape and PathIterator 2D’s toolbox of shapes in the java.awt.geom package 2D’s support for combining shapes with each other 3.1 Points The java.awt.geom.Point2D class encapsulates a single point (an x and a y) in User Space. It is the most basic of the Java 2D classes and is used throughout the API. Note that a point is not the same as a pixel. A pixel is a tiny square (ideally) on a screen or printer that contains some color. A point, by contrast, has no area, so it can’t be rendered. Points are used to build rectangles or other shapes that have area and can be rendered. Point2D demonstrates an inheritance pattern that is used throughout java.awt.geom. In particular, Point2D is an abstract class with inner child classes that provide concrete implementations. Figure 3.1 shows Point2D’s family tree. It’s a pattern that you’ll see again and again in the java.awt.geompackage. Figure 3.1. Point2D family of classes Point2D represents a point in User Space, but it doesn’t specify how the point’s coordinates are stored. The subclasses provide different levels of precision for storing the coordinates of the point. page 25
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services