< prev index next >
test/jdk/java/awt/Window/ShapedAndTranslucentWindows/Common.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 259,283 ****
Point location = window.getLocationOnScreen();
for (Point p : points) {
p.translate(location.x, location.y);
if (areBackgroundPoints) {
! if (!robot.getPixelColor(p.x, p.y).equals(BG_COLOR))
throw new RuntimeException("Background point " + p + " color " + robot.getPixelColor(p.x, p.y) +
" does not equal to background color " + BG_COLOR);
else
System.out.println("OK with background point " + p);
} else {
! if (robot.getPixelColor(p.x, p.y).equals(BG_COLOR))
throw new RuntimeException("Foreground point " + p +
" equals to background color " + BG_COLOR);
else
System.out.println("OK with foreground point " + p);
}
}
}
public void initBackgroundFrame() {
background = new Frame();
background.setUndecorated(true);
background.setBackground(BG_COLOR);
background.setSize(500, 500);
--- 259,294 ----
Point location = window.getLocationOnScreen();
for (Point p : points) {
p.translate(location.x, location.y);
if (areBackgroundPoints) {
! if (!similarColors(robot.getPixelColor(p.x, p.y), BG_COLOR))
throw new RuntimeException("Background point " + p + " color " + robot.getPixelColor(p.x, p.y) +
" does not equal to background color " + BG_COLOR);
else
System.out.println("OK with background point " + p);
} else {
! if (similarColors(robot.getPixelColor(p.x, p.y), BG_COLOR))
throw new RuntimeException("Foreground point " + p +
" equals to background color " + BG_COLOR);
else
System.out.println("OK with foreground point " + p);
}
}
}
+ public static boolean similarColors(final Color c1, final Color c2) {
+ if((Math.abs(c1.getRed() - c2.getRed()) < 40) &&
+ (Math.abs(c1.getBlue() - c2.getBlue()) < 40) &&
+ (Math.abs(c1.getGreen() - c2.getGreen()) < 40)) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
public void initBackgroundFrame() {
background = new Frame();
background.setUndecorated(true);
background.setBackground(BG_COLOR);
background.setSize(500, 500);
< prev index next >