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();
}
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;
}
Aggregations