Results 1 to 4 of 4
  1. #1
    Tchoumo is offline Member
    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0

    Default converting double to pixel coordinates

    Hello,

    I want to draw a Line with DrawLine ().

    What I would like to make, it is from coordinates such as A (0,2) and B (6,9), to ask gDrawLine to draw me this right with these coordinates. However, gDrawLine use a system of pixel to represent it.

    As a result, for what I try to make, it is to create a function xToPixel, yToPixel so that the right coordinates A and B displays well in my window.

    In a way, that my Line is proportional in my JFrame

    Tracks? Thanks you
    Last edited by Tchoumo; 10-12-2013 at 02:41 PM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    3,329
    Rep Power
    5

    Default Re: converting double to pixel coordinates

    Where is your code? What is gDrawline and in what class is it defined?

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    Tchoumo is offline Member
    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0

    Default Re: converting double to pixel coordinates

    Edit : It's a simple DrawLine

    I want to do a translation coordinate/pixel.
    I display them in a JComponent.

    But the probleme is that I don't know how to do this conversion ..

    I tried to do a translation of my real coordinate to pixel coordinate I'm searching a function to calcul it using xMin , xMax, the width of my JComponent etc

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    3,329
    Rep Power
    5

    Default Re: converting double to pixel coordinates

    Please show your class definition and other relevant code. And (x,y) coordinates on a JComponent are pixels. And just so you know, Java doesn't have functions, it has methods.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

Similar Threads

  1. Replies: 1
    Last Post: 07-18-2012, 09:50 PM
  2. Converting Double to Int
    By Rahim2312 in forum New To Java
    Replies: 15
    Last Post: 05-02-2012, 05:58 PM
  3. converting double to pixel coordinates
    By mkj in forum New To Java
    Replies: 2
    Last Post: 02-05-2012, 06:43 PM
  4. Replies: 6
    Last Post: 11-02-2010, 04:14 PM
  5. Arc2D.Double coordinates
    By alley in forum Java 2D
    Replies: 2
    Last Post: 11-07-2007, 10:27 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
  •