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 |
|
---|
19 | package org.expeditee.items;
|
---|
20 |
|
---|
21 | import java.util.Collection;
|
---|
22 | import java.util.LinkedList;
|
---|
23 | import java.util.List;
|
---|
24 |
|
---|
25 | import org.expeditee.core.Colour;
|
---|
26 | import org.expeditee.core.Point;
|
---|
27 | import org.expeditee.gui.DisplayController;
|
---|
28 | import org.expeditee.gui.FrameGraphics;
|
---|
29 |
|
---|
30 | public 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
|
---|
104 | public Colour getColor() {
|
---|
105 | return _source.getColor();
|
---|
106 | }
|
---|
107 |
|
---|
108 | @Override
|
---|
109 | public void setColor(Colour c) {
|
---|
110 | _source.setColor(c);
|
---|
111 | invalidateCommonTrait(ItemAppearence.ForegroundColorChanged);
|
---|
112 | }
|
---|
113 |
|
---|
114 | @Override
|
---|
115 | public void setBackgroundColor(Colour c) {
|
---|
116 | _source.setBackgroundColor(c);
|
---|
117 | }
|
---|
118 |
|
---|
119 | @Override
|
---|
120 | public void setFillColor(Colour c) {
|
---|
121 | _source.setFillColor(c);
|
---|
122 | }
|
---|
123 |
|
---|
124 | @Override
|
---|
125 | public void setBorderColor(Colour c) {
|
---|
126 | _source.setBorderColor(c);
|
---|
127 | invalidateCommonTrait(ItemAppearence.BorderColorChanged);
|
---|
128 | }
|
---|
129 |
|
---|
130 | @Override
|
---|
131 | public void setGradientColor(Colour c) {
|
---|
132 | _source.setGradientColor(c);
|
---|
133 | }
|
---|
134 |
|
---|
135 | @Override
|
---|
136 | public void setTooltips(List<String> tooltips) {
|
---|
137 | _source.setTooltips(tooltips);
|
---|
138 | }
|
---|
139 |
|
---|
140 | @Override
|
---|
141 | public void setTooltip(String tooltip) {
|
---|
142 | _source.setTooltip(tooltip);
|
---|
143 | }
|
---|
144 |
|
---|
145 | @Override
|
---|
146 | public List<String> getTooltip() {
|
---|
147 | return _source.getTooltip();
|
---|
148 | }
|
---|
149 |
|
---|
150 | @Override
|
---|
151 | public float getThickness() {
|
---|
152 | return _source.getThickness();
|
---|
153 | }
|
---|
154 |
|
---|
155 | @Override
|
---|
156 | public Integer getAnchorLeft() {
|
---|
157 | return _source.getAnchorLeft();
|
---|
158 | }
|
---|
159 |
|
---|
160 | @Override
|
---|
161 | public Integer getAnchorRight() {
|
---|
162 | return _source.getAnchorRight();
|
---|
163 | }
|
---|
164 |
|
---|
165 | @Override
|
---|
166 | public Integer getAnchorTop() {
|
---|
167 | return _source.getAnchorTop();
|
---|
168 | }
|
---|
169 |
|
---|
170 | @Override
|
---|
171 | public Integer getAnchorBottom() {
|
---|
172 | return _source.getAnchorBottom();
|
---|
173 | }
|
---|
174 |
|
---|
175 |
|
---|
176 | @Override
|
---|
177 | public Colour getBorderColor() {
|
---|
178 | return _source.getBorderColor();
|
---|
179 | }
|
---|
180 |
|
---|
181 | @Override
|
---|
182 | public void setThickness(float thick, boolean setConnected) {
|
---|
183 | this.invalidateCommonTrait(ItemAppearence.Thickness);
|
---|
184 | _source.setThickness(thick, setConnected);
|
---|
185 | this.invalidateCommonTrait(ItemAppearence.Thickness);
|
---|
186 | }
|
---|
187 |
|
---|
188 | @Override
|
---|
189 | public Colour getBackgroundColor() {
|
---|
190 | return _source.getBackgroundColor();
|
---|
191 | }
|
---|
192 |
|
---|
193 | @Override
|
---|
194 | public Colour getFillColor() {
|
---|
195 | return _source.getFillColor();
|
---|
196 | }
|
---|
197 |
|
---|
198 | @Override
|
---|
199 | public Colour getGradientColor() {
|
---|
200 | return _source.getGradientColor();
|
---|
201 | }
|
---|
202 |
|
---|
203 | @Override
|
---|
204 | public String getFillPattern() {
|
---|
205 | return _source.getFillPattern();
|
---|
206 | }
|
---|
207 |
|
---|
208 | @Override
|
---|
209 | public boolean hasLink() {
|
---|
210 | return getLink() != null;
|
---|
211 | }
|
---|
212 |
|
---|
213 | @Override
|
---|
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 | }
|
---|
226 | if(frameName == null)
|
---|
227 | invalidateAll();
|
---|
228 | _source.setLink(frameName);
|
---|
229 | invalidateBounds();
|
---|
230 | //TODO: only invalidate the link bit
|
---|
231 | invalidateAll();
|
---|
232 | }
|
---|
233 |
|
---|
234 | @Override
|
---|
235 | public void setActions(List<String> action) {
|
---|
236 | if (_source == null){
|
---|
237 | return;
|
---|
238 | }
|
---|
239 | if(action == null || action.size() == 0)
|
---|
240 | invalidateAll();
|
---|
241 | _source.setActions(action);
|
---|
242 | invalidateBounds();
|
---|
243 | invalidateAll();
|
---|
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
|
---|
255 | public void translate(Point origin, double ratio){
|
---|
256 | //_source.translate(origin, ratio);
|
---|
257 | invalidateBounds();
|
---|
258 | }
|
---|
259 |
|
---|
260 | @Override
|
---|
261 | public void setPosition(float x, float y) {
|
---|
262 | //_source.setPosition(x, y);
|
---|
263 |
|
---|
264 | }
|
---|
265 |
|
---|
266 | @Override
|
---|
267 | public boolean isAnchored() {
|
---|
268 | return _source.isAnchored();
|
---|
269 | }
|
---|
270 |
|
---|
271 | @Override
|
---|
272 | public boolean isAnchoredX() {
|
---|
273 | return _source.isAnchoredX();
|
---|
274 | }
|
---|
275 |
|
---|
276 | @Override
|
---|
277 | public boolean isAnchoredY() {
|
---|
278 | return _source.isAnchoredY();
|
---|
279 | }
|
---|
280 |
|
---|
281 | @Override
|
---|
282 | public void setAnchorTop(Integer anchor) {
|
---|
283 | _source.setAnchorTop(anchor);
|
---|
284 | if (anchor != null)
|
---|
285 | _source.setY(anchor);
|
---|
286 | }
|
---|
287 |
|
---|
288 | @Override
|
---|
289 | public void setAnchorBottom(Integer anchor) {
|
---|
290 | _source.setAnchorBottom(anchor);
|
---|
291 | if (anchor != null)
|
---|
292 | _source.setY(DisplayController.getFramePaintArea().getHeight() - getHeight() - anchor);
|
---|
293 | }
|
---|
294 |
|
---|
295 |
|
---|
296 | @Override
|
---|
297 | public void setAnchorLeft(Integer anchor) {
|
---|
298 | _source.setAnchorLeft(anchor);
|
---|
299 | }
|
---|
300 |
|
---|
301 | @Override
|
---|
302 | public void setAnchorRight(Integer anchor) {
|
---|
303 | _source.setAnchorRight(anchor);
|
---|
304 | _source.setX(DisplayController.getFramePaintArea().getWidth() - anchor - this.getWidth());
|
---|
305 | }
|
---|
306 |
|
---|
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 | }
|
---|
315 |
|
---|
316 | @Override
|
---|
317 | public boolean hasPermission(UserAppliedPermission p) {
|
---|
318 | return _source.hasPermission(p);
|
---|
319 | }
|
---|
320 |
|
---|
321 | @Override
|
---|
322 | public void setPermission(PermissionPair permissionPair) {
|
---|
323 | _source.setPermission(permissionPair);
|
---|
324 | }
|
---|
325 | }
|
---|