Search in sources :

Example 61 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class CySessionManagerImpl method disposeCurrentSession.

@Override
public void disposeCurrentSession() {
    logger.debug("Disposing current session...");
    // Destroy network views
    final CyNetworkViewManager nvMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
    final Set<CyNetworkView> netViews = nvMgr.getNetworkViewSet();
    for (final CyNetworkView nv : netViews) nvMgr.destroyNetworkView(nv);
    nvMgr.reset();
    // Destroy networks
    final CyNetworkManager netMgr = serviceRegistrar.getService(CyNetworkManager.class);
    final Set<CyNetwork> networks = netMgr.getNetworkSet();
    for (final CyNetwork n : networks) netMgr.destroyNetwork(n);
    netMgr.reset();
    // Destroy styles
    logger.debug("Removing current visual styles...");
    final VisualMappingManager vmMgr = serviceRegistrar.getService(VisualMappingManager.class);
    final VisualStyle defaultStyle = vmMgr.getDefaultVisualStyle();
    final List<VisualStyle> allStyles = new ArrayList<>(vmMgr.getAllVisualStyles());
    for (final VisualStyle vs : allStyles) {
        if (!vs.equals(defaultStyle))
            vmMgr.removeVisualStyle(vs);
    }
    // Destroy tables
    final CyTableManager tblMgr = serviceRegistrar.getService(CyTableManager.class);
    tblMgr.reset();
    // Reset groups
    serviceRegistrar.getService(CyGroupManager.class).reset();
    // Unregister session properties
    final Set<CyProperty<?>> cyPropsClone = getAllProperties();
    for (CyProperty<?> cyProps : cyPropsClone) {
        if (cyProps.getSavePolicy().equals(CyProperty.SavePolicy.SESSION_FILE)) {
            serviceRegistrar.unregisterAllServices(cyProps);
            sessionProperties.remove(cyProps.getName());
        }
    }
    // Clear undo stack
    serviceRegistrar.getService(UndoSupport.class).reset();
    // Reset current table and rendering engine
    final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
    appMgr.reset();
    currentFileName = null;
    disposed = true;
}
Also used : CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyApplicationManager(org.cytoscape.application.CyApplicationManager) SimpleCyProperty(org.cytoscape.property.SimpleCyProperty) CyProperty(org.cytoscape.property.CyProperty) CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyTableManager(org.cytoscape.model.CyTableManager) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyGroupManager(org.cytoscape.group.CyGroupManager)

Example 62 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class CreateNetworkViewsAction method updateEnableState.

@Override
public void updateEnableState() {
    final List<CyNetwork> networks = serviceRegistrar.getService(CyApplicationManager.class).getSelectedNetworks();
    final List<CyNetwork> networksWithoutViews = new ArrayList<>();
    final CyNetworkViewManager netViewManager = serviceRegistrar.getService(CyNetworkViewManager.class);
    // TODO Remove when multiple views per network are fully supported
    for (CyNetwork n : networks) {
        if (!netViewManager.viewExists(n))
            networksWithoutViews.add(n);
    }
    int count = networksWithoutViews.size();
    if (count > 0)
        setName("Create " + count + " View" + (count == 1 ? "" : "s"));
    else
        setName("Create Views");
    setEnabled(count > 0);
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork)

Example 63 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class ExportNetworkAction method updateEnableState.

@Override
public void updateEnableState() {
    List<CyNetwork> networks = serviceRegistrar.getService(CyApplicationManager.class).getSelectedNetworks();
    CyNetwork currentNet = serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetwork();
    setEnabled(networks.size() == 1 && networks.get(0).equals(currentNet));
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyNetwork(org.cytoscape.model.CyNetwork)

Example 64 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class LayoutMenuPopulator method checkEnabled.

private boolean checkEnabled() {
    CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
    CyNetwork network = appMgr.getCurrentNetwork();
    if (network == null)
        return false;
    CyNetworkView view = appMgr.getCurrentNetworkView();
    if (view == null)
        return false;
    else
        return true;
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 65 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class EnhancedSearchPanel method doSearching.

// Do searching based on the query string from user on text-field
private void doSearching() {
    final String queryStr = tfSearchText.getText().trim();
    // Ignore if the search term is empty
    if (queryStr == null || queryStr.length() == 0)
        return;
    final CyApplicationManager appManager = serviceRegistrar.getService(CyApplicationManager.class);
    final CyNetwork currentNetwork = appManager.getCurrentNetwork();
    if (currentNetwork != null) {
        final SearchTaskFactory factory = new SearchTaskFactory(searchMgr, queryStr, serviceRegistrar);
        final DialogTaskManager taskMgr = serviceRegistrar.getService(DialogTaskManager.class);
        taskMgr.execute(factory.createTaskIterator(currentNetwork));
    } else {
        logger.error("Could not find network for search");
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) SearchTaskFactory(org.cytoscape.search.internal.SearchTaskFactory) CyNetwork(org.cytoscape.model.CyNetwork) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager)

Aggregations

CyNetwork (org.cytoscape.model.CyNetwork)517 CyNode (org.cytoscape.model.CyNode)183 CyNetworkView (org.cytoscape.view.model.CyNetworkView)129 CyEdge (org.cytoscape.model.CyEdge)108 Test (org.junit.Test)107 ArrayList (java.util.ArrayList)87 CyTable (org.cytoscape.model.CyTable)75 CyApplicationManager (org.cytoscape.application.CyApplicationManager)70 CyIdentifiable (org.cytoscape.model.CyIdentifiable)57 CyRow (org.cytoscape.model.CyRow)48 HashSet (java.util.HashSet)45 CyNetworkManager (org.cytoscape.model.CyNetworkManager)40 HashMap (java.util.HashMap)35 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)35 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)32 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)31 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)30 AbstractNetworkReaderTest (org.cytoscape.io.internal.read.AbstractNetworkReaderTest)27 TaskIterator (org.cytoscape.work.TaskIterator)27 List (java.util.List)26