blob: 18b1cb42d87378e2a3fac74ff9b3f9b10e842d5a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/*******************************************************************************
* Copyright (c) 2013 Mia-Software.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Grégoire Dupé (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table
******************************************************************************/
package org.eclipse.papyrus.emf.facet.util.swt.internal.colorprovider;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.papyrus.emf.facet.util.swt.colorprovider.IColorProvider;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.RGB;
public class ColorProvider implements IColorProvider {
private Map<RGB, Color> cash = new HashMap<RGB, Color>();
private Device device;
public ColorProvider(final Device device) {
this.device = device;
}
public Color getColor(final RGB rgb) {
Color result = this.cash.get(rgb);
if (result == null) {
result = new Color(this.device, rgb);
this.cash.put(rgb, result);
}
return result;
}
}
|