source: trunk/src/org/expeditee/items/widgets/WidgetEdge.java@ 1102

Last change on this file since 1102 was 1102, checked in by davidb, 6 years ago

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

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