|
Lines 66-78
Link Here
|
| 66 |
addMouseListener(new MouseListener.Stub() { |
66 |
addMouseListener(new MouseListener.Stub() { |
| 67 |
public void mousePressed(MouseEvent event) { |
67 |
public void mousePressed(MouseEvent event) { |
| 68 |
event.consume(); |
68 |
event.consume(); |
| 69 |
offset.setWidth(event.x - getLocation().x()); |
69 |
offset.width = event.x - getLocation().x; |
| 70 |
offset.setHeight(event.y - getLocation().y()); |
70 |
offset.height = event.y - getLocation().y; |
| 71 |
} |
71 |
} |
| 72 |
|
72 |
|
| 73 |
public void mouseReleased(MouseEvent event) { |
73 |
public void mouseReleased(MouseEvent event) { |
| 74 |
offset.setWidth(0); |
74 |
offset.width = 0; |
| 75 |
offset.setHeight(0); |
75 |
offset.height = 0; |
| 76 |
if (event.button == 3) { |
76 |
if (event.button == 3) { |
| 77 |
getParent().remove(oFigure); |
77 |
getParent().remove(oFigure); |
| 78 |
getParent().remove(thisFigure); |
78 |
getParent().remove(thisFigure); |
|
Lines 95-102
Link Here
|
| 95 |
addMouseMotionListener(new MouseMotionListener.Stub() { |
95 |
addMouseMotionListener(new MouseMotionListener.Stub() { |
| 96 |
public void mouseDragged(MouseEvent event) { |
96 |
public void mouseDragged(MouseEvent event) { |
| 97 |
Rectangle rect = getBounds().getCopy(); |
97 |
Rectangle rect = getBounds().getCopy(); |
| 98 |
rect.setX(event.x - offset.width()); |
98 |
rect.x = event.x - offset.width; |
| 99 |
rect.setY(event.y - offset.height()); |
99 |
rect.y = event.y - offset.height; |
| 100 |
setBounds(rect); |
100 |
setBounds(rect); |
| 101 |
int index = 0; |
101 |
int index = 0; |
| 102 |
if (isSource) { |
102 |
if (isSource) { |
|
Lines 105-111
Link Here
|
| 105 |
router.removePath(path); |
105 |
router.removePath(path); |
| 106 |
paths.remove(path); |
106 |
paths.remove(path); |
| 107 |
sourceList.remove(loc); |
107 |
sourceList.remove(loc); |
| 108 |
loc = new Point(rect.x() + 10, rect.y() + 10); |
108 |
loc = new Point(rect.x + 10, rect.y + 10); |
| 109 |
sourceList.add(index, loc); |
109 |
sourceList.add(index, loc); |
| 110 |
path = new Path(loc, (Point) targetList.get(index)); |
110 |
path = new Path(loc, (Point) targetList.get(index)); |
| 111 |
router.addPath(path); |
111 |
router.addPath(path); |
|
Lines 117-123
Link Here
|
| 117 |
router.removePath(path); |
117 |
router.removePath(path); |
| 118 |
paths.remove(path); |
118 |
paths.remove(path); |
| 119 |
targetList.remove(loc); |
119 |
targetList.remove(loc); |
| 120 |
loc = new Point(rect.x() + 10, rect.y() + 10); |
120 |
loc = new Point(rect.x + 10, rect.y + 10); |
| 121 |
targetList.add(index, loc); |
121 |
targetList.add(index, loc); |
| 122 |
path = new Path((Point) sourceList.get(index), loc); |
122 |
path = new Path((Point) sourceList.get(index), loc); |
| 123 |
router.addPath(path); |
123 |
router.addPath(path); |
|
Lines 148-160
Link Here
|
| 148 |
addMouseListener(new MouseListener.Stub() { |
148 |
addMouseListener(new MouseListener.Stub() { |
| 149 |
public void mousePressed(MouseEvent event) { |
149 |
public void mousePressed(MouseEvent event) { |
| 150 |
event.consume(); |
150 |
event.consume(); |
| 151 |
offset.setWidth(event.x - getLocation().x()); |
151 |
offset.width = event.x - getLocation().x; |
| 152 |
offset.setHeight(event.y - getLocation().y()); |
152 |
offset.height = event.y - getLocation().y; |
| 153 |
} |
153 |
} |
| 154 |
|
154 |
|
| 155 |
public void mouseReleased(MouseEvent event) { |
155 |
public void mouseReleased(MouseEvent event) { |
| 156 |
offset.setWidth(0); |
156 |
offset.width = 0; |
| 157 |
offset.setHeight(0); |
157 |
offset.height = 0; |
| 158 |
if (event.button == 3) { |
158 |
if (event.button == 3) { |
| 159 |
getParent().remove(thisFigure); |
159 |
getParent().remove(thisFigure); |
| 160 |
router.removeObstacle((Rectangle) ObstructionExample.obstacleMap |
160 |
router.removeObstacle((Rectangle) ObstructionExample.obstacleMap |
|
Lines 167-174
Link Here
|
| 167 |
public void mouseDragged(MouseEvent event) { |
167 |
public void mouseDragged(MouseEvent event) { |
| 168 |
|
168 |
|
| 169 |
Rectangle rect = getBounds().getCopy(); |
169 |
Rectangle rect = getBounds().getCopy(); |
| 170 |
rect.setX(event.x - offset.width()); |
170 |
rect.x = event.x - offset.width; |
| 171 |
rect.setY(event.y - offset.height()); |
171 |
rect.y = event.y - offset.height; |
| 172 |
router.updateObstacle( |
172 |
router.updateObstacle( |
| 173 |
(Rectangle) ObstructionExample.obstacleMap |
173 |
(Rectangle) ObstructionExample.obstacleMap |
| 174 |
.get(thisFigure), rect); |
174 |
.get(thisFigure), rect); |
|
Lines 183-191
Link Here
|
| 183 |
super.paint(graphics); |
183 |
super.paint(graphics); |
| 184 |
Rectangle b = getBounds(); |
184 |
Rectangle b = getBounds(); |
| 185 |
Point p = b.getCenter().translate(-22, -15); |
185 |
Point p = b.getCenter().translate(-22, -15); |
| 186 |
graphics.drawString("y:" + b.y() + "h:" + b.height(), p); |
186 |
graphics.drawString("y:" + b.y + "h:" + b.height, p); |
| 187 |
p.setY(p.y() + 12); |
187 |
p.y = p.y + 12; |
| 188 |
graphics.drawString("x:" + b.x() + "w:" + b.width(), p); |
188 |
graphics.drawString("x:" + b.x + "w:" + b.width, p); |
| 189 |
} |
189 |
} |
| 190 |
} |
190 |
} |
| 191 |
|
191 |
|
|
Lines 211-217
Link Here
|
| 211 |
|
211 |
|
| 212 |
public void mouseReleased(MouseEvent event) { |
212 |
public void mouseReleased(MouseEvent event) { |
| 213 |
if (event.button == 1) { |
213 |
if (event.button == 1) { |
| 214 |
if (Math.abs(pPoint.x() - event.getLocation().x()) > 10) { |
214 |
if (Math.abs(pPoint.x - event.getLocation().x) > 10) { |
| 215 |
DragFigure f = new DragFigure(); |
215 |
DragFigure f = new DragFigure(); |
| 216 |
add(f); |
216 |
add(f); |
| 217 |
|
217 |
|
|
Lines 229-237
Link Here
|
| 229 |
targetList.add(event.getLocation()); |
229 |
targetList.add(event.getLocation()); |
| 230 |
EllipseDragFigure eFigure = new EllipseDragFigure( |
230 |
EllipseDragFigure eFigure = new EllipseDragFigure( |
| 231 |
event.getLocation(), false); |
231 |
event.getLocation(), false); |
| 232 |
eFigure.setBounds(new Rectangle(event.getLocation() |
232 |
eFigure.setBounds(new Rectangle( |
| 233 |
.x() - 10, event.getLocation().y() - 10, |
233 |
event.getLocation().x - 10, event |
| 234 |
20, 20)); |
234 |
.getLocation().y - 10, 20, 20)); |
| 235 |
add(eFigure); |
235 |
add(eFigure); |
| 236 |
firstPointCreated = false; |
236 |
firstPointCreated = false; |
| 237 |
figure.addOtherFigure(eFigure); |
237 |
figure.addOtherFigure(eFigure); |
|
Lines 250-258
Link Here
|
| 250 |
pressPoint = event.getLocation(); |
250 |
pressPoint = event.getLocation(); |
| 251 |
EllipseDragFigure eFigure = new EllipseDragFigure( |
251 |
EllipseDragFigure eFigure = new EllipseDragFigure( |
| 252 |
event.getLocation(), true); |
252 |
event.getLocation(), true); |
| 253 |
eFigure.setBounds(new Rectangle(event.getLocation() |
253 |
eFigure.setBounds(new Rectangle( |
| 254 |
.x() - 10, event.getLocation().y() - 10, |
254 |
event.getLocation().x - 10, event |
| 255 |
20, 20)); |
255 |
.getLocation().y - 10, 20, 20)); |
| 256 |
add(eFigure); |
256 |
add(eFigure); |
| 257 |
figure = eFigure; |
257 |
figure = eFigure; |
| 258 |
firstPointCreated = true; |
258 |
firstPointCreated = true; |