Search in sources :

Example 66 with CyEdge

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

the class CySubNetworkTest method testAddNewEdgeEventBeforeNetworkAdd.

@Test
public void testAddNewEdgeEventBeforeNetworkAdd() {
    CySubNetwork sub = root.addSubNetwork();
    CyNode nx1 = sub.addNode();
    CyNode nx2 = sub.addNode();
    CyEdge ex1 = sub.addEdge(nx1, nx2, false);
    Object payload = deh.getLastPayload();
    assertNull(payload);
}
Also used : CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge) Test(org.junit.Test)

Example 67 with CyEdge

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

the class VizMapperMediator method createPreviewNetworkView.

private void createPreviewNetworkView() {
    // Create dummy view first
    final CyNetwork net = servicesUtil.get(CyNetworkFactory.class).createNetworkWithPrivateTables(SavePolicy.DO_NOT_SAVE);
    final CyNode source = net.addNode();
    final CyNode target = net.addNode();
    net.getRow(source).set(CyNetwork.NAME, "Source");
    net.getRow(target).set(CyNetwork.NAME, "Target");
    final CyEdge edge = net.addEdge(source, target, true);
    net.getRow(edge).set(CyNetwork.NAME, "Source (interaction) Target");
    net.getRow(net).set(CyNetwork.NAME, "Default Appearance");
    final CyNetworkView view = servicesUtil.get(CyNetworkViewFactory.class).createNetworkView(net);
    // Set node locations
    view.getNodeView(source).setVisualProperty(NODE_X_LOCATION, 0d);
    view.getNodeView(source).setVisualProperty(NODE_Y_LOCATION, 0d);
    view.getNodeView(target).setVisualProperty(NODE_X_LOCATION, 150d);
    view.getNodeView(target).setVisualProperty(NODE_Y_LOCATION, 20d);
    previewNetView = view;
}
Also used : CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkFactory(org.cytoscape.model.CyNetworkFactory) CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 68 with CyEdge

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

the class GetGroupTask method groupJSON.

public String groupJSON(CyNetwork network, CyGroup group) {
    this.jsonUtil = serviceRegistrar.getService(CyJSONUtil.class);
    long suid = group.getGroupNode().getSUID();
    List<CyNode> nodes = group.getNodeList();
    List<CyEdge> internalEdges = group.getInternalEdgeList();
    Set<CyEdge> externalEdges = group.getExternalEdgeList();
    CyRow groupRow = ((CySubNetwork) net).getRootNetwork().getRow(group.getGroupNode(), CyRootNetwork.SHARED_ATTRS);
    String name = groupRow.get(CyRootNetwork.SHARED_NAME, String.class);
    String result = "{\"group\":" + suid + "," + "\"name\":\"" + name + "\",";
    result += "\"nodes\":" + jsonUtil.cyIdentifiablesToJson(nodes) + ",";
    result += "\"internalEdges\":" + jsonUtil.cyIdentifiablesToJson(internalEdges) + ",";
    result += "\"externalEdges\":" + jsonUtil.cyIdentifiablesToJson(externalEdges) + ",";
    result += "\"collapsed\":";
    if (group.isCollapsed(network))
        result += "true";
    else
        result += "false";
    result += "}";
    return result;
}
Also used : CyNode(org.cytoscape.model.CyNode) CyRow(org.cytoscape.model.CyRow) CyEdge(org.cytoscape.model.CyEdge) CyJSONUtil(org.cytoscape.util.json.CyJSONUtil)

Example 69 with CyEdge

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

the class GroupEdit method createShadowGroup.

private void createShadowGroup(CyGroup group) {
    // Get the nodes, edges, and external edges
    nodeMap.put(group, group.getNodeList());
    List<CyEdge> edgesList = new ArrayList<CyEdge>(group.getInternalEdgeList());
    edgesList.addAll(group.getExternalEdgeList());
    edgesMap.put(group, edgesList);
    // Get the networks
    networkMap.put(group, new ArrayList<CyNetwork>(group.getNetworkSet()));
    // Get the collapse set
    List<CyNetwork> collapseList = new ArrayList<CyNetwork>();
    for (CyNetwork net : group.getNetworkSet()) {
        if (group.isCollapsed(net)) {
            collapseList.add(net);
        }
    }
    collapseMap.put(group, collapseList);
}
Also used : ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) CyEdge(org.cytoscape.model.CyEdge)

Example 70 with CyEdge

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

the class RemoveFromGroupTask method run.

@Override
public void run(TaskMonitor tm) throws Exception {
    net = nodesAndEdges.getNetwork();
    if (groupName == null) {
        tm.showMessage(TaskMonitor.Level.ERROR, "Group must be specified");
        return;
    }
    CyGroup grp = getGroup(groupName);
    if (grp == null) {
        tm.showMessage(TaskMonitor.Level.ERROR, "Can't find group '" + groupName + "' in network: " + net.toString());
        return;
    }
    List<CyEdge> edgeList = nodesAndEdges.getEdgeList(false);
    List<CyNode> nodeList = nodesAndEdges.getNodeList(false);
    if (edgeList == null && nodeList == null) {
        tm.showMessage(TaskMonitor.Level.ERROR, "Nothing to remove");
        return;
    }
    int edges = 0;
    if (edgeList != null)
        edges = edgeList.size();
    int nodes = 0;
    if (nodeList != null)
        nodes = nodeList.size();
    tm.showMessage(TaskMonitor.Level.INFO, "Removing " + nodes + " nodes and " + edges + " edges from group " + getGroupDesc(grp));
    if (edgeList != null && edgeList.size() > 0) {
        grp.removeEdges(edgeList);
    }
    if (nodeList != null && nodeList.size() > 0) {
        grp.removeNodes(nodeList);
    }
    tm.showMessage(TaskMonitor.Level.INFO, "Removed " + nodes + " nodes and " + edges + " edges from group " + getGroupDesc(grp));
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge)

Aggregations

CyEdge (org.cytoscape.model.CyEdge)302 CyNode (org.cytoscape.model.CyNode)231 CyNetwork (org.cytoscape.model.CyNetwork)103 ArrayList (java.util.ArrayList)77 Test (org.junit.Test)71 CyNetworkView (org.cytoscape.view.model.CyNetworkView)55 HashSet (java.util.HashSet)42 CyRow (org.cytoscape.model.CyRow)41 CyIdentifiable (org.cytoscape.model.CyIdentifiable)29 HashMap (java.util.HashMap)26 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)25 CyTable (org.cytoscape.model.CyTable)21 DummyCyEdge (org.cytoscape.model.DummyCyEdge)21 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)18 DummyCyNode (org.cytoscape.model.DummyCyNode)17 View (org.cytoscape.view.model.View)16 List (java.util.List)13 CyEventHelper (org.cytoscape.event.CyEventHelper)12 CyGroup (org.cytoscape.group.CyGroup)12 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)12