This repository has been archived by the owner on Jan 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
ColorTheme.java
62 lines (50 loc) · 1.91 KB
/
ColorTheme.java
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*******************************************************************************
* Copyright (c) 2010-2012, Zoltan Ujhelyi, Istvan Rath and Daniel Varro
* 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:
* Zoltan Ujhelyi- initial API and implementation
*******************************************************************************/
package org.eclipse.incquery.tooling.ui.retevis.theme;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.services.IDisposable;
import com.google.common.base.Preconditions;
public class ColorTheme implements IDisposable {
private Color[] nodeColors;
private Color[] textColors;
private int size;
public ColorTheme(Display display) {
size = 3;
nodeColors = new Color[size];
textColors = new Color[size];
nodeColors[0] = new Color(display, 255, 255, 255);
textColors[0] = new Color(display, 0, 0, 0);
nodeColors[1] = new Color(display, 55, 112, 231);
textColors[1] = new Color(display, 255, 255, 255);
nodeColors[2] = new Color(display, 127, 0, 77);
textColors[2] = new Color(display, 255, 255, 255);
}
public Color getNodeColor(int id) {
Preconditions.checkElementIndex(id, size);
return nodeColors[id];
}
public Color getTextColor(int id) {
Preconditions.checkElementIndex(id, size);
return textColors[id];
}
@Override
public void dispose() {
for (int i = 0; i < size; i++) {
if (nodeColors[i] != null) {
nodeColors[i].dispose();
}
if (textColors[i] != null) {
textColors[i].dispose();
}
}
}
}