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 | if (widgetSource == null)
|
---|
22 | throw new NullPointerException("widgetSource");
|
---|
23 | _widgetSource = widgetSource;
|
---|
24 | }
|
---|
25 |
|
---|
26 | public InteractiveWidget getWidgetSource() {
|
---|
27 | return _widgetSource;
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | public Item forceMerge(Item merger, int mouseX, int mouseY) {
|
---|
32 | return null; // Don't allow breaking up of borders
|
---|
33 | }
|
---|
34 |
|
---|
35 | // @Override
|
---|
36 | // public void setThickness(float thick) {
|
---|
37 | // // Ignore
|
---|
38 | // }
|
---|
39 |
|
---|
40 | @Override
|
---|
41 | public void toggleArrow() {
|
---|
42 | // Ignore
|
---|
43 | }
|
---|
44 |
|
---|
45 | @Override
|
---|
46 | public void toggleDashed(int amount) {
|
---|
47 | // Ignore
|
---|
48 | }
|
---|
49 |
|
---|
50 | @Override
|
---|
51 | public void toggleArrowHeadRatio(int amount) {
|
---|
52 | // Ignore
|
---|
53 | }
|
---|
54 |
|
---|
55 | @Override
|
---|
56 | public void toggleArrowHeadLength(int amount) {
|
---|
57 | // Ignore
|
---|
58 | }
|
---|
59 |
|
---|
60 | // @OVERRIDE
|
---|
61 | // PUBLIC VOID SETCOLOR(COLOR C) {
|
---|
62 | // // IGNORE
|
---|
63 | // }
|
---|
64 |
|
---|
65 | @Override
|
---|
66 | public void setAnnotation(boolean val) {
|
---|
67 | // Ignore
|
---|
68 | }
|
---|
69 |
|
---|
70 | @Override
|
---|
71 | public boolean isAnnotation() {
|
---|
72 | return false;
|
---|
73 | }
|
---|
74 |
|
---|
75 | @Override
|
---|
76 | public void setArrow(float length, double ratio) {
|
---|
77 | }
|
---|
78 |
|
---|
79 | @Override
|
---|
80 | public void setArrowhead(Polygon arrow) {
|
---|
81 | }
|
---|
82 |
|
---|
83 | @Override
|
---|
84 | public void setArrowheadLength(float length) {
|
---|
85 | }
|
---|
86 |
|
---|
87 | @Override
|
---|
88 | public void setArrowheadRatio(double ratio) {
|
---|
89 | }
|
---|
90 |
|
---|
91 | @Override
|
---|
92 | public void setBackgroundColor(Color c) {
|
---|
93 | }
|
---|
94 |
|
---|
95 | @Override
|
---|
96 | public void setBottomShadowColor(Color bottom) {
|
---|
97 | }
|
---|
98 |
|
---|
99 | @Override
|
---|
100 | public void setFillColor(Color c) {
|
---|
101 | }
|
---|
102 |
|
---|
103 | @Override
|
---|
104 | public void setFillPattern(String patternLink) {
|
---|
105 | }
|
---|
106 |
|
---|
107 | @Override
|
---|
108 | public void setSize(float size) {
|
---|
109 | }
|
---|
110 |
|
---|
111 | @Override
|
---|
112 | public boolean contains(int x, int y) {
|
---|
113 | return super.contains(x, y) && !getEnclosedShape().contains(x, y);
|
---|
114 | }
|
---|
115 |
|
---|
116 | @Override
|
---|
117 | public Polygon getEnclosedShape() {
|
---|
118 | return getStartItem().getEnclosedShape();
|
---|
119 | }
|
---|
120 |
|
---|
121 | @Override
|
---|
122 | public String getLink() {
|
---|
123 | return _widgetSource.getSource().getLink();
|
---|
124 | }
|
---|
125 |
|
---|
126 | @Override
|
---|
127 | public void setLink(String link) {
|
---|
128 | _widgetSource.setLink(link);
|
---|
129 | }
|
---|
130 |
|
---|
131 | @Override
|
---|
132 | protected boolean dontPaint() {
|
---|
133 | return getThickness() <= 0;
|
---|
134 | }
|
---|
135 |
|
---|
136 | @Override
|
---|
137 | public void setThickness(float newThickness, boolean setConnected) {
|
---|
138 | if (_widgetSource != null) {
|
---|
139 | float minThickness = _widgetSource.getMinimumBorderThickness();
|
---|
140 | if(newThickness < minThickness)
|
---|
141 | newThickness = minThickness;
|
---|
142 | super.setThickness(newThickness, setConnected);
|
---|
143 | _widgetSource.getSource().setThickness(newThickness, false);
|
---|
144 | }
|
---|
145 | }
|
---|
146 |
|
---|
147 | @Override
|
---|
148 | public void setColor(Color color) {
|
---|
149 | if (_widgetSource != null) {
|
---|
150 | super.setColor(color);
|
---|
151 | _widgetSource.getSource().setColor(color);
|
---|
152 | }
|
---|
153 | }
|
---|
154 | }
|
---|