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 retrieving revision 1.64 diff -u -r1.64 RunDialog.java --- graph/examples/src/org/netbeans/modules/visual/examples/RunDialog.java 2 May 2007 04:34:21 -0000 1.64 +++ graph/examples/src/org/netbeans/modules/visual/examples/RunDialog.java 28 May 2007 14:03:38 -0000 @@ -51,6 +51,7 @@ "test.constraint.ConstraintsTest", "test.context.ContextTest", "test.controlpoint.AddRemoveControlPointTest", + "test.controlpoint.ControlPointsCursorTest", "test.convolve.ConvolveTest", "test.custom.CustomWidgetTest", "test.devolve.DevolveTest", Index: graph/examples/src/test/controlpoint/ControlPointsCursorTest.java =================================================================== RCS file: graph/examples/src/test/controlpoint/ControlPointsCursorTest.java diff -N graph/examples/src/test/controlpoint/ControlPointsCursorTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ graph/examples/src/test/controlpoint/ControlPointsCursorTest.java 28 May 2007 14:03:38 -0000 @@ -0,0 +1,85 @@ +/* + * 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 test.controlpoint; + +import org.netbeans.api.visual.anchor.AnchorFactory; +import org.netbeans.api.visual.anchor.PointShape; +import org.netbeans.api.visual.router.RouterFactory; +import org.netbeans.api.visual.widget.ConnectionWidget; +import org.netbeans.api.visual.widget.Scene; +import org.netbeans.api.visual.widget.LabelWidget; +import org.netbeans.api.visual.layout.LayoutFactory; +import test.SceneSupport; + +import java.awt.*; + +/** + * @author David Kaspar + */ +public class ControlPointsCursorTest { + + public static void main (String[] args) { + Scene scene = new Scene (); + + ConnectionWidget conn1 = new ConnectionWidget (scene); + conn1.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point(100, 100))); + conn1.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point(200, 150))); + conn1.setRouter (RouterFactory.createOrthogonalSearchRouter ()); + conn1.setControlPointShape (PointShape.SQUARE_FILLED_SMALL); + conn1.setEndPointShape (PointShape.SQUARE_FILLED_BIG); + conn1.setCursor (Cursor.getPredefinedCursor (Cursor.CROSSHAIR_CURSOR)); + conn1.setControlPointsCursor (Cursor.getPredefinedCursor (Cursor.MOVE_CURSOR)); + conn1.setPaintControlPoints (true); + scene.addChild (conn1); + LabelWidget label1 = new LabelWidget (scene, "both connection widget and control points cursors should be used"); + conn1.addChild (label1); + conn1.setConstraint (label1, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_RIGHT, 0.5f); + + ConnectionWidget conn2 = new ConnectionWidget (scene); + conn2.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point(100, 200))); + conn2.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point(200, 250))); + conn2.setRouter (RouterFactory.createOrthogonalSearchRouter ()); + conn2.setControlPointShape (PointShape.SQUARE_FILLED_SMALL); + conn2.setEndPointShape (PointShape.SQUARE_FILLED_BIG); + conn2.setCursor (Cursor.getPredefinedCursor (Cursor.CROSSHAIR_CURSOR)); + conn2.setControlPointsCursor (null); + conn2.setPaintControlPoints (true); + scene.addChild (conn2); + LabelWidget label2 = new LabelWidget (scene, "connection widget cursor should be used only"); + conn2.addChild (label2); + conn2.setConstraint (label2, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_RIGHT, 0.5f); + + ConnectionWidget conn3 = new ConnectionWidget (scene); + conn3.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point(100, 300))); + conn3.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point(200, 350))); + conn3.setRouter (RouterFactory.createOrthogonalSearchRouter ()); + conn3.setControlPointShape (PointShape.SQUARE_FILLED_SMALL); + conn3.setEndPointShape (PointShape.SQUARE_FILLED_BIG); + conn3.setCursor (Cursor.getPredefinedCursor (Cursor.CROSSHAIR_CURSOR)); + conn3.setControlPointsCursor (Cursor.getPredefinedCursor (Cursor.MOVE_CURSOR)); + conn3.setPaintControlPoints (false); + scene.addChild (conn3); + LabelWidget label3 = new LabelWidget (scene, "none of cursors should be used"); + conn3.addChild (label3); + conn3.setConstraint (label3, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_RIGHT, 0.5f); + + SceneSupport.show (scene); + } + +} Index: graph/lib/apichanges.xml =================================================================== RCS file: /cvs/graph/lib/apichanges.xml,v retrieving revision 1.8 diff -u -r1.8 apichanges.xml --- graph/lib/apichanges.xml 3 Apr 2007 16:59:58 -0000 1.8 +++ graph/lib/apichanges.xml 28 May 2007 14:03:38 -0000 @@ -137,6 +137,21 @@ + + + + Widget.getCursorAt method introduced, ConnectionWidget.controlPointsCursor property added + + + + + + Now the mouse cursor is changed also based on its local location in a widget. + Therefore ConnectionWidget has controlPointsCursor property which defines a cursor for mouse over control points. + + + + Index: graph/lib/manifest.mf =================================================================== RCS file: /cvs/graph/lib/manifest.mf,v retrieving revision 1.9 diff -u -r1.9 manifest.mf --- graph/lib/manifest.mf 6 Apr 2007 06:43:33 -0000 1.9 +++ graph/lib/manifest.mf 28 May 2007 14:03:38 -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/ConnectionWidget.java =================================================================== RCS file: /cvs/graph/lib/src/org/netbeans/api/visual/widget/ConnectionWidget.java,v retrieving revision 1.37 diff -u -r1.37 ConnectionWidget.java --- graph/lib/src/org/netbeans/api/visual/widget/ConnectionWidget.java 30 Jan 2007 16:07:27 -0000 1.37 +++ graph/lib/src/org/netbeans/api/visual/widget/ConnectionWidget.java 28 May 2007 14:03:38 -0000 @@ -75,6 +75,7 @@ private Stroke stroke; private boolean paintControlPoints; private Color lineColor; + private Cursor controlPointsCursor; private Anchor.Entry sourceEntry; private Anchor.Entry targetEntry; @@ -155,7 +156,7 @@ /** * Sets whether the control (and end) points are painted - * @param paintControlPoints + * @param paintControlPoints if true, then control points are painted */ public final void setPaintControlPoints (boolean paintControlPoints) { this.paintControlPoints = paintControlPoints; @@ -163,6 +164,24 @@ } /** + * Returns the cursor for control point. + * @return the cursor + * @since 2.3 + */ + public final Cursor getControlPointsCursor () { + return controlPointsCursor; + } + + /** + * Sets a control points cursor. The cursor is used only when mouse is over a visible control point + * @param controlPointsCursor the control points cursor + * @since 2.3 + */ + public final void setControlPointsCursor (Cursor controlPointsCursor) { + this.controlPointsCursor = controlPointsCursor; + } + + /** * Returns a source anchor of the connection widget. * @return the source anchor */ @@ -458,6 +477,7 @@ revalidate (); } + /** * Returns the first control point. * @return the first control point; null, if list of control points is empty @@ -580,6 +600,23 @@ } return -1; + } + + /** + * Returns a cursor for a specified local location in the widget. + * If paintControlPoints is true and controlPointsCursor is non-null and local location is over a control point, then it return controlPointsCursor. + * Otherwise it return value from super.getCursorAt method. + * @param localLocation the local location + * @return the cursor + * @since 2.3 + */ + protected Cursor getCursorAt (Point localLocation) { + if (paintControlPoints) { + Cursor pointsCursor = getControlPointsCursor (); + if (pointsCursor != null && getControlPointHitAt (localLocation) >= 0) + return pointsCursor; + } + return super.getCursorAt (localLocation); } /** 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 retrieving revision 1.36 diff -u -r1.36 SceneComponent.java --- 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:03:38 -0000 @@ -473,7 +473,7 @@ return true; } if (widget.isHitAt (point)) - context.update (widget); + context.update (widget, point); } // point.translate (location.x, location.y); @@ -601,9 +601,9 @@ private Cursor cursor; private AccessibleContext accessibleContext; - public boolean update (Widget widget) { + public boolean update (Widget widget, Point localLocation) { if (cursor == null) - cursor = widget.getCursor (); + cursor = widget.getCursorAt (localLocation); if (toolTipText == null) toolTipText = widget.getToolTipText (); if (accessibleContext == null) Index: graph/lib/src/org/netbeans/api/visual/widget/Widget.java =================================================================== RCS file: /cvs/graph/lib/src/org/netbeans/api/visual/widget/Widget.java,v retrieving revision 1.56 diff -u -r1.56 Widget.java --- graph/lib/src/org/netbeans/api/visual/widget/Widget.java 11 Apr 2007 09:39:22 -0000 1.56 +++ graph/lib/src/org/netbeans/api/visual/widget/Widget.java 28 May 2007 14:03:38 -0000 @@ -753,6 +753,15 @@ } /** + * Returns a mouse cursor for a specified local location in the widget. + * @return the mouse cursor; default implementation return value of cursor property. + * @since 2.3 + */ + protected Cursor getCursorAt (Point localLocation) { + return getCursor (); + } + + /** * Returns a mouse cursor for the widget. * @return the mouse cursor */ 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 retrieving revision 1.9 diff -u -r1.9 documentation.html --- graph/lib/src/org/netbeans/api/visual/widget/doc-files/documentation.html 23 Apr 2007 15:24:52 -0000 1.9 +++ graph/lib/src/org/netbeans/api/visual/widget/doc-files/documentation.html 28 May 2007 14:03:39 -0000 @@ -320,6 +320,9 @@ getBorder
setBorder Controls the widget border. EmptyBorder by default. See Border section. +getCursor
setCursor +Controls the widget cursor. null by default. + getLayout
setLayout Controls the widget layout. The layout defines placement of children. AbsoluteLayout by default. See Layout section. @@ -400,6 +403,9 @@ protected notifyAdded
protected notifyRemoved Called to notify that a widget is being show or hidden in the view. Within these methods, do not modify the tree hierarchy of scene. + +protected getCursorAt(Point localLocation) +Called to get a cursor of a specified local location of the widget.

@@ -1125,6 +1131,9 @@

A connection can have assigned a source and a target AnchorShape and a end-point and control-point PointShape. Source AnchorShape is used for defining a shape of a source point. Target anchor shape is used for defining a shape of a target point. An end point shape is used defining a shape of first or last control point. A control point shape is used for defining a shape of other control points except first and last. There are 4 predefined anchor shapes: AnchorShape.NONE, AnchorShape.TRIANGLE_HOLLOW, AnchorShape.TRIANGLE_FILLED, AnchorShape.TRIANGLE_OUT. Other built-in anchor shapes can be created by AnchorShapeFactory class. There are 2 predefined point shapes: PointShape.SQUARE_FILLED_BIG, PointShape.SQUARE_FILLED_SMALL. Other built-in point shapes can be created using PointShapeFactory class. + +

+There is a controlPointsCursor property which defines a mouse cursor when the mouse is over a visible control point.

Router

Index: graph/www/documentation.html =================================================================== RCS file: /cvs/graph/www/documentation.html,v retrieving revision 1.83 diff -u -r1.83 documentation.html --- graph/www/documentation.html 2 May 2007 04:34:21 -0000 1.83 +++ graph/www/documentation.html 28 May 2007 14:03:39 -0000 @@ -122,6 +122,7 @@
  • test.constraint.ConstraintsTest - how to use widget constraints
  • test.context.ContextTest - test of mouse-cursor context resolving
  • test.controlpoint.AddRemoveControlPointTest - how to use AddRemoveControlPointAction and MoveControlPointAction +
  • test.controlpoint.ControlPointsCursorTest - test of ConnectionWidget.controlPointsCursor property
  • test.convolve.ConvolveTest - how to use ConvolveWidget
  • test.custom.CustomWidgetTest - how to create a custom widget
  • test.devolve.DevolveTest - how to use scene-layout