0N/A/*
3149N/A * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A */
0N/A
0N/A/**
1879N/A * @test
1879N/A * @bug 6576507
1879N/A * @summary Both lines of text should be readable
1879N/A * @run main/manual=yesno LCDTextAndGraphicsState
1879N/A */
1879N/Aimport java.awt.*;
1879N/Aimport java.awt.geom.*;
2772N/A
2772N/Apublic class LCDTextAndGraphicsState extends Component {
2772N/A
2772N/A String text = "This test passes only if this text appears SIX TIMES";
2772N/A
1879N/A public void paint(Graphics g) {
1879N/A
1879N/A Graphics2D g2d = (Graphics2D)g.create();
1879N/A g2d.setColor(Color.white);
1879N/A g2d.fillRect(0,0,getSize().width, getSize().height);
1879N/A
1879N/A test1(g.create(0, 0, 500, 200));
1879N/A test2(g.create(0, 200, 500, 200));
1879N/A test3(g.create(0, 400, 500, 200));
2772N/A }
1879N/A
1879N/A public void test1(Graphics g) {
1879N/A Graphics2D g2d = (Graphics2D)g;
1879N/A g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
1879N/A RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
1879N/A g2d.setColor(Color.black);
1879N/A g2d.drawString(text, 10, 50);
1879N/A g2d.setComposite(AlphaComposite.getInstance(
1879N/A AlphaComposite.SRC_OVER, 0.9f));
1879N/A g2d.drawString(text, 10, 80);
3695N/A }
1879N/A
1879N/A public void test2(Graphics g) {
1879N/A Graphics2D g2d = (Graphics2D)g;
1879N/A g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
1879N/A RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
4141N/A g2d.setColor(Color.black);
1879N/A g2d.drawString(text, 10, 50);
1879N/A g2d.setPaint(new GradientPaint(
1879N/A 0f, 0f, Color.BLACK, 100f, 100f, Color.GRAY));
1879N/A g2d.drawString(text, 10, 80);
1879N/A }
1879N/A
1879N/A public void test3(Graphics g) {
1879N/A Graphics2D g2d = (Graphics2D)g;
1879N/A g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
1879N/A RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
1879N/A g2d.setColor(Color.black);
1879N/A g2d.drawString(text, 10, 50);
1879N/A Shape s = new RoundRectangle2D.Double(0, 60, 400, 50, 5, 5);
1879N/A g2d.clip(s);
1879N/A g2d.drawString(text, 10, 80);
1879N/A }
2258N/A
1879N/A public Dimension getPreferredSize() {
1879N/A return new Dimension(500,600);
1879N/A }
1879N/A
1879N/A public static void main(String[] args) throws Exception {
1879N/A
1879N/A Frame f = new Frame("Composite and Text Test");
1879N/A f.add(new LCDTextAndGraphicsState(), BorderLayout.CENTER);
1879N/A f.pack();
1879N/A f.setVisible(true);
1879N/A }
1879N/A}
1879N/A