如何获得具有特定价值的所有节点?

时间:2017-07-12 06:41:00

标签: java cytoscape

我刚刚开始开发cytoscape插件。我试图隐藏在“共享名称”列中具有“pronaliz:status”语句的所有节点。我看到下面的链接,我试了但是无法做到。它没有隐藏任何节点。

http://wiki.cytoscape.org/Cytoscape_3/AppDeveloper/Cytoscape_3_App_Cookbook#How_to_get_all_the_nodes_with_a_specific_attribute_value.3F

这是我的代码。我正在热身Cytoscape类和方法。有人可以帮我吗?

public class MenuAction extends AbstractCyAction {
private final CyAppAdapter adapter;

public MenuAction(CyAppAdapter adapter) {
    super("Hide Status",
            adapter.getCyApplicationManager(),
            "network",
            adapter.getCyNetworkViewManager());
    this.adapter = adapter;
    setPreferredMenu("Select");
}

public void actionPerformed(ActionEvent e){
    final CyApplicationManager manager = adapter.getCyApplicationManager();
    final CyNetworkView networkView = manager.getCurrentNetworkView();
    final CyNetwork network = networkView.getModel();
    final CyTable table = network.getDefaultNodeTable();

    final Set<CyNode> nodes = new HashSet<CyNode>();
    final Collection<CyRow> matchingRows = table.getMatchingRows("shared name", ":status");
    final String primaryKeyColname = table.getPrimaryKey().getName();

    for (final CyRow row : matchingRows) {
        final Long nodeId = row.get(primaryKeyColname, Long.class);
        if (nodeId == null)
            continue;
        final CyNode node = network.getNode(nodeId);
        if (node == null)
            continue;
        nodes.add(node);
    }

    for(CyNode node: nodes){
        networkView.getNodeView(node).setVisualProperty(BasicVisualLexicon.NODE_VISIBLE, false);
    }
    networkView.updateView();
}

}

1 个答案:

答案 0 :(得分:0)

此问题已在Cytoscape帮助台上得到解答:https://groups.google.com/forum/?hl=en_US/#!topic/cytoscape-helpdesk/9ru4Nx0oxvc

祝你好运, 皮特