01: package nz.ac.massey.take.takeep.editor;
02:
03: import java.util.HashMap;
04:
05: import org.eclipse.swt.SWT;
06: import org.eclipse.swt.graphics.Color;
07: import org.eclipse.swt.graphics.RGB;
08: import org.eclipse.swt.widgets.Display;
09:
10: public class DesignManager {
11:
12: private RGB defaultColor = new RGB(0, 0, 0);
13: private int defaultStyle = SWT.NORMAL;
14:
15: private HashMap<String, RGB> colors = new HashMap<String, RGB>();
16: private HashMap<String, Integer> styles = new HashMap<String, Integer>();
17:
18: public void addStyle(String group, int style) {
19: this .styles.put(group, style);
20: }
21:
22: public void addColor(String group, RGB color) {
23: this .colors.put(group, color);
24: }
25:
26: public Color getColor(String group) {
27: RGB rgb = this .colors.get(group);
28: if (rgb == null) {
29: return new Color(Display.getCurrent(), this .defaultColor);
30: }
31: return new Color(Display.getCurrent(), rgb);
32: }
33:
34: public int getStyle(String group) {
35: Integer style = this.styles.get(group);
36: if (style == null) {
37: return this.defaultStyle;
38: }
39: return style;
40: }
41: }
|