Graphics2D g2d;
final AffineTransform trans = g2d.getDeviceConfiguration().getNormalizingTransform();
System.out.println(trans.getScaleX()*72+" DPI horizontally");
System.out.println(trans.getScaleY()*72+" DPI vertically");
You can set the transformation to the Graphics2D
to force 72 DPI or scale it to any other DPI using the ratio between your desired DPI and 72 DPI.