metric parameters

I want to paint lines with a specified metric length (say 5cm), no mather what the resolution and the size of the target screen is.
In the Java-API I found GraphicsConfiguration.getNormalizingTransform() which should provide me with a transformation for the user space to make it 72 units on user space/1 inch on screen. However, the test class I’ve written doesn’t seem to work as it always returns an identity transformation.

Also, I read that it doesn’t work anywhere because for example Windows always returns the same value no matter what the true resolution is.

Does anybody know how I could draw lines with exact length? It must be somehow possible.

I was testing on Windows 2000 with Detonator graphics drivers. My test class was:

public class g2dUnitTest extends Frame {

public void start() {
Graphics2D g = (Graphics2D)getGraphics();
GraphicsConfiguration gc = g.getDeviceConfiguration();

AffineTransform at = gc.getNormalizingTransform();
System.out.println(at.getScaleX()+" : "+at.getScaleY());
// returns 1.0 : 1.0

}

public static void main(String args[]) {
g2dUnitTest ut = new g2dUnitTest();
ut.setSize(640,480);
ut.setVisible(true);
ut.start();
}
}

Draw a line on the screen and ask the user to measure it and enter the value. Otherwise no, there is no way of finding the actual physical dimensions of the monitor. Well I suppose you could find the name/model and look up the size in a table of common monitors.

But there are programs (for example the ArcIMS Java Frontent) which display maps with scalebars, so there must be a possibility.

If you are displaying a scalebar and a map on the same screen then there is no need for real-world dimensions.

The scale line will distort in exactly the same way the map does.

sorry, i meant scales, not scalebars.

Try measuring those scales with a ruler, unless you are lucky they won’t match. The best solution is just to take the resolution you get from Toolkit.getScreenResolution and pretend that is the real value. It ought to be the value that the user actually wants which is better than being physically accurate.