当前位置: 首页>>代码示例>>Java>>正文


Java CyNetworkView.getModel方法代码示例

本文整理汇总了Java中org.cytoscape.view.model.CyNetworkView.getModel方法的典型用法代码示例。如果您正苦于以下问题:Java CyNetworkView.getModel方法的具体用法?Java CyNetworkView.getModel怎么用?Java CyNetworkView.getModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.cytoscape.view.model.CyNetworkView的用法示例。


在下文中一共展示了CyNetworkView.getModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateEdgeWeightColumnList

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
private void updateEdgeWeightColumnList() {
    weightColumnModel.removeAllElements();

    if (session == null) {
        return;
    }

    CyNetworkView view = session.getNetworkView();
    CyNetwork model = view.getModel();
    CyTable table = model.getDefaultEdgeTable();
    table.getColumns()
         .stream()
         .filter(c -> !CyIdentifiable.SUID.equals(c.getName()) && Number.class.isAssignableFrom(c.getType()))
         .map(c -> c.getName())
         .sorted(String.CASE_INSENSITIVE_ORDER)
         .forEach(name -> weightColumnModel.addElement(name));

    weightColumn.setSelectedItem(session.getWeightColumn());

    if (weightColumn.getSelectedIndex() == -1 && weightColumnModel.getSize() > 0) {
        weightColumn.setSelectedIndex(0);
    }
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:24,代码来源:ImportPanelController.java

示例2: updateColumnList

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
void updateColumnList(SafeSession session) {
    lastAnnotationPath = null;
    this.session = session;

    nodeIdsModel.removeAllElements();

    if (session == null) {
        return;
    }

    CyNetworkView view = session.getNetworkView();
    CyNetwork model = view.getModel();
    CyTable table = model.getDefaultNodeTable();
    SafeUtil.getStringColumnNames(table)
            .forEach(name -> {
                nodeIdsModel.addElement(name);
            });

    nodeIds.setSelectedItem(session.getIdColumn());
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:21,代码来源:AnnotationChooserController.java

示例3: setNetworkView

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
void setNetworkView(CyNetworkView view) {
    if (view == null) {
        setSession(null);
        return;
    }

    long suid = view.getSUID();
    synchronized (sessionMutex) {
        SafeSession session = sessionsBySuid.get(suid);
        if (session == null) {
            session = createNewSession(view);
            sessionsBySuid.put(suid, session);

            CyNetwork network = view.getModel();
            CyTable nodeTable = network.getDefaultNodeTable();
            sessionsBySuid.put(nodeTable.getSUID(), session);
        }
        setSession(session);
    }
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:21,代码来源:SafeController.java

示例4: serializeSession

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
void serializeSession(CyTable dataTable,
                      SafeSession session) {
    CyNetworkView networkView = session.getNetworkView();
    CyNetwork network = networkView.getModel();
    CyTable networkTable = network.getDefaultNetworkTable();
    CyRow row = networkTable.getRow(network.getSUID());

    checkColumn(networkTable, DATA_TABLE_COLUMN, Long.class);
    Long suid = dataTable.getSUID();
    row.set(DATA_TABLE_COLUMN, suid);

    CyRow viewRow = dataTable.getRow(networkView.getSUID());
    try (StringWriter writer = new StringWriter()) {
        toJson(session, writer);
        String json = writer.toString();
        viewRow.set(SAFE_DATA_COLUMN, json);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:21,代码来源:SafeSessionSerializer.java

示例5: runClusterMaker

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
private Map<String,Collection<CyNode>> runClusterMaker(Optional<Double> cutoff) {
	CyNetworkView networkView = params.getNetworkView();
	CyNetwork network = networkView.getModel();
	boolean hasHidden = hasHiddenNodes(networkView);
	if(hasHidden) {
		Collection<CyNode> visibleNodes = getVisibleNodes(networkView);
		CreateSubnetworkTask subnetworkTask = subnetworkTaskFactory.create(network, visibleNodes);
		ResultObserver<CyNetwork> observer = new ResultObserver<>(subnetworkTask, CyNetwork.class);
		syncTaskManager.execute(new TaskIterator(subnetworkTask), observer);
		network = observer.getResults().get();
		networkManager.addNetwork(network, false);
	}
	
	RunClusterMakerTaskFactory clusterMakerTaskFactory = 
			clusterMakerFactoryFactory.create(network, params.getClusterAlgorithm(), params.getClusterMakerEdgeAttribute(), cutoff.orElse(null));
	RunClusterMakerResultObserver clusterResultObserver = new RunClusterMakerResultObserver();
	TaskIterator tasks = clusterMakerTaskFactory.createTaskIterator(clusterResultObserver);
	syncTaskManager.execute(tasks);
	Map<String,Collection<CyNode>> result =  clusterResultObserver.getResult();
	
	if(hasHidden) {
		networkManager.destroyNetwork(network);
	}
	
	return result;
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:27,代码来源:CreateAnnotationSetTask.java

示例6: UpdateNodeNames

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
public static void UpdateNodeNames(CyNetworkView myNetView) {
if (done == 1) {
    return;
}

CyNetwork myNetwork = myNetView.getModel();
DataConnectionRest dataConnection = new DataConnectionRest();

for (View<CyNode> myNode : myNetView.getNodeViews()) {
    int nodeID = Integer.parseInt(myNetwork.getRow(myNode.getModel()).get(CyNetwork.NAME, String.class).replaceAll("\"", ""));
    String userName = dataConnection.getUserNameFromID(nodeID);
    myNode.setVisualProperty(BasicVisualLexicon.NODE_LABEL, userName);
    myNode.setVisualProperty(BasicVisualLexicon.NODE_WIDTH, userName.length() * 7.5);
}
myNetView.updateView();
done = 1;
   }
 
开发者ID:AutonlabCMU,项目名称:ActiveSearch,代码行数:18,代码来源:UpdateNodeNameViewTask.java

示例7: serialize

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
@Override
public void serialize(final CyNetworkView networkView, JsonGenerator jgen, SerializerProvider provider)
		throws IOException, JsonProcessingException {

	final CyNetwork network = networkView.getModel();
	Collection<CyRow> root = network.getDefaultNodeTable().getMatchingRows(CyNetwork.SELECTED, true);

	if (root.size() != 1) {
		throw new IllegalStateException("You need to select one node as the root for this tree.");
	}

	CyRow rootNodeRow = root.iterator().next();
	final CyNode rootNode = network.getNode(rootNodeRow.get(CyIdentifiable.SUID, Long.class));
	if (rootNode == null) {
		throw new IllegalStateException("Could not find the root for this tree.");
	}

	jgen.useDefaultPrettyPrinter();

	expanded = new HashSet<CyNode>();
	getChildren(network, rootNode, jgen);
}
 
开发者ID:keiono,项目名称:cytoscape-d3,代码行数:23,代码来源:D3CyNetworkViewTreeSerializer.java

示例8: setEnrichmentLandscape

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
void setEnrichmentLandscape(EnrichmentLandscape landscape) {
    if (session == null) {
        notifyListeners();
        return;
    }

    isEnabled = true;

    Long[] nodeMappings = session.getNodeMappings();
    if (nodeMappings == null) {
        notifyListeners();
        return;
    }

    CyNetworkView view = session.getNetworkView();
    CyNetwork network = view.getModel();
    CyTable nodeTable = network.getDefaultNodeTable();
    nodeTableId = nodeTable.getSUID();

    Arrays.stream(nodeMappings)
          .forEach(suid -> {
              CyRow row = nodeTable.getRow(suid);
              boolean selected = row.get(CyNetwork.SELECTED, Boolean.class);
              if (selected) {
                  nodeSuids.add(suid);
              }
          });

    notifyListeners();
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:31,代码来源:SelectionTracker.java

示例9: selectSignificantNodes

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
private void selectSignificantNodes() {
    SignificancePredicate predicate = getSignificancePredicate();
    int[] rows = filteredTable.getTable()
                              .getSelectedRows();
    TableRowSorter<TableModel> sorter = filteredTable.getSorter();
    Long[] nodeMappings = session.getNodeMappings();

    CyNetworkView view = session.getNetworkView();
    CyNetwork network = view.getModel();
    CyTable nodeTable = network.getDefaultNodeTable();
    CyTable edgeTable = network.getDefaultEdgeTable();

    SafeUtil.clearSelection(nodeTable);
    SafeUtil.clearSelection(edgeTable);

    EnrichmentLandscape landscape = session.getEnrichmentLandscape();
    List<? extends Neighborhood> neighborhoods = landscape.getNeighborhoods();
    neighborhoods.stream()
                 .forEach(n -> {
                     boolean include = Arrays.stream(rows)
                                             .map(i -> sorter.convertRowIndexToModel(i))
                                             .filter(i -> predicate.test(n, i))
                                             .findAny()
                                             .isPresent();

                     Long suid = nodeMappings[n.getNodeIndex()];
                     CyRow row = nodeTable.getRow(suid);
                     row.set(CyNetwork.SELECTED, include);
                 });
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:31,代码来源:AttributeBrowserController.java

示例10: checkIdCoverage

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
void checkIdCoverage(File file) throws IOException {
    CyNetworkView view = session.getNetworkView();
    CyNetwork network = view.getModel();
    CyTable nodeTable = network.getDefaultNodeTable();

    List<String> names = SafeUtil.getStringColumnNames(nodeTable)
                                 .collect(Collectors.toList());
    CyNodeTableVisitor visitor = new CyNodeTableVisitor(nodeTable, names);

    String path = file.getPath();
    AnalyzeAnnotationConsumer consumer = new AnalyzeAnnotationConsumer() {
        @Override
        public void accept(IdMappingResult result) {
            idMappingResult = result;
            IntIntMap coverage = result.coverage;
            int topIndex = Util.getTopKey(coverage, -1);

            columnCoverage = new ObjectIntHashMap<>();
            coverage.forEach((Consumer<? super IntIntCursor>) c -> columnCoverage.addTo(names.get(c.key), c.value));

            nodeIds.setSelectedIndex(topIndex);

            try {
                String canonicalPath = file.getCanonicalPath();
                lastAnnotationPath = canonicalPath;
                notifyListeners(file);
            } catch (IOException e) {
                fail(e, "Unexpected error");
            }
        }
    };

    SimpleTaskFactory taskFactory = new SimpleTaskFactory(() -> new AnalyzeAnnotationTask(path, visitor, consumer));
    taskManager.execute(taskFactory.createTaskIterator());
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:36,代码来源:AnnotationChooserController.java

示例11: handleEvent

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
@Override
public void handleEvent(NetworkViewAboutToBeDestroyedEvent event) {
    synchronized (sessionMutex) {
        CyNetworkView view = event.getNetworkView();
        CyNetwork network = view.getModel();
        CyTable nodeTable = network.getDefaultNodeTable();
        sessionsBySuid.remove(nodeTable.getSUID());

        long suid = view.getSUID();
        SafeSession session = sessionsBySuid.remove(suid);
        if (session != null && this.session == session) {
            setSession(null);
        }
    }
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:16,代码来源:SafeController.java

示例12: BaseExportReportsTask

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
public BaseExportReportsTask(SafeSession session) {

        CyNetworkView view = session.getNetworkView();
        CyNetwork network = view.getModel();
        nodeTable = network.getDefaultNodeTable();
        List<String> names = SafeUtil.getStringColumnNames(nodeTable)
                                     .collect(Collectors.toList());
        nodeNameColumn = new ListSingleSelection<>(names);

        nodeNameColumn.setSelectedValue(CyNetwork.NAME);

        this.session = session;
    }
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:14,代码来源:BaseExportReportsTask.java

示例13: CyNetworkParser

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
public CyNetworkParser(CyNetworkView view,
                       String nameColumn,
                       String idColumn,
                       String weightColumn) {
    this.view = view;
    this.network = view.getModel();
    this.nameColumn = nameColumn;
    this.idColumn = idColumn;
    this.weightColumn = weightColumn;
    forceUndirected = true;
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:12,代码来源:CyNetworkParser.java

示例14: computeClustersFromColumn

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
private Map<String,Collection<CyNode>> computeClustersFromColumn() {
	String attribute = params.getClusterDataColumn();
	CyNetworkView networkView = params.getNetworkView();
	CyNetwork network = networkView.getModel();
	
	Map<String,Collection<CyNode>> clusters = new HashMap<>();
	
	boolean isList = false;
	Class<?> type = network.getDefaultNodeTable().getColumn(attribute).getType();
	if(type == List.class) {
		isList = true;
		type = network.getDefaultNodeTable().getColumn(attribute).getListElementType();
	}
	
	for(CyNode node : network.getNodeList()) {
		if(isHidden(node, networkView))
			continue;
		
		List<?> list;
		if(isList)
			list = network.getRow(node).getList(attribute, type);
		else
			list = Collections.singletonList(network.getRow(node).get(attribute, type));

		for(Object o : list) {
			if(o != null) {
				String key = String.valueOf(o).trim();
				if(!key.isEmpty()) {
					clusters.computeIfAbsent(key, k -> new HashSet<>()).add(node);
				}
			}
		}
	}
	return clusters;
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:36,代码来源:CreateAnnotationSetTask.java

示例15: getUnclusteredNodes

import org.cytoscape.view.model.CyNetworkView; //导入方法依赖的package包/类
private Collection<CyNode> getUnclusteredNodes(Map<String,Collection<CyNode>> clusters) {
	CyNetworkView networkView = params.getNetworkView();
	CyNetwork network = networkView.getModel();
	Set<CyNode> nodes = new HashSet<>(network.getNodeList());
	for(Collection<CyNode> cluster : clusters.values()) {
		nodes.removeAll(cluster);
	}
	
	// filter out hidden nodes
	nodes.removeIf(node -> isHidden(node, networkView));
	return nodes;
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:13,代码来源:CreateAnnotationSetTask.java


注:本文中的org.cytoscape.view.model.CyNetworkView.getModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。