Search in sources :

Example 1 with HeaderInfo

use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo in project clusterMaker2 by RBVI.

the class TreeView method setNodeSelection.

private void setNodeSelection(List<CyNode> nodeArray, boolean select) {
    // System.out.println("Selecting "+nodeArray.size()+" nodes in network "+myNetwork);
    HeaderInfo geneInfo = dataModel.getGeneHeaderInfo();
    geneSelection.deleteObserver(this);
    geneSelection.setSelectedNode(null);
    geneSelection.deselectAllIndexes();
    for (CyNode cyNode : nodeArray) {
        if (!myNetwork.containsNode(cyNode))
            continue;
        int geneIndex = geneInfo.getHeaderIndex(ModelUtils.getName(myNetwork, cyNode));
        // System.out.println("setting "+cyNode+"("+geneIndex+") to "+select);
        geneSelection.setIndex(geneIndex, select);
    }
    geneSelection.deleteObserver(this);
    geneSelection.notifyObservers();
    geneSelection.addObserver(this);
}
Also used : HeaderInfo(edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo) CyNode(org.cytoscape.model.CyNode)

Example 2 with HeaderInfo

use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo in project clusterMaker2 by RBVI.

the class TreeView method update.

public void update(Observable o, Object arg) {
    CyNetworkView currentView = manager.getNetworkView();
    CyNetwork currentNetwork = manager.getNetwork();
    // See if we're supposed to disable our listeners
    if ((o == arraySelection) && (arg instanceof Boolean)) {
        // System.out.println("Changing disable listeners to: "+arg.toString());
        disableListeners = ((Boolean) arg).booleanValue();
    }
    if (disableListeners)
        return;
    if (o == geneSelection) {
        // System.out.println("Gene selection");
        selectedNodes.clear();
        int[] selections = geneSelection.getSelectedIndexes();
        HeaderInfo geneInfo = dataModel.getGeneHeaderInfo();
        String[] names = geneInfo.getNames();
        for (int i = 0; i < selections.length; i++) {
            String nodeName = geneInfo.getHeader(selections[i])[0];
            CyNode node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, nodeName, CyNode.class);
            // Now see if this network has this node
            if (node != null && !currentNetwork.containsNode(node)) {
                // No, try dropping any suffixes from the node name
                String[] tokens = nodeName.split(" ");
                node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, tokens[0], CyNode.class);
            }
            if (node != null)
                selectedNodes.add(node);
        }
        // System.out.println("Selecting "+selectedNodes.size()+" nodes");
        if (dataModel.isAssymetricEdge() || !dataModel.isSymmetrical() || selectedArrays.size() == 0) {
            // System.out.println("Adding "+selectedNodes.size()+" gene nodes to current network");
            selectNodes(currentNetwork, selectedNodes, true);
            if (currentView != null)
                currentView.updateView();
        }
        return;
    } else if (o == arraySelection) {
        // We only care about array selection for symmetrical models
        if (!dataModel.isSymmetrical() && !dataModel.isAssymetricEdge())
            return;
        selectedArrays.clear();
        int[] selections = arraySelection.getSelectedIndexes();
        if (selections.length == dataModel.nExpr())
            return;
        HeaderInfo arrayInfo = dataModel.getArrayHeaderInfo();
        String[] names = arrayInfo.getNames();
        for (int i = 0; i < selections.length; i++) {
            String nodeName = arrayInfo.getHeader(selections[i])[0];
            CyNode node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, nodeName, CyNode.class);
            if (node != null && !currentNetwork.containsNode(node)) {
                // No, try dropping any suffixes from the node name
                String[] tokens = nodeName.split(" ");
                node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, tokens[0], CyNode.class);
            }
            if (node != null)
                selectedArrays.add(node);
        }
        if (selectedNodes.size() > 0)
            selectNodes(currentNetwork, selectedArrays, false);
        else
            selectNodes(currentNetwork, selectedArrays, true);
    }
    HashMap<CyEdge, CyEdge> edgesToSelect = new HashMap<CyEdge, CyEdge>();
    ignoreSelection = true;
    List<CyEdge> edgesToClear = CyTableUtil.getEdgesInState(currentNetwork, CyNetwork.SELECTED, true);
    for (CyEdge edge : edgesToClear) {
        if (myNetwork.containsEdge(edge))
            myNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.FALSE);
        if (currentNetwork.containsEdge(edge))
            currentNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.FALSE);
    }
    for (CyNode node1 : selectedNodes) {
        for (CyNode node2 : selectedArrays) {
            List<CyEdge> edges = currentNetwork.getConnectingEdgeList(node1, node2, CyEdge.Type.ANY);
            if (edges == null) {
                continue;
            }
            for (CyEdge edge : edges) {
                if (currentNetwork.containsEdge(edge))
                    currentNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.TRUE);
                if (myNetwork.containsEdge(edge))
                    myNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.TRUE);
            }
        }
    }
    manager.getService(CyEventHelper.class).flushPayloadEvents();
    ignoreSelection = false;
    if (currentView != null)
        currentView.updateView();
    selectedNodes.clear();
    selectedArrays.clear();
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) HashMap(java.util.HashMap) CyNetwork(org.cytoscape.model.CyNetwork) CyEdge(org.cytoscape.model.CyEdge) HeaderInfo(edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo) CyNode(org.cytoscape.model.CyNode) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 3 with HeaderInfo

use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo in project clusterMaker2 by RBVI.

the class TreeView method setEdgeSelection.

private void setEdgeSelection(List<CyEdge> edgeArray, boolean select) {
    HeaderInfo geneInfo = dataModel.getGeneHeaderInfo();
    HeaderInfo arrayInfo = dataModel.getArrayHeaderInfo();
    // Avoid loops -- delete ourselves as observers
    geneSelection.deleteObserver(this);
    arraySelection.deleteObserver(this);
    // Clear everything that's currently selected
    geneSelection.setSelectedNode(null);
    geneSelection.deselectAllIndexes();
    arraySelection.setSelectedNode(null);
    arraySelection.deselectAllIndexes();
    // Do the actual selection
    for (CyEdge cyEdge : edgeArray) {
        if (!myNetwork.containsEdge(cyEdge))
            continue;
        CyNode source = cyEdge.getSource();
        CyNode target = cyEdge.getTarget();
        int geneIndex = geneInfo.getHeaderIndex(ModelUtils.getName(myNetwork, source));
        int arrayIndex = arrayInfo.getHeaderIndex(ModelUtils.getName(myNetwork, target));
        geneSelection.setIndex(geneIndex, select);
        arraySelection.setIndex(arrayIndex, select);
    }
    // Notify all of the observers
    geneSelection.notifyObservers();
    arraySelection.notifyObservers();
    // OK, now we can listen again
    geneSelection.addObserver(this);
    arraySelection.addObserver(this);
}
Also used : HeaderInfo(edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo) CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge)

Example 4 with HeaderInfo

use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo in project clusterMaker2 by RBVI.

the class HeatMapView method setNodeSelection.

private void setNodeSelection(List<CyNode> nodeArray, boolean select) {
    HeaderInfo geneInfo = dataModel.getGeneHeaderInfo();
    geneSelection.deleteObserver(this);
    geneSelection.setSelectedNode(null);
    geneSelection.deselectAllIndexes();
    for (CyNode cyNode : nodeArray) {
        if (!myNetwork.containsNode(cyNode))
            continue;
        int geneIndex = geneInfo.getHeaderIndex(ModelUtils.getName(myNetwork, cyNode));
        // System.out.println("setting "+cyNode.getIdentifier()+"("+geneIndex+") to "+select);
        geneSelection.setIndex(geneIndex, select);
    }
    geneSelection.deleteObserver(this);
    geneSelection.notifyObservers();
    geneSelection.addObserver(this);
}
Also used : HeaderInfo(edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo) CyNode(org.cytoscape.model.CyNode)

Example 5 with HeaderInfo

use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo in project clusterMaker2 by RBVI.

the class HeatMapView method update.

public void update(Observable o, Object arg) {
    CyNetworkView currentView = manager.getNetworkView();
    CyNetwork currentNetwork = manager.getNetwork();
    // See if we're supposed to disable our listeners
    if ((o == arraySelection) && (arg instanceof Boolean)) {
        // System.out.println("Changing disable listeners to: "+arg.toString());
        disableListeners = ((Boolean) arg).booleanValue();
    }
    if (disableListeners)
        return;
    if (o == geneSelection) {
        // System.out.println("gene selection");
        selectedNodes.clear();
        int[] selections = geneSelection.getSelectedIndexes();
        HeaderInfo geneInfo = dataModel.getGeneHeaderInfo();
        String[] names = geneInfo.getNames();
        for (int i = 0; i < selections.length; i++) {
            String nodeName = geneInfo.getHeader(selections[i])[0];
            CyNode node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, nodeName, CyNode.class);
            // Now see if this network has this node
            if (node != null && !currentNetwork.containsNode(node)) {
                // No, try dropping any suffixes from the node name
                String[] tokens = nodeName.split(" ");
                node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, tokens[0], CyNode.class);
            }
            if (node != null)
                selectedNodes.add(node);
        }
        // System.out.println("Selecting "+selectedNodes.size()+" nodes");
        if (!dataModel.isSymmetrical() || selectedArrays.size() == 0) {
            List<CyNode> nodesToClear = CyTableUtil.getNodesInState(currentNetwork, CyNetwork.SELECTED, true);
            ignoreSelection = true;
            for (CyNode node : nodesToClear) {
                myNetwork.getRow(node).set(CyNetwork.SELECTED, Boolean.FALSE);
                if (currentNetwork.containsNode(node))
                    currentNetwork.getRow(node).set(CyNetwork.SELECTED, Boolean.FALSE);
            }
            for (CyNode node : selectedNodes) {
                if (currentNetwork.containsNode(node))
                    currentNetwork.getRow(node).set(CyNetwork.SELECTED, Boolean.TRUE);
                myNetwork.getRow(node).set(CyNetwork.SELECTED, Boolean.TRUE);
            }
            manager.getService(CyEventHelper.class).flushPayloadEvents();
            ignoreSelection = false;
            if (currentView != null)
                currentView.updateView();
        }
        return;
    } else if (o == arraySelection) {
        // We only care about array selection for symmetrical models
        if (!dataModel.isSymmetrical())
            return;
        selectedArrays.clear();
        int[] selections = arraySelection.getSelectedIndexes();
        if (selections.length == dataModel.nExpr())
            return;
        HeaderInfo arrayInfo = dataModel.getArrayHeaderInfo();
        String[] names = arrayInfo.getNames();
        for (int i = 0; i < selections.length; i++) {
            String nodeName = arrayInfo.getHeader(selections[i])[0];
            CyNode node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, nodeName, CyNode.class);
            if (node != null && !currentNetwork.containsNode(node)) {
                // No, try dropping any suffixes from the node name
                String[] tokens = nodeName.split(" ");
                node = (CyNode) ModelUtils.getNetworkObjectWithName(currentNetwork, tokens[0], CyNode.class);
            }
            if (node != null)
                selectedArrays.add(node);
        }
    }
    HashMap<CyEdge, CyEdge> edgesToSelect = new HashMap<CyEdge, CyEdge>();
    ignoreSelection = true;
    List<CyEdge> edgesToClear = CyTableUtil.getEdgesInState(currentNetwork, CyNetwork.SELECTED, true);
    for (CyEdge edge : edgesToClear) {
        myNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.FALSE);
        if (currentNetwork.containsEdge(edge))
            currentNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.FALSE);
    }
    for (CyNode node1 : selectedNodes) {
        for (CyNode node2 : selectedArrays) {
            List<CyEdge> edges = currentNetwork.getConnectingEdgeList(node1, node2, CyEdge.Type.ANY);
            if (edges == null) {
                continue;
            }
            for (CyEdge edge : edges) {
                myNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.TRUE);
                if (currentNetwork.containsEdge(edge))
                    currentNetwork.getRow(edge).set(CyNetwork.SELECTED, Boolean.TRUE);
            }
        }
    }
    manager.getService(CyEventHelper.class).flushPayloadEvents();
    ignoreSelection = false;
    if (currentView != null)
        currentView.updateView();
    selectedNodes.clear();
    selectedArrays.clear();
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) HashMap(java.util.HashMap) CyNetwork(org.cytoscape.model.CyNetwork) CyEdge(org.cytoscape.model.CyEdge) HeaderInfo(edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo) CyNode(org.cytoscape.model.CyNode) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

HeaderInfo (edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo)12 CyNode (org.cytoscape.model.CyNode)6 CyEdge (org.cytoscape.model.CyEdge)4 TreeDrawerNode (edu.ucsf.rbvi.clusterMaker2.internal.treeview.TreeDrawerNode)3 HashMap (java.util.HashMap)2 CyEventHelper (org.cytoscape.event.CyEventHelper)2 CyNetwork (org.cytoscape.model.CyNetwork)2 CyNetworkView (org.cytoscape.view.model.CyNetworkView)2 ClusterManager (edu.ucsf.rbvi.clusterMaker2.internal.api.ClusterManager)1 DataModel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.DataModel)1 LoadException (edu.ucsf.rbvi.clusterMaker2.internal.treeview.LoadException)1 ModelessSettingsDialog (edu.ucsf.rbvi.clusterMaker2.internal.treeview.ModelessSettingsDialog)1 AtrTVModel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.AtrTVModel)1 DataModelWriter (edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.DataModelWriter)1 ReorderedDataModel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.ReorderedDataModel)1 TVModel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.TVModel)1 TreeViewModel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.TreeViewModel)1 NetworkColorDialog (edu.ucsf.rbvi.clusterMaker2.internal.ui.NetworkColorDialog)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1