本文整理汇总了Java中org.cytoscape.view.model.CyNetworkView类的典型用法代码示例。如果您正苦于以下问题:Java CyNetworkView类的具体用法?Java CyNetworkView怎么用?Java CyNetworkView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CyNetworkView类属于org.cytoscape.view.model包,在下文中一共展示了CyNetworkView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAttributeBrowserStyle
import org.cytoscape.view.model.CyNetworkView; //导入依赖的package包/类
void setAttributeBrowserStyle(CyNetworkView view) {
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(() -> setAttributeBrowserStyle(view));
return;
}
VisualStyle style = visualMappingManager.getAllVisualStyles()
.stream()
.filter(s -> s.getTitle()
.equals(StyleFactory.ATTRIBUTE_BROWSER_STYLE))
.findFirst()
.orElse(null);
if (style == null) {
style = styleFactory.createAttributeBrowserStyle();
visualMappingManager.addVisualStyle(style);
}
VisualStyle viewStyle = visualMappingManager.getVisualStyle(view);
if (viewStyle != style) {
visualMappingManager.setVisualStyle(style, view);
}
}
示例2: 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);
}
}
示例3: setDomainBrowserStyle
import org.cytoscape.view.model.CyNetworkView; //导入依赖的package包/类
void setDomainBrowserStyle(CyNetworkView view) {
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(() -> setDomainBrowserStyle(view));
return;
}
VisualStyle style = visualMappingManager.getAllVisualStyles()
.stream()
.filter(s -> s.getTitle()
.equals(StyleFactory.DOMAIN_BROWSER_STYLE))
.findFirst()
.orElse(null);
if (style == null) {
style = styleFactory.createDomainBrowserStyle();
visualMappingManager.addVisualStyle(style);
}
VisualStyle viewStyle = visualMappingManager.getVisualStyle(view);
if (viewStyle != style) {
visualMappingManager.setVisualStyle(style, view);
}
}
示例4: 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());
}
示例5: 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);
}
}
示例6: 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();
}
}
示例7: loadFromSession
import org.cytoscape.view.model.CyNetworkView; //导入依赖的package包/类
public LongObjectMap<SafeSession> loadFromSession(CySession cySession) throws IOException {
CyTable dataTable = cySession.getTables()
.stream()
.map(metadata -> metadata.getTable())
.filter(table -> DATA_TABLE_TITLE.equals(table.getTitle()))
.findFirst()
.orElse(null);
LongObjectMap<SafeSession> sessions = new LongObjectHashMap<>();
if (dataTable == null) {
return sessions;
}
for (CyRow row : dataTable.getAllRows()) {
String json = row.get(SAFE_DATA_COLUMN, String.class);
SafeSession session = parseSession(json);
Long oldSuid = row.get(CyIdentifiable.SUID, Long.class);
CyNetworkView view = cySession.getObject(oldSuid, CyNetworkView.class);
session.setNetworkView(view);
sessions.put(view.getSUID(), session);
}
return sessions;
}
示例8: forNodes
import org.cytoscape.view.model.CyNetworkView; //导入依赖的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);
}
示例9: expandAllClusters
import org.cytoscape.view.model.CyNetworkView; //导入依赖的package包/类
/**
* This is a huge hack to get around a bug in cytoscape.
* All groups must be expanded before the session is saved.
*/
private void expandAllClusters() {
Collection<CyNetworkView> networkViews =
modelManagerProvider.get()
.getNetworkViewSets()
.stream()
.map(NetworkViewSet::getNetworkView)
.collect(Collectors.toSet());
if(networkViews.isEmpty())
return;
TaskIterator tasks = getExpandTasks(networkViews);
Semaphore semaphore = new Semaphore(0);
dialogTaskManager.execute(tasks, TaskTools.allFinishedObserver(() -> semaphore.release()));
// We need to block while the groups are expanding because this must happen before the session is saved.
semaphore.acquireUninterruptibly();
}
示例10: exportModel
import org.cytoscape.view.model.CyNetworkView; //导入依赖的package包/类
public void exportModel() {
for(CyNetwork network: networkManager.getNetworkSet()) {
CyTable asTable = createAnnotationSetTable(network);
CyTable clusterTable = createClusterTable(network);
Ids ids = new Ids();
Collection<CyNetworkView> networkViews = networkViewManager.getNetworkViews(network);
for(CyNetworkView networkView : networkViews) {
Optional<NetworkViewSet> nvs = modelManagerProvider.get().getExistingNetworkViewSet(networkView);
if(nvs.isPresent()) {
try {
exportModel(nvs.get(), asTable, clusterTable, ids);
}catch(Exception ex) {
ex.printStackTrace();
}
continue;
}
}
}
}
示例11: run
import org.cytoscape.view.model.CyNetworkView; //导入依赖的package包/类
@Override
public void run(TaskMonitor taskMonitor) {
taskMonitor.setTitle(BuildProperties.APP_NAME);
taskMonitor.setStatusMessage("Removing Annotations");
CyNetworkView networkView = networkViewSet.getNetworkView();
List<Annotation> annotations = annotationManager.getAnnotations(networkView);
if(annotations != null) { // seriously?
for(Annotation annotation : annotations) {
try {
SwingUtilities.invokeAndWait(annotation::removeAnnotation);
} catch (Exception e) {}
}
}
for(Cluster cluster : networkViewSet.getAllClusters()) {
annotationRenderer.removeShapeAnnoation(cluster);
annotationRenderer.removeTextAnnotation(cluster);
}
}
示例12: 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;
}
示例13: run
import org.cytoscape.view.model.CyNetworkView; //导入依赖的package包/类
/**
* This is fast because no events are fired while the summary network is being built.
* The summary network and view are registered at the end.
*/
@Override
public void run(TaskMonitor taskMonitor) {
taskMonitor.setTitle(BuildProperties.APP_NAME);
taskMonitor.setStatusMessage(SummaryNetworkAction.TITLE);
CyNetwork originNetwork = annotationSet.getParent().getNetwork();
List<SummaryCluster> summaryClusters = getSummaryClusters();
// create summary network
SummaryNetwork summaryNetwork = createSummaryNetwork(originNetwork, summaryClusters);
// create summary network view
CyNetworkView summaryNetworkView = createNetworkView(summaryNetwork);
// apply visual style
applyVisualStyle(annotationSet.getParent().getNetworkView(), summaryNetworkView, summaryNetwork);
// register
networkManager.addNetwork(summaryNetwork.network);
networkViewManager.addNetworkView(summaryNetworkView);
summaryNetworkView.fitContent();
resultNetwork = summaryNetwork.network;
}
示例14: applyVisualStyle
import org.cytoscape.view.model.CyNetworkView; //导入依赖的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);
}
示例15: getNetworkView
import org.cytoscape.view.model.CyNetworkView; //导入依赖的package包/类
private CyNetworkView getNetworkView() throws IllegalArgumentException {
if(network == null) {
network = applicationManager.getCurrentNetwork();
if(network == null)
throw new IllegalArgumentException("Please create a network first.");
}
else {
// Unfortunatly clusterMaker2 is buggy regarding the network parameter,
// the only way to get clusterMaker2 to run without problems is to make the desired network the current one.
applicationManager.setCurrentNetwork(network);
}
Collection<CyNetworkView> netViews = networkViewManager.getNetworkViews(network);
if(netViews == null || netViews.isEmpty())
throw new IllegalArgumentException("Selected network does not have a view.");
return netViews.iterator().next();
}