Lines 34-44
Link Here
|
34 |
*/ |
34 |
*/ |
35 |
final class SceneComponent extends JComponent implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener,FocusListener, DropTargetListener { |
35 |
final class SceneComponent extends JComponent implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener,FocusListener, DropTargetListener { |
36 |
|
36 |
|
|
|
37 |
private static final int AUTO_SHIFT = 32; |
38 |
|
37 |
private Scene scene; |
39 |
private Scene scene; |
38 |
private Widget lockedWidget; |
40 |
private Widget lockedWidget; |
39 |
private WidgetAction lockedAction; |
41 |
private WidgetAction lockedAction; |
40 |
private long eventIDcounter = 0; |
42 |
private long eventIDcounter = 0; |
41 |
private AccessibleContext accessibleContext; |
43 |
private AccessibleContext accessibleContext; |
|
|
44 |
private Point shiftedMouseLocation = new Point (); |
42 |
|
45 |
|
43 |
public SceneComponent (Scene scene) { |
46 |
public SceneComponent (Scene scene) { |
44 |
this.scene = scene; |
47 |
this.scene = scene; |
Lines 208-214
Link Here
|
208 |
} |
211 |
} |
209 |
|
212 |
|
210 |
private WidgetAction.State processLocationOperator (Operator operator, WidgetAction.WidgetLocationEvent event) { |
213 |
private WidgetAction.State processLocationOperator (Operator operator, WidgetAction.WidgetLocationEvent event) { |
211 |
event.setPoint (scene.convertViewToScene (event.getPoint ())); |
214 |
Point viewPoint = event.getPoint (); |
|
|
215 |
Point oldScenePoint = scene.convertViewToScene (viewPoint); |
216 |
Point scenePoint = new Point (oldScenePoint); |
217 |
scenePoint.translate (- shiftedMouseLocation.x, - shiftedMouseLocation.y); |
218 |
event.setPoint (scenePoint); |
212 |
|
219 |
|
213 |
WidgetAction.State state; |
220 |
WidgetAction.State state; |
214 |
Point location; |
221 |
Point location; |
Lines 244-252
Link Here
|
244 |
lockedAction = state.getLockedAction (); |
251 |
lockedAction = state.getLockedAction (); |
245 |
scene.validate (); |
252 |
scene.validate (); |
246 |
|
253 |
|
247 |
if (lockedWidget != null) |
254 |
if (lockedWidget != null) { |
|
|
255 |
Point previousScreenLocation = getLocationOnScreen (); |
248 |
scrollRectToVisible (scene.convertSceneToView (lockedWidget.convertLocalToScene (lockedWidget.getBounds ()))); |
256 |
scrollRectToVisible (scene.convertSceneToView (lockedWidget.convertLocalToScene (lockedWidget.getBounds ()))); |
249 |
|
257 |
Point newScreenLocation = getLocationOnScreen (); |
|
|
258 |
Point newViewPoint = new Point (viewPoint); |
259 |
newViewPoint.translate (- (newScreenLocation.x - previousScreenLocation.x), - (newScreenLocation.y - previousScreenLocation.y)); |
260 |
Point newScenePoint = scene.convertViewToScene (newViewPoint); |
261 |
shiftedMouseLocation.x += newScenePoint.x - oldScenePoint.x; |
262 |
shiftedMouseLocation.y += newScenePoint.y - oldScenePoint.y; |
263 |
if (operator == Operator.MOUSE_DRAGGED) { |
264 |
Rectangle visibleRect = getVisibleRect (); |
265 |
if (viewPoint.x < visibleRect.x) |
266 |
shiftedMouseLocation.x += AUTO_SHIFT; |
267 |
else if (viewPoint.x >= visibleRect.x + visibleRect.width) |
268 |
shiftedMouseLocation.x -= AUTO_SHIFT; |
269 |
if (viewPoint.y < visibleRect.y) |
270 |
shiftedMouseLocation.y += AUTO_SHIFT; |
271 |
else if (viewPoint.y >= visibleRect.y + visibleRect.width) |
272 |
shiftedMouseLocation.y -= AUTO_SHIFT; |
273 |
} |
274 |
} else |
275 |
shiftedMouseLocation.x = shiftedMouseLocation.y = 0; |
276 |
|
250 |
return state; |
277 |
return state; |
251 |
} |
278 |
} |
252 |
|
279 |
|