tmf: API clean-up of sequence diagram framework
[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, 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.IColor;
16 import org.eclipse.swt.graphics.Color;
17 import org.eclipse.swt.widgets.Display;
18
19 /**
20 * Default implementation of the IColor interface.
21 *
22 * @version 1.0
23 * @author sveyrier
24 *
25 */
26 public class ColorImpl implements IColor {
27
28 // ------------------------------------------------------------------------
29 // Attributes
30 // ------------------------------------------------------------------------
31 /**
32 * The color object.
33 */
34 private final Color fColor;
35 /**
36 * Flag to indicate that this object is managing the resource.
37 */
38 private boolean fManageColor = true;
39
40 // ------------------------------------------------------------------------
41 // Constructors
42 // ------------------------------------------------------------------------
43 /**
44 * Constructor
45 *
46 * @param display The display to use
47 * @param r A value for red
48 * @param g A value for green
49 * @param b A value for blue
50 */
51 public ColorImpl(Display display, int r, int g, int b) {
52 fColor = new Color(display, r, g, b);
53 }
54
55 /**
56 * Copy constructor
57 *
58 * @param color
59 * 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 @Override
81 public Object getColor() {
82 return fColor;
83 }
84
85 @Override
86 public void dispose() {
87 if ((fColor != null) && (fManageColor)) {
88 fColor.dispose();
89 }
90 }
91
92 }
This page took 0.033337 seconds and 5 git commands to generate.