Sams Teach Yourself Java™ in 24 Hours (Covering Java 7 and Android)

(singke) #1
ptg7068951

340 HOUR 23:Creating Java2D Graphics


Summary
By using fonts, colors and graphics, you can draw more attention to ele-
ments of your programs and make them more compelling for users.
Drawing something using the shapes available with Java might seem like
more trouble than it’s worth. However, graphics depicted with polygons
have two advantages over graphics that are loaded from image files:

. Speed—Even a small graphic, such as an icon, would take longer to
load and display than a series of polygons.
. Scaling—You can change the size of an entire image that uses poly-
gons simply by changing the values to create it. For example, you
could add a function to the Signclass that multiplies all (x,y) points
in each shape by two before they are created, and it would result in
an image twice as large. Polygon images scale much more quickly
than image files and produce better results.

Free download pdf