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


Java CyNode类代码示例

本文整理汇总了Java中org.cytoscape.model.CyNode的典型用法代码示例。如果您正苦于以下问题:Java CyNode类的具体用法?Java CyNode怎么用?Java CyNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createAdjMatrix

import org.cytoscape.model.CyNode; //导入依赖的package包/类
public double[][] createAdjMatrix(CyNetwork network) {
    List<CyNode> nodeList = network.getNodeList();
    int totalnodecount = network.getNodeList().size();
    double[][] adjacencyMatrixOfNetwork = new double[totalnodecount][totalnodecount];
    List<CyEdge> edges = network.getEdgeList();
    
    for(CyEdge e : edges) {
        CyNode a = e.getSource();
        CyNode b = e.getTarget();
        if(isDirected){ // -1 convention for now
            if(adjacencyMatrixOfNetwork[nodeList.indexOf(a)][nodeList.indexOf(b)] == 0 && adjacencyMatrixOfNetwork[nodeList.indexOf(b)][nodeList.indexOf(a)] == 0) {
                adjacencyMatrixOfNetwork[nodeList.indexOf(a)][nodeList.indexOf(b)] = 1;
                adjacencyMatrixOfNetwork[nodeList.indexOf(b)][nodeList.indexOf(a)] = -1;
            } else {
                adjacencyMatrixOfNetwork[nodeList.indexOf(a)][nodeList.indexOf(b)] = 1;
                adjacencyMatrixOfNetwork[nodeList.indexOf(b)][nodeList.indexOf(a)] = 1;
            }
            
        } else{
            adjacencyMatrixOfNetwork[nodeList.indexOf(a)][nodeList.indexOf(b)] = 1;
            adjacencyMatrixOfNetwork[nodeList.indexOf(b)][nodeList.indexOf(a)] = 1;
        } 
        
    }
    return adjacencyMatrixOfNetwork;
}
 
开发者ID:srikanthBezawada,项目名称:AdjacencyMatrixExporter,代码行数:27,代码来源:AdjNetworkWriter.java

示例2: MapColumnTask

import org.cytoscape.model.CyNode; //导入依赖的package包/类
public MapColumnTask(CyServiceRegistrar registrar) {
	this.applicationManager = registrar.getService(CyApplicationManager.class);
	this.mappingManager = registrar.getService(DataSeriesMappingManager.class);
	
	DataSeriesManager dataSeriesManager = registrar.getService(DataSeriesManager.class);
	CyNetworkManager networkManager = registrar.getService(CyNetworkManager.class);
	
	targetClass = new ListSingleSelection<>(new TargetClassInfo("Nodes", CyNode.class), new TargetClassInfo("Edges", CyEdge.class));
	dataSeries = new ListSingleSelection<>(dataSeriesManager.getAllDataSeries());
	existingColumnForMapping = new ListSingleSelection<>();
	mapRowNamesWithColumn = new ListSingleSelection<>();
	
	targetNetwork = new ListSingleSelection<>(networkManager.getNetworkSet().stream().toArray(CyNetwork[]::new));
	if(applicationManager.getCurrentNetwork() != null)
	{
		targetNetwork.setSelectedValue(applicationManager.getCurrentNetwork());
	}
	
	updateExistingColumnForMapping(CyNode.class);
	updateMapRowNamesWithColumn(CyNode.class);
	
}
 
开发者ID:cas-bioinf,项目名称:cy-dataseries,代码行数:23,代码来源:MapColumnTask.java

示例3: handleEvent

import org.cytoscape.model.CyNode; //导入依赖的package包/类
@Override
	public void handleEvent(RowsSetEvent e) {
		if (!e.containsColumn(CyNetwork.SELECTED) || ignoreSelection) 
		{
			return;
		}
		
		CyNetwork currentNetwork = cyApplicationManager.getCurrentNetwork();
		
		if(currentNetwork == null 
				|| e.getSource().equals(currentNetwork.getTable(CyNode.class, CyNetwork.LOCAL_ATTRS)) 
				|| e.getSource().equals(currentNetwork.getTable(CyEdge.class, CyNetwork.LOCAL_ATTRS)))
		{
			updateVisual();
	
			//TODO the above is very inefficient, replace with maintaining the list of selected nodes with
//			 for (RowSetRecord record: e.getColumnRecords(CyNetwork.SELECTED)) {
//		          Long suid = record.getRow().get(CyIdentifiable.SUID, Long.class);
//		          Boolean value = (Boolean)record.getValue();
			
		}
	}
 
开发者ID:cas-bioinf,项目名称:cy-dataseries,代码行数:23,代码来源:DataSeriesVisualPanel.java

示例4: getExpandedNodeCount

import org.cytoscape.model.CyNode; //导入依赖的package包/类
int getExpandedNodeCount(Cluster cluster) {
	Set<CyNode> nodes = cluster.getNodes();
	if(cluster.isCollapsed()) {
		if(nodes.isEmpty())
			return 0;
		CyNode groupNode = nodes.iterator().next();
		CyGroup group = groupManager.getGroup(groupNode, cluster.getNetwork());
		if(group == null)
			return 0;
		List<CyNode> groupNodes = group.getNodeList();
		if(groupNodes == null)
			return 0;
		return groupNodes.size();
	}
	else {
		return nodes.size();
	}
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:19,代码来源:ModelManager.java

示例5: forNodes

import org.cytoscape.model.CyNode; //导入依赖的package包/类
public static CoordinateData forNodes(CyNetworkView networkView, Collection<CyNode> nodes) {
	double xmin = 100000000;
	double xmax = -100000000;
	double ymin = 100000000;
	double ymax = -100000000;
	
	Map<CyNode,double[]> coordinates = new HashMap<>();
	Map<CyNode,Double> radii = new HashMap<>();
	
	for(CyNode node : nodes) {
		View<CyNode> nodeView = networkView.getNodeView(node);
		if(nodeView != null) {
			double x = nodeView.getVisualProperty(BasicVisualLexicon.NODE_X_LOCATION);
			double y = nodeView.getVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION);
			double radius = nodeView.getVisualProperty(BasicVisualLexicon.NODE_WIDTH);
			
			coordinates.put(node, new double[]{x,y});
			radii.put(node, radius);
			
			xmin = Double.min(xmin, x);
			xmax = Double.max(xmax, x);
			ymin = Double.min(ymin, y);
			ymax = Double.max(ymax, y);
		}
	}
	
	return new CoordinateData(xmin, xmax, ymin, ymax, coordinates, radii);
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:29,代码来源:CoordinateData.java

示例6: createCluster

import org.cytoscape.model.CyNode; //导入依赖的package包/类
private void createCluster(AnnotationSet annotationSet) {
	LabelMaker labelMaker = labelManager.get().getLabelMaker(annotationSet);
	if(!labelMaker.isReady()) {
		return;
	}
	
	List<CyNode> nodes = CyTableUtil.getNodesInState(networkView.getModel(), CyNetwork.SELECTED, true);
	CyNetwork network = networkView.getModel();
	
	// Remove selected nodes from existing clusters. Bug #37
	annotationSet.removeNodes(nodes);
			
	String label = labelMaker.makeLabel(network, nodes, annotationSet.getLabelColumn());
	Cluster cluster = annotationSet.createCluster(nodes, label, false);
	
	// It was the intention to only allow ModelEvents to be fired from inside the model package.
	// But the cluster is already selected and firing the event here is much simpler than 
	// re-selecting the nodes to get the event to fire.
	EventBus eventBus = eventBusProvider.get();
	eventBus.post(new ModelEvents.ClustersSelected(annotationSet, Collections.singleton(cluster)));
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:22,代码来源:CreateClusterTask.java

示例7: createAnnotationSetAndCluster

import org.cytoscape.model.CyNode; //导入依赖的package包/类
private void createAnnotationSetAndCluster() {
	// Automatically create an annotation set
	ModelManager modelManager = modelManagerProvider.get();
	NetworkViewSet nvs = modelManager.getNetworkViewSet(networkView);
	List<CyNode> nodes = CyTableUtil.getNodesInState(networkView.getModel(), CyNetwork.SELECTED, true);
	String labelColumn = getLabelColumn();
	
	@SuppressWarnings("rawtypes")
	LabelMakerFactory labelMakerFactory = labelManagerProvider.get().getDefaultFactory();
	@SuppressWarnings("unchecked")
	LabelMaker labelMaker = labelMakerFactory.createLabelMaker(labelMakerFactory.getDefaultContext());
	String label = labelMaker.makeLabel(networkView.getModel(), nodes, labelColumn);
	
	String suggestedName = nvs.suggestName();
	AnnotationSetBuilder builder = nvs.getAnnotationSetBuilder(suggestedName, labelColumn);
	builder.addCluster(nodes, label, false);
	AnnotationSet as = builder.build();
	
	nvs.select(as);
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:21,代码来源:CreateClusterTask.java

示例8: nodesOutOfCluster

import org.cytoscape.model.CyNode; //导入依赖的package包/类
private static boolean nodesOutOfCluster(CoordinateData data, double width, double height, double centreX, double centreY, int ellipseWidth) {
	double semimajor_axis = width / 2;
	double semiminor_axis = height / 2;
	Map<CyNode,double[]> nodesToCoordinates = data.getCoordinates();
	Map<CyNode,Double> nodesToRadii = data.getRadii();
	
	for (CyNode node : nodesToCoordinates.keySet()) {
		double[] coordinates = nodesToCoordinates.get(node);
		double nodeSize = nodesToRadii.get(node);
		if (Math.pow((coordinates[0] - centreX - ellipseWidth) / semimajor_axis, 2) + Math.pow(nodeSize / semimajor_axis, 2)
				+ Math.pow((coordinates[1] - centreY - ellipseWidth) / semiminor_axis, 2) + Math.pow(nodeSize / semiminor_axis, 2) >= 1) {
			return true;
		}
	}
	return false;
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:17,代码来源:DrawClusterTask.java

示例9: runClusterMaker

import org.cytoscape.model.CyNode; //导入依赖的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

示例10: createTaskIterator

import org.cytoscape.model.CyNode; //导入依赖的package包/类
@Override
public TaskIterator createTaskIterator() {
	TaskIterator tasks = new TaskIterator();
	
	CyLayoutAlgorithm attributeCircle = layoutManager.getLayout("attributes-layout");
	TaskIterator attributeLayoutTasks = attributeCircle.createTaskIterator(view, attributeCircle.createLayoutContext(), CyLayoutAlgorithm.ALL_NODE_VIEWS, layoutAttribute);
	tasks.append(attributeLayoutTasks);
	
	CyLayoutAlgorithm force_directed = layoutManager.getLayout("force-directed");
	
	for(Collection<CyNode> cluster : clusters) {
		Set<View<CyNode>> nodeViewSet = new HashSet<>();
		for(CyNode node : cluster) {
			nodeViewSet.add(view.getNodeView(node));
		}
		// Only apply layout to nodes of size greater than 4
		if (nodeViewSet.size() > 4) {
			TaskIterator forceTasks = force_directed.createTaskIterator(view, force_directed.createLayoutContext(), nodeViewSet, null);
			tasks.append(forceTasks);
		}
	}
	
	return tasks;
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:25,代码来源:LayoutClustersTaskFactory.java

示例11: getSummaryClusters

import org.cytoscape.model.CyNode; //导入依赖的package包/类
private List<SummaryCluster> getSummaryClusters() {
	List<SummaryCluster> summaryClusters = new ArrayList<>();
	
	// Add all the clusters regular clusters
	for(Cluster cluster : clusters) {
		summaryClusters.add(new NormalCluster(cluster));
	}
	
	if(includeUnclustered) {
		Set<CyNode> clusteredNodes = clusters.stream().flatMap(c->c.getNodes().stream()).collect(Collectors.toSet());
		Set<CyNode> allNodes = new HashSet<>(annotationSet.getParent().getNetwork().getNodeList());
		Set<CyNode> unclusteredNodes = Sets.difference(allNodes, clusteredNodes);
		
		for(CyNode node : unclusteredNodes) {
			summaryClusters.add(new SingletonCluster(node));
		}
	}
	return summaryClusters;
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:20,代码来源:SummaryNetworkTask.java

示例12: findMetaEdges

import org.cytoscape.model.CyNode; //导入依赖的package包/类
private Set<MetaEdge> findMetaEdges(CyNetwork originNetwork, Collection<SummaryCluster> clusters) {
	Map<CyNode, SummaryCluster> nodeToCluster = new HashMap<>();
	for(SummaryCluster cluster : clusters) {
		for(CyNode node : cluster.getNodes()) {
			nodeToCluster.put(node, cluster);
		}
	}
	
	Set<MetaEdge> metaEdges = new HashSet<>();
	for(SummaryCluster sourceCluster : clusters) {
		Set<CyNode> targets = getAllTargets(originNetwork, sourceCluster);
		for(CyNode target : targets) {
			SummaryCluster targetCluster = nodeToCluster.get(target);
			if(targetCluster != null) {
				metaEdges.add(new MetaEdge(sourceCluster, targetCluster));
			}
		}
	}
	return metaEdges;
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:21,代码来源:SummaryNetworkTask.java

示例13: getAllTargets

import org.cytoscape.model.CyNode; //导入依赖的package包/类
/**
 * Returns all nodes outside the cluster that are connected to a node in the cluster.
 */
private Set<CyNode> getAllTargets(CyNetwork network, SummaryCluster c) {
	Set<CyNode> targets = new HashSet<>();
	Collection<CyNode> nodes = c.getNodes();
	for(CyNode node : nodes) {
		for(CyEdge edge : network.getAdjacentEdgeIterable(node, Type.ANY)) {
			CyNode source = edge.getSource();
			CyNode target = edge.getTarget();
			
			if(!nodes.contains(source)) {
				targets.add(source);
			}
			else if(!nodes.contains(target)) {
				targets.add(target);
			}
		}
	}
	return targets;
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:22,代码来源:SummaryNetworkTask.java

示例14: applyVisualStyle

import org.cytoscape.model.CyNode; //导入依赖的package包/类
private void applyVisualStyle(CyNetworkView originNetworkView, CyNetworkView summaryNetworkView, SummaryNetwork summaryNetwork) {
	VisualStyle vs = visualMappingManager.getVisualStyle(originNetworkView);
	
	for(View<CyNode> nodeView : summaryNetworkView.getNodeViews()) {
		// Label
		String name = summaryNetworkView.getModel().getRow(nodeView.getModel()).get("name", String.class);
		nodeView.setLockedValue(BasicVisualLexicon.NODE_LABEL, name);
		
		// Node size
		CyNode node = nodeView.getModel();
		SummaryCluster cluster = summaryNetwork.getClusterFor(node);
		int numNodes = cluster.getNodes().size();
		nodeView.setLockedValue(BasicVisualLexicon.NODE_SIZE, (double)numNodes);
	}
	
	visualMappingManager.setVisualStyle(vs, summaryNetworkView);
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:18,代码来源:SummaryNetworkTask.java

示例15: collapse

import org.cytoscape.model.CyNode; //导入依赖的package包/类
private void collapse() {
	if(!cluster.isCollapsed()) {
		modelManager.ignore(VIEW_CHANGE, SELECTION).whileRunning(() -> {
			CyNetwork network = cluster.getNetwork();
			List<CyNode> nodes = new ArrayList<>(cluster.getNodes());
			
			CyGroup group = groupFactory.createGroup(network, nodes, null, true);
			
			CyRow groupRow = ((CySubNetwork)network).getRootNetwork().getRow(group.getGroupNode(), CyRootNetwork.SHARED_ATTRS);
	 		groupRow.set(CyRootNetwork.SHARED_NAME, cluster.getLabel());
	 		
			group.collapse(network);
			
			if(overrideAttribute) {
				maybeCreateAnotherAttributeForName(network, groupRow);
			}
		});
	}
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:20,代码来源:CollapseTask.java


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