org.netbeans.api.visual.router.RouterFactory Java Examples

The following examples show how to use org.netbeans.api.visual.router.RouterFactory. 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: VMDGraphScene.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a VMD graph scene with a specific color scheme.
 * @param scheme the color scheme
 */
public VMDGraphScene (VMDColorScheme scheme) {
    this.scheme = scheme;
    setKeyEventProcessingType (EventProcessingType.FOCUSED_WIDGET_AND_ITS_PARENTS);

    addChild (backgroundLayer);
    addChild (mainLayer);
    addChild (connectionLayer);
    addChild (upperLayer);

    router = RouterFactory.createOrthogonalSearchRouter (mainLayer, connectionLayer);

    getActions ().addAction (ActionFactory.createZoomAction ());
    getActions ().addAction (ActionFactory.createPanAction ());
    getActions ().addAction (ActionFactory.createRectangularSelectAction (this, backgroundLayer));

    sceneLayout = LayoutFactory.createSceneGraphLayout (this, new GridGraphLayout<String, String> ().setChecker (true));
}
 
Example #2
Source File: ConnectionWidget.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a connection widget.
 * @param scene the scene
 */
public ConnectionWidget (Scene scene) {
    super (scene);
    sourceAnchorShape = AnchorShape.NONE;
    targetAnchorShape = AnchorShape.NONE;
    controlPointShape = PointShape.NONE;
    endPointShape = PointShape.NONE;
    router = RouterFactory.createDirectRouter ();
    routingRequired = true;
    connectionWidgetLayout = new ConnectionWidgetLayout ();
    setLayout (connectionWidgetLayout);
    stroke = STROKE_DEFAULT;
    paintControlPoints = false;
    controlPointCutDistance = 0;
    sourceEntry = new ConnectionEntry (true);
    targetEntry = new ConnectionEntry (false);

    routingPolicy = RoutingPolicy.ALWAYS_ROUTE;
}
 
Example #3
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 #4
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 #5
Source File: ControlFlowScene.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    ConnectionWidget w = new BlockConnectionWidget(this, edge);
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #6
Source File: ControlFlowScene.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    ConnectionWidget w = new BlockConnectionWidget(this, edge);
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #7
Source File: ControlFlowScene.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    ConnectionWidget w = new BlockConnectionWidget(this, edge);
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #8
Source File: PageFlowScene.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a VMD graph scene.
 * @param pageFlowView or TopComponent/container.
 */
public PageFlowScene(PageFlowView view) {
    super();
    refPageFlowView = new WeakReference<PageFlowView>(view);

    setOpaque(true);
    setBackground(PAINT_BACKGROUND);

    setKeyEventProcessingType(EventProcessingType.FOCUSED_WIDGET_AND_ITS_PARENTS);

    addChild(backgroundLayer);
    addChild(mainLayer);
    addChild(connectionLayer);
    addChild(upperLayer);

    router = RouterFactory.createOrthogonalSearchRouter(mainLayer, connectionLayer);

    Chain actions = getActions();
    actions.addAction(ActionFactory.createZoomAction());
    actions.addAction(ActionFactory.createPanAction());
    actions.addAction(ActionFactory.createRectangularSelectAction(this, backgroundLayer));
    /*** POPUP_HACK: I have no access to PopupAction so I can't look through the actions and determine which one is a popup.
     * In order to added accessibility to popup I need access to this provider unless an API is created
     * to figure this out another means.
     **/
    actions.addAction(pagePopupAction);
    actions.addAction(createActionMap());
    pfObjectSceneListener = new PFObjectSceneListener();
    addObjectSceneListener(pfObjectSceneListener, ObjectSceneEventType.OBJECT_SELECTION_CHANGED);


    /* Temporary workaround  ISSUE# 107506 Still an issue. */
    //InputMap inputMap = MapActionUtility.initInputMap();
    //ActionMap actionMap = MapActionUtility.initActionMap();
    //actions.addAction(ActionFactory.createActionMapAction(inputMap, actionMap));
    //MyActionMapAction action = new MyActionMapAction(null, null);
    fpnl = new FreePlaceNodesLayouter(this, view.getVisibleRect());
    
}
 
Example #9
Source File: QBGraphScene.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public QBGraphScene(QueryBuilderGraphFrame qbGF) {
    qbGF._firstTableInserted = false;
    mainLayer = new LayerWidget(this);
    connectionLayer = new LayerWidget(this);
    addChild(mainLayer);
    addChild(connectionLayer);
    
    router = RouterFactory.createOrthogonalSearchRouter(mainLayer, connectionLayer);
    getActions().addAction(mouseHoverAction);
    // getActions().addAction(ActionFactory.createZoomAction());
    // ToDo: qbGF has been passed in only to support the menu; eventually, merge QBGF into this
    getActions().addAction(ActionFactory.createPopupMenuAction(qbGF));
}
 
Example #10
Source File: ControlFlowScene.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    ConnectionWidget w = new BlockConnectionWidget(this, edge);
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #11
Source File: ControlFlowScene.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    BlockConnectionWidget w = new BlockConnectionWidget(this, edge);
    switch (edge.getState()) {
        case NEW:
            w.setBold(true);
            break;
        case DELETED:
            w.setDashed(true);
            break;
    }
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #12
Source File: ControlFlowScene.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    ConnectionWidget w = new BlockConnectionWidget(this, edge);
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #13
Source File: ControlFlowScene.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    ConnectionWidget w = new BlockConnectionWidget(this, edge);
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #14
Source File: ControlFlowScene.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachEdgeWidget(InputBlockEdge edge) {
    ConnectionWidget w = new BlockConnectionWidget(this, edge);
    w.setRouter(RouterFactory.createDirectRouter());
    w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    edgeLayer.addChild(w);
    return w;
}
 
Example #15
Source File: LunaticDepScene.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
public LunaticDepScene(VMDColorScheme scheme) {
    this.scheme = scheme;
    setKeyEventProcessingType(EventProcessingType.FOCUSED_WIDGET_AND_ITS_PARENTS);
    addChild(backgroundLayer);
    addChild(mainLayer);
    addChild(connectionLayer);
    addChild(upperLayer);
    orthoRouter = RouterFactory.createOrthogonalSearchRouter(mainLayer, connectionLayer);
    getActions().addAction(ActionFactory.createZoomAction());
    getActions().addAction(ActionFactory.createPanAction());
    getActions().addAction(ActionFactory.createRectangularSelectAction(this, backgroundLayer));
}