Copyright header update, 2015 edition
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / views / uml2sd / drawings / impl / FontImpl.java
CommitLineData
73005152 1/**********************************************************************
ed902a2b 2 * Copyright (c) 2005, 2014 IBM Corporation, Ericsson
73005152
BH
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
c8422608
AM
7 *
8 * Contributors:
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
73005152 11 **********************************************************************/
c8422608 12
2bdf0193 13package org.eclipse.tracecompass.tmf.ui.views.uml2sd.drawings.impl;
73005152 14
73005152
BH
15import org.eclipse.swt.graphics.Font;
16import org.eclipse.swt.graphics.FontData;
17import org.eclipse.swt.widgets.Display;
2bdf0193 18import org.eclipse.tracecompass.tmf.ui.views.uml2sd.drawings.IFont;
73005152
BH
19
20/**
df0b8ff4 21 * Default implementation of the IFont interface.
c8422608 22 *
df0b8ff4 23 * @version 1.0
73005152 24 * @author sveyrier
c8422608 25 *
73005152
BH
26 */
27public class FontImpl implements IFont {
28
df0b8ff4
BH
29 // ------------------------------------------------------------------------
30 // Attributes
31 // ------------------------------------------------------------------------
c8422608 32
df0b8ff4
BH
33 /**
34 * The font object
35 */
cab6c8ff 36 private final Font fFont;
df0b8ff4
BH
37 /**
38 * Flag to indicate that this object is managing the resource.
39 */
eb63f5ff 40 protected boolean fManageFont = true;
73005152 41
df0b8ff4
BH
42 // ------------------------------------------------------------------------
43 // Constructors
44 // ------------------------------------------------------------------------
45 /**
46 * Default constructor.
c8422608 47 *
df0b8ff4
BH
48 * @param display The display to use
49 * @param data A font data
50 */
73005152 51 public FontImpl(Display display, FontData data) {
eb63f5ff 52 fFont = new Font(display, data);
73005152
BH
53 }
54
df0b8ff4
BH
55 /**
56 * Copy constructor
c8422608 57 *
df0b8ff4
BH
58 * @param value A font to copy.
59 */
73005152 60 protected FontImpl(Font value) {
eb63f5ff
BH
61 fFont = value;
62 fManageFont = false;
73005152
BH
63 }
64
df0b8ff4
BH
65 // ------------------------------------------------------------------------
66 // Methods
67 // ------------------------------------------------------------------------
11252342 68
df0b8ff4
BH
69 /**
70 * Returns a font implementation based system font.
c8422608 71 *
df0b8ff4
BH
72 * @return a font implementation based system font.
73 */
73005152
BH
74 public static FontImpl getSystemFont() {
75 return new FontImpl(Display.getDefault().getSystemFont());
76 }
77
df0b8ff4
BH
78 @Override
79 public Object getFont() {
eb63f5ff 80 return fFont;
df0b8ff4 81 }
c8422608 82
73005152
BH
83 @Override
84 public void dispose() {
eb63f5ff
BH
85 if (fFont != null) {
86 fFont.dispose();
df0b8ff4 87 }
73005152 88 }
73005152 89}
This page took 0.077001 seconds and 5 git commands to generate.