[WIP] CFV Refactor
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / internal / provisional / tmf / ui / views / timegraph2 / swtjfx / JfxColorFactory.java
1 /*******************************************************************************
2 * Copyright (c) 2016 EfficiOS Inc., Alexandre Montplaisir
3 *
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 *******************************************************************************/
9
10 package org.eclipse.tracecompass.internal.provisional.tmf.ui.views.timegraph2.swtjfx;
11
12 import java.util.Map;
13 import java.util.concurrent.ConcurrentHashMap;
14
15 import org.eclipse.tracecompass.internal.provisional.tmf.core.views.timegraph2.ColorDefinition;
16
17 import javafx.scene.paint.Color;
18
19 final class JfxColorFactory {
20
21 private JfxColorFactory() {}
22
23 private static final Map<ColorDefinition, Color> COLOR_MAP = new ConcurrentHashMap<>();
24
25 /**
26 * Instantiate a {@link Color} from a {@link ColorDefinition} object.
27 *
28 * @param colorDef
29 * The ColorDefinition
30 * @return The Color object
31 */
32 public static Color getColorFromDef(ColorDefinition colorDef) {
33 Color color = COLOR_MAP.get(colorDef);
34 if (color == null) {
35 color = Color.rgb(colorDef.fRed, colorDef.fGreen, colorDef.fBlue, (double) colorDef.fAlpha / (double) ColorDefinition.MAX);
36 COLOR_MAP.put(colorDef, color);
37 }
38 return color;
39 }
40
41 }
This page took 0.030899 seconds and 5 git commands to generate.