How to know the "real" distance between two point on the screen?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Sunday, September 18, 2005 02:25 AM

Hello, My program would like to known how far a point is from the left edge (and the top edge) of a canvas, the measurement unit is inch. For example, when I catch a mouse event and determine that the mouse position is (72, 72), which is the number of points counted from the left edge and the top edge (72 pixcels in the 1024x768 screen is different from 72 pixcels in 800x600 screen), how I translate these points into the actual distance (in inch)? In many java 2D documents, they say that 72 device units will be mapped into one inch. How should I understand this issue? Many thanks for your answers. I sorry if my question is so basic since I'm getting acquainted with java 2D.    More>>

Hello,


My program would like to known how far a point is from the left edge (and the top edge) of a canvas, the measurement unit is inch.


For example, when I catch a mouse event and determine that the mouse position is (72, 72), which is the number of points counted from the left edge and the top edge (72 pixcels in the 1024x768 screen is different from 72 pixcels in 800x600 screen), how I translate these points into the actual distance (in inch)?


In many java 2D documents, they say that 72 device units will be mapped into one inch. How should I understand this issue?


Many thanks for your answers. I sorry if my question is so basic since I'm getting acquainted with java 2D.


Bao.

   <<Less

Re: How to know the "real" distance between two point on the screen?

Posted By:   Almagest_FUTT  
Posted On:   Monday, September 19, 2005 01:44 AM

You have a method:
int getScreenResolution() (in dots per inch, check the javadoc)
in java.awt.Toolkit.

You access java.awt.Toolkit either via:
java.awt.Toolkit.getDefaultToolkit()
or
(instanceof java.awt.Component).getToolkit().
About | Sitemap | Contact