448a916f40ec0dac4d9ecfb386b737daabb570d4
[public/netxms.git] / webui / webapp / swtchart / src / org / swtchart / internal / Util.java
1 /*******************************************************************************
2 * Copyright (c) 2008-2011 SWTChart project. All rights reserved.
3 *
4 * This code is distributed under the terms of the Eclipse Public License v1.0
5 * which is available at http://www.eclipse.org/legal/epl-v10.html
6 *******************************************************************************/
7 package org.swtchart.internal;
8
9 import org.eclipse.rap.rwt.graphics.Graphics;
10 import org.eclipse.swt.graphics.Font;
11 import org.eclipse.swt.graphics.Point;
12
13 /**
14 * A utility class providing generic methods.
15 */
16 public final class Util
17 {
18 /**
19 * Gets the text extent with given font in GC. If the given text or font is
20 * <code>null</code> or already disposed, point containing size zero will be
21 * returned.
22 *
23 * @param font
24 * the font
25 * @param text
26 * the text
27 * @return a point containing text extent
28 */
29 public static Point getExtentInGC(Font font, String text)
30 {
31 if (text == null || font == null || font.isDisposed())
32 {
33 return new Point(0, 0);
34 }
35
36 return Graphics.textExtent(font, text, 0);
37 }
38 }