Index: graph/lib/apichanges.xml
===================================================================
RCS file: /cvs/graph/lib/apichanges.xml,v
--- graph/lib/apichanges.xml 3 Apr 2007 16:59:58 -0000 1.8
+++ graph/lib/apichanges.xml 28 May 2007 14:08:00 -0000
@@ -137,6 +137,19 @@
+
+
+
+ Mouse dragging event processing improved
+
+
+
+
+
+ Mouse dragging event processing improved. MoveAction and others are now smoothly scrolling a view.
+
+
+
Index: graph/lib/manifest.mf
===================================================================
RCS file: /cvs/graph/lib/manifest.mf,v
--- graph/lib/manifest.mf 6 Apr 2007 06:43:33 -0000 1.9
+++ graph/lib/manifest.mf 28 May 2007 14:08:00 -0000
@@ -1,4 +1,4 @@
Manifest-Version: 1.0
OpenIDE-Module: org.netbeans.api.visual
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/visual/resources/Bundle.properties
-OpenIDE-Module-Specification-Version: 2.1
+OpenIDE-Module-Specification-Version: 2.3
Index: graph/lib/src/org/netbeans/api/visual/widget/SceneComponent.java
===================================================================
RCS file: /cvs/graph/lib/src/org/netbeans/api/visual/widget/SceneComponent.java,v
--- graph/lib/src/org/netbeans/api/visual/widget/SceneComponent.java 10 Apr 2007 11:50:44 -0000 1.36
+++ graph/lib/src/org/netbeans/api/visual/widget/SceneComponent.java 28 May 2007 14:08:00 -0000
@@ -34,11 +34,14 @@
*/
final class SceneComponent extends JComponent implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener,FocusListener, DropTargetListener {
+ private static final int AUTO_SHIFT = 32;
+
private Scene scene;
private Widget lockedWidget;
private WidgetAction lockedAction;
private long eventIDcounter = 0;
private AccessibleContext accessibleContext;
+ private Point shiftedMouseLocation = new Point ();
public SceneComponent (Scene scene) {
this.scene = scene;
@@ -208,7 +211,11 @@
}
private WidgetAction.State processLocationOperator (Operator operator, WidgetAction.WidgetLocationEvent event) {
- event.setPoint (scene.convertViewToScene (event.getPoint ()));
+ Point viewPoint = event.getPoint ();
+ Point oldScenePoint = scene.convertViewToScene (viewPoint);
+ Point scenePoint = new Point (oldScenePoint);
+ scenePoint.translate (- shiftedMouseLocation.x, - shiftedMouseLocation.y);
+ event.setPoint (scenePoint);
WidgetAction.State state;
Point location;
@@ -244,9 +251,29 @@
lockedAction = state.getLockedAction ();
scene.validate ();
- if (lockedWidget != null)
+ if (lockedWidget != null) {
+ Point previousScreenLocation = getLocationOnScreen ();
scrollRectToVisible (scene.convertSceneToView (lockedWidget.convertLocalToScene (lockedWidget.getBounds ())));
-
+ Point newScreenLocation = getLocationOnScreen ();
+ Point newViewPoint = new Point (viewPoint);
+ newViewPoint.translate (- (newScreenLocation.x - previousScreenLocation.x), - (newScreenLocation.y - previousScreenLocation.y));
+ Point newScenePoint = scene.convertViewToScene (newViewPoint);
+ shiftedMouseLocation.x += newScenePoint.x - oldScenePoint.x;
+ shiftedMouseLocation.y += newScenePoint.y - oldScenePoint.y;
+ if (operator == Operator.MOUSE_DRAGGED) {
+ Rectangle visibleRect = getVisibleRect ();
+ if (viewPoint.x < visibleRect.x)
+ shiftedMouseLocation.x += AUTO_SHIFT;
+ else if (viewPoint.x >= visibleRect.x + visibleRect.width)
+ shiftedMouseLocation.x -= AUTO_SHIFT;
+ if (viewPoint.y < visibleRect.y)
+ shiftedMouseLocation.y += AUTO_SHIFT;
+ else if (viewPoint.y >= visibleRect.y + visibleRect.width)
+ shiftedMouseLocation.y -= AUTO_SHIFT;
+ }
+ } else
+ shiftedMouseLocation.x = shiftedMouseLocation.y = 0;
+
return state;
}