KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit > util > PixelConverter


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.junit.util;
12
13 import org.eclipse.swt.graphics.FontMetrics;
14 import org.eclipse.swt.graphics.GC;
15 import org.eclipse.swt.widgets.Control;
16
17 import org.eclipse.jface.dialogs.Dialog;
18
19 /*
20  * class copied from jdt ui
21  */

22 public class PixelConverter {
23     
24     private FontMetrics fFontMetrics;
25     
26     public PixelConverter(Control control) {
27         GC gc = new GC(control);
28         gc.setFont(control.getFont());
29         fFontMetrics= gc.getFontMetrics();
30         gc.dispose();
31     }
32     
33     /**
34      * @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int)
35      */

36     public int convertHeightInCharsToPixels(int chars) {
37         return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
38     }
39
40     /**
41      * @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int)
42      */

43     public int convertHorizontalDLUsToPixels(int dlus) {
44         return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus);
45     }
46
47     /**
48      * @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int)
49      */

50     public int convertVerticalDLUsToPixels(int dlus) {
51         return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus);
52     }
53     
54     /**
55      * @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int)
56      */

57     public int convertWidthInCharsToPixels(int chars) {
58         return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);
59     }
60
61 }
62
Popular Tags