ss: Move plugins to Trace Compass namespace
[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, 2013 IBM Corporation, Ericsson
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 - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
11 **********************************************************************/
12
13 package org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.impl;
14
15 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IFont;
16 import org.eclipse.swt.graphics.Font;
17 import org.eclipse.swt.graphics.FontData;
18 import org.eclipse.swt.widgets.Display;
19
20 /**
21 * Default implementation of the IFont interface.
22 *
23 * @version 1.0
24 * @author sveyrier
25 *
26 */
27 public class FontImpl implements IFont {
28
29 // ------------------------------------------------------------------------
30 // Attributes
31 // ------------------------------------------------------------------------
32
33 /**
34 * The font object
35 */
36 private final Font fFont;
37 /**
38 * Flag to indicate that this object is managing the resource.
39 */
40 protected boolean fManageFont = true;
41
42 // ------------------------------------------------------------------------
43 // Constructors
44 // ------------------------------------------------------------------------
45 /**
46 * Default constructor.
47 *
48 * @param display The display to use
49 * @param data A font data
50 */
51 public FontImpl(Display display, FontData data) {
52 fFont = new Font(display, data);
53 }
54
55 /**
56 * Copy constructor
57 *
58 * @param value A font to copy.
59 */
60 protected FontImpl(Font value) {
61 fFont = value;
62 fManageFont = false;
63 }
64
65 // ------------------------------------------------------------------------
66 // Methods
67 // ------------------------------------------------------------------------
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 @Override
79 public Object getFont() {
80 return fFont;
81 }
82
83 @Override
84 public void dispose() {
85 if (fFont != null) {
86 fFont.dispose();
87 }
88 }
89 }
This page took 0.035225 seconds and 5 git commands to generate.