Chapter 11 Graphics and Java2D 623 Positive angles (Make web site)
Chapter 11 Graphics and Java2D 623 Positive angles Negative angles 90 90 180 0 180 0 270 270 Fig. 11.17Positive and negative arc angles. 11.17 Method Description public void drawArc( int x, int y, int width, int height, int startAngle, int arcAngle ) Draws an arc relative to the bounding rectangle s top-left coordinates (x, y) with the specified widthand height. The arc segment is drawn starting at startAngle and sweeps arcAngle degrees. public void fillArc( int x, int y, int width, int height, int startAngle, int arcAngle ) Draws a solid arc (i.e., a sector) relative to the bounding rectangle s top-left coordinates (x, y) with the specified widthand height. The arc segment is drawn starting at startAngle and sweeps arcAngle degrees. Fig. 11.18 Graphicsmethods for drawing arcs. The program of Fig. 11.19 demonstrates the arc methods of Fig. 11.18. The program draws six arcs (three unfilled and three filled). To illustrate the bounding rectangle that helps determine where the arc appears, the first three arcs are displayed inside a yellow rectangle that has the same x, y, widthand heightarguments as the arcs. 1 // Fig. 11.19: DrawArcs.java 2 // Drawing arcs 3 4 // Java core packages 5 import java.awt.*; 6 import java.awt.event.*; 7 8 // Java extension packages 9 import javax.swing.*; 10 11 public class DrawArcs extends JFrame { 12 Fig. 11.19 Demonstrating drawArcand fillArc(part 1 of 3). Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/7/01