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 |
} |