org.netbeans.api.visual.anchor.AnchorFactory Java Examples

The following examples show how to use org.netbeans.api.visual.anchor.AnchorFactory. 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 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 #2
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 #3
Source File: PageFlowScene.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Anchor getPinAnchor(Pin pin) {
    if (pin == null) {
        return null;
    }
    VMDNodeWidget nodeWidget = (VMDNodeWidget) findWidget(getPinNode(pin));
    Widget pinMainWidget = findWidget(pin);
    Anchor anchor;
    if (pinMainWidget != null) {
        anchor = AnchorFactory.createDirectionalAnchor(pinMainWidget, AnchorFactory.DirectionalAnchorKind.HORIZONTAL, 8);
        anchor = nodeWidget.createAnchorPin(anchor);
    } else {
        anchor = nodeWidget.getNodeAnchor();
    }
    return anchor;
}
 
Example #4
Source File: VMDGraphScene.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Anchor getPinAnchor (String pin) {
    if (pin == null)
        return null;
    VMDNodeWidget nodeWidget = (VMDNodeWidget) findWidget (getPinNode (pin));
    Widget pinMainWidget = findWidget (pin);
    Anchor anchor;
    if (pinMainWidget != null) {
        anchor = AnchorFactory.createDirectionalAnchor (pinMainWidget, AnchorFactory.DirectionalAnchorKind.HORIZONTAL, 8);
        anchor = nodeWidget.createAnchorPin (anchor);
    } else
        anchor = nodeWidget.getNodeAnchor ();
    return anchor;
}
 
Example #5
Source File: VMDNodeWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an extended pin anchor with an ability of reconnecting to the node anchor when the node is minimized.
 * @param anchor the original pin anchor from which the extended anchor is created
 * @return the extended pin anchor, the returned anchor is cached and returns a single extended pin anchor instance of each original pin anchor
 */
public Anchor createAnchorPin (Anchor anchor) {
    Anchor proxyAnchor = proxyAnchorCache.get (anchor);
    if (proxyAnchor == null) {
        proxyAnchor = AnchorFactory.createProxyAnchor (stateModel, anchor, nodeAnchor);
        proxyAnchorCache.put (anchor, proxyAnchor);
    }
    return proxyAnchor;
}
 
Example #6
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 #7
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);
}
 
Example #8
Source File: AbegoTreeLayoutForNetbeansDemo.java    From treelayout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void attachEdgeSourceAnchor(String edge,
		String oldSourceNode, String sourceNode) {
	ConnectionWidget edgeWidget = (ConnectionWidget) findWidget(edge);
	Widget sourceNodeWidget = findWidget(sourceNode);
	Anchor sourceAnchor = AnchorFactory
			.createRectangularAnchor(sourceNodeWidget);
	edgeWidget.setSourceAnchor(sourceAnchor);
}
 
Example #9
Source File: RuleScene.java    From jlibs with Apache License 2.0 4 votes vote down vote up
@Override
protected void attachEdgeSourceAnchor(Edge edge, Node oldSource, Node newSource){
    Widget w = newSource!=null ? findWidget(newSource) : null;
    ((ConnectionWidget)findWidget(edge)).setSourceAnchor(AnchorFactory.createRectangularAnchor(w));
}
 
Example #10
Source File: QBGraphScene.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void attachEdgeSourceAnchor(Object edge, Object oldSourceNode, Object sourceNode) {
    ((ConnectionWidget) findWidget(edge)).setSourceAnchor(AnchorFactory.createRectangularAnchor(findWidget(sourceNode)));
}
 
Example #11
Source File: QBGraphScene.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void attachEdgeTargetAnchor(Object edge, Object oldTargetNode, Object targetNode) {
    ((ConnectionWidget) findWidget(edge)).setTargetAnchor(AnchorFactory.createRectangularAnchor(findWidget(targetNode)));
}
 
Example #12
Source File: StringGraphScene.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
protected void attachEdgeTargetAnchor (String edge, String oldTargetNode, String targetNode) {
    ((ConnectionWidget) findWidget (edge)).setTargetAnchor (AnchorFactory.createRectangularAnchor (findWidget (targetNode)));
}
 
Example #13
Source File: RuleScene.java    From jlibs with Apache License 2.0 4 votes vote down vote up
@Override
protected void attachEdgeTargetAnchor(Edge edge, Node oldTarget, Node newTarget){
    Widget w = newTarget!=null ? findWidget(newTarget) : null;
    ((ConnectionWidget)findWidget(edge)).setTargetAnchor(AnchorFactory.createRectangularAnchor(w));
}
 
Example #14
Source File: ModelGraphScene.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
protected void attachEdgeSourceAnchor (String edge, String oldSourceNode, String sourceNode) {
    Widget w = sourceNode != null ? findWidget (sourceNode) : null;
    ((ConnectionWidget) findWidget (edge)).setSourceAnchor (AnchorFactory.createRectangularAnchor (w));
}
 
Example #15
Source File: ModelGraphScene.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
protected void attachEdgeTargetAnchor (String edge, String oldTargetNode, String targetNode) {
    Widget w = targetNode != null ? findWidget (targetNode) : null;
    ((ConnectionWidget) findWidget (edge)).setTargetAnchor (AnchorFactory.createRectangularAnchor (w));
}
 
Example #16
Source File: StringGraphScene.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
protected void attachEdgeSourceAnchor (String edge, String oldSourceNode, String sourceNode) {
    ((ConnectionWidget) findWidget (edge)).setSourceAnchor (AnchorFactory.createRectangularAnchor (findWidget (sourceNode)));
}
 
Example #17
Source File: DependencyGraphScene.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override protected void attachEdgeSourceAnchor(GraphEdge edge,
        GraphNode oldsource,
        GraphNode source) {
    ((ConnectionWidget) findWidget(edge)).setSourceAnchor(AnchorFactory.createRectangularAnchor(findWidget(source)));
    
}
 
Example #18
Source File: Utils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void attachEdgeTargetAnchor(String edge, String oldTargetNode, String targetNode) {
    Widget w = targetNode != null ? findWidget(targetNode) : null;
    ((ConnectionWidget) findWidget(edge)).setTargetAnchor(AnchorFactory.createRectangularAnchor(w));
}
 
Example #19
Source File: Utils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void attachEdgeSourceAnchor(String edge, String oldSourceNode, String sourceNode) {
    Widget w = sourceNode != null ? findWidget(sourceNode) : null;
    ((ConnectionWidget) findWidget(edge)).setSourceAnchor(AnchorFactory.createRectangularAnchor(w));
}
 
Example #20
Source File: GraphLayoutListenerRemoval197502Test.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void attachEdgeTargetAnchor(String edge, String oldTargetNode, String targetNode) {
    ((ConnectionWidget) findWidget(edge)).setTargetAnchor(AnchorFactory.createRectangularAnchor(findWidget(targetNode)));
}
 
Example #21
Source File: GraphLayoutListenerRemoval197502Test.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void attachEdgeSourceAnchor(String edge, String oldSourceNode, String sourceNode) {
    ((ConnectionWidget) findWidget(edge)).setSourceAnchor(AnchorFactory.createRectangularAnchor(findWidget(sourceNode)));
}
 
Example #22
Source File: ActionFactory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Anchor createFloatAnchor (Point location) {
    return AnchorFactory.createFixedAnchor (location);
}
 
Example #23
Source File: ActionFactory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Anchor createReplacementWidgetAnchor (Widget replacementWidget) {
    return AnchorFactory.createCenterAnchor (replacementWidget);
}
 
Example #24
Source File: ActionFactory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Anchor createFloatAnchor (Point location) {
    return AnchorFactory.createFixedAnchor (location);
}
 
Example #25
Source File: ActionFactory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Anchor createTargetAnchor (Widget targetWidget) {
    return AnchorFactory.createCenterAnchor (targetWidget);
}
 
Example #26
Source File: ActionFactory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Anchor createSourceAnchor (Widget sourceWidget) {
    return AnchorFactory.createCenterAnchor (sourceWidget);
}
 
Example #27
Source File: DirectionalAnchor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public DirectionalAnchor (Widget widget, AnchorFactory.DirectionalAnchorKind kind, int gap) {
        super (widget);
//        assert widget != null;
        this.kind = kind;
        this.gap = gap;
    }
 
Example #28
Source File: DependencyGraphScene.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override protected void attachEdgeTargetAnchor(GraphEdge edge,
        GraphNode oldtarget,
        GraphNode target) {
    NodeWidget wid = (NodeWidget)findWidget(target);
    ((ConnectionWidget) findWidget(edge)).setTargetAnchor(AnchorFactory.createRectangularAnchor(wid));
}