6f38e0eec928f9b502f7d406765a1e215f8b72b4
[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 color
60 * A color to copy
61 */
62 protected ColorImpl(Color color) {
63 fColor = color;
64 fManageColor = false;
65 }
66
67 // ------------------------------------------------------------------------
68 // Methods
69 // ------------------------------------------------------------------------
70
71 /**
72 * Returns a system color.
73 *
74 * @param color The color ID
75 * @return a system color
76 */
77 public static ColorImpl getSystemColor(int color) {
78 return new ColorImpl(Display.getDefault().getSystemColor(color));
79 }
80
81 /*
82 * (non-Javadoc)
83 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor#getColor()
84 */
85 @Override
86 public Object getColor() {
87 return fColor;
88 }
89
90 /*
91 * (non-Javadoc)
92 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor#dispose()
93 */
94 @Override
95 public void dispose() {
96 if ((fColor != null) && (fManageColor)) {
97 fColor.dispose();
98 }
99 }
100
101 }
This page took 0.031769 seconds and 5 git commands to generate.