]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-before/internal compatibility/org/eclipse/jdt/internal/ui/util/PixelConverter.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / internal compatibility / org / eclipse / jdt / internal / ui / util / PixelConverter.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2010 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.ui.util;
12
13 import org.eclipse.swt.graphics.Font;
14 import org.eclipse.swt.graphics.FontMetrics;
15 import org.eclipse.swt.graphics.GC;
16 import org.eclipse.swt.widgets.Control;
17
18 import org.eclipse.jface.dialogs.Dialog;
19
20
21 /**
22  * DO NOT REMOVE, used in a product.
23  * @deprecated As of 3.5, replaced by {@link org.eclipse.jface.layout.PixelConverter}
24  */
25 public class PixelConverter {
26
27         private final FontMetrics fFontMetrics;
28
29         public PixelConverter(Control control) {
30                 this(control.getFont());
31         }
32
33         public PixelConverter(Font font) {
34                 GC gc = new GC(font.getDevice());
35                 gc.setFont(font);
36                 fFontMetrics= gc.getFontMetrics();
37                 gc.dispose();
38         }
39
40         /*
41          * see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int)
42          */
43         public int convertHeightInCharsToPixels(int chars) {
44                 return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
45         }
46
47         /*
48          * see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int)
49          */
50         public int convertHorizontalDLUsToPixels(int dlus) {
51                 return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus);
52         }
53
54         /*
55          * see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int)
56          */
57         public int convertVerticalDLUsToPixels(int dlus) {
58                 return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus);
59         }
60
61         /*
62          * see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int)
63          */
64         public int convertWidthInCharsToPixels(int chars) {
65                 return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);
66         }
67
68 }