0c2dac1326650f5d07b53cb9a830103203965fc0
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / drawings / impl / FontImpl.java
1 /**********************************************************************
2 * Copyright (c) 2005, 2008 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
4 *
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
9 *
10 * Contributors:
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.impl;
15
16 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IFont;
17 import org.eclipse.swt.graphics.Font;
18 import org.eclipse.swt.graphics.FontData;
19 import org.eclipse.swt.widgets.Display;
20
21 /**
22 * Default implementation of the IFont interface.
23 *
24 * @version 1.0
25 * @author sveyrier
26 *
27 */
28 public class FontImpl implements IFont {
29
30 // ------------------------------------------------------------------------
31 // Attributes
32 // ------------------------------------------------------------------------
33
34 /**
35 * The font object
36 */
37 protected Font font = null;
38 /**
39 * Flag to indicate that this object is managing the resource.
40 */
41 protected boolean manageFont = true;
42
43 // ------------------------------------------------------------------------
44 // Constructors
45 // ------------------------------------------------------------------------
46 /**
47 * Default constructor.
48 *
49 * @param display The display to use
50 * @param data A font data
51 */
52 public FontImpl(Display display, FontData data) {
53 font = new Font(display, data);
54 }
55
56 /**
57 * Copy constructor
58 *
59 * @param value A font to copy.
60 */
61 protected FontImpl(Font value) {
62 font = value;
63 manageFont = false;
64 }
65
66 // ------------------------------------------------------------------------
67 // Methods
68 // ------------------------------------------------------------------------
69 /**
70 * Returns a font implementation based system font.
71 *
72 * @return a font implementation based system font.
73 */
74 public static FontImpl getSystemFont() {
75 return new FontImpl(Display.getDefault().getSystemFont());
76 }
77
78 /*
79 * (non-Javadoc)
80 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IFont#getFont()
81 */
82 @Override
83 public Object getFont() {
84 return font;
85 }
86
87 /*
88 * (non-Javadoc)
89 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IFont#dispose()
90 */
91 @Override
92 public void dispose() {
93 if (font != null) {
94 font.dispose();
95 }
96 }
97 }
This page took 0.031627 seconds and 5 git commands to generate.