O'Reilly logo

Java™ After Hours: 10 Projects You'll Never Do at Work by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Drawing Ellipses

If the ellipse flag is true, the user is drawing ellipses. Ellipses are a little more complex, because they can be filled in with color, texture, gradients, and so on. You can start by defining the ellipse the user wants to draw:

    if(ellipse && width != 0 && height != 0){

        Ellipse2D.Double ellipse =
            new Ellipse2D.Double(tempStart.x, tempStart.y,
            width, height);
.
.
.

If the shadow flag is set to true, the user wants to draw drop shadows, which you can do like this (note that if the ellipse is filled in, which means one of the solid, shade, transparent, or texture flags will be set to true, you should draw the shadow to match, which you do with the gImage context's fill method, not the draw method):

					if(shadow){
					paint = gImage.getPaint(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required