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

(singke) #1
ptg7068951

341


Q&A


Q. How can I draw arcs that go clockwise rather than counterclockwise?
A. Yo u c a n a c c o m p l i s h t h i s by s p e c i f y i n g t h e s i z e o f t h e a r c a s a n e g a t i v e
number. The arc begins at the same point,but goes in the opposite
direction in an elliptical path. For example,the following statement draws
an open arc at (35,20) that is 90 degrees long,begins at the 0 degree
mark,goes clockwise,and has a height of 20 and a width of 15:

Arc2D.Float smile = new Arc2D.Float(35F, 20F, 15F, 20F,
0F, -90F, Arc2D.Float.OPEN);

Q. Ellipses and circles don’t have corners. What are the (x,y) coordinates
specified with the Ellipses.Floatconstructor method?
A. The (x,y) coordinates represent the smallest x value and smallest y
value of the oval or circle. If you drew an invisible rectangle around it,
the upper-left corner of the rectangle would be the x and y coordinates
used as arguments to the method.

Q. How can I use XRender with Java?
A. Java 7 adds support for drawing Java2D graphics with the XRender ren-
dering engine in X11-based environments,typically on Linux. This func-
tionality is off by default and must be turned on using a command-line
option:Dsun.java2d.xrender=true. XRender enables Java programs to
employ the capabilities of modern graphics processing units (GPUs).
In NetBeans,you can set these options by choosing Run,Set Project
Configuration,Customize. Use the VM Options field to set this option
and click OK.

Q. Why do photographers ask you to say “cheese”?
A. The word cheese forces your mouth into a smile,as do the words
“whiskey,” “breeze,” and “money.” Words that end with a long “e” gener-
ally cause the sides of your lips to curl upward and your teeth to show.
Another word that photographers sometimes use is “grin.” Though it
doesn’t end in an “e,” it contorts the mouth and the meaning makes
people smile.

Workshop


Te s t w h e t h e r y o u r f o n t a n d c o l o r s k i l l s a r e M A H - v e - l o u s by a n s we r i n g t h e
following questions.


Workshop
Free download pdf