Search in sources :

Example 6 with GravityTracker

use of org.cytoscape.util.swing.GravityTracker in project cytoscape-impl by cytoscape.

the class CytoscapeMenuBar method getMenu.

/**
 * @return the menu named in the given String. The String may contain
 *         multiple menu names, separated by dots ('.'). If any contained
 *         menu name does not correspond to an existing menu, then that menu
 *         will be created as a child of the menu preceeding the most recent
 *         dot or, if there is none, then as a child of this MenuBar.
 */
public JMenu getMenu(String menu_string) {
    if (menu_string == null)
        menu_string = DEFAULT_MENU_SPECIFIER;
    final GravityTracker gravityTracker = menuTracker.getGravityTracker(menu_string);
    revalidate();
    repaint();
    return (JMenu) gravityTracker.getMenu();
}
Also used : GravityTracker(org.cytoscape.util.swing.GravityTracker) JMenu(javax.swing.JMenu)

Example 7 with GravityTracker

use of org.cytoscape.util.swing.GravityTracker in project cytoscape-impl by cytoscape.

the class PopupMenuHelper method addCyMenuItem.

/**
 * This method creates popup menu submenus and menu items based on the
 * "preferredMenu" keyword.
 */
private void addCyMenuItem(View<?> view, JPopupMenu popup, CyMenuItem menuItem, JMenuTracker tracker, Map props) {
    String pref = null;
    if (props != null)
        pref = (String) (props.get(PREFERRED_MENU));
    if (pref == null)
        pref = APPS_MENU;
    // This is a *very* special case we used to help with Dynamic Linkout
    if (pref.equalsIgnoreCase(menuItem.getMenuItem().getText()) && menuItem.getMenuItem() instanceof JMenu) {
        final GravityTracker gravityTracker = tracker.getGravityTracker(pref);
        JMenu menu = (JMenu) menuItem.getMenuItem();
        for (int menuIndex = 0; menuIndex < menu.getItemCount(); menuIndex++) {
            JMenuItem item = menu.getItem(menuIndex);
            gravityTracker.addMenuItem(item, -1);
        }
        return;
    }
    final GravityTracker gravityTracker = tracker.getGravityTracker(pref);
    gravityTracker.addMenuItem(menuItem.getMenuItem(), menuItem.getMenuGravity());
    return;
}
Also used : GravityTracker(org.cytoscape.util.swing.GravityTracker) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) Point(java.awt.Point)

Aggregations

GravityTracker (org.cytoscape.util.swing.GravityTracker)7 JMenu (javax.swing.JMenu)5 JMenuItem (javax.swing.JMenuItem)4 Point (java.awt.Point)2 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)1 KeyStroke (javax.swing.KeyStroke)1 AbstractCyAction (org.cytoscape.application.swing.AbstractCyAction)1 CyEdge (org.cytoscape.model.CyEdge)1 CyNetwork (org.cytoscape.model.CyNetwork)1 CyNode (org.cytoscape.model.CyNode)1 VisualProperty (org.cytoscape.view.model.VisualProperty)1