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

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

New piping and functionality implementation to support the encrypting of images.

File size: 7.1 KB
RevLine 
[919]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
[109]19package org.expeditee.items;
20
21import java.util.Collection;
22import java.util.LinkedList;
23import java.util.List;
24
[1102]25import org.expeditee.core.Colour;
26import org.expeditee.core.Point;
[1427]27import org.expeditee.encryption.core.EncryptedImage;
[1423]28import org.expeditee.encryption.items.surrogates.Label;
[1102]29import org.expeditee.gui.DisplayController;
[282]30
[109]31public abstract class XRayable extends Item {
32
33 protected Text _source = null;
34
35 public XRayable(Text source){
36 super();
37 _source = source;
38 source.setHidden(true);
39 source.addEnclosure(this);
40 }
41
[1420]42 @Override
[1426]43 public Item getPrimary() {
44 return _source.getPrimary();
45 }
46
47 @Override
48 public boolean isSurrogate() {
49 return _source.isSurrogate();
50 }
51
52 @Override
[1420]53 public void setEncryptionLabel(String label) {
54 _source.setEncryptionLabel(label);
55 }
56
[1423]57 public boolean sourceIsAccessible() {
58 String encryptionLabel = _source.getEncryptionLabel();
59 if (encryptionLabel == null || encryptionLabel.isEmpty()) {
60 return true;
61 } else {
62 List<String> accessibleLabelsNames = Label.getAccessibleLabelsNames(this.getParent().getBody());
63 return accessibleLabelsNames.contains(encryptionLabel);
64 }
65 }
66
[109]67 public Collection<Item> getItemsToSave() {
68 Collection<Item> toSave = new LinkedList<Item>();
69 toSave.add(_source);
70 return toSave;
71 }
72
73 @Override
74 public Collection<Item> getConnected() {
75 Collection<Item> conn = super.getConnected();
76 conn.add(_source);
77 return conn;
78 }
79
80 @Override
81 public void addAllConnected(Collection<Item> connected) {
82 super.addAllConnected(connected);
83 if (!connected.contains(_source)) {
84 connected.add(_source);
85 }
86 }
87
88 /*
89 * (non-Javadoc)
90 *
91 * @see org.expeditee.items.Item#merge(org.expeditee.items.Item, int, int)
92 */
93 @Override
94 public Item merge(Item merger, int mouseX, int mouseY) {
95 return merger;
96 }
97
98 /**
99 * Returns the Text Item that was used to create this Picture object. This
100 * is required when saving the Frame.
101 *
102 * @return The Text Item used to create this Picture.
103 */
104 public Text getSource() {
105 return _source;
106 }
107
108 @Override
109 public int getID() {
110 return _source.getID();
111 }
112
113 @Override
114 public void setID(int newID) {
115 _source.setID(newID);
116 }
117
118 @Override
119 public int getY() {
120 return _source.getY();
121 }
122
123 @Override
124 public int getX() {
125 return _source.getX();
126 }
127
128 @Override
[1102]129 public Colour getColor() {
[109]130 return _source.getColor();
131 }
132
133 @Override
[1102]134 public void setColor(Colour c) {
[109]135 _source.setColor(c);
[124]136 invalidateCommonTrait(ItemAppearence.ForegroundColorChanged);
[109]137 }
138
139 @Override
[1102]140 public void setBackgroundColor(Colour c) {
[109]141 _source.setBackgroundColor(c);
142 }
143
144 @Override
[1102]145 public void setFillColor(Colour c) {
[109]146 _source.setFillColor(c);
147 }
148
149 @Override
[1102]150 public void setBorderColor(Colour c) {
[242]151 _source.setBorderColor(c);
152 invalidateCommonTrait(ItemAppearence.BorderColorChanged);
153 }
154
155 @Override
[1102]156 public void setGradientColor(Colour c) {
[145]157 _source.setGradientColor(c);
158 }
159
160 @Override
[707]161 public void setTooltips(List<String> tooltips) {
162 _source.setTooltips(tooltips);
163 }
164
165 @Override
[665]166 public void setTooltip(String tooltip) {
167 _source.setTooltip(tooltip);
168 }
169
170 @Override
[707]171 public List<String> getTooltip() {
[665]172 return _source.getTooltip();
173 }
174
175 @Override
[109]176 public float getThickness() {
177 return _source.getThickness();
178 }
179
180 @Override
[1102]181 public Integer getAnchorLeft() {
[720]182 return _source.getAnchorLeft();
[282]183 }
184
185 @Override
[1102]186 public Integer getAnchorRight() {
[282]187 return _source.getAnchorRight();
188 }
[720]189
190 @Override
[1102]191 public Integer getAnchorTop() {
[720]192 return _source.getAnchorTop();
193 }
194
195 @Override
[1102]196 public Integer getAnchorBottom() {
[720]197 return _source.getAnchorBottom();
198 }
[282]199
[720]200
[282]201 @Override
[1102]202 public Colour getBorderColor() {
[242]203 return _source.getBorderColor();
204 }
205
206 @Override
[311]207 public void setThickness(float thick, boolean setConnected) {
[121]208 this.invalidateCommonTrait(ItemAppearence.Thickness);
[311]209 _source.setThickness(thick, setConnected);
[121]210 this.invalidateCommonTrait(ItemAppearence.Thickness);
[109]211 }
212
213 @Override
[1102]214 public Colour getBackgroundColor() {
[109]215 return _source.getBackgroundColor();
216 }
217
218 @Override
[1102]219 public Colour getFillColor() {
[109]220 return _source.getFillColor();
221 }
[147]222
223 @Override
[1102]224 public Colour getGradientColor() {
[147]225 return _source.getGradientColor();
226 }
[109]227
228 @Override
229 public String getFillPattern() {
230 return _source.getFillPattern();
231 }
232
233 @Override
[697]234 public boolean hasLink() {
235 return getLink() != null;
236 }
237
238 @Override
[109]239 public String getLink() {
240 if (_source == null)
241 return null;
242 else
243 return _source.getLink();
244 }
245
246 @Override
247 public void setLink(String frameName) {
248 if (_source == null) {
249 return;
250 }
[154]251 if(frameName == null)
252 invalidateAll();
253 _source.setLink(frameName);
[1102]254 invalidateBounds();
[154]255 //TODO: only invalidate the link bit
256 invalidateAll();
[109]257 }
258
259 @Override
260 public void setActions(List<String> action) {
[154]261 if (_source == null){
[109]262 return;
[154]263 }
[156]264 if(action == null || action.size() == 0)
[154]265 invalidateAll();
266 _source.setActions(action);
[1102]267 invalidateBounds();
[154]268 invalidateAll();
[109]269 }
270
271 @Override
272 public List<String> getAction() {
273 if (_source == null)
274 return null;
275 else
276 return _source.getAction();
277 }
278
279 @Override
[1102]280 public void translate(Point origin, double ratio){
[109]281 //_source.translate(origin, ratio);
[1102]282 invalidateBounds();
[109]283 }
284
285 @Override
286 public void setPosition(float x, float y) {
287 //_source.setPosition(x, y);
[121]288
[109]289 }
290
[278]291 @Override
[774]292 public boolean isAnchored() {
293 return _source.isAnchored();
294 }
295
296 @Override
[805]297 public boolean isAnchoredX() {
298 return _source.isAnchoredX();
299 }
300
301 @Override
302 public boolean isAnchoredY() {
303 return _source.isAnchoredY();
304 }
305
306 @Override
[1102]307 public void setAnchorTop(Integer anchor) {
[720]308 _source.setAnchorTop(anchor);
309 if (anchor != null)
[875]310 _source.setY(anchor);
[720]311 }
312
313 @Override
[1102]314 public void setAnchorBottom(Integer anchor) {
[278]315 _source.setAnchorBottom(anchor);
[282]316 if (anchor != null)
[1258]317 _source.setY(DisplayController.getFramePaintAreaHeight() - getHeight() - anchor);
[278]318 }
[720]319
[278]320
321 @Override
[1102]322 public void setAnchorLeft(Integer anchor) {
[720]323 _source.setAnchorLeft(anchor);
324 }
325
326 @Override
[1102]327 public void setAnchorRight(Integer anchor) {
[278]328 _source.setAnchorRight(anchor);
[1258]329 _source.setX(DisplayController.getFramePaintAreaWidth() - anchor - this.getWidth());
[278]330 }
331
[109]332 public boolean refresh(){
333 return true;
334 }
335
336 @Override
337 public void setXY(float x, float y){
338 _source.setXY(x, y);
339 }
[147]340
341 @Override
[450]342 public boolean hasPermission(UserAppliedPermission p) {
[147]343 return _source.hasPermission(p);
344 }
345
346 @Override
[1402]347 public void setPermission(PermissionTriple permissionPair) {
[737]348 _source.setPermission(permissionPair);
[147]349 }
[109]350}
Note: See TracBrowser for help on using the repository browser.