This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 104662
Collapse All | Expand All

(-)graph/examples/src/org/netbeans/modules/visual/examples/RunDialog.java (+1 lines)
Lines 51-56 Link Here
51
        "test.constraint.ConstraintsTest",
51
        "test.constraint.ConstraintsTest",
52
        "test.context.ContextTest",
52
        "test.context.ContextTest",
53
        "test.controlpoint.AddRemoveControlPointTest",
53
        "test.controlpoint.AddRemoveControlPointTest",
54
        "test.controlpoint.ControlPointsCursorTest",
54
        "test.convolve.ConvolveTest",
55
        "test.convolve.ConvolveTest",
55
        "test.custom.CustomWidgetTest",
56
        "test.custom.CustomWidgetTest",
56
        "test.devolve.DevolveTest",
57
        "test.devolve.DevolveTest",
(-)graph/examples/src/test/controlpoint/ControlPointsCursorTest.java (+85 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
19
package test.controlpoint;
20
21
import org.netbeans.api.visual.anchor.AnchorFactory;
22
import org.netbeans.api.visual.anchor.PointShape;
23
import org.netbeans.api.visual.router.RouterFactory;
24
import org.netbeans.api.visual.widget.ConnectionWidget;
25
import org.netbeans.api.visual.widget.Scene;
26
import org.netbeans.api.visual.widget.LabelWidget;
27
import org.netbeans.api.visual.layout.LayoutFactory;
28
import test.SceneSupport;
29
30
import java.awt.*;
31
32
/**
33
 * @author David Kaspar
34
 */
35
public class ControlPointsCursorTest {
36
37
    public static void main (String[] args) {
38
        Scene scene = new Scene ();
39
40
        ConnectionWidget conn1 = new ConnectionWidget (scene);
41
        conn1.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point(100, 100)));
42
        conn1.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point(200, 150)));
43
        conn1.setRouter (RouterFactory.createOrthogonalSearchRouter ());
44
        conn1.setControlPointShape (PointShape.SQUARE_FILLED_SMALL);
45
        conn1.setEndPointShape (PointShape.SQUARE_FILLED_BIG);
46
        conn1.setCursor (Cursor.getPredefinedCursor (Cursor.CROSSHAIR_CURSOR));
47
        conn1.setControlPointsCursor (Cursor.getPredefinedCursor (Cursor.MOVE_CURSOR));
48
        conn1.setPaintControlPoints (true);
49
        scene.addChild (conn1);
50
        LabelWidget label1 = new LabelWidget (scene, "both connection widget and control points cursors should be used");
51
        conn1.addChild (label1);
52
        conn1.setConstraint (label1, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_RIGHT, 0.5f);
53
54
        ConnectionWidget conn2 = new ConnectionWidget (scene);
55
        conn2.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point(100, 200)));
56
        conn2.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point(200, 250)));
57
        conn2.setRouter (RouterFactory.createOrthogonalSearchRouter ());
58
        conn2.setControlPointShape (PointShape.SQUARE_FILLED_SMALL);
59
        conn2.setEndPointShape (PointShape.SQUARE_FILLED_BIG);
60
        conn2.setCursor (Cursor.getPredefinedCursor (Cursor.CROSSHAIR_CURSOR));
61
        conn2.setControlPointsCursor (null);
62
        conn2.setPaintControlPoints (true);
63
        scene.addChild (conn2);
64
        LabelWidget label2 = new LabelWidget (scene, "connection widget cursor should be used only");
65
        conn2.addChild (label2);
66
        conn2.setConstraint (label2, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_RIGHT, 0.5f);
67
68
        ConnectionWidget conn3 = new ConnectionWidget (scene);
69
        conn3.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point(100, 300)));
70
        conn3.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point(200, 350)));
71
        conn3.setRouter (RouterFactory.createOrthogonalSearchRouter ());
72
        conn3.setControlPointShape (PointShape.SQUARE_FILLED_SMALL);
73
        conn3.setEndPointShape (PointShape.SQUARE_FILLED_BIG);
74
        conn3.setCursor (Cursor.getPredefinedCursor (Cursor.CROSSHAIR_CURSOR));
75
        conn3.setControlPointsCursor (Cursor.getPredefinedCursor (Cursor.MOVE_CURSOR));
76
        conn3.setPaintControlPoints (false);
77
        scene.addChild (conn3);
78
        LabelWidget label3 = new LabelWidget (scene, "none of cursors should be used");
79
        conn3.addChild (label3);
80
        conn3.setConstraint (label3, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_RIGHT, 0.5f);
81
82
        SceneSupport.show (scene);
83
    }
84
85
}
(-)graph/lib/apichanges.xml (+15 lines)
Lines 137-142 Link Here
137
            <class package="org.netbeans.api.visual.widget" name="Widget" link="yes"/>
137
            <class package="org.netbeans.api.visual.widget" name="Widget" link="yes"/>
138
            <issue number="98307"/>
138
            <issue number="98307"/>
139
        </change>
139
        </change>
140
141
        <change>
142
            <api name="general"/>
143
            <summary>Widget.getCursorAt method introduced, ConnectionWidget.controlPointsCursor property added</summary>
144
            <version major="2" minor="3"/>
145
            <date day="28" month="5" year="2007"/>
146
            <author login="dkaspar"/>
147
            <compatibility addition="yes"/>
148
            <description>
149
                Now the mouse cursor is changed also based on its local location in a widget.
150
		        Therefore ConnectionWidget has controlPointsCursor property which defines a cursor for mouse over control points.
151
            </description>
152
            <package name="org.netbeans.api.visual.widget" link="yes"/>
153
            <issue number="104662"/>
154
        </change>
140
    </changes>
155
    </changes>
141
156
142
    <htmlcontents>
157
    <htmlcontents>
(-)graph/lib/manifest.mf (-1 / +1 lines)
Lines 1-4 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.api.visual
2
OpenIDE-Module: org.netbeans.api.visual
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/visual/resources/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/visual/resources/Bundle.properties
4
OpenIDE-Module-Specification-Version: 2.1
4
OpenIDE-Module-Specification-Version: 2.3
(-)graph/lib/src/org/netbeans/api/visual/widget/ConnectionWidget.java (-1 / +38 lines)
Lines 75-80 Link Here
75
    private Stroke stroke;
75
    private Stroke stroke;
76
    private boolean paintControlPoints;
76
    private boolean paintControlPoints;
77
    private Color lineColor;
77
    private Color lineColor;
78
    private Cursor controlPointsCursor;
78
79
79
    private Anchor.Entry sourceEntry;
80
    private Anchor.Entry sourceEntry;
80
    private Anchor.Entry targetEntry;
81
    private Anchor.Entry targetEntry;
Lines 155-161 Link Here
155
156
156
    /**
157
    /**
157
     * Sets whether the control (and end) points are painted
158
     * Sets whether the control (and end) points are painted
158
     * @param paintControlPoints
159
     * @param paintControlPoints if true, then control points are painted
159
     */
160
     */
160
    public final void setPaintControlPoints (boolean paintControlPoints) {
161
    public final void setPaintControlPoints (boolean paintControlPoints) {
161
        this.paintControlPoints = paintControlPoints;
162
        this.paintControlPoints = paintControlPoints;
Lines 163-168 Link Here
163
    }
164
    }
164
165
165
    /**
166
    /**
167
     * Returns the cursor for control point.
168
     * @return the cursor
169
     * @since 2.3
170
     */
171
    public final Cursor getControlPointsCursor () {
172
        return controlPointsCursor;
173
    }
174
175
    /**
176
     * Sets a control points cursor. The cursor is used only when mouse is over a visible control point
177
     * @param controlPointsCursor the control points cursor
178
     * @since 2.3
179
     */
180
    public final void setControlPointsCursor (Cursor controlPointsCursor) {
181
        this.controlPointsCursor = controlPointsCursor;
182
    }
183
184
    /**
166
     * Returns a source anchor of the connection widget.
185
     * Returns a source anchor of the connection widget.
167
     * @return the source anchor
186
     * @return the source anchor
168
     */
187
     */
Lines 458-463 Link Here
458
        revalidate ();
477
        revalidate ();
459
    }
478
    }
460
479
480
461
    /**
481
    /**
462
     * Returns the first control point.
482
     * Returns the first control point.
463
     * @return the first control point; null, if list of control points is empty
483
     * @return the first control point; null, if list of control points is empty
Lines 580-585 Link Here
580
        }
600
        }
581
601
582
        return -1;
602
        return -1;
603
    }
604
605
    /**
606
     * Returns a cursor for a specified local location in the widget.
607
     * If paintControlPoints is true and controlPointsCursor is non-null and local location is over a control point, then it return controlPointsCursor.
608
     * Otherwise it return value from super.getCursorAt method.
609
     * @param localLocation the local location
610
     * @return the cursor
611
     * @since 2.3
612
     */
613
    protected Cursor getCursorAt (Point localLocation) {
614
        if (paintControlPoints) {
615
            Cursor pointsCursor = getControlPointsCursor ();
616
            if (pointsCursor != null  &&  getControlPointHitAt (localLocation) >= 0)
617
                return pointsCursor;
618
        }
619
        return super.getCursorAt (localLocation);
583
    }
620
    }
584
621
585
    /**
622
    /**
(-)graph/lib/src/org/netbeans/api/visual/widget/SceneComponent.java (-3 / +3 lines)
Lines 473-479 Link Here
473
                    return true;
473
                    return true;
474
            }
474
            }
475
            if (widget.isHitAt (point))
475
            if (widget.isHitAt (point))
476
                context.update (widget);
476
                context.update (widget, point);
477
        }
477
        }
478
478
479
//        point.translate (location.x, location.y);
479
//        point.translate (location.x, location.y);
Lines 601-609 Link Here
601
        private Cursor cursor;
601
        private Cursor cursor;
602
        private AccessibleContext accessibleContext;
602
        private AccessibleContext accessibleContext;
603
603
604
        public boolean update (Widget widget) {
604
        public boolean update (Widget widget, Point localLocation) {
605
            if (cursor == null)
605
            if (cursor == null)
606
                cursor = widget.getCursor ();
606
                cursor = widget.getCursorAt (localLocation);
607
            if (toolTipText == null)
607
            if (toolTipText == null)
608
                toolTipText = widget.getToolTipText ();
608
                toolTipText = widget.getToolTipText ();
609
            if (accessibleContext == null)
609
            if (accessibleContext == null)
(-)graph/lib/src/org/netbeans/api/visual/widget/Widget.java (+9 lines)
Lines 753-758 Link Here
753
    }
753
    }
754
754
755
    /**
755
    /**
756
     * Returns a mouse cursor for a specified local location in the widget.
757
     * @return the mouse cursor; default implementation return value of cursor property.
758
     * @since 2.3
759
     */
760
    protected Cursor getCursorAt (Point localLocation) {
761
        return getCursor ();
762
    }
763
764
    /**
756
     * Returns a mouse cursor for the widget.
765
     * Returns a mouse cursor for the widget.
757
     * @return the mouse cursor
766
     * @return the mouse cursor
758
     */
767
     */
(-)graph/lib/src/org/netbeans/api/visual/widget/doc-files/documentation.html (+9 lines)
Lines 320-325 Link Here
320
<td>getBorder<br>setBorder
320
<td>getBorder<br>setBorder
321
<td>Controls the widget border. <code>EmptyBorder</code> by default. See <a href="#Border">Border</a> section.
321
<td>Controls the widget border. <code>EmptyBorder</code> by default. See <a href="#Border">Border</a> section.
322
<tr>
322
<tr>
323
<td>getCursor<br>setCursor
324
<td>Controls the widget cursor. <code>null</code> by default.
325
<tr>
323
<td>getLayout<br>setLayout
326
<td>getLayout<br>setLayout
324
<td>Controls the widget layout. The layout defines placement of children. <code>AbsoluteLayout</code> by default. See <a href="#Layout">Layout</a> section.
327
<td>Controls the widget layout. The layout defines placement of children. <code>AbsoluteLayout</code> by default. See <a href="#Layout">Layout</a> section.
325
<tr>
328
<tr>
Lines 400-405 Link Here
400
<tr>
403
<tr>
401
<td>protected notifyAdded<br>protected notifyRemoved
404
<td>protected notifyAdded<br>protected notifyRemoved
402
<td>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.
405
<td>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.
406
<tr>
407
<td>protected getCursorAt(Point localLocation)
408
<td>Called to get a cursor of a specified local location of the widget.
403
</table>
409
</table>
404
410
405
<p>
411
<p>
Lines 1125-1130 Link Here
1125
1131
1126
<p>
1132
<p>
1127
A connection can have assigned a source and a target <code>AnchorShape</code> and a end-point and control-point <code>PointShape</code>. 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: <code>AnchorShape.NONE</code>, <code>AnchorShape.TRIANGLE_HOLLOW</code>, <code>AnchorShape.TRIANGLE_FILLED</code>, <code>AnchorShape.TRIANGLE_OUT</code>. Other built-in anchor shapes can be created by <code>AnchorShapeFactory</code> class. There are 2 predefined point shapes: <code>PointShape.SQUARE_FILLED_BIG</code>, <code>PointShape.SQUARE_FILLED_SMALL</code>. Other built-in point shapes can be created using <code>PointShapeFactory</code> class.
1133
A connection can have assigned a source and a target <code>AnchorShape</code> and a end-point and control-point <code>PointShape</code>. 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: <code>AnchorShape.NONE</code>, <code>AnchorShape.TRIANGLE_HOLLOW</code>, <code>AnchorShape.TRIANGLE_FILLED</code>, <code>AnchorShape.TRIANGLE_OUT</code>. Other built-in anchor shapes can be created by <code>AnchorShapeFactory</code> class. There are 2 predefined point shapes: <code>PointShape.SQUARE_FILLED_BIG</code>, <code>PointShape.SQUARE_FILLED_SMALL</code>. Other built-in point shapes can be created using <code>PointShapeFactory</code> class.
1134
1135
<p>
1136
There is a <code>controlPointsCursor</code> property which defines a mouse cursor when the mouse is over a visible control point.
1128
1137
1129
<h3><a name="Router">Router</a></h3>
1138
<h3><a name="Router">Router</a></h3>
1130
1139
(-)graph/www/documentation.html (+1 lines)
Lines 122-127 Link Here
122
<li><strong>test.constraint.ConstraintsTest</strong> - how to use widget constraints
122
<li><strong>test.constraint.ConstraintsTest</strong> - how to use widget constraints
123
<li><strong>test.context.ContextTest</strong> - test of mouse-cursor context resolving
123
<li><strong>test.context.ContextTest</strong> - test of mouse-cursor context resolving
124
<li><strong>test.controlpoint.AddRemoveControlPointTest</strong> - how to use <code>AddRemoveControlPointAction</code> and <code>MoveControlPointAction</code>
124
<li><strong>test.controlpoint.AddRemoveControlPointTest</strong> - how to use <code>AddRemoveControlPointAction</code> and <code>MoveControlPointAction</code>
125
<li><strong>test.controlpoint.ControlPointsCursorTest</strong> - test of <code>ConnectionWidget.controlPointsCursor</code> property
125
<li><strong>test.convolve.ConvolveTest</strong> - how to use <code>ConvolveWidget</code>
126
<li><strong>test.convolve.ConvolveTest</strong> - how to use <code>ConvolveWidget</code>
126
<li><strong>test.custom.CustomWidgetTest</strong> - how to create a custom widget
127
<li><strong>test.custom.CustomWidgetTest</strong> - how to create a custom widget
127
<li><strong>test.devolve.DevolveTest</strong> - how to use scene-layout
128
<li><strong>test.devolve.DevolveTest</strong> - how to use scene-layout

Return to bug 104662