1 | package org.expeditee.items.widgets;
|
---|
2 |
|
---|
3 | import java.awt.Color;
|
---|
4 | import java.awt.Polygon;
|
---|
5 | import java.util.List;
|
---|
6 |
|
---|
7 | import org.expeditee.items.Item;
|
---|
8 | import org.expeditee.items.Line;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Widget edges define the boundries of an interactive widget.
|
---|
12 | *
|
---|
13 | * @author Brook Novak
|
---|
14 | */
|
---|
15 | public class WidgetEdge extends Line {
|
---|
16 |
|
---|
17 | private InteractiveWidget _widgetSource;
|
---|
18 |
|
---|
19 | WidgetEdge(WidgetCorner start, WidgetCorner end, int id,
|
---|
20 | InteractiveWidget widgetSource) {
|
---|
21 | super(start, end, id);
|
---|
22 |
|
---|
23 | if (widgetSource == null)
|
---|
24 | throw new NullPointerException("widgetSource");
|
---|
25 | _widgetSource = widgetSource;
|
---|
26 | }
|
---|
27 |
|
---|
28 | public InteractiveWidget getWidgetSource() {
|
---|
29 | return _widgetSource;
|
---|
30 | }
|
---|
31 |
|
---|
32 | @Override
|
---|
33 | public Item forceMerge(Item merger, int mouseX, int mouseY) {
|
---|
34 | return null; // Don't allow breaking up of borders
|
---|
35 | }
|
---|
36 |
|
---|
37 | @Override
|
---|
38 | public void toggleArrow() {
|
---|
39 | // Ignore
|
---|
40 | }
|
---|
41 |
|
---|
42 | @Override
|
---|
43 | public void toggleDashed(int amount) {
|
---|
44 | // Ignore
|
---|
45 | }
|
---|
46 |
|
---|
47 | @Override
|
---|
48 | public void toggleArrowHeadRatio(int amount) {
|
---|
49 | // Ignore
|
---|
50 | }
|
---|
51 |
|
---|
52 | @Override
|
---|
53 | public void toggleArrowHeadLength(int amount) {
|
---|
54 | // Ignore
|
---|
55 | }
|
---|
56 |
|
---|
57 | @Override
|
---|
58 | public void setAnnotation(boolean val) {
|
---|
59 | // Ignore
|
---|
60 | }
|
---|
61 |
|
---|
62 | @Override
|
---|
63 | public boolean isAnnotation() {
|
---|
64 | return false;
|
---|
65 | }
|
---|
66 |
|
---|
67 | @Override
|
---|
68 | public void setArrow(float length, double ratio) {
|
---|
69 | }
|
---|
70 |
|
---|
71 | @Override
|
---|
72 | public void setArrowhead(Polygon arrow) {
|
---|
73 | }
|
---|
74 |
|
---|
75 | @Override
|
---|
76 | public void setArrowheadLength(float length) {
|
---|
77 | }
|
---|
78 |
|
---|
79 | @Override
|
---|
80 | public void setArrowheadRatio(double ratio) {
|
---|
81 | }
|
---|
82 |
|
---|
83 | @Override
|
---|
84 | public void setBottomShadowColor(Color bottom) {
|
---|
85 | }
|
---|
86 |
|
---|
87 | @Override
|
---|
88 | public void setFillColor(Color c) {
|
---|
89 | }
|
---|
90 |
|
---|
91 | @Override
|
---|
92 | public void setFillPattern(String patternLink) {
|
---|
93 | }
|
---|
94 |
|
---|
95 | @Override
|
---|
96 | public void setSize(float size) {
|
---|
97 | }
|
---|
98 |
|
---|
99 | @Override
|
---|
100 | public void setFormula(String formula) {
|
---|
101 | }
|
---|
102 |
|
---|
103 | @Override
|
---|
104 | public void setAnchorBottom(Float anchor) {
|
---|
105 | _widgetSource.setAnchorBottom(anchor);
|
---|
106 | }
|
---|
107 |
|
---|
108 | @Override
|
---|
109 | public void setAnchorRight(Float anchor) {
|
---|
110 | _widgetSource.setAnchorRight(anchor);
|
---|
111 | }
|
---|
112 |
|
---|
113 | @Override
|
---|
114 | public Float getAnchorBottom() {
|
---|
115 | return _widgetSource.getSource().getAnchorBottom();
|
---|
116 | }
|
---|
117 |
|
---|
118 | @Override
|
---|
119 | public Float getAnchorRight() {
|
---|
120 | return _widgetSource.getSource().getAnchorRight();
|
---|
121 | }
|
---|
122 |
|
---|
123 | @Override
|
---|
124 | public boolean contains(int x, int y) {
|
---|
125 | return super.contains(x, y) && !_widgetSource.getBounds().contains(x, y);
|
---|
126 | }
|
---|
127 |
|
---|
128 | @Override
|
---|
129 | public Polygon getEnclosedShape() {
|
---|
130 | return getStartItem().getEnclosedShape();
|
---|
131 | }
|
---|
132 |
|
---|
133 | @Override
|
---|
134 | public String getLink() {
|
---|
135 | return _widgetSource.getSource().getLink();
|
---|
136 | }
|
---|
137 |
|
---|
138 | @Override
|
---|
139 | public void setLink(String link) {
|
---|
140 | _widgetSource.setLink(link);
|
---|
141 | }
|
---|
142 |
|
---|
143 | @Override
|
---|
144 | public void setThickness(float newThickness, boolean setConnected) {
|
---|
145 | if (_widgetSource != null) {
|
---|
146 | float minThickness = _widgetSource.getMinimumBorderThickness();
|
---|
147 | if(newThickness < minThickness)
|
---|
148 | newThickness = minThickness;
|
---|
149 | super.setThickness(newThickness, setConnected);
|
---|
150 | _widgetSource.setSourceThickness(newThickness, false);
|
---|
151 | }
|
---|
152 | }
|
---|
153 |
|
---|
154 | @Override
|
---|
155 | public void setBackgroundColor(Color c) {
|
---|
156 | if (_widgetSource != null) {
|
---|
157 | super.setBackgroundColor(c);
|
---|
158 | _widgetSource.setBackgroundColor(c);
|
---|
159 | }
|
---|
160 | }
|
---|
161 |
|
---|
162 | @Override
|
---|
163 | public void setColor(Color c) {
|
---|
164 | if (_widgetSource != null) {
|
---|
165 | super.setColor(c);
|
---|
166 | _widgetSource.setSourceBorderColor(c);
|
---|
167 | }
|
---|
168 | }
|
---|
169 |
|
---|
170 | @Override
|
---|
171 | public void setData(List<String> data) {
|
---|
172 | _widgetSource.setSourceData(data);
|
---|
173 | }
|
---|
174 |
|
---|
175 | @Override
|
---|
176 | public String getName() {
|
---|
177 | return _widgetSource.getName();
|
---|
178 | }
|
---|
179 |
|
---|
180 | }
|
---|