June 2005
Beginner to intermediate
336 pages
6h 29m
English
Another type of figure you can draw using the Graphics2D methods is the rounded rectangle, where the corners are rounded. If the user wants to draw rounded rectangles, you can use the RoundRectangle2D.Double class, whose constructor is just like the Rectangle2D.Double class, except that it also takes two values giving the X and Y radius you want to use for rounding the corners. Painter sets those radii to 10 pixels:
if(rounded && width != 0 && height != 0){
RoundRectangle2D.Double round =
new RoundRectangle2D.Double(tempStart.x,
tempStart.y, width, height, 10, 10);
.
.
.
After you've created the figure you want to draw, you can apply various effects as before, if required:
if(shadow){ paint = gImage.getPaint(); composite ...Read now
Unlock full access