3591 return new Point(0, 0); |
3591 return new Point(0, 0); |
3592 } |
3592 } |
3593 |
3593 |
3594 // ****************** END OF MIXING CODE ******************************** |
3594 // ****************** END OF MIXING CODE ******************************** |
3595 |
3595 |
3596 // This method gets the window location/size as reported by the native |
3596 /** |
3597 // system since the locally cached values may represent outdated data. |
3597 * Limit the given double value with the given range. |
3598 // NOTE: this method is invoked on the toolkit thread, and therefore |
3598 */ |
3599 // is not supposed to become public/user-overridable. |
3599 private static double limit(double value, double min, double max) { |
|
3600 value = Math.max(value, min); |
|
3601 value = Math.min(value, max); |
|
3602 return value; |
|
3603 } |
|
3604 |
|
3605 /** |
|
3606 * Calculate the position of the security warning. |
|
3607 * |
|
3608 * This method gets the window location/size as reported by the native |
|
3609 * system since the locally cached values may represent outdated data. |
|
3610 * |
|
3611 * The method is used from the native code, or via AWTAccessor. |
|
3612 * |
|
3613 * NOTE: this method is invoked on the toolkit thread, and therefore is not |
|
3614 * supposed to become public/user-overridable. |
|
3615 */ |
3600 private Point2D calculateSecurityWarningPosition(double x, double y, |
3616 private Point2D calculateSecurityWarningPosition(double x, double y, |
3601 double w, double h) |
3617 double w, double h) |
3602 { |
3618 { |
3603 return new Point2D.Double( |
3619 // The position according to the spec of SecurityWarning.setPosition() |
3604 x + w * securityWarningAlignmentX + securityWarningPointX, |
3620 double wx = x + w * securityWarningAlignmentX + securityWarningPointX; |
3605 y + h * securityWarningAlignmentY + securityWarningPointY); |
3621 double wy = y + h * securityWarningAlignmentY + securityWarningPointY; |
|
3622 |
|
3623 // First, make sure the warning is not too far from the window bounds |
|
3624 wx = Window.limit(wx, |
|
3625 x - securityWarningWidth - 2, |
|
3626 x + w + 2); |
|
3627 wy = Window.limit(wy, |
|
3628 y - securityWarningHeight - 2, |
|
3629 y + h + 2); |
|
3630 |
|
3631 // Now make sure the warning window is visible on the screen |
|
3632 Rectangle screenBounds = graphicsConfig.getBounds(); |
|
3633 Insets screenInsets = |
|
3634 Toolkit.getDefaultToolkit().getScreenInsets(graphicsConfig); |
|
3635 |
|
3636 wx = Window.limit(wx, |
|
3637 screenBounds.x + screenInsets.left, |
|
3638 screenBounds.x + screenBounds.width - screenInsets.right |
|
3639 - securityWarningWidth); |
|
3640 wy = Window.limit(wy, |
|
3641 screenBounds.y + screenInsets.top, |
|
3642 screenBounds.y + screenBounds.height - screenInsets.bottom |
|
3643 - securityWarningHeight); |
|
3644 |
|
3645 return new Point2D.Double(wx, wy); |
3606 } |
3646 } |
3607 |
3647 |
3608 static { |
3648 static { |
3609 AWTAccessor.setWindowAccessor(new AWTAccessor.WindowAccessor() { |
3649 AWTAccessor.setWindowAccessor(new AWTAccessor.WindowAccessor() { |
3610 public float getOpacity(Window window) { |
3650 public float getOpacity(Window window) { |