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();
}
}