This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.

How can i draw a curve in java language ?
The figure show the curve i going to draw ....if i have coordinate, then how to draw the curve,
and i also need to draw the curve and link it to become a circle if i only have 3 coordinates as shown,
the other may need to do estimation to draw it.
Anyone have the best way to do so ?

I think that Graphics.drawArc can help you draw that line, but you will probably need to transform your coordinates a bit. That's where basic math comes in, with sin, cos and tan (which are all available in the Math class).

Consider this little example:
The rectangle is to indicate how the x, y width and height values work. As you see, they form a rectangle all around the oval (end angle == 360). Now all you need to do is take these three coordinates and calculate x, y, width, height, the start angle and the end angle (0 and 60 respectively in my example).

Here's a hint:
- calculate the angle between (x,y) and (x1,y1) using Math
- calculate the angle between (x,y) and (x2,y2) using Math
- calculate x3 for which (x3,y) would be on the oval, using Math
- calculate y3 for which (x,y3) would be on the oval, using Math
- calculate the width and x position for the arc using x and x3
- calculate the height and y position for the arc using y and y3
- draw the arc!

Rob Prime wrote:I think that Graphics.drawArc can help you draw that line, but you will probably need to transform your coordinates a bit. That's where basic math comes in, with sin, cos and tan (which are all available in the Math class).