6687298: Reg testcase java/awt/Graphics2D/DrawString/RotTransText.java fails on windows
Reviewed-by: igor, tdv
This commit is contained in:
parent
f82f310aba
commit
9e39cf49ed
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @bug 6683472
|
* @bug 6683472 6687298
|
||||||
* @summary Transformed fonts using drawString and TextLayout should be in
|
* @summary Transformed fonts using drawString and TextLayout should be in
|
||||||
* the same position.
|
* the same position.
|
||||||
*/
|
*/
|
||||||
@ -44,14 +44,15 @@ public class RotTransText {
|
|||||||
|
|
||||||
Graphics2D g2d = bi.createGraphics();
|
Graphics2D g2d = bi.createGraphics();
|
||||||
|
|
||||||
g2d.setColor(Color.white);
|
|
||||||
g2d.fillRect(0, 0, wid, hgt);
|
|
||||||
|
|
||||||
int x=130, y=130;
|
int x=130, y=130;
|
||||||
String s = "Text";
|
String s = "Text";
|
||||||
|
|
||||||
int xt=90, yt=50;
|
int xt=90, yt=50;
|
||||||
for (int angle=0;angle<360;angle+=30) {
|
for (int angle=0;angle<360;angle+=30) {
|
||||||
|
|
||||||
|
g2d.setColor(Color.white);
|
||||||
|
g2d.fillRect(0, 0, wid, hgt);
|
||||||
|
|
||||||
AffineTransform aff = AffineTransform.getTranslateInstance(50,90);
|
AffineTransform aff = AffineTransform.getTranslateInstance(50,90);
|
||||||
aff.rotate(angle * Math.PI/180.0);
|
aff.rotate(angle * Math.PI/180.0);
|
||||||
|
|
||||||
@ -69,20 +70,27 @@ public class RotTransText {
|
|||||||
fnt = fnt.deriveFont(attrMap);
|
fnt = fnt.deriveFont(attrMap);
|
||||||
TextLayout tl = new TextLayout(s, fnt, frc);
|
TextLayout tl = new TextLayout(s, fnt, frc);
|
||||||
tl.draw(g2d, (float)x, (float)y);
|
tl.draw(g2d, (float)x, (float)y);
|
||||||
}
|
|
||||||
// Test BI: should be no blue: only red and white.
|
// Test BI: should be minimal blue relative to red.
|
||||||
int red = Color.red.getRGB();
|
int redCount = 0;
|
||||||
int blue = Color.blue.getRGB();
|
int blueCount = 0;
|
||||||
int white = Color.white.getRGB();
|
int red = Color.red.getRGB();
|
||||||
for (int px=0;px<wid;px++) {
|
int blue = Color.blue.getRGB();
|
||||||
for (int py=0;py<hgt;py++) {
|
for (int px=0;px<wid;px++) {
|
||||||
int rgb = bi.getRGB(px, py);
|
for (int py=0;py<hgt;py++) {
|
||||||
if (rgb == blue || ( rgb != red && rgb != white)) {
|
int rgb = bi.getRGB(px, py);
|
||||||
throw new RuntimeException
|
if (rgb == red) {
|
||||||
("Unexpected color : " + Integer.toHexString(rgb) +
|
redCount++;
|
||||||
" at x=" + x + " y="+ y);
|
} else if (rgb == blue) {
|
||||||
|
blueCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (redCount == 0 || (blueCount/(double)redCount) > 0.1) {
|
||||||
|
throw new
|
||||||
|
RuntimeException("Ratio of blue to red is too great: " +
|
||||||
|
(blueCount/(double)redCount));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user