Results 1 to 4 of 4

Thread: Drawing a point

  1. #1
    chappa is offline Member
    Join Date
    Dec 2009
    Posts
    19
    Rep Power
    0

    Default Drawing a point

    Hi,


    I have written a code that gives me the position of a planet in relation to the sun.

    What i get is the position x and the position y.

    now I would like to draw these positions in a window. The window I made is from the Graphics class.

    I am searching a method (like drawLine) but for points.


    Thanks in advance.

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    Java Code:
    Point p;
    g2.fill(new Ellipse2D.Double(p.x-1.5, p.y-1.5, 4, 4));

  3. #3
    dan409 is offline Member
    Join Date
    Dec 2009
    Posts
    1
    Rep Power
    0

    Default

    An ellipse is a good choice if you wish to give the planets some "volume" to be seen better.

    There does not seem to be a specific method to draw points. But you can use drawLine and make the two points in between which it would draw the line the same.
    g.drawLine(p.x, p.y, p.x, p.y);

  4. #4
    chappa is offline Member
    Join Date
    Dec 2009
    Posts
    19
    Rep Power
    0

    Default

    thanks to both of you.



    I got it sorted out with dans method!

Similar Threads

  1. Can someone point me to an example?
    By smhjr in forum New To Java
    Replies: 2
    Last Post: 08-27-2009, 11:38 PM
  2. Point System
    By Zosden in forum Suggestions & Feedback
    Replies: 2
    Last Post: 02-14-2009, 12:45 PM
  3. In which circle is the Point lying?
    By nidhirastogi in forum New To Java
    Replies: 1
    Last Post: 07-02-2008, 11:12 PM
  4. is it bug? or am i missing a point?
    By blowguy in forum Threads and Synchronization
    Replies: 1
    Last Post: 11-20-2007, 06:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •