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.
6
* You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
* or http://www.netbeans.org/cddl.txt.
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]"
15
* The Original Software is NetBeans. The Initial Developer of the Original
16
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17
* Microsystems, Inc. All Rights Reserved.
21
import org.netbeans.api.visual.action.ActionFactory;
22
import org.netbeans.api.visual.anchor.Anchor;
23
import org.netbeans.api.visual.router.Router;
24
import org.netbeans.api.visual.router.RouterFactory;
25
import org.netbeans.api.visual.widget.ConnectionWidget;
26
import org.netbeans.api.visual.widget.LayerWidget;
27
import org.netbeans.api.visual.widget.Scene;
28
import test.SceneSupport;
33
* This test describes issue #96460. It should route the connection correctly. The bug happens when the connection is router as directly (not orthogonally).
35
* @author David Kaspar
37
public class OSRComputeControlPointsTest {
39
public static void main (String[] args) {
40
Scene scene = new Scene ();
41
scene.getActions ().addAction (ActionFactory.createZoomAction (2.0, false));
42
scene.getActions ().addAction (ActionFactory.createPanAction ());
44
LayerWidget connectionLayer = new LayerWidget (scene);
45
scene.addChild (connectionLayer);
47
Router router = RouterFactory.createOrthogonalSearchRouter (connectionLayer);
49
ConnectionWidget conn1 = new ConnectionWidget (scene);
50
conn1.setForeground (new Color (0, 255, 0, 128));
51
conn1.setSourceAnchor (new DirAnchor (new Point (100, 200), Anchor.Direction.LEFT));
52
conn1.setTargetAnchor (new DirAnchor (new Point (400, 300), Anchor.Direction.RIGHT));
53
conn1.setRouter (router);
54
connectionLayer.addChild (conn1);
56
ConnectionWidget conn3 = new ConnectionWidget (scene);
57
conn3.setForeground (new Color (0, 0, 255, 128));
58
conn3.setSourceAnchor (new DirAnchor (new Point (100, 300), Anchor.Direction.LEFT));
59
conn3.setTargetAnchor (new DirAnchor (new Point (400, 200), Anchor.Direction.RIGHT));
60
conn3.setRouter (router);
61
connectionLayer.addChild (conn3);
63
SceneSupport.show (scene);
66
static class DirAnchor extends Anchor {
68
private Point location;
69
private Direction direction;
71
public DirAnchor (Point location, Direction direction) {
73
this.location = location;
74
this.direction = direction;
77
public Point getRelatedSceneLocation () {
81
public Result compute (Entry entry) {
82
return new Result (location, direction);