Search in sources :

Example 36 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.

the class ImportTableDataTask method init.

private final void init() {
    this.name2NetworkMap = new HashMap<>();
    this.name2RootMap = new HashMap<>();
    this.source2targetColumnMap = new HashMap<>();
    this.mappedTables = new ArrayList<>();
    final CyNetworkManager netMgr = serviceRegistrar.getService(CyNetworkManager.class);
    if (netMgr.getNetworkSet().size() > 0) {
        whereImportTable = new ListSingleSelection<>(NETWORK_COLLECTION, NETWORK_SELECTION, UNASSIGNED_TABLE);
        whereImportTable.setSelectedValue(NETWORK_COLLECTION);
        networksPresent = true;
    } else {
        whereImportTable = new ListSingleSelection<>(UNASSIGNED_TABLE);
        whereImportTable.setSelectedValue(UNASSIGNED_TABLE);
    }
    if (byReader) {
        if (reader != null && reader.getTables() != null)
            newTableName = reader.getTables()[0].getTitle();
    } else
        newTableName = globalTable.getTitle();
    if (networksPresent) {
        final List<TableType> options = new ArrayList<>();
        for (TableType type : TableType.values()) options.add(type);
        dataTypeTargetForNetworkCollection = new ListSingleSelection<>(options);
        dataTypeTargetForNetworkCollection.setSelectedValue(TableType.NODE_ATTR);
        dataTypeTargetForNetworkList = new ListSingleSelection<>(options);
        dataTypeTargetForNetworkList.setSelectedValue(TableType.NODE_ATTR);
        for (CyNetwork net : netMgr.getNetworkSet()) {
            final String netName = net.getRow(net).get(CyNetwork.NAME, String.class);
            name2NetworkMap.put(netName, net);
        }
        final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
        final List<String> names = new ArrayList<>();
        names.addAll(name2NetworkMap.keySet());
        sort(names);
        if (names.isEmpty()) {
            targetNetworkList = new ListMultipleSelection<>(NO_NETWORKS);
        } else {
            targetNetworkList = new ListMultipleSelection<>(names);
            final CyNetwork currNet = appMgr.getCurrentNetwork();
            if (currNet != null) {
                final String currName = currNet.getRow(currNet).get(CyNetwork.NAME, String.class);
                if (currName != null && targetNetworkList.getPossibleValues().contains(currName))
                    targetNetworkList.setSelectedValues(Collections.singletonList(currName));
            }
            final List<CyNetwork> selectedNetworks = new ArrayList<>();
            for (String netName : targetNetworkList.getSelectedValues()) {
                if (name2NetworkMap.containsKey(netName))
                    selectedNetworks.add(name2NetworkMap.get(netName));
            }
            keyColumnForMappingNetworkList = getColumns(selectedNetworks, dataTypeTargetForNetworkList.getSelectedValue(), CyRootNetwork.DEFAULT_ATTRS);
        }
        final CyRootNetworkManager rootNetMgr = serviceRegistrar.getService(CyRootNetworkManager.class);
        for (CyNetwork net : netMgr.getNetworkSet()) {
            final CyRootNetwork rootNet = rootNetMgr.getRootNetwork(net);
            if (!name2RootMap.containsValue(rootNet))
                name2RootMap.put(rootNet.getRow(rootNet).get(CyRootNetwork.NAME, String.class), rootNet);
        }
        final List<String> rootNames = new ArrayList<>();
        rootNames.addAll(name2RootMap.keySet());
        sort(rootNames);
        targetNetworkCollection = new ListSingleSelection<>(rootNames);
        if (!rootNames.isEmpty()) {
            targetNetworkCollection.setSelectedValue(rootNames.get(0));
            final CyNetwork currNet = appMgr.getCurrentNetwork();
            final CyRootNetwork currRootNet = currNet instanceof CySubNetwork ? rootNetMgr.getRootNetwork(currNet) : null;
            if (currRootNet != null) {
                final String currName = currRootNet.getRow(currRootNet).get(CyNetwork.NAME, String.class);
                if (currName != null && targetNetworkCollection.getPossibleValues().contains(currName))
                    targetNetworkCollection.setSelectedValue(currName);
            }
            keyColumnForMapping = getColumns(Collections.singletonList(name2RootMap.get(targetNetworkCollection.getSelectedValue())), dataTypeTargetForNetworkCollection.getSelectedValue(), CyRootNetwork.SHARED_ATTRS);
        }
    }
}
Also used : CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyNetworkManager(org.cytoscape.model.CyNetworkManager) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 37 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project clusterMaker2 by RBVI.

the class CyActivator method start.

public void start(BundleContext bc) {
    // See if we have a graphics console or not
    boolean haveGUI = true;
    CySwingApplication swingAppRef = getService(bc, CySwingApplication.class);
    if (swingAppRef == null) {
        // if haveGUI is false, we don't want to provide any hooks to the treeview
        haveGUI = false;
    }
    CyApplicationManager appRef = getService(bc, CyApplicationManager.class);
    CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
    CyGroupManager groupManager = getService(bc, CyGroupManager.class);
    CyGroupFactory groupFactory = getService(bc, CyGroupFactory.class);
    CyTableFactory tableFactory = getService(bc, CyTableFactory.class);
    CyTableManager tableManager = getService(bc, CyTableManager.class);
    // Create our context object.  This will probably keep track of all of the
    // registered clustering algorithms, settings, etc.
    ClusterManagerImpl clusterManager = new ClusterManagerImpl(appRef, serviceRegistrar, groupFactory, groupManager, tableFactory, tableManager);
    registerServiceListener(bc, clusterManager, "addClusterAlgorithm", "removeClusterAlgorithm", ClusterTaskFactory.class);
    registerServiceListener(bc, clusterManager, "addClusterVisualizer", "removeClusterVisualizer", ClusterVizFactory.class);
    registerServiceListener(bc, clusterManager, "addRankingAlgorithm", "removeRankingAlgorithm", RankFactory.class);
    // Register each of our algorithms
    // Attribute clusterers
    registerService(bc, new AttributeClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new AutoSOMETaskFactory(clusterManager, true), ClusterTaskFactory.class, new Properties());
    registerService(bc, new FeatureVectorTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new HierarchicalTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new KMeansTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new KMedoidTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new HopachPAMTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new PAMTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    // FIXME: FFT is seriously broken!
    registerService(bc, new FFTTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new DBSCANTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    /*
		 * Hold off on these until we get improve the performance sufficiently
		 * to allow them to be useful
		 */
    // registerService(bc, new BicFinderTaskFactory(clusterManager),
    // ClusterTaskFactory.class, new Properties());
    // registerService(bc, new BiMineTaskFactory(clusterManager),
    // ClusterTaskFactory.class, new Properties());
    registerService(bc, new ChengChurchTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    // Network clusterers
    registerService(bc, new NetworkClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new APClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new AutoSOMETaskFactory(clusterManager, false), ClusterTaskFactory.class, new Properties());
    registerService(bc, new FuzzifierTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new GLayClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new ConnectedComponentsTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new FCMClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new MCLClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new MCODEClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new SCPSClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new TransClustClusterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    // Cluster ranking
    registerService(bc, new MAATaskFactory(clusterManager), RankFactory.class, new Properties());
    registerService(bc, new MAMTaskFactory(clusterManager), RankFactory.class, new Properties());
    registerService(bc, new PRWPTaskFactory(clusterManager), RankFactory.class, new Properties());
    registerService(bc, new PRTaskFactory(clusterManager), RankFactory.class, new Properties());
    registerService(bc, new HITSTaskFactory(clusterManager), RankFactory.class, new Properties());
    // Filters
    registerService(bc, new FilterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new BestNeighborFilterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new CuttingEdgeFilterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new DensityFilterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new HairCutFilterTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    // registerService(bc, new UITaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    // Visualizations
    registerService(bc, new NewNetworkViewFactory(clusterManager, false), ClusterVizFactory.class, new Properties());
    registerService(bc, new NewNetworkViewFactory(clusterManager, true), ClusterVizFactory.class, new Properties());
    registerService(bc, new HeatMapViewTaskFactory(clusterManager), ClusterVizFactory.class, new Properties());
    registerService(bc, new KnnViewTaskFactory(clusterManager), ClusterVizFactory.class, new Properties());
    registerService(bc, new BiclusterViewTaskFactory(clusterManager), ClusterVizFactory.class, new Properties());
    registerService(bc, new TreeViewTaskFactory(clusterManager), ClusterVizFactory.class, new Properties());
    registerService(bc, new CreateResultsPanelTaskFactory(clusterManager, true), ClusterVizFactory.class, new Properties());
    registerService(bc, new CreateRankingPanelTaskFactory(clusterManager, true), ClusterVizFactory.class, new Properties());
    registerService(bc, new DestroyResultsPanelTaskFactory(clusterManager, true), ClusterVizFactory.class, new Properties());
    registerService(bc, new DestroyRankingPanelTaskFactory(clusterManager, true), ClusterVizFactory.class, new Properties());
    // Dimensionality Reduction
    // registerService(bc, new PCAMenuTaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new PCATaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new PCoATaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    registerService(bc, new tSNETaskFactory(clusterManager), ClusterTaskFactory.class, new Properties());
    {
        // Link Network Selections
        LinkSelectionTaskFactory linkTaskFactory = new LinkSelectionTaskFactory(clusterManager);
        Properties linkSelectionProps = new Properties();
        linkSelectionProps.setProperty(INSERT_SEPARATOR_BEFORE, "true");
        linkSelectionProps.setProperty(PREFERRED_MENU, "Apps.clusterMaker Visualizations");
        linkSelectionProps.setProperty(TITLE, "Link selection across networks");
        linkSelectionProps.setProperty(COMMAND, "linkSelection");
        linkSelectionProps.setProperty(COMMAND_NAMESPACE, "clusterviz");
        linkSelectionProps.setProperty(ENABLE_FOR, "networkAndView");
        linkSelectionProps.setProperty(IN_MENU_BAR, "true");
        linkSelectionProps.setProperty(MENU_GRAVITY, "100.0");
        registerService(bc, linkTaskFactory, NetworkTaskFactory.class, linkSelectionProps);
    }
    {
        // UnLink Network Selections
        UnlinkSelectionTaskFactory unlinkTaskFactory = new UnlinkSelectionTaskFactory(clusterManager);
        Properties unlinkSelectionProps = new Properties();
        unlinkSelectionProps.setProperty(PREFERRED_MENU, "Apps.clusterMaker Visualizations");
        unlinkSelectionProps.setProperty(TITLE, "Unlink selection across networks");
        unlinkSelectionProps.setProperty(COMMAND, "unlinkSelection");
        unlinkSelectionProps.setProperty(COMMAND_NAMESPACE, "clusterviz");
        unlinkSelectionProps.setProperty(ENABLE_FOR, "networkAndView");
        unlinkSelectionProps.setProperty(IN_MENU_BAR, "true");
        unlinkSelectionProps.setProperty(MENU_GRAVITY, "100.0");
        registerService(bc, unlinkTaskFactory, NetworkTaskFactory.class, unlinkSelectionProps);
    }
    // Commands
    // These task factories provide useful commands that only make sense in the context of REST or
    // the command interface
    {
        TaskFactory commandTaskFactory = new CommandTaskFactory(clusterManager, "hascluster");
        Properties props = new Properties();
        props.setProperty(COMMAND_NAMESPACE, "cluster");
        props.setProperty(COMMAND, CommandTaskFactory.HASCLUSTER);
        props.setProperty(COMMAND_DESCRIPTION, "Test to see if this network has a cluster of the requested type");
        registerService(bc, commandTaskFactory, TaskFactory.class, props);
    }
    {
        TaskFactory commandTaskFactory = new CommandTaskFactory(clusterManager, "getnetworkcluster");
        Properties props = new Properties();
        props.setProperty(COMMAND_NAMESPACE, "cluster");
        props.setProperty(COMMAND, CommandTaskFactory.GETNETWORKCLUSTER);
        props.setProperty(COMMAND_DESCRIPTION, "Get a cluster network cluster result");
        registerService(bc, commandTaskFactory, TaskFactory.class, props);
    }
    {
        TaskFactory commandTaskFactory = new CommandTaskFactory(clusterManager, "getcluster");
        Properties props = new Properties();
        props.setProperty(COMMAND_NAMESPACE, "cluster");
        props.setProperty(COMMAND, CommandTaskFactory.GETCLUSTER);
        props.setProperty(COMMAND_DESCRIPTION, "Get an attribute cluster result");
        registerService(bc, commandTaskFactory, TaskFactory.class, props);
    }
}
Also used : MCODEClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.MCODE.MCODEClusterTaskFactory) MAMTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.MAM.MAMTaskFactory) HITSTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.HITS.HITSTaskFactory) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) BestNeighborFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.BestNeighbor.BestNeighborFilterTaskFactory) FilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.FilterTaskFactory) DensityFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.Density.DensityFilterTaskFactory) HairCutFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.HairCut.HairCutFilterTaskFactory) CuttingEdgeFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.CuttingEdge.CuttingEdgeFilterTaskFactory) FCMClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.FCM.FCMClusterTaskFactory) CyGroupFactory(org.cytoscape.group.CyGroupFactory) KMedoidTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.kmedoid.KMedoidTaskFactory) CySwingApplication(org.cytoscape.application.swing.CySwingApplication) HairCutFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.HairCut.HairCutFilterTaskFactory) PCATaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.pca.PCATaskFactory) HopachPAMTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.hopach.HopachPAMTaskFactory) FuzzifierTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.Fuzzifier.FuzzifierTaskFactory) MAATaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.MAA.MAATaskFactory) MCLClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.MCL.MCLClusterTaskFactory) CuttingEdgeFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.CuttingEdge.CuttingEdgeFilterTaskFactory) CyApplicationManager(org.cytoscape.application.CyApplicationManager) FFTTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.fft.FFTTaskFactory) HierarchicalTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.hierarchical.HierarchicalTaskFactory) KMeansTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.kmeans.KMeansTaskFactory) ChengChurchTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.ChengChurch.ChengChurchTaskFactory) GLayClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.GLay.GLayClusterTaskFactory) PCoATaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.pcoa.PCoATaskFactory) PAMTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.pam.PAMTaskFactory) HopachPAMTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.hopach.HopachPAMTaskFactory) NetworkClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.NetworkClusterTaskFactory) Properties(java.util.Properties) FeatureVectorTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.featureVector.FeatureVectorTaskFactory) PRTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.PR.PRTaskFactory) BestNeighborFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.BestNeighbor.BestNeighborFilterTaskFactory) CyGroupManager(org.cytoscape.group.CyGroupManager) ConnectedComponentsTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.ConnectedComponents.ConnectedComponentsTaskFactory) TransClustClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.TransClustClusterTaskFactory) AutoSOMETaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.autosome.AutoSOMETaskFactory) DBSCANTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.DBSCAN.DBSCANTaskFactory) AttributeClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.AttributeClusterTaskFactory) APClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.AP.APClusterTaskFactory) PRWPTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.PRWP.PRWPTaskFactory) SCPSClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.SCPS.SCPSClusterTaskFactory) CommandTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.commands.CommandTaskFactory) CyTableFactory(org.cytoscape.model.CyTableFactory) edu.ucsf.rbvi.clusterMaker2.internal.algorithms.tSNEWrapper.tSNETaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.tSNEWrapper.tSNETaskFactory) CyTableManager(org.cytoscape.model.CyTableManager) DensityFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.Density.DensityFilterTaskFactory) NetworkTaskFactory(org.cytoscape.task.NetworkTaskFactory) HITSTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.HITS.HITSTaskFactory) AutoSOMETaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.autosome.AutoSOMETaskFactory) FCMClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.FCM.FCMClusterTaskFactory) KMeansTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.kmeans.KMeansTaskFactory) TransClustClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.TransClustClusterTaskFactory) PCAMenuTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.pca.PCAMenuTaskFactory) FFTTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.fft.FFTTaskFactory) KMedoidTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.kmedoid.KMedoidTaskFactory) SCPSClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.SCPS.SCPSClusterTaskFactory) MCLClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.MCL.MCLClusterTaskFactory) NetworkClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.NetworkClusterTaskFactory) PCATaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.pca.PCATaskFactory) ChengChurchTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.ChengChurch.ChengChurchTaskFactory) APClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.AP.APClusterTaskFactory) edu.ucsf.rbvi.clusterMaker2.internal.algorithms.tSNEWrapper.tSNETaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.tSNEWrapper.tSNETaskFactory) DBSCANTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.DBSCAN.DBSCANTaskFactory) FeatureVectorTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.featureVector.FeatureVectorTaskFactory) HierarchicalTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.hierarchical.HierarchicalTaskFactory) PAMTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.pam.PAMTaskFactory) BestNeighborFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.BestNeighbor.BestNeighborFilterTaskFactory) AttributeClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.AttributeClusterTaskFactory) ConnectedComponentsTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.ConnectedComponents.ConnectedComponentsTaskFactory) PRWPTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.PRWP.PRWPTaskFactory) FilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.FilterTaskFactory) ClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.api.ClusterTaskFactory) TaskFactory(org.cytoscape.work.TaskFactory) DensityFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.Density.DensityFilterTaskFactory) HairCutFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.HairCut.HairCutFilterTaskFactory) NetworkTaskFactory(org.cytoscape.task.NetworkTaskFactory) MAATaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.MAA.MAATaskFactory) FuzzifierTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.Fuzzifier.FuzzifierTaskFactory) PCoATaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.pcoa.PCoATaskFactory) GLayClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.GLay.GLayClusterTaskFactory) MAMTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.MAM.MAMTaskFactory) PRTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.PR.PRTaskFactory) CommandTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.commands.CommandTaskFactory) HopachPAMTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.hopach.HopachPAMTaskFactory) MCODEClusterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.MCODE.MCODEClusterTaskFactory) CuttingEdgeFilterTaskFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.clusterFilters.CuttingEdge.CuttingEdgeFilterTaskFactory)

Example 38 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project cytoscape-api by cytoscape.

the class SetCurrentNetworkViewEventTest method testGoodGetNetworkView.

@Test
public void testGoodGetNetworkView() {
    CyApplicationManager source = mock(CyApplicationManager.class);
    CyNetworkView n = mock(CyNetworkView.class);
    SetCurrentNetworkViewEvent e = new SetCurrentNetworkViewEvent(source, n);
    assertNotNull(e.getNetworkView());
    assertEquals(n, e.getNetworkView());
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) SetCurrentNetworkViewEvent(org.cytoscape.application.events.SetCurrentNetworkViewEvent) CyNetworkView(org.cytoscape.view.model.CyNetworkView) Test(org.junit.Test)

Example 39 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.

the class CySessionManagerImpl method restoreNetworkViews.

private void restoreNetworkViews(final CySession sess, List<CyNetwork> selectedNetworks) {
    logger.debug("Restoring network views...");
    Set<CyNetworkView> netViews = sess.getNetworkViews();
    List<CyNetworkView> selectedViews = new ArrayList<>();
    for (CyNetworkView nv : netViews) {
        CyNetwork network = nv.getModel();
        if (selectedNetworks.contains(network)) {
            selectedViews.add(nv);
        }
    }
    Map<CyNetworkView, Map<VisualProperty<?>, Object>> viewVPMap = new HashMap<>();
    if (netViews != null) {
        final CyNetworkViewManager nvMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
        for (CyNetworkView nv : netViews) {
            if (nv != null) {
                // Save the original values of these visual properties,
                // because we will have to set them again after the views are rendered
                Map<VisualProperty<?>, Object> vpMap = new HashMap<>();
                viewVPMap.put(nv, vpMap);
                vpMap.put(BasicVisualLexicon.NETWORK_HEIGHT, nv.getVisualProperty(BasicVisualLexicon.NETWORK_HEIGHT));
                vpMap.put(BasicVisualLexicon.NETWORK_WIDTH, nv.getVisualProperty(BasicVisualLexicon.NETWORK_WIDTH));
                nvMgr.addNetworkView(nv, false);
            }
        }
    }
    // Let's guarantee the network views are rendered
    final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
    eventHelper.flushPayloadEvents();
    // Set the saved visual properties again, because the renderer may have overwritten the original values
    for (Entry<CyNetworkView, Map<VisualProperty<?>, Object>> entry1 : viewVPMap.entrySet()) {
        CyNetworkView nv = entry1.getKey();
        for (Entry<VisualProperty<?>, Object> entry2 : entry1.getValue().entrySet()) nv.setVisualProperty(entry2.getKey(), entry2.getValue());
    }
    final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
    if (!selectedViews.isEmpty())
        appMgr.setCurrentNetworkView(selectedViews.get(0));
    appMgr.setSelectedNetworkViews(selectedViews);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) HashMap(java.util.HashMap) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) CyApplicationManager(org.cytoscape.application.CyApplicationManager) VisualProperty(org.cytoscape.view.model.VisualProperty) CyNetworkView(org.cytoscape.view.model.CyNetworkView) HashMap(java.util.HashMap) Map(java.util.Map)

Example 40 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.

the class CyNetworkManagerImpl method addNetwork.

@Override
public void addNetwork(final CyNetwork network, final boolean setCurrent) {
    if (network == null)
        throw new NullPointerException("Network is null");
    synchronized (lock) {
        logger.debug("Adding new Network Model: Model ID = " + network.getSUID());
        // Make sure the network has a name
        final CyRow row = network.getRow(network);
        final String name = row.get(CyNetwork.NAME, String.class);
        final String sharedName = row.get(CyRootNetwork.SHARED_NAME, String.class);
        if (name != null && !name.trim().isEmpty() && (sharedName == null || sharedName.trim().isEmpty())) {
            row.set(CyRootNetwork.SHARED_NAME, name);
        } else if (sharedName != null && !sharedName.trim().isEmpty() && (name == null || name.trim().isEmpty())) {
            row.set(CyNetwork.NAME, sharedName);
        } else if ((sharedName == null || sharedName.trim().isEmpty()) && (name == null || name.trim().isEmpty())) {
            final CyNetworkNaming namingUtil = serviceRegistrar.getService(CyNetworkNaming.class);
            final String newName = namingUtil.getSuggestedNetworkTitle("Network");
            row.set(CyNetwork.NAME, newName);
            row.set(CyRootNetwork.SHARED_NAME, newName);
        }
        // Add the new network to the internal map
        networkMap.put(network.getSUID(), network);
    }
    final CyEventHelper cyEventHelper = serviceRegistrar.getService(CyEventHelper.class);
    cyEventHelper.fireEvent(new NetworkAddedEvent(CyNetworkManagerImpl.this, network));
    if (setCurrent) {
        final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
        if (// It may be null when running unit tests
        applicationManager != null)
            applicationManager.setCurrentNetwork(network);
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyEventHelper(org.cytoscape.event.CyEventHelper) NetworkAddedEvent(org.cytoscape.model.events.NetworkAddedEvent) CyNetworkNaming(org.cytoscape.session.CyNetworkNaming) CyRow(org.cytoscape.model.CyRow)

Aggregations

CyApplicationManager (org.cytoscape.application.CyApplicationManager)80 CyNetwork (org.cytoscape.model.CyNetwork)40 CyNetworkView (org.cytoscape.view.model.CyNetworkView)30 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)18 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)16 CyNetworkManager (org.cytoscape.model.CyNetworkManager)14 CyEventHelper (org.cytoscape.event.CyEventHelper)12 CyTable (org.cytoscape.model.CyTable)12 ArrayList (java.util.ArrayList)11 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)10 CyNode (org.cytoscape.model.CyNode)9 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)9 Test (org.junit.Test)9 HashSet (java.util.HashSet)8 CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)8 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)8 TaskIterator (org.cytoscape.work.TaskIterator)8 HashMap (java.util.HashMap)7 CyGroupManager (org.cytoscape.group.CyGroupManager)7 CyTableManager (org.cytoscape.model.CyTableManager)7