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