Java Reference
In-Depth Information
Figure 6.8 This diagram shows a portion of the java.awt.geom package hierarchy.
The java.awt.Shape interface is implemented by the non-abstract classes
(rectangles) and abstract classes (parallelograms). Each of the abstract ā€œ2Dā€ classes
contains nested non-abstract Float and Double subclasses as shown here only for
Line2D .
The ellipse drawn fits inside a rectangle with upper left corner at (x, y)
(25.0,
25.0) and with width 100.0 and height 100.0. Since this rectangle is really a
square (width
=
=
=
100.0), the ellipse is a circle.
This may seem a lot of work but remember that for simple one pixel wide
primitives you can still use the simpler Graphics methods. Also, some settings,
such as the RenderingHints , are normally set just once at the start of your
paintComponent() method.
height
6.8.3 Drawing demo
The following subclass of JPanel illustrates some of the techniques discussed
above. The Graphics2D object is cast from the Graphics object. Anti-aliasing
Search WWH ::




Custom Search