KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > ui > parts > 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.update.internal.ui.parts;
12
13 import org.eclipse.jface.dialogs.Dialog;
14 import org.eclipse.swt.graphics.*;
15 import org.eclipse.swt.widgets.*;
16
17 public class PixelConverter {
18     
19     private FontMetrics fFontMetrics;
20     
21     public PixelConverter(Control control) {
22         GC gc = new GC(control);
23         gc.setFont(control.getFont());
24         fFontMetrics= gc.getFontMetrics();
25         gc.dispose();
26     }
27     
28     public int convertHeightInCharsToPixels(int chars) {
29         return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
30     }
31
32     public int convertHorizontalDLUsToPixels(int dlus) {
33         return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus);
34     }
35
36     public int convertVerticalDLUsToPixels(int dlus) {
37         return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus);
38     }
39     
40     public int convertWidthInCharsToPixels(int chars) {
41         return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);
42     }
43
44 }
45
46
Popular Tags