Fix static analysis warnings for UML2SD
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / drawings / impl / ColorImpl.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.IColor;
17 import org.eclipse.swt.graphics.Color;
18 import org.eclipse.swt.widgets.Display;
19
20 /**
21 * Default implementation of the IColor interface.
22 *
23 * @version 1.0
24 * @author sveyrier
25 *
26 */
27 public class ColorImpl implements IColor {
28
29 // ------------------------------------------------------------------------
30 // Attributes
31 // ------------------------------------------------------------------------
32 /**
33 * The color object.
34 */
35 protected Color fColor = null;
36 /**
37 * Flag to indicate that this object is managing the resource.
38 */
39 protected boolean fManageColor = true;
40
41 // ------------------------------------------------------------------------
42 // Constructors
43 // ------------------------------------------------------------------------
44 /**
45 * Constructor
46 *
47 * @param display The display to use
48 * @param r A value for red
49 * @param g A value for green
50 * @param b A value for blue
51 */
52 public ColorImpl(Display display, int r, int g, int b) {
53 fColor = new Color(display, r, g, b);
54 }
55
56 /**
57 * Copy constructor
58 *
59 * @param A color to copy
60 */
61 protected ColorImpl(Color color) {
62 fColor = color;
63 fManageColor = false;
64 }
65
66 // ------------------------------------------------------------------------
67 // Methods
68 // ------------------------------------------------------------------------
69
70 /**
71 * Returns a system color.
72 *
73 * @param color The color ID
74 * @return a system color
75 */
76 public static ColorImpl getSystemColor(int color) {
77 return new ColorImpl(Display.getDefault().getSystemColor(color));
78 }
79
80 /*
81 * (non-Javadoc)
82 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor#getColor()
83 */
84 @Override
85 public Object getColor() {
86 return fColor;
87 }
88
89 /*
90 * (non-Javadoc)
91 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor#dispose()
92 */
93 @Override
94 public void dispose() {
95 if ((fColor != null) && (fManageColor)) {
96 fColor.dispose();
97 }
98 }
99
100 }
This page took 0.033055 seconds and 5 git commands to generate.