< prev index next >
src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java
Print this page
@@ -36,10 +36,11 @@
import sun.util.logging.PlatformLogger;
import java.awt.geom.AffineTransform;
import sun.awt.*;
import sun.java2d.pipe.Region;
+import sun.swing.SwingUtilities2;
public class WWindowPeer extends WPanelPeer implements WindowPeer,
DisplayChangedListener
{
@@ -628,13 +629,46 @@
sysX = x;
sysY = y;
sysW = width;
sysH = height;
+ int cx = x + width / 2;
+ int cy = y + height / 2;
+ GraphicsConfiguration current = getGraphicsConfiguration();
+ GraphicsConfiguration other = SwingUtilities2.getGraphicsConfigurationAtPoint(current, cx, cy);
+ if (!current.equals(other)) {
+ AffineTransform tx = other.getDefaultTransform();
+ double otherScaleX = tx.getScaleX();
+ double otherScaleY = tx.getScaleY();
+ initScales();
+ if (scaleX != otherScaleX || scaleY != otherScaleY) {
+ x = sysX = (int) Math.floor(x * otherScaleX / scaleX);
+ y = sysY = (int) Math.floor(y * otherScaleY / scaleY);
+ }
+ }
+
super.setBounds(x, y, width, height, op);
}
+ private final void initScales() {
+
+ if (scaleX >= 1 && scaleY >= 1) {
+ return;
+ }
+
+ GraphicsConfiguration gc = getGraphicsConfiguration();
+ if (gc instanceof Win32GraphicsConfig) {
+ Win32GraphicsDevice gd = ((Win32GraphicsConfig) gc).getDevice();
+ scaleX = gd.getDefaultScaleX();
+ scaleY = gd.getDefaultScaleY();
+ } else {
+ AffineTransform tx = gc.getDefaultTransform();
+ scaleX = (float) tx.getScaleX();
+ scaleY = (float) tx.getScaleY();
+ }
+ }
+
@Override
public void print(Graphics g) {
// We assume we print the whole frame,
// so we expect no clip was set previously
Shape shape = AWTAccessor.getWindowAccessor().getShape((Window)target);
< prev index next >