• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Line inside a circle

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Marshal
Posts: 64704
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

[edit]Corrected line number[/edit]
 
Nathalie Monvoisin
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No i have not got any spelling error on line 54. i have to have a shape like Key attribute in ERD.
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tony Docherty. yeah i have a spelling problem :/ i will correct it
 
Rancher
Posts: 3051
22
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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);
 
Saloon Keeper
Posts: 3304
146
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!