Java Code Examples for org.netbeans.api.visual.widget.ConnectionWidget#setTargetAnchor()

The following examples show how to use org.netbeans.api.visual.widget.ConnectionWidget#setTargetAnchor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConnectionWidgetCollisionsCollectorTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testCollisionsCollector () {
    Scene scene = new Scene ();

    ConnectionWidget widget = new ConnectionWidget (scene);
    widget.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point (100, 100)));
    widget.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point (300, 200)));
    widget.setRouter (RouterFactory.createOrthogonalSearchRouter (new CollisionsCollector() {
        public void collectCollisions (List<Rectangle> verticalCollisions, List<Rectangle> horizontalCollisions) {
            getRef ().println ("CollisionsCollector invoked");
        }
    }));
    scene.addChild (widget);

    JFrame frame = showFrame (scene);
    frame.setVisible(false);
    frame.dispose ();
    
    compareReferenceFiles ();
}
 
Example 2
Source File: ConnectionWidgetCollisionsCollectorTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testConnectionWidgetCollisionsCollector () {
    Scene scene = new Scene ();

    final ConnectionWidget widget = new ConnectionWidget (scene);
    widget.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point (100, 100)));
    widget.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point (300, 200)));
    widget.setRouter (RouterFactory.createOrthogonalSearchRouter (new ConnectionWidgetCollisionsCollector () {
        public void collectCollisions (ConnectionWidget connectionWidget, List<Rectangle> verticalCollisions, List<Rectangle> horizontalCollisions) {
            getRef ().println ("ConnectionWidgetCollisionsCollector invoked - is widget valid: " + (connectionWidget == widget));
        }
    }));
    scene.addChild (widget);

    JFrame frame = showFrame (scene);
    frame.setVisible(false);
    frame.dispose ();

    compareReferenceFiles ();
}
 
Example 3
Source File: BasicTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testShow () {
    Scene scene = new Scene ();
    
    LayerWidget mainLayer = new LayerWidget (scene);
    scene.addChild(mainLayer);
    
    Widget w1 = new Widget (scene);
    w1.setBorder (BorderFactory.createLineBorder ());
    w1.setPreferredLocation (new Point (100, 100));
    w1.setPreferredSize (new Dimension (40, 20));
    mainLayer.addChild(w1);
    
    Widget w2 = new Widget (scene);
    w2.setBorder (BorderFactory.createLineBorder ());
    w2.setPreferredLocation (new Point (200, 100));
    w2.setPreferredSize (new Dimension (40, 20));
    mainLayer.addChild(w2);
    
    LayerWidget connLayer = new LayerWidget (scene);
    scene.addChild(connLayer);
    
    ConnectionWidget conn = new ConnectionWidget(scene);
    conn.setSourceAnchor(AnchorFactory.createRectangularAnchor(w1));
    conn.setTargetAnchor(AnchorFactory.createRectangularAnchor(w2));
    connLayer.addChild(conn);
    
    Color color = (Color) (new DefaultLookFeel()).getBackground();
    assertScene (scene, color,
            new Rectangle (99, 99, 42, 22),
            new Rectangle (199, 99, 42, 22),
            new Rectangle (138, 108, 64, 4)
    );
}
 
Example 4
Source File: AnchorNotificationTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testNotify () {
    StringBuffer log = new StringBuffer ();
    Scene scene = new Scene ();

    Widget w = new Widget (scene);
    scene.addChild (w);

    ConnectionWidget c = new ConnectionWidget (scene);
    scene.addChild (c);
    TestAnchor testAnchor = new TestAnchor (w, log);
    c.setSourceAnchor (testAnchor);
    c.setTargetAnchor (testAnchor);

    JFrame frame = showFrame (scene);

    c.setSourceAnchor (null);
    c.setTargetAnchor (null);
    scene.validate ();

    frame.setVisible (false);
    frame.dispose ();

    assertEquals (log.toString (),
            "notifyEntryAdded\n" +
            "notifyUsed\n" +
            "notifyRevalidate\n" +
            "notifyEntryAdded\n" +
            "notifyRevalidate\n" +
            "notifyRevalidate\n" +
            "compute\n" +
            "compute\n" +
            "notifyEntryRemoved\n" +
            "notifyRevalidate\n" +
            "notifyEntryRemoved\n" +
            "notifyUnused\n" +
            "notifyRevalidate\n"
            );
}
 
Example 5
Source File: AbegoTreeLayoutForNetbeansDemo.java    From treelayout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void attachEdgeTargetAnchor(String edge,
		String oldTargetNode, String targetNode) {
	ConnectionWidget edgeWidget = (ConnectionWidget) findWidget(edge);
	Widget targetNodeWidget = findWidget(targetNode);
	Anchor targetAnchor = AnchorFactory
			.createRectangularAnchor(targetNodeWidget);
	edgeWidget.setTargetAnchor(targetAnchor);
}