source: trunk/src/org/expeditee/items/XRayable.java@ 1420

Last change on this file since 1420 was 1420, checked in by bln4, 5 years ago

Injecting an encryption label into an XRayable Item now injects that encryption label into the source item as well.

File size: 6.6 KB
Line 
1/**
2 * XRayable.java
3 * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package org.expeditee.items;
20
21import java.util.Collection;
22import java.util.LinkedList;
23import java.util.List;
24
25import org.expeditee.core.Colour;
26import org.expeditee.core.Point;
27import org.expeditee.gui.DisplayController;
28
29public abstract class XRayable extends Item {
30
31
32 protected Text _source = null;
33
34 public XRayable(Text source){
35 super();
36 _source = source;
37 source.setHidden(true);
38 source.addEnclosure(this);
39 }
40
41 @Override
42 public void setEncryptionLabel(String label) {
43 // When the encryption label is set on a XRayable is sets it on its source as well.
44 super.setEncryptionLabel(label);
45 _source.setEncryptionLabel(label);
46 }
47
48 public Collection<Item> getItemsToSave() {
49 Collection<Item> toSave = new LinkedList<Item>();
50 toSave.add(_source);
51 return toSave;
52 }
53
54 @Override
55 public Collection<Item> getConnected() {
56 Collection<Item> conn = super.getConnected();
57 conn.add(_source);
58 return conn;
59 }
60
61 @Override
62 public void addAllConnected(Collection<Item> connected) {
63 super.addAllConnected(connected);
64 if (!connected.contains(_source)) {
65 connected.add(_source);
66 }
67 }
68
69 /*
70 * (non-Javadoc)
71 *
72 * @see org.expeditee.items.Item#merge(org.expeditee.items.Item, int, int)
73 */
74 @Override
75 public Item merge(Item merger, int mouseX, int mouseY) {
76 return merger;
77 }
78
79 /**
80 * Returns the Text Item that was used to create this Picture object. This
81 * is required when saving the Frame.
82 *
83 * @return The Text Item used to create this Picture.
84 */
85 public Text getSource() {
86 return _source;
87 }
88
89 @Override
90 public int getID() {
91 return _source.getID();
92 }
93
94 @Override
95 public void setID(int newID) {
96 _source.setID(newID);
97 }
98
99 @Override
100 public int getY() {
101 return _source.getY();
102 }
103
104 @Override
105 public int getX() {
106 return _source.getX();
107 }
108
109 @Override
110 public Colour getColor() {
111 return _source.getColor();
112 }
113
114 @Override
115 public void setColor(Colour c) {
116 _source.setColor(c);
117 invalidateCommonTrait(ItemAppearence.ForegroundColorChanged);
118 }
119
120 @Override
121 public void setBackgroundColor(Colour c) {
122 _source.setBackgroundColor(c);
123 }
124
125 @Override
126 public void setFillColor(Colour c) {
127 _source.setFillColor(c);
128 }
129
130 @Override
131 public void setBorderColor(Colour c) {
132 _source.setBorderColor(c);
133 invalidateCommonTrait(ItemAppearence.BorderColorChanged);
134 }
135
136 @Override
137 public void setGradientColor(Colour c) {
138 _source.setGradientColor(c);
139 }
140
141 @Override
142 public void setTooltips(List<String> tooltips) {
143 _source.setTooltips(tooltips);
144 }
145
146 @Override
147 public void setTooltip(String tooltip) {
148 _source.setTooltip(tooltip);
149 }
150
151 @Override
152 public List<String> getTooltip() {
153 return _source.getTooltip();
154 }
155
156 @Override
157 public float getThickness() {
158 return _source.getThickness();
159 }
160
161 @Override
162 public Integer getAnchorLeft() {
163 return _source.getAnchorLeft();
164 }
165
166 @Override
167 public Integer getAnchorRight() {
168 return _source.getAnchorRight();
169 }
170
171 @Override
172 public Integer getAnchorTop() {
173 return _source.getAnchorTop();
174 }
175
176 @Override
177 public Integer getAnchorBottom() {
178 return _source.getAnchorBottom();
179 }
180
181
182 @Override
183 public Colour getBorderColor() {
184 return _source.getBorderColor();
185 }
186
187 @Override
188 public void setThickness(float thick, boolean setConnected) {
189 this.invalidateCommonTrait(ItemAppearence.Thickness);
190 _source.setThickness(thick, setConnected);
191 this.invalidateCommonTrait(ItemAppearence.Thickness);
192 }
193
194 @Override
195 public Colour getBackgroundColor() {
196 return _source.getBackgroundColor();
197 }
198
199 @Override
200 public Colour getFillColor() {
201 return _source.getFillColor();
202 }
203
204 @Override
205 public Colour getGradientColor() {
206 return _source.getGradientColor();
207 }
208
209 @Override
210 public String getFillPattern() {
211 return _source.getFillPattern();
212 }
213
214 @Override
215 public boolean hasLink() {
216 return getLink() != null;
217 }
218
219 @Override
220 public String getLink() {
221 if (_source == null)
222 return null;
223 else
224 return _source.getLink();
225 }
226
227 @Override
228 public void setLink(String frameName) {
229 if (_source == null) {
230 return;
231 }
232 if(frameName == null)
233 invalidateAll();
234 _source.setLink(frameName);
235 invalidateBounds();
236 //TODO: only invalidate the link bit
237 invalidateAll();
238 }
239
240 @Override
241 public void setActions(List<String> action) {
242 if (_source == null){
243 return;
244 }
245 if(action == null || action.size() == 0)
246 invalidateAll();
247 _source.setActions(action);
248 invalidateBounds();
249 invalidateAll();
250 }
251
252 @Override
253 public List<String> getAction() {
254 if (_source == null)
255 return null;
256 else
257 return _source.getAction();
258 }
259
260 @Override
261 public void translate(Point origin, double ratio){
262 //_source.translate(origin, ratio);
263 invalidateBounds();
264 }
265
266 @Override
267 public void setPosition(float x, float y) {
268 //_source.setPosition(x, y);
269
270 }
271
272 @Override
273 public boolean isAnchored() {
274 return _source.isAnchored();
275 }
276
277 @Override
278 public boolean isAnchoredX() {
279 return _source.isAnchoredX();
280 }
281
282 @Override
283 public boolean isAnchoredY() {
284 return _source.isAnchoredY();
285 }
286
287 @Override
288 public void setAnchorTop(Integer anchor) {
289 _source.setAnchorTop(anchor);
290 if (anchor != null)
291 _source.setY(anchor);
292 }
293
294 @Override
295 public void setAnchorBottom(Integer anchor) {
296 _source.setAnchorBottom(anchor);
297 if (anchor != null)
298 _source.setY(DisplayController.getFramePaintAreaHeight() - getHeight() - anchor);
299 }
300
301
302 @Override
303 public void setAnchorLeft(Integer anchor) {
304 _source.setAnchorLeft(anchor);
305 }
306
307 @Override
308 public void setAnchorRight(Integer anchor) {
309 _source.setAnchorRight(anchor);
310 _source.setX(DisplayController.getFramePaintAreaWidth() - anchor - this.getWidth());
311 }
312
313 public boolean refresh(){
314 return true;
315 }
316
317 @Override
318 public void setXY(float x, float y){
319 _source.setXY(x, y);
320 }
321
322 @Override
323 public boolean hasPermission(UserAppliedPermission p) {
324 return _source.hasPermission(p);
325 }
326
327 @Override
328 public void setPermission(PermissionTriple permissionPair) {
329 _source.setPermission(permissionPair);
330 }
331}
Note: See TracBrowser for help on using the repository browser.