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

Last change on this file since 919 was 919, checked in by jts21, 10 years ago

Added license headers to all files, added full GPL3 license file, moved license header generator script to dev/bin/scripts

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