Cross Reference: LCDTextSrcEa.java
xref
: /
openjdk7
/
jdk
/
test
/
java
/
awt
/
Graphics2D
/
DrawString
/
LCDTextSrcEa.java
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
3271
N/A
/*
3271
N/A
* Copyright (c) 2010, Oracle
and
/
or
its affiliates. All rights reserved.
3271
N/A
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3271
N/A
*
3271
N/A
* This code is free software; you can redistribute it
and
/
or
modify it
3271
N/A
* under the terms of the GNU General Public License version 2 only, as
3271
N/A
* published by the Free Software Foundation.
3271
N/A
*
3271
N/A
* This code is distributed in the hope that it will be useful, but WITHOUT
3271
N/A
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3271
N/A
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3271
N/A
* version 2 for more details (a copy is included in the LICENSE file that
3271
N/A
* accompanied this code).
3271
N/A
*
3271
N/A
* You should have received a copy of the GNU General Public License version
3271
N/A
* 2 along with this work; if not, write to the Free Software Foundation,
3271
N/A
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3271
N/A
*
3271
N/A
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3271
N/A
* or visit www.oracle.com if you need additional information or have any
3271
N/A
* questions.
3271
N/A
*/
3271
N/A
3271
N/A
/**
3271
N/A
*
@test
3271
N/A
*
@bug
6996867
3271
N/A
*
@summary
Render as LCD Text in SrcEa composite mode.
3271
N/A
*/
3271
N/A
3271
N/A
import
java
.
awt
.*;
3271
N/A
import
java
.
awt
.
event
.*;
3271
N/A
import
java
.
awt
.
image
.*;
3271
N/A
3271
N/A
public
class
LCDTextSrcEa
extends
Component
{
3271
N/A
3271
N/A
static
int
SZ
=
150
;
3271
N/A
BufferedImage
target
=
3271
N/A
new
BufferedImage
(
SZ
,
SZ
,
BufferedImage
.
TYPE_INT_RGB
);
3271
N/A
3271
N/A
public
static
void
main
(
String
args
[]) {
3271
N/A
Frame
f =
new
Frame
(
"LCD Text SrcEa Test"
);
3271
N/A
f.
addWindowListener
(
new
WindowAdapter
() {
3271
N/A
@
Override
3271
N/A
public
void
windowClosing
(
WindowEvent
e) {
3271
N/A
System
.
exit
(
0
);
3271
N/A
}
3271
N/A
});
3271
N/A
LCDTextSrcEa
td
=
new
LCDTextSrcEa
();
3271
N/A
f.
add
(
"Center"
,
td
);
3271
N/A
f.
pack
();
3271
N/A
f.
setVisible
(
true
);
3271
N/A
}
3271
N/A
3271
N/A
public
Dimension
getPreferredSize
() {
3271
N/A
return
new
Dimension
(
SZ
,
SZ
);
3271
N/A
}
3271
N/A
3271
N/A
public
void
paint
(
Graphics
gx
) {
3271
N/A
3271
N/A
Graphics2D
g2d
= (
Graphics2D
)
target
.
getGraphics
();
3271
N/A
g2d
.
setColor
(
Color
.
white
);
3271
N/A
g2d
.
fillRect
(
0
,
0
,
getWidth
(),
getHeight
());
3271
N/A
3271
N/A
g2d
.
setComposite
(
AlphaComposite
.
getInstance
(
AlphaComposite
.
SRC
,
0.01f
));
3271
N/A
g2d
.
setRenderingHint
(
3271
N/A
RenderingHints
.
KEY_TEXT_ANTIALIASING
,
3271
N/A
RenderingHints
.
VALUE_TEXT_ANTIALIAS_LCD_VBGR
);
3271
N/A
g2d
.
setRenderingHint
(
3271
N/A
RenderingHints
.
KEY_ANTIALIASING
,
3271
N/A
RenderingHints
.
VALUE_ANTIALIAS_ON
);
3271
N/A
3271
N/A
g2d
.
setColor
(
Color
.
black
);
3271
N/A
g2d
.
drawString
(
"Some sample text."
,
10
,
20
);
3271
N/A
gx
.
drawImage
(
target
,
0
,
0
,
null
);
3271
N/A
boolean
nongrey
=
false
;
3271
N/A
//Test BI: should be some non-greyscale color
3271
N/A
for
(
int
px
=
0
;
px
<
SZ
;
px
++) {
3271
N/A
for
(
int
py
=
0
;
py
<
SZ
;
py
++) {
3271
N/A
int
rgb
=
target
.
getRGB
(
px
,
py
);
3271
N/A
int
r = (
rgb
&
0xff0000
) >>
16
;
3271
N/A
int
g = (
rgb
&
0x00ff00
) >>
8
;
3271
N/A
int
b = (
rgb
&
0x0000ff
);
3271
N/A
if
(r != g || r !=b || g != b) {
3271
N/A
nongrey
=
true
;
3271
N/A
break
;
3271
N/A
}
3271
N/A
}
3271
N/A
}
3271
N/A
if
(!
nongrey
) {
3271
N/A
throw
new
RuntimeException
(
"No LCD text found"
);
3271
N/A
}
3271
N/A
}
3271
N/A
}