Package diva.graph

Examples of diva.graph.NodeInteractor


        // Add a menu creator.
        _menuCreator = new MenuCreator(null);
        _menuCreator.setMouseFilter(new PopupMouseFilter());

        // FIXME: Why doesn't getNodeInteractor() return a NodeInteractor?
        NodeInteractor interactor = (NodeInteractor) getNodeInteractor();
        interactor.addInteractor(_menuCreator);

        // The contents of the menu is determined by the associated
        // menu factory, which is a protected member of this class.
        // Derived classes can add menu items to it.
        _menuFactory = new PtolemyMenuFactory(controller);

        List configsList = Configuration.configurations();

        Configuration config = null;
        for (Iterator it = configsList.iterator(); it.hasNext();) {
            config = (Configuration) it.next();
            if (config != null)
                break;
        }

        //If a MenuFactory has been defined in the configuration, use this
        //one; otherwise, use the default Ptolemy one:
        if (config != null && _contextMenuFactoryCreator == null) {
            _contextMenuFactoryCreator = (ContextMenuFactoryCreator) config
                    .getAttribute("contextMenuFactory");
        }
        if (_contextMenuFactoryCreator != null) {
            try {
                _menuFactory = (PtolemyMenuFactory) _contextMenuFactoryCreator
                        .createContextMenuFactory(controller);
            } catch (Exception ex) {
                //do nothing - will default to ptii right-click menus
                System.out
                        .println("Unable to use the alternative right-click menu "
                                + "handler that was specified in the "
                                + "configuration; defaulting to ptii handler. "
                                + "Exception was: " + ex);
            }

        }

        // If the above has failed in any way, _menuFactory will still be null,
        // in which case we should default to ptii context menus
        if (_menuFactory == null) {
            _menuFactory = new PtolemyMenuFactory(controller);
        }

        // In this base class, there is only one configure command, so
        // there won't be a submenu. Subclasses convert this to a submenu.
        _configureMenuFactory = new MenuActionFactory(_configureAction);
        _menuFactory.addMenuItemFactory(_configureMenuFactory);
        _menuCreator.setMenuFactory(_menuFactory);

        // Add a double click interactor.
        ActionInteractor doubleClickInteractor = new ActionInteractor(
                _configureAction);
        doubleClickInteractor.setConsuming(false);
        doubleClickInteractor.setMouseFilter(new MouseFilter(1, 0, 0, 2));

        interactor.addInteractor(doubleClickInteractor);

        // NOTE: This dance is so that the
        // doubleClickInteractor gets the events before the drag interactor.
        interactor.setDragInteractor(interactor.getDragInteractor());

        // Set the selection model to allow this to be independently selected.
        SelectionModel sm = controller.getSelectionModel();
        interactor.setSelectionModel(sm);
    }
View Full Code Here


     @param controller The graph controller.
     */
    public LocatableNodeController(GraphController controller) {
        super(controller);

        NodeInteractor nodeInteractor = (NodeInteractor) getNodeInteractor();
        _dragInteractor = new LocatableNodeDragInteractor(this);
        nodeInteractor.setDragInteractor(_dragInteractor);
    }
View Full Code Here

TOP

Related Classes of diva.graph.NodeInteractor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.