Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Graphics2D/DrawString/LCDTextSrcEa.java
38828 views
1
/*
2
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/**
25
* @test
26
* @bug 6996867
27
* @summary Render as LCD Text in SrcEa composite mode.
28
*/
29
30
import java.awt.*;
31
import java.awt.event.*;
32
import java.awt.image.*;
33
34
public class LCDTextSrcEa extends Component {
35
36
static int SZ=150;
37
BufferedImage target =
38
new BufferedImage(SZ, SZ, BufferedImage.TYPE_INT_RGB);
39
40
public static void main(String args[]) {
41
Frame f = new Frame("LCD Text SrcEa Test");
42
f.addWindowListener(new WindowAdapter() {
43
@Override
44
public void windowClosing(WindowEvent e) {
45
System.exit(0);
46
}
47
});
48
LCDTextSrcEa td = new LCDTextSrcEa();
49
f.add("Center", td);
50
f.pack();
51
f.setVisible(true);
52
}
53
54
public Dimension getPreferredSize() {
55
return new Dimension(SZ,SZ);
56
}
57
58
public void paint(Graphics gx) {
59
60
Graphics2D g2d = (Graphics2D) target.getGraphics();
61
g2d.setColor(Color.white);
62
g2d.fillRect(0, 0, getWidth(), getHeight());
63
64
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 0.01f));
65
g2d.setRenderingHint(
66
RenderingHints.KEY_TEXT_ANTIALIASING,
67
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR);
68
g2d.setRenderingHint(
69
RenderingHints.KEY_ANTIALIASING,
70
RenderingHints.VALUE_ANTIALIAS_ON);
71
72
g2d.setColor(Color.black);
73
g2d.drawString("Some sample text.", 10, 20);
74
gx.drawImage(target, 0, 0, null);
75
boolean nongrey = false;
76
//Test BI: should be some non-greyscale color
77
for (int px=0;px<SZ;px++) {
78
for (int py=0;py<SZ;py++) {
79
int rgb = target.getRGB(px, py);
80
int r = (rgb & 0xff0000) >> 16;
81
int g = (rgb & 0x00ff00) >> 8;
82
int b = (rgb & 0x0000ff);
83
if (r != g || r !=b || g != b) {
84
nongrey=true;
85
break;
86
}
87
}
88
}
89
if (!nongrey) {
90
throw new RuntimeException("No LCD text found");
91
}
92
}
93
}
94
95