1 | package org.expeditee.items.widgets;
|
---|
2 |
|
---|
3 | import java.awt.Color;
|
---|
4 | import java.awt.Graphics2D;
|
---|
5 | import java.awt.Polygon;
|
---|
6 | import java.awt.geom.Point2D;
|
---|
7 |
|
---|
8 | import org.expeditee.items.Dot;
|
---|
9 | import org.expeditee.items.ItemParentStateChangedEvent;
|
---|
10 |
|
---|
11 | public class WidgetCorner extends Dot {
|
---|
12 |
|
---|
13 | private InteractiveWidget _widgetSource;
|
---|
14 |
|
---|
15 | WidgetCorner(int x, int y, int id, InteractiveWidget widgetSource) {
|
---|
16 | super(x, y, id);
|
---|
17 |
|
---|
18 |
|
---|
19 | // TODO: REVISE - this is temporary! thickness will of coarse be saved etc..
|
---|
20 | super.setThickness(2.0f);
|
---|
21 |
|
---|
22 | if (widgetSource == null)
|
---|
23 | throw new NullPointerException("widgetSource");
|
---|
24 | _widgetSource = widgetSource;
|
---|
25 | }
|
---|
26 |
|
---|
27 | @Override
|
---|
28 | public void updatePolygon() {
|
---|
29 | super.updatePolygon();
|
---|
30 | if (_widgetSource != null)
|
---|
31 | _widgetSource.onBoundsChanged();
|
---|
32 | }
|
---|
33 |
|
---|
34 | @Override
|
---|
35 | public void setPosition(float x, float y) {
|
---|
36 |
|
---|
37 | invalidateFill();
|
---|
38 | if (_widgetSource != null) { // _widgetSource == null on construction
|
---|
39 | if (!_widgetSource.setPositions(this, x, y)) {
|
---|
40 | super.setPosition(x, y);
|
---|
41 | }
|
---|
42 | } else
|
---|
43 | super.setPosition(x, y);
|
---|
44 | invalidateFill();
|
---|
45 | }
|
---|
46 |
|
---|
47 | @Override
|
---|
48 | public void setXY(float x, float y) {
|
---|
49 | invalidateFill();
|
---|
50 | if (_widgetSource != null) { // _widgetSource == null on construction
|
---|
51 | if (!_widgetSource.setPositions(this, x, y)) {
|
---|
52 | super.setXY(x, y);
|
---|
53 | }
|
---|
54 | } else
|
---|
55 | super.setXY(x, y);
|
---|
56 | invalidateFill();
|
---|
57 | }
|
---|
58 |
|
---|
59 | @Override
|
---|
60 | public void translate(Point2D origin, double ratio) {
|
---|
61 | // super.translate(origin, ratio);
|
---|
62 | }
|
---|
63 |
|
---|
64 | @Override
|
---|
65 | public void onParentStateChanged(ItemParentStateChangedEvent e) {
|
---|
66 | super.onParentStateChanged(e);
|
---|
67 | _widgetSource.onParentStateChanged(e);
|
---|
68 | }
|
---|
69 |
|
---|
70 | public InteractiveWidget getWidgetSource() {
|
---|
71 | return _widgetSource;
|
---|
72 | }
|
---|
73 |
|
---|
74 | @Override
|
---|
75 | public void paint(Graphics2D g) {
|
---|
76 | // For fixed widgets, always have corner selected with connected context
|
---|
77 | HighlightMode tmp = _mode; // save mode
|
---|
78 | if (_mode == HighlightMode.Normal && _widgetSource.isFixedSize()) {
|
---|
79 | _mode = HighlightMode.Connected; // draw as connected context for
|
---|
80 | // fixed widgets
|
---|
81 | }
|
---|
82 | super.paint(g);
|
---|
83 | _mode = tmp; // restore mode
|
---|
84 | }
|
---|
85 |
|
---|
86 | @Override
|
---|
87 | public void paintFill(Graphics2D g) {
|
---|
88 | _widgetSource.paintFill(g); // only paints a fill if floating
|
---|
89 | }
|
---|
90 |
|
---|
91 | @Override
|
---|
92 | public void setAnnotation(boolean val) {
|
---|
93 | // Ignore
|
---|
94 | }
|
---|
95 |
|
---|
96 | @Override
|
---|
97 | public boolean isAnnotation() {
|
---|
98 | return false;
|
---|
99 | }
|
---|
100 |
|
---|
101 | @Override
|
---|
102 | public String toString() {
|
---|
103 | return "WidgetCorner: [" + this.getX() + "," + this.getY() + "]";
|
---|
104 | }
|
---|
105 |
|
---|
106 |
|
---|
107 | @Override
|
---|
108 | public void setThickness(float thick) {
|
---|
109 | // TODO: REVISE
|
---|
110 | }
|
---|
111 |
|
---|
112 | @Override
|
---|
113 | public void setArrow(float length, double ratio) {
|
---|
114 | }
|
---|
115 |
|
---|
116 | @Override
|
---|
117 | public void setArrowhead(Polygon arrow) {
|
---|
118 | }
|
---|
119 |
|
---|
120 | @Override
|
---|
121 | public void setArrowheadLength(float length) {
|
---|
122 | }
|
---|
123 |
|
---|
124 | @Override
|
---|
125 | public void setArrowheadRatio(double ratio) {
|
---|
126 | }
|
---|
127 |
|
---|
128 | @Override
|
---|
129 | public void setBackgroundColor(Color c) {
|
---|
130 | if (_widgetSource != null) {
|
---|
131 | super.setBackgroundColor(c);
|
---|
132 | _widgetSource.getSource().setBackgroundColor(c);
|
---|
133 | }
|
---|
134 | }
|
---|
135 |
|
---|
136 | @Override
|
---|
137 | public void setBottomShadowColor(Color bottom) {
|
---|
138 | }
|
---|
139 |
|
---|
140 | @Override
|
---|
141 | public void setFillColor(Color c) {
|
---|
142 | }
|
---|
143 |
|
---|
144 | @Override
|
---|
145 | public void setFillPattern(String patternLink) {
|
---|
146 | }
|
---|
147 |
|
---|
148 | @Override
|
---|
149 | public void toggleDashed(int amount) {
|
---|
150 | }
|
---|
151 |
|
---|
152 | @Override
|
---|
153 | public void setSize(float size) {
|
---|
154 | }
|
---|
155 |
|
---|
156 | @Override
|
---|
157 | public String getLink() {
|
---|
158 | return _widgetSource.getSource().getLink();
|
---|
159 | }
|
---|
160 |
|
---|
161 | @Override
|
---|
162 | public void setLink(String link) {
|
---|
163 | _widgetSource.setLink(link);
|
---|
164 | }
|
---|
165 |
|
---|
166 | @Override
|
---|
167 | public boolean contains(int x, int y) {
|
---|
168 | return super.contains(x, y) && !getEnclosedShape().contains(x, y);
|
---|
169 | }
|
---|
170 |
|
---|
171 | @Override
|
---|
172 | public void setThickness(float newThickness, boolean setConnected) {
|
---|
173 | if (_widgetSource != null) {
|
---|
174 | float minThickness = _widgetSource.getMinimumBorderThickness();
|
---|
175 | if(newThickness < minThickness)
|
---|
176 | newThickness = minThickness;
|
---|
177 | super.setThickness(newThickness, setConnected);
|
---|
178 | _widgetSource.getSource().setThickness(newThickness, false);
|
---|
179 | }
|
---|
180 | }
|
---|
181 |
|
---|
182 | @Override
|
---|
183 | public void setColor(Color color) {
|
---|
184 | if (_widgetSource != null) {
|
---|
185 | super.setColor(color);
|
---|
186 | _widgetSource.getSource().setColor(color);
|
---|
187 | }
|
---|
188 | }
|
---|
189 | }
|
---|