1 /*******************************************************************************
2 * Copyright (c) 2016 EfficiOS Inc., Alexandre Montplaisir
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.internal
.provisional
.tmf
.ui
.views
.timegraph2
.swt
;
12 import java
.util
.HashMap
;
15 import org
.eclipse
.swt
.graphics
.Color
;
16 import org
.eclipse
.swt
.widgets
.Display
;
17 import org
.eclipse
.tracecompass
.internal
.provisional
.tmf
.core
.views
.timegraph2
.ColorDefinition
;
19 final class SwtColorFactory
{
21 private SwtColorFactory() {}
23 private static final Map
<ColorDefinition
, Color
> COLOR_MAP
= new HashMap
<>();
26 * Instantiate a {@link Color} from a {@link ColorDefinition} object.
28 * Must be called by the UI thread only, so it should not need any special
33 * @return The Color object
35 public static Color
getColorFromDef(ColorDefinition colorDef
) {
36 Color color
= COLOR_MAP
.get(colorDef
);
38 color
= new Color(Display
.getDefault(), colorDef
.fRed
, colorDef
.fGreen
, colorDef
.fBlue
, colorDef
.fAlpha
);
39 COLOR_MAP
.put(colorDef
, color
);
This page took 0.038427 seconds and 5 git commands to generate.