1 | /**
|
---|
2 | * WidgetEdge.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.widgets;
|
---|
20 |
|
---|
21 | import java.awt.Color;
|
---|
22 | import java.awt.Polygon;
|
---|
23 | import java.util.List;
|
---|
24 |
|
---|
25 | import org.expeditee.items.Item;
|
---|
26 | import org.expeditee.items.Line;
|
---|
27 | import org.expeditee.items.Text;
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Widget edges define the boundries of an interactive widget.
|
---|
31 | *
|
---|
32 | * @author Brook Novak
|
---|
33 | */
|
---|
34 | public class WidgetEdge extends Line {
|
---|
35 |
|
---|
36 | private InteractiveWidget _widgetSource;
|
---|
37 |
|
---|
38 | WidgetEdge(WidgetCorner start, WidgetCorner end, int id,
|
---|
39 | InteractiveWidget widgetSource) {
|
---|
40 | super(start, end, id);
|
---|
41 |
|
---|
42 | if (widgetSource == null)
|
---|
43 | throw new NullPointerException("widgetSource");
|
---|
44 | _widgetSource = widgetSource;
|
---|
45 | }
|
---|
46 |
|
---|
47 | public InteractiveWidget getWidgetSource() {
|
---|
48 | return _widgetSource;
|
---|
49 | }
|
---|
50 |
|
---|
51 | @Override
|
---|
52 | public Item forceMerge(Item merger, int mouseX, int mouseY) {
|
---|
53 | return null; // Don't allow breaking up of borders
|
---|
54 | }
|
---|
55 |
|
---|
56 | @Override
|
---|
57 | public void toggleArrow() {
|
---|
58 | // Ignore
|
---|
59 | }
|
---|
60 |
|
---|
61 | @Override
|
---|
62 | public void toggleDashed(int amount) {
|
---|
63 | // Ignore
|
---|
64 | }
|
---|
65 |
|
---|
66 | @Override
|
---|
67 | public void toggleArrowHeadRatio(int amount) {
|
---|
68 | // Ignore
|
---|
69 | }
|
---|
70 |
|
---|
71 | @Override
|
---|
72 | public void toggleArrowHeadLength(int amount) {
|
---|
73 | // Ignore
|
---|
74 | }
|
---|
75 |
|
---|
76 | @Override
|
---|
77 | public void setAnnotation(boolean val) {
|
---|
78 | // Ignore
|
---|
79 | }
|
---|
80 |
|
---|
81 | @Override
|
---|
82 | public boolean isAnnotation() {
|
---|
83 | return false;
|
---|
84 | }
|
---|
85 |
|
---|
86 | @Override
|
---|
87 | public void setArrow(float length, double ratio, double nib_perc) {
|
---|
88 | }
|
---|
89 |
|
---|
90 | @Override
|
---|
91 | public void setArrowhead(Polygon arrow) {
|
---|
92 | }
|
---|
93 |
|
---|
94 | @Override
|
---|
95 | public void setArrowheadLength(float length) {
|
---|
96 | }
|
---|
97 |
|
---|
98 | @Override
|
---|
99 | public void setArrowheadRatio(double ratio) {
|
---|
100 | }
|
---|
101 |
|
---|
102 | @Override
|
---|
103 | public void setBottomShadowColor(Color bottom) {
|
---|
104 | }
|
---|
105 |
|
---|
106 | @Override
|
---|
107 | public void setFillColor(Color c) {
|
---|
108 | }
|
---|
109 |
|
---|
110 | @Override
|
---|
111 | public void setFillPattern(String patternLink) {
|
---|
112 | }
|
---|
113 |
|
---|
114 | @Override
|
---|
115 | public void setSize(float size) {
|
---|
116 | }
|
---|
117 |
|
---|
118 | @Override
|
---|
119 | public void setFormula(String formula) {
|
---|
120 | }
|
---|
121 |
|
---|
122 | @Override
|
---|
123 | public void setAnchorTop(Float anchor) {
|
---|
124 | _widgetSource.setAnchorTop(anchor);
|
---|
125 | }
|
---|
126 |
|
---|
127 | @Override
|
---|
128 | public void setAnchorBottom(Float anchor) {
|
---|
129 | _widgetSource.setAnchorBottom(anchor);
|
---|
130 | }
|
---|
131 |
|
---|
132 | @Override
|
---|
133 | public void setAnchorLeft(Float anchor) {
|
---|
134 | _widgetSource.setAnchorLeft(anchor);
|
---|
135 | }
|
---|
136 |
|
---|
137 | @Override
|
---|
138 | public void setAnchorRight(Float anchor) {
|
---|
139 | _widgetSource.setAnchorRight(anchor);
|
---|
140 | }
|
---|
141 |
|
---|
142 | @Override
|
---|
143 | public boolean isAnchored() {
|
---|
144 | return _widgetSource.isAnchored();
|
---|
145 | }
|
---|
146 |
|
---|
147 | @Override
|
---|
148 | public boolean isAnchoredX() {
|
---|
149 | return _widgetSource.isAnchoredX();
|
---|
150 | }
|
---|
151 |
|
---|
152 | @Override
|
---|
153 | public boolean isAnchoredY() {
|
---|
154 | return _widgetSource.isAnchoredY();
|
---|
155 | }
|
---|
156 |
|
---|
157 | @Override
|
---|
158 | public Float getAnchorTop() {
|
---|
159 | return _widgetSource.getSource().getAnchorTop();
|
---|
160 | }
|
---|
161 |
|
---|
162 | @Override
|
---|
163 | public Float getAnchorBottom() {
|
---|
164 | return _widgetSource.getSource().getAnchorBottom();
|
---|
165 | }
|
---|
166 |
|
---|
167 | @Override
|
---|
168 | public Float getAnchorLeft() {
|
---|
169 | return _widgetSource.getSource().getAnchorLeft();
|
---|
170 | }
|
---|
171 |
|
---|
172 | @Override
|
---|
173 | public Float getAnchorRight() {
|
---|
174 | return _widgetSource.getSource().getAnchorRight();
|
---|
175 | }
|
---|
176 |
|
---|
177 | @Override
|
---|
178 | public boolean contains(int x, int y) {
|
---|
179 | return super.contains(x, y) && !_widgetSource.getBounds().contains(x, y);
|
---|
180 | }
|
---|
181 |
|
---|
182 | @Override
|
---|
183 | public Polygon getEnclosedShape() {
|
---|
184 | return getStartItem().getEnclosedShape();
|
---|
185 | }
|
---|
186 |
|
---|
187 | @Override
|
---|
188 | public String getLink() {
|
---|
189 | return _widgetSource.getSource().getLink();
|
---|
190 | }
|
---|
191 |
|
---|
192 | @Override
|
---|
193 | public void setLink(String link) {
|
---|
194 | _widgetSource.setLink(link, null);
|
---|
195 | }
|
---|
196 |
|
---|
197 | /**
|
---|
198 | * @param link
|
---|
199 | * The new frame link. Can be null (for no link)
|
---|
200 | *
|
---|
201 | * @param linker
|
---|
202 | * The text item creating the link. Null if not created from
|
---|
203 | * a text item.
|
---|
204 | */
|
---|
205 | public void setLink(String link, Text linker) {
|
---|
206 | _widgetSource.setLink(link, linker);
|
---|
207 | }
|
---|
208 |
|
---|
209 | @Override
|
---|
210 | public void setThickness(float newThickness, boolean setConnected) {
|
---|
211 | if (_widgetSource != null) {
|
---|
212 | float minThickness = _widgetSource.getMinimumBorderThickness();
|
---|
213 | if(newThickness < minThickness)
|
---|
214 | newThickness = minThickness;
|
---|
215 | super.setThickness(newThickness, setConnected);
|
---|
216 | _widgetSource.setSourceThickness(newThickness, false);
|
---|
217 | }
|
---|
218 | }
|
---|
219 |
|
---|
220 | @Override
|
---|
221 | public void setBackgroundColor(Color c) {
|
---|
222 | if (_widgetSource != null) {
|
---|
223 | super.setBackgroundColor(c);
|
---|
224 | _widgetSource.setBackgroundColor(c);
|
---|
225 | }
|
---|
226 | }
|
---|
227 |
|
---|
228 | @Override
|
---|
229 | public void setColor(Color c) {
|
---|
230 | if (_widgetSource != null) {
|
---|
231 | super.setColor(c);
|
---|
232 | _widgetSource.setSourceBorderColor(c);
|
---|
233 | }
|
---|
234 | }
|
---|
235 |
|
---|
236 | @Override
|
---|
237 | public void setData(List<String> data) {
|
---|
238 | _widgetSource.setSourceData(data);
|
---|
239 | }
|
---|
240 |
|
---|
241 | @Override
|
---|
242 | public String getName() {
|
---|
243 | return _widgetSource.getName();
|
---|
244 | }
|
---|
245 |
|
---|
246 | }
|
---|