LCDScale.java revision 3349
0N/A/*
470N/A * Copyright (c) 2010, 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 *
0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
0N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A *
0N/A * @bug 6925760
0N/A * @summary Scaled graphics causes overlapped LCD glyphs on Windows
0N/A */
0N/A
0N/Aimport java.awt.*;
0N/Aimport java.awt.font.*;
0N/Aimport java.awt.geom.*;
0N/A
0N/Apublic class LCDScale extends Component {
0N/A
0N/A public static void main(String args[]) {
0N/A Frame f = new Frame("TL TEST");
0N/A LCDScale td = new LCDScale();
0N/A f.add("Center", td);
0N/A f.pack(); f.setVisible(true);
0N/A }
0N/A
0N/A
0N/A public LCDScale() {
0N/A super();
0N/A }
0N/A
0N/A public Dimension getPreferredSize() {
0N/A return new Dimension(500,500);
0N/A }
0N/A
0N/A public void paint(Graphics g) {
0N/A Graphics2D g2d = (Graphics2D)g;
0N/A g2d.setRenderingHint(
0N/A RenderingHints.KEY_TEXT_ANTIALIASING,
0N/A RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
0N/A
0N/A Font f = new Font("Dialog", Font.PLAIN, 40);
0N/A g.setFont(f);
0N/A FontRenderContext frc = g2d.getFontRenderContext();
0N/A GlyphVector gv = f.createGlyphVector(frc, "Help");
0N/A g2d.drawGlyphVector(gv, 10f, 50f);
0N/A Rectangle2D bds1 = gv.getLogicalBounds();
0N/A
0N/A f = new Font("Arial", Font.PLAIN, 25);
0N/A g.setFont(f);
0N/A double s = 2.0;
0N/A AffineTransform tx = AffineTransform.getScaleInstance(s,s);
0N/A g2d.transform(tx);
0N/A frc = g2d.getFontRenderContext();
0N/A gv = f.createGlyphVector(frc, "Help");
0N/A g2d.drawGlyphVector(gv, 10f, 100f);
0N/A Rectangle2D bds2 = gv.getLogicalBounds();
0N/A
0N/A System.out.println(bds1);
0N/A System.out.println(bds2);
0N/A if (bds2.getWidth()*s < bds1.getWidth()) {
0N/A throw new RuntimeException("Bounds too small");
0N/A }
0N/A }
0N/A}
0N/A
0N/A
0N/A