1 | package org.expeditee.items;
|
---|
2 |
|
---|
3 | import java.awt.Color;
|
---|
4 | import java.awt.geom.Point2D;
|
---|
5 | import java.util.Collection;
|
---|
6 | import java.util.LinkedList;
|
---|
7 | import java.util.List;
|
---|
8 |
|
---|
9 | import org.expeditee.gui.FrameGraphics;
|
---|
10 |
|
---|
11 | public abstract class XRayable extends Item {
|
---|
12 |
|
---|
13 |
|
---|
14 | protected Text _source = null;
|
---|
15 |
|
---|
16 | public XRayable(Text source){
|
---|
17 | super();
|
---|
18 | _source = source;
|
---|
19 | source.setHidden(true);
|
---|
20 | source.addEnclosure(this);
|
---|
21 | }
|
---|
22 |
|
---|
23 | public Collection<Item> getItemsToSave() {
|
---|
24 | Collection<Item> toSave = new LinkedList<Item>();
|
---|
25 | toSave.add(_source);
|
---|
26 | return toSave;
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Override
|
---|
30 | public Collection<Item> getConnected() {
|
---|
31 | Collection<Item> conn = super.getConnected();
|
---|
32 | conn.add(_source);
|
---|
33 | return conn;
|
---|
34 | }
|
---|
35 |
|
---|
36 | @Override
|
---|
37 | public void addAllConnected(Collection<Item> connected) {
|
---|
38 | super.addAllConnected(connected);
|
---|
39 | if (!connected.contains(_source)) {
|
---|
40 | connected.add(_source);
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | /*
|
---|
45 | * (non-Javadoc)
|
---|
46 | *
|
---|
47 | * @see org.expeditee.items.Item#merge(org.expeditee.items.Item, int, int)
|
---|
48 | */
|
---|
49 | @Override
|
---|
50 | public Item merge(Item merger, int mouseX, int mouseY) {
|
---|
51 | return merger;
|
---|
52 | }
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Returns the Text Item that was used to create this Picture object. This
|
---|
56 | * is required when saving the Frame.
|
---|
57 | *
|
---|
58 | * @return The Text Item used to create this Picture.
|
---|
59 | */
|
---|
60 | public Text getSource() {
|
---|
61 | return _source;
|
---|
62 | }
|
---|
63 |
|
---|
64 | @Override
|
---|
65 | public int getID() {
|
---|
66 | return _source.getID();
|
---|
67 | }
|
---|
68 |
|
---|
69 | @Override
|
---|
70 | public void setID(int newID) {
|
---|
71 | _source.setID(newID);
|
---|
72 | }
|
---|
73 |
|
---|
74 | @Override
|
---|
75 | public int getY() {
|
---|
76 | return _source.getY();
|
---|
77 | }
|
---|
78 |
|
---|
79 | @Override
|
---|
80 | public int getX() {
|
---|
81 | return _source.getX();
|
---|
82 | }
|
---|
83 |
|
---|
84 | @Override
|
---|
85 | public Color getColor() {
|
---|
86 | return _source.getColor();
|
---|
87 | }
|
---|
88 |
|
---|
89 | @Override
|
---|
90 | public void setColor(Color c) {
|
---|
91 | _source.setColor(c);
|
---|
92 | invalidateCommonTrait(ItemAppearence.ForegroundColorChanged);
|
---|
93 | }
|
---|
94 |
|
---|
95 | @Override
|
---|
96 | public void setBackgroundColor(Color c) {
|
---|
97 | _source.setBackgroundColor(c);
|
---|
98 | }
|
---|
99 |
|
---|
100 | @Override
|
---|
101 | public void setFillColor(Color c) {
|
---|
102 | _source.setFillColor(c);
|
---|
103 | }
|
---|
104 |
|
---|
105 | @Override
|
---|
106 | public void setBorderColor(Color c) {
|
---|
107 | _source.setBorderColor(c);
|
---|
108 | invalidateCommonTrait(ItemAppearence.BorderColorChanged);
|
---|
109 | }
|
---|
110 |
|
---|
111 | @Override
|
---|
112 | public void setGradientColor(Color c) {
|
---|
113 | _source.setGradientColor(c);
|
---|
114 | }
|
---|
115 |
|
---|
116 | @Override
|
---|
117 | public float getThickness() {
|
---|
118 | return _source.getThickness();
|
---|
119 | }
|
---|
120 |
|
---|
121 | @Override
|
---|
122 | public Float getAnchorBottom() {
|
---|
123 | return _source.getAnchorBottom();
|
---|
124 | }
|
---|
125 |
|
---|
126 | @Override
|
---|
127 | public Float getAnchorRight() {
|
---|
128 | return _source.getAnchorRight();
|
---|
129 | }
|
---|
130 |
|
---|
131 | @Override
|
---|
132 | public Color getBorderColor() {
|
---|
133 | return _source.getBorderColor();
|
---|
134 | }
|
---|
135 |
|
---|
136 | @Override
|
---|
137 | public void setThickness(float thick) {
|
---|
138 | this.invalidateCommonTrait(ItemAppearence.Thickness);
|
---|
139 | _source.setThickness(thick);
|
---|
140 | this.invalidateCommonTrait(ItemAppearence.Thickness);
|
---|
141 | }
|
---|
142 |
|
---|
143 | @Override
|
---|
144 | public Color getBackgroundColor() {
|
---|
145 | return _source.getBackgroundColor();
|
---|
146 | }
|
---|
147 |
|
---|
148 | @Override
|
---|
149 | public Color getFillColor() {
|
---|
150 | return _source.getFillColor();
|
---|
151 | }
|
---|
152 |
|
---|
153 | @Override
|
---|
154 | public Color getGradientColor() {
|
---|
155 | return _source.getGradientColor();
|
---|
156 | }
|
---|
157 |
|
---|
158 | @Override
|
---|
159 | public String getFillPattern() {
|
---|
160 | return _source.getFillPattern();
|
---|
161 | }
|
---|
162 |
|
---|
163 | @Override
|
---|
164 | public String getLink() {
|
---|
165 | if (_source == null)
|
---|
166 | return null;
|
---|
167 | else
|
---|
168 | return _source.getLink();
|
---|
169 | }
|
---|
170 |
|
---|
171 | @Override
|
---|
172 | public void setLink(String frameName) {
|
---|
173 | if (_source == null) {
|
---|
174 | return;
|
---|
175 | }
|
---|
176 | if(frameName == null)
|
---|
177 | invalidateAll();
|
---|
178 | _source.setLink(frameName);
|
---|
179 | updatePolygon();
|
---|
180 | //TODO: only invalidate the link bit
|
---|
181 | invalidateAll();
|
---|
182 | }
|
---|
183 |
|
---|
184 | @Override
|
---|
185 | public void setActions(List<String> action) {
|
---|
186 | if (_source == null){
|
---|
187 | return;
|
---|
188 | }
|
---|
189 | if(action == null || action.size() == 0)
|
---|
190 | invalidateAll();
|
---|
191 | _source.setActions(action);
|
---|
192 | updatePolygon();
|
---|
193 | invalidateAll();
|
---|
194 | }
|
---|
195 |
|
---|
196 | @Override
|
---|
197 | public List<String> getAction() {
|
---|
198 | if (_source == null)
|
---|
199 | return null;
|
---|
200 | else
|
---|
201 | return _source.getAction();
|
---|
202 | }
|
---|
203 |
|
---|
204 | @Override
|
---|
205 | public void translate(Point2D origin, double ratio){
|
---|
206 | //_source.translate(origin, ratio);
|
---|
207 | updatePolygon();
|
---|
208 | }
|
---|
209 |
|
---|
210 | @Override
|
---|
211 | public void setPosition(float x, float y) {
|
---|
212 | //_source.setPosition(x, y);
|
---|
213 |
|
---|
214 | }
|
---|
215 |
|
---|
216 | @Override
|
---|
217 | public void setAnchorBottom(Float anchor) {
|
---|
218 | _source.setAnchorBottom(anchor);
|
---|
219 | if (anchor != null)
|
---|
220 | _source.setY(FrameGraphics.getMaxFrameSize().height - getHeight() - anchor);
|
---|
221 | }
|
---|
222 |
|
---|
223 | @Override
|
---|
224 | public void setAnchorRight(Float anchor) {
|
---|
225 | _source.setAnchorRight(anchor);
|
---|
226 | }
|
---|
227 |
|
---|
228 | public boolean refresh(){
|
---|
229 | return true;
|
---|
230 | }
|
---|
231 |
|
---|
232 | @Override
|
---|
233 | public void setXY(float x, float y){
|
---|
234 | _source.setXY(x, y);
|
---|
235 | }
|
---|
236 |
|
---|
237 | @Override
|
---|
238 | public boolean hasPermission(Permission p) {
|
---|
239 | return _source.hasPermission(p);
|
---|
240 | }
|
---|
241 |
|
---|
242 | @Override
|
---|
243 | public void setPermission(Permission p) {
|
---|
244 | _source.setPermission(p);
|
---|
245 | }
|
---|
246 | }
|
---|