Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# Line inside a circle

Nathalie Monvoisin
Ranch Hand
Posts: 50
Hello everyone
I want to draw a line inside a circle, i what to have a horizontal line.
Here is what i have done so far.
can you tell me whats wrong
thank you

Campbell Ritchie
Sheriff
Posts: 50714
83
I still think you should move back into the realms of object orientation. Also that a circle and a line are usually separate shapes, so you might do well to draw them separately.

You should tell us what goes wrong and what you expected, then we can consider it.
Can you add a circle to a general path at all? Why have you got a spelling error on line 55 54?

Corrected line number[/edit]

Nathalie Monvoisin
Ranch Hand
Posts: 50
No i have not got any spelling error on line 54. i have to have a shape like Key attribute in ERD.

Tony Docherty
Bartender
Posts: 3048
59
Nathalie Monvoisin wrote:No i have not got any spelling error on line 54. i have to have a shape like Key attribute in ERD.

It looks like something is mis-spelled to me.

As to your problem, the constructor for Line2D.Float takes the x and y start location and the x and y end location of the line. If you want a horizontal line the start and end y values must be the same.

Nathalie Monvoisin
Ranch Hand
Posts: 50
Thanks Tony Docherty. yeah i have a spelling problem :/ i will correct it

Rob Camick
Ranch Hand
Posts: 2639
9
• 1
I want to draw a line inside a circle, i what to have a horizontal line.

Basic math. You know the top/left point where the oval is painted and you know the with height of the oval.

So the starting point of the line will be:

(x, y + height / 2);

and the ending point will be:

(x + width, y + height / 2);

Piet Souris
Rancher
Posts: 1403
29
• 1
hi Nathalie,

I've made a small example of a shape containing a circle and an arrow, and rotating and
drawing it a couple of times. It looks much like your code, but maybe you see one or two
things that might be useful. I use "natural" coordinates for the shape, and set up the
scaling, position and scaling just before drawing. The idea is to use coordinates in your
shape that are natural to that shape. That makes things sometimes much easier.

Greetz,
Piet