Search in sources :

Example 76 with CyNetwork

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

the class GetEdgePropertiesTask method run.

@Override
public void run(final TaskMonitor taskMonitor) {
    edgePropertiesMap = new HashMap<CyEdge, Map<String, VisualPropertyObjectTuple>>();
    CyNetwork network = edgeTunable.getNetwork();
    if (propertyList == null || propertyList.length() == 0) {
        taskMonitor.showMessage(TaskMonitor.Level.ERROR, "Property list must be specified");
        return;
    }
    // Get the list of properties
    String[] props = propertyList.split(",");
    for (CyEdge edge : edgeTunable.getEdgeList()) {
        taskMonitor.showMessage(TaskMonitor.Level.INFO, "   Edge property values for edge " + DataUtils.getEdgeName(network.getDefaultEdgeTable(), edge) + ":");
        Map<String, VisualPropertyObjectTuple> propertyMap = new HashMap<String, VisualPropertyObjectTuple>();
        for (String property : props) {
            try {
                VisualProperty vp = getProperty(network, edge, property.trim());
                Object value = getPropertyValue(network, edge, vp);
                if (value != null) {
                    taskMonitor.showMessage(TaskMonitor.Level.INFO, "        " + vp.getDisplayName() + "=" + value.toString());
                    propertyMap.put(vp.getIdString(), new VisualPropertyObjectTuple(vp, value));
                }
            } catch (Exception e) {
                taskMonitor.showMessage(TaskMonitor.Level.ERROR, e.getMessage());
                return;
            }
        }
        edgePropertiesMap.put(edge, propertyMap);
    }
}
Also used : HashMap(java.util.HashMap) VisualProperty(org.cytoscape.view.model.VisualProperty) CyNetwork(org.cytoscape.model.CyNetwork) CyEdge(org.cytoscape.model.CyEdge) HashMap(java.util.HashMap) Map(java.util.Map)

Example 77 with CyNetwork

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

the class UnGroupNodesTaskFactoryImpl method isReady.

public boolean isReady(CyNetworkView netView) {
    if (netView == null) {
        return false;
    }
    // Get all of the selected nodes
    CyNetwork net = netView.getModel();
    final List<CyNode> selNodes = CyTableUtil.getNodesInState(net, CyNetwork.SELECTED, true);
    if (getGroups(net, selNodes).size() > 0)
        return true;
    return false;
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode)

Example 78 with CyNetwork

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

the class UnGroupNodesTaskFactoryImpl method createTaskIterator.

public TaskIterator createTaskIterator(CyNetworkView netView) {
    CyNetwork net = netView.getModel();
    final List<CyNode> selNodes = CyTableUtil.getNodesInState(net, CyNetwork.SELECTED, true);
    Set<CyGroup> groups = getGroups(net, selNodes);
    return new TaskIterator(new UnGroupNodesTask(undoSupport, netView.getModel(), factory, groups, mgr, netView));
}
Also used : CyGroup(org.cytoscape.group.CyGroup) TaskIterator(org.cytoscape.work.TaskIterator) CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode)

Example 79 with CyNetwork

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

the class HideFromSelectionTask method run.

@Override
public void run(final TaskMonitor tm) {
    tm.setProgress(0.0);
    final CyNetwork network = view.getModel();
    final List<CyIdentifiable> elements = new ArrayList<>();
    List<CyNode> nodes = null;
    List<CyEdge> edges = null;
    if (hideNodes) {
        nodes = CyTableUtil.getNodesInState(network, CyNetwork.SELECTED, selectionValue);
        elements.addAll(nodes);
    }
    tm.setProgress(0.1);
    if (hideEdges) {
        edges = CyTableUtil.getEdgesInState(network, CyNetwork.SELECTED, selectionValue);
        elements.addAll(edges);
    }
    final UndoSupport undoSupport = serviceRegistrar.getService(UndoSupport.class);
    final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
    final VisualMappingManager vmMgr = serviceRegistrar.getService(VisualMappingManager.class);
    undoSupport.postEdit(new HideEdit(description, view, elements, false, eventHelper, vmMgr));
    tm.setProgress(0.4);
    if (nodes != null)
        HideUtils.setVisibleNodes(nodes, false, view);
    tm.setProgress(0.6);
    if (edges != null)
        HideUtils.setVisibleEdges(edges, false, view);
    tm.setProgress(0.8);
    VisualStyle style = vmMgr.getVisualStyle(view);
    for (CyIdentifiable e : elements) {
        View<? extends CyIdentifiable> ev = null;
        if (e instanceof CyNode)
            ev = view.getNodeView((CyNode) e);
        else if (e instanceof CyEdge)
            ev = view.getEdgeView((CyEdge) e);
        if (ev != null)
            style.apply(network.getRow(e), ev);
    }
    view.updateView();
    tm.setProgress(1.0);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) CyEdge(org.cytoscape.model.CyEdge) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyNode(org.cytoscape.model.CyNode) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) CyIdentifiable(org.cytoscape.model.CyIdentifiable)

Example 80 with CyNetwork

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

the class GroupNodesTaskFactoryImpl method isReady.

public boolean isReady(View<CyNode> nodeView, CyNetworkView netView) {
    if (nodeView == null || netView == null)
        return false;
    // Get all of the selected nodes
    CyNetwork net = netView.getModel();
    final List<CyNode> selNodes = CyTableUtil.getNodesInState(net, CyNetwork.SELECTED, true);
    return (selNodes.size() > 1);
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode)

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