-
Notifications
You must be signed in to change notification settings - Fork 96
/
OpalItem.java
162 lines (141 loc) · 3.38 KB
/
OpalItem.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*******************************************************************************
* Copyright (c) 2011 Laurent CARON
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
*******************************************************************************/
package org.eclipse.nebula.widgets.opal.commons;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
/**
* Instances of this object are items manipulated by the widgets of the Opal Project. These items are highly customizable, you can set :
* <ul>
* <li>Background and foreground colors,
* <li>Font
* <li>Image
* <li>Text
* <li>Height
* </ul>
* You can also store data using the <code>setData<code> methods.
*
*/
public abstract class OpalItem {
private final Map<String, Object> data = new HashMap<String, Object>();
private Object datum;
private Color background;
private Font font;
private Color foreground;
private Image image;
private String text;
private int height = -1;
/**
* @return the background color of the item
*/
public Color getBackground() {
return this.background;
}
/**
* @return the the data stored in this item
*/
public Object getData() {
return this.datum;
}
/**
* @param key a key
* @return the the data stored in this item associated to this key
*/
public Object getData(final String key) {
return this.data.get(key);
}
/**
* @return the font of the item
*/
public Font getFont() {
return this.font;
}
/**
* @return the foreground color of the item
*/
public Color getForeground() {
return this.foreground;
}
/**
* @return the height of the item
*/
public int getHeight() {
return this.height;
}
/**
* @return the image stored in this item
*/
public Image getImage() {
return this.image;
}
/**
* @return the text stored in this item
*/
public String getText() {
return this.text;
}
/**
* @param background set the background color of this item
*/
public void setBackground(final Color background) {
this.background = background;
}
/**
* @param font set the font of this item
*/
public void setFont(final Font font) {
this.font = font;
}
/**
* @param foreground set the foreground color of this item
*/
public void setForeground(final Color foreground) {
this.foreground = foreground;
}
/**
* @param height set the height of this item
*/
public void setHeight(final int height) {
this.height = height;
}
/**
* @param image set the image of this item
*/
public void setImage(final Image image) {
this.image = image;
}
/**
* @param text set the text of this item
*/
public void setText(final String text) {
this.text = text;
}
/**
* @param data set the data stored in this item
*/
public void setData(final Object data) {
this.datum = data;
}
/**
* Store a data associated to a given key in this item
*
* @param key key
* @param value value associated to this key
*/
public void setData(final String key, final Object value) {
this.data.put(key, value);
}
}