@@ -0,0 +1,3138 @@
+/*******************************************************************************%0D%0A * Copyright (c) 2015 Oak Ridge National Laboratory.%0D%0A * All rights reserved. This program and the accompanying materials%0D%0A * are made available under the terms of the Eclipse Public License v1.0%0D%0A * which accompanies this distribution, and is available at%0D%0A * http://www.eclipse.org/legal/epl-v10.html%0D%0A *******************************************************************************/%0D%0Apackage org.csstudio.display.builder.representation.javafx;%0D%0A%0D%0Aimport java.awt.BorderLayout;%0D%0Aimport java.awt.Font;%0D%0Aimport java.awt.Frame;%0D%0Aimport java.awt.Graphics2D;%0D%0Aimport java.awt.TextField;%0D%0Aimport java.awt.event.WindowAdapter;%0D%0Aimport java.awt.event.WindowEvent;%0D%0Aimport java.awt.geom.Rectangle2D;%0D%0Aimport java.awt.image.BufferedImage;%0D%0Aimport java.util.logging.Handler;%0D%0Aimport java.util.logging.Level;%0D%0Aimport java.util.logging.Logger;%0D%0A%0D%0Aimport org.csstudio.display.builder.representation.FontCalibration;%0D%0A%0D%0A/** Java AWT calibration%0D%0A *%0D%0A *  %3Cp%3ECan also be executed as demo%0D%0A *%0D%0A *  @author Kay Kasemir%0D%0A */%0D%0A@SuppressWarnings(%22nls%22)%0D%0Apublic class AWTFontCalibration implements Runnable, FontCalibration%0D%0A%7B%0D%0A    private final Logger logger = Logger.getLogger(getClass().getName());%0D%0A    final Font font = new Font(FontCalibration.FONT, Font.PLAIN, FontCalibration.SIZE);%0D%0A%0D%0A    @Override%0D%0A    public double getCalibrationFactor()%0D%0A    %7B%0D%0A        final BufferedImage buf = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);%0D%0A        final Graphics2D gc = buf.createGraphics();%0D%0A        gc.setFont(font);%0D%0A        final Rectangle2D measure = gc.getFontMetrics().getStringBounds(FontCalibration.TEXT, gc);%0D%0A        gc.dispose();%0D%0A%0D%0A        logger.log(Level.FINE,%0D%0A                   %22Font calibration measure: %22 + measure.getWidth() + %22 x %22 + measure.getHeight());%0D%0A        final double factor = FontCalibration.PIXEL_WIDTH / measure.getWidth();%0D%0A        logger.log(Level.CONFIG, %22JFX font calibration factor: %7B0%7D%22, factor);%0D%0A        return factor;%0D%0A    %7D%0D%0A%0D%0A    @Override%0D%0A    public void run()%0D%0A    %7B%0D%0A        Logger.getLogger(%22%22).setLevel(Level.CONFIG);%0D%0A        for (Handler handler : Logger.getLogger(%22%22).getHandlers())%0D%0A            handler.setLevel(Level.CONFIG);%0D%0A%0D%0A        final double factor = getCalibrationFactor();%0D%0A%0D%0A        final Frame frame = new Frame(%22Java AWT: Calibration factor %22 + factor);%0D%0A        frame.setLayout(new BorderLayout());%0D%0A        final TextField text = new TextField(FontCalibration.TEXT);%0D%0A        text.setFont(font);%0D%0A        text.setEditable(false);%0D%0A        frame.add(text, BorderLayout.CENTER);%0D%0A        frame.addWindowListener(new WindowAdapter()%0D%0A        %7B%0D%0A            @Override%0D%0A            public void windowClosing(WindowEvent windowEvent)%0D%0A            %7B%0D%0A                System.exit(0);%0D%0A            %7D%0D%0A        %7D);%0D%0A%0D%0A        frame.pack();%0D%0A        frame.setVisible(true);%0D%0A%0D%0A        if (Math.abs(factor - 1.0) %3E 0.01)%0D%0A            System.err.println(%22Calibration is not 1.0 but %22 + factor);%0D%0A    %7D%0D%0A%0D%0A    public static void main(final String%5B%5D args)%0D%0A    %7B%0D%0A        new AWTFontCalibration().run();%0D%0A    %7D%0D%0A%7D

Add AWT font calibration