Index: graph/examples/src/org/netbeans/modules/visual/examples/RunDialog.java =================================================================== RCS file: /cvs/graph/examples/src/org/netbeans/modules/visual/examples/RunDialog.java,v --- graph/examples/src/org/netbeans/modules/visual/examples/RunDialog.java 19 Jul 2007 07:15:42 -0000 1.77 +++ graph/examples/src/org/netbeans/modules/visual/examples/RunDialog.java 26 Jul 2007 13:21:11 -0000 @@ -35,6 +35,7 @@ "javaone.demo6.LODDemo", "test.action.ActionMapActionTest", "test.action.SelectLockedActionTest", + "test.action.WheelPanActionTest", "test.alignwith.AlignWithMoveGuideLinesTest", "test.alignwith.AlignWithTest", "test.alignwith.AlignWithResizeTest", Index: graph/examples/src/test/action/WheelPanActionTest.java =================================================================== RCS file: graph/examples/src/test/action/WheelPanActionTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ graph/examples/src/test/action/WheelPanActionTest.java 26 Jul 2007 13:21:11 -0000 @@ -0,0 +1,45 @@ +/* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package test.action; + +import org.netbeans.api.visual.action.ActionFactory; +import test.SceneSupport; +import test.general.StringGraphScene; + +import java.awt.*; + +/** + * @author David Kaspar + */ +public class WheelPanActionTest { + + public static void main (String[] args) { + StringGraphScene scene = new StringGraphScene (); + + for (int a = 1; a <= 100; a ++) + scene.addNode (String.valueOf(a)).setPreferredLocation (new Point (a * 10, a * 10)); + + scene.getActions ().addAction (ActionFactory.createWheelPanAction ()); + scene.getActions ().addAction (ActionFactory.createMouseCenteredZoomAction (1.5)); + + SceneSupport.show (scene); + } + +} Index: graph/lib/apichanges.xml =================================================================== RCS file: /cvs/graph/lib/apichanges.xml,v --- graph/lib/apichanges.xml 18 Jul 2007 13:39:40 -0000 1.24 +++ graph/lib/apichanges.xml 26 Jul 2007 13:21:11 -0000 @@ -330,6 +330,20 @@ + + + + WheelPanAction introduced + + + + + + WheelPanAction has been added to allow vertical and horizontal scrolling of a scene view using mouse wheel. + + + + Index: graph/lib/manifest.mf =================================================================== RCS file: /cvs/graph/lib/manifest.mf,v --- graph/lib/manifest.mf 25 Jun 2007 14:10:16 -0000 1.13 +++ graph/lib/manifest.mf 26 Jul 2007 13:21:11 -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.5 +OpenIDE-Module-Specification-Version: 2.7 Index: graph/lib/src/org/netbeans/api/visual/action/ActionFactory.java =================================================================== RCS file: /cvs/graph/lib/src/org/netbeans/api/visual/action/ActionFactory.java,v --- graph/lib/src/org/netbeans/api/visual/action/ActionFactory.java 5 Jun 2007 08:43:25 -0000 1.24 +++ graph/lib/src/org/netbeans/api/visual/action/ActionFactory.java 26 Jul 2007 13:21:11 -0000 @@ -130,6 +130,10 @@ private static final WidgetAction CYCLE_FOCUS_OBJECT_SCENE = createCycleFocusAction (new CycleObjectSceneFocusProvider ()); + private static final PanAction PAN_ACTION = new PanAction (); + + private static final WheelPanAction WHEEL_PAN_ACTION = new WheelPanAction (); + private ActionFactory () { } @@ -401,7 +405,16 @@ * @return the pan action */ public static WidgetAction createPanAction () { - return new PanAction (); + return PAN_ACTION; + } + + /** + * Creates a scene view panning action using mouse-wheel. + * @return the wheel pan action + * @since 2.7 + */ + public static WidgetAction createWheelPanAction () { + return WHEEL_PAN_ACTION; } /** Index: graph/lib/src/org/netbeans/api/visual/widget/doc-files/documentation.html =================================================================== RCS file: /cvs/graph/lib/src/org/netbeans/api/visual/widget/doc-files/documentation.html,v --- graph/lib/src/org/netbeans/api/visual/widget/doc-files/documentation.html 25 Jun 2007 14:10:19 -0000 1.20 +++ graph/lib/src/org/netbeans/api/visual/widget/doc-files/documentation.html 26 Jul 2007 13:21:12 -0000 @@ -967,10 +967,13 @@

PanAction

-Created by: ActionFactory.createPanAction () +Created by: ActionFactory.createPanAction (), ActionFactory.createWheelPanAction ()

The action allows to scroll the view using mouse movement while mouse-middle-button is pressed. It requires to have JComponent view placed into a JScrollPane. This action is usually assigned to a Scene only. + +

+The WheelPanAction allows to scroll ascene view using mouse-wheel. Then no key modifier is pressed, then the view is scrolled vertically. If shift key is held, then the view is scrolled horizontally.

PopupMenuAction

Index: graph/lib/src/org/netbeans/modules/visual/action/WheelPanAction.java =================================================================== RCS file: graph/lib/src/org/netbeans/modules/visual/action/WheelPanAction.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ graph/lib/src/org/netbeans/modules/visual/action/WheelPanAction.java 26 Jul 2007 13:21:12 -0000 @@ -0,0 +1,54 @@ +/* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.modules.visual.action; + +import org.netbeans.api.visual.action.WidgetAction; +import org.netbeans.api.visual.widget.Widget; + +import javax.swing.*; +import java.awt.event.InputEvent; +import java.awt.*; + +/** + * @author David Kaspar + */ +public class WheelPanAction extends WidgetAction.Adapter { + + public State mouseWheelMoved (Widget widget, WidgetMouseWheelEvent event) { + JComponent view = widget.getScene ().getView (); + Rectangle visibleRect = view.getVisibleRect (); + int amount = event.getWheelRotation () * 64; + + switch (event.getModifiers () & (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK | InputEvent.ALT_MASK)) { + case InputEvent.SHIFT_MASK: + visibleRect.x += amount; + break; + case 0: + visibleRect.y += amount; + break; + default: + return State.REJECTED; + } + + view.scrollRectToVisible (visibleRect); + return State.CONSUMED; + } + +} Index: graph/www/documentation.html =================================================================== RCS file: /cvs/graph/www/documentation.html,v --- graph/www/documentation.html 19 Jul 2007 07:15:43 -0000 1.97 +++ graph/www/documentation.html 26 Jul 2007 13:21:12 -0000 @@ -106,6 +106,7 @@
  • javaone.demo6.LODDemo - how to use LevelOfDetailsWidget. Zoom-in to see more.
  • test.action.ActionMapActionTest - how to use ActionMapAction
  • test.action.SelectLockedActionTest - example of proper cooperation of select (which opens another Swing windows) and locking action +
  • test.action.WheelPanActionTest - how to use wheel pan action
  • test.alignwith.AlignWithMoveGuideLinesTest - test of #97034 - incorrectly painted guide-lines for MoveAlignWithAction
  • test.alignwith.AlignWithTest - how to use MoveAlignWithAction
  • test.alignwith.AlignWithResizeTest - how to use AlignWithMoveAction and AlignWithResizeAction