• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Line inside a circle

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tony Docherty. yeah i have a spelling problem :/ i will correct it
 
Rancher
Posts: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
 
Bartender
Posts: 5465
212
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Onion rings are vegetable donuts. Taste this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic