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

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

Permission is now a triple rather than a pair. The new second bit is not yet used but will be used for group level permissions.

gazumpts

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