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