Archived

This topic is now archived and is closed to further replies.

[java] drawing 2D lines with floating points

This topic is 5422 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m creating a GUI where I need to draw a graph using floating point numbers. The problem is that the Graphics class in the awt package only has DrawLine(int,int,int,int) Does anyone know what I could use to get a more precise line?

Share this post


Link to post
Share on other sites
Off the top of my head:

Perhaps you could increase the scale of the integers, such that "36" on the screen actually represents 3.6 logically.

Exactly how precise does the graph have to be? If you are simply drawing a line, find two points that correspond to integer positions and voila!

It might be worth trying to simply cast the values as ints and see if the results are any good - if the difference is not noticible, well hey! Problem solved!

Share this post


Link to post
Share on other sites
Hi,

IMO if the lines are to be drawn to a display that consists of a rectangular area filled with distinct light emitting dots, you''ll be forced to round your "floating point" lines into an integer space.


Petr Stedry

Share this post


Link to post
Share on other sites