Java 2D Graphics line segments and multiple sub-shapes,
Java 2D Graphics A related set of methods tests to see if any part of a rectangle intersects the interior of the Shape: public abstract boolean intersects(double x, double y, double w, double h) public abstract boolean intersects(Rectangle2D r) These methods return true if any part of the given rectangle is in the interior of the Shape. Finally, a Shape can describe its own outline, using the getPathIterator() methods. These methods return a PathIterator, which I’ll talk about later in this chapter. For now, just think of it as an object that describes a geometric outline. The getPathIterator() methods accept a transform object that can be used to move, rotate, or otherwise modify the PathIterator that is returned. I’ll cover transformations in detail in Chapter 5. public abstract PathIterator getPathIterator(AffineTransform at) This method returns a PathIterator representing the Shape’s outline, transformed by the given AffineTransform. You can pass null for this parameter if you don’t wish to transform the outline. public abstract PathIterator getPathIterator(AffineTransform at, double flatness) This method returns a flattened PathIterator representing the Shape’s outline, transformed by the given transform. A flattened path contains only straight line segments. The flatness parameter is the maximum allowed distance from the original path to the flattened version of the path. You’ll probably never have to call this method yourself. (See the sidebar.) Flattened Shapes A flattened path is a path whose curved line segments have been approximated by multiple straight line segments. Your Graphics2D implementation may not be able to draw or fill shapes with curved line segments, so a flattened path may be used to render shapes that have curved line segments. In fact, the 2D API includes a class, java.awt.geom.FlatteningPathIterator, that does the work of flattening a path. Normally, path flattening happens behind the scenes, and you won’t ever have to worry about the details. All the geometric classes in Java 2D implement the Shape interface, as illustrated in Figure 3.3. Directly or indirectly, every geometric class in Java 2D implements the Shape interface. This means that they can all be passed to Graphics2D’s draw() and paint() methods. Figure 3.3. The Shape interface and its progeny page 29
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services