Project

General

Profile

Download (3.52 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.model;
10

    
11
import org.eclipse.jface.resource.ColorRegistry;
12
import org.eclipse.swt.graphics.Color;
13
import org.eclipse.swt.graphics.RGB;
14

    
15
import eu.etaxonomy.taxeditor.preference.Resources;
16

    
17
/**
18
 * @author pplitzner
19
 * @since Nov 1, 2017
20
 */
21
public class ColorResources {
22

    
23
	private static ColorResources instance;
24

    
25
	public static ColorResources getInstance(){
26
		if(instance == null){
27
			instance = new ColorResources();
28
		}
29
		return instance;
30
	}
31

    
32
	private static ColorRegistry colorRegistry;
33

    
34
	public ColorRegistry getColorRegistry() {
35
        if (colorRegistry == null) {
36
            colorRegistry = new ColorRegistry();
37
            initializeColorRegistry(colorRegistry);
38
        }
39
        return colorRegistry;
40
    }
41

    
42
	public static Color getColor(String key){
43
	    return getInstance().getColorRegistry().get(key);
44
	}
45

    
46
	protected void initializeColorRegistry(ColorRegistry registry) {
47
	    registerColor(registry, Resources.COLOR_SWT_BG_DEFAULT, 214, 214, 214);
48
	    registerColor(registry, Resources.COLOR_MATRIX_SUMMARY_BG, 255, 255, 153);
49
	    registerColor(registry, Resources.COLOR_BULK_EDITOR_CANDIDATE, 243, 240, 165);
50
	    registerColor(registry, Resources.COLOR_BULK_EDITOR_TARGET, 135, 255, 135);
51
	    registerColor(registry, Resources.COLOR_COMPOSITE_BACKGROUND, 255,255,255);
52
	    registerColor(registry, Resources.COLOR_CONTROL_BACKGROUND, 220, 220, 220);
53
	    registerColor(registry, Resources.COLOR_CONTROL_SELECTED, 210, 210, 210);
54
	    registerColor(registry, Resources.COLOR_CONTROL_SELECTED_FOCUS, 232,242,254);
55

    
56
	    //colors1 and 2 are computed as next neutral color from the combined color
57
	    //light colors are computed as second last color tints
58
	    //see https://htmlcolorcodes.com/color-picker/
59
		registerColor(registry, Resources.COLOR_COMPOSITE_IRRELEVANT1, 241,156,18);
60
		registerColor(registry, Resources.COLOR_COMPOSITE_IRRELEVANT1_LIGHT, 251, 230, 196);
61
        registerColor(registry, Resources.COLOR_COMPOSITE_IRRELEVANT2, 241, 190, 18);
62
        registerColor(registry, Resources.COLOR_COMPOSITE_IRRELEVANT2_LIGHT, 251, 239, 196);
63
        registerColor(registry, Resources.COLOR_COMPOSITE_IRRELEVANT1_2, 241, 140, 18);
64
        registerColor(registry, Resources.COLOR_COMPOSITE_IRRELEVANT1_2_LIGHT, 251, 226, 196);
65

    
66
        registerColor(registry, Resources.SEARCH_VIEW_FOREGROUND, 192, 192, 192);
67
		registerColor(registry, Resources.SEARCH_VIEW_FOCUS, 0, 0, 0);
68
		registerColor(registry, Resources.BLACK, 0, 0, 0);
69
		registerColor(registry, Resources.COLOR_LIST_BACKGROUND, 150,150,150);
70
		registerColor(registry, Resources.COLOR_FONT_DEFAULT, 0,0,0);
71
		registerColor(registry, Resources.COLOR_TEXT_DISABLED, 150,150,150);
72
		registerColor(registry, Resources.COLOR_TEXT_DISABLED_BACKGROUND, 230,230,230);
73
		registerColor(registry, Resources.COLOR_DRAG_ENTER, 185,255,133);
74
		registerColor(registry, Resources.COLOR_LIST_EVEN, 255,255,255);
75
		registerColor(registry, Resources.COLOR_LIST_ODD, 230,230,230);
76
		registerColor(registry, Resources.COLOR_PARSE_ERROR, 255,0,0);
77
		registerColor(registry, Resources.COLOR_DISABLED_EDITOR, 105,114,124);
78
		registerColor(registry, Resources.COLOR_EDITOR_ERROR, 255,0,0);
79
	}
80

    
81
	private void registerColor(ColorRegistry registry, String key,
82
	        int red, int green, int blue) {
83
	    registry.put(key, new RGB(red, green, blue));
84
	}
85
}
(7-7/41)