use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class DetermineDistinctValuesTask method run.
/**
* DOCUMENT ME!
*/
public void run(TaskMonitor taskMonitor) {
taskMonitor.setProgress(-1);
// Obtain distinct attribute values
CyNetwork network = applicationManager.getCurrentNetwork();
Iterator<? extends CyIdentifiable> iterator;
if (parentDialog.getIndexType() == QuickFind.INDEX_NODES) {
iterator = network.getNodeList().iterator();
} else {
iterator = network.getEdgeList().iterator();
}
String[] values = CyAttributesUtil.getDistinctAttributeValues(network, iterator, attributeKey, 5);
if ((values != null) && (values.length > 0)) {
for (int i = 0; i < values.length; i++) {
tableModel.setValueAt(values[i], i, 0);
}
parentDialog.enableApplyButton(true);
} else {
VisualLexicon lexicon = applicationManager.getCurrentRenderingEngine().getVisualLexicon();
CyNetworkView view = applicationManager.getCurrentNetworkView();
String title = VisualPropertyUtil.get(lexicon, view, "NETWORK_TITLE", BasicVisualLexicon.NETWORK, String.class);
tableModel.setValueAt("No values found in network: " + title + ". Cannot create index.", 0, 0);
}
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class FilterUtil method isDynamicFilter.
// If a network size (node count and edge count) is less than DYNAMIC_FILTER_THRESHOLD, return true
// Otherwise, return false
public static boolean isDynamicFilter(CompositeFilter pFilter) {
CyNetwork theNetwork = pFilter.getNetwork();
if (theNetwork == null) {
return false;
}
int nodeCount = theNetwork.getNodeCount();
int edgeCount = theNetwork.getEdgeCount();
int dynamicFilterThresholdValue = -1;
// // TODO: What do we do about CyInit*?
// String dynamicFilterThreshold = CytoscapeInit.getProperties().getProperty(DYNAMIC_FILTER_THRESHOLD);
// if (dynamicFilterThreshold == null) { // threshold not defined, use the default value
dynamicFilterThresholdValue = DEFAULT_DYNAMIC_FILTER_THRESHOLD;
if (pFilter.getAdvancedSetting().isNodeChecked() && pFilter.getAdvancedSetting().isEdgeChecked()) {
// Select both nodes and edges
if (nodeCount > dynamicFilterThresholdValue || edgeCount > dynamicFilterThresholdValue) {
return false;
}
return true;
} else if (pFilter.getAdvancedSetting().isNodeChecked()) {
// Select node only
if (nodeCount < dynamicFilterThresholdValue) {
return true;
}
} else if (pFilter.getAdvancedSetting().isEdgeChecked()) {
// select edge only
if (edgeCount < dynamicFilterThresholdValue) {
return true;
}
}
return false;
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class CySessionManagerImpl method getCurrentSession.
@Override
public CySession getCurrentSession() {
// Apps who want to save anything to a session will have to listen for this event
// and will then be responsible for adding files through SessionAboutToBeSavedEvent.addAppFiles(..)
final SessionAboutToBeSavedEvent savingEvent = new SessionAboutToBeSavedEvent(this);
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
eventHelper.fireEvent(savingEvent);
final Set<CyNetwork> networks = getSerializableNetworks();
final CyNetworkViewManager nvMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
final Set<CyNetworkView> netViews = nvMgr.getNetworkViewSet();
// Visual Styles Map
final Map<CyNetworkView, String> stylesMap = new HashMap<>();
final VisualMappingManager vmMgr = serviceRegistrar.getService(VisualMappingManager.class);
if (netViews != null) {
for (final CyNetworkView nv : netViews) {
final VisualStyle style = vmMgr.getVisualStyle(nv);
if (style != null)
stylesMap.put(nv, style.getTitle());
}
}
final Map<String, List<File>> appMap = savingEvent.getAppFileListMap();
final Set<CyTableMetadata> metadata = createTablesMetadata(networks);
final Set<VisualStyle> styles = vmMgr.getAllVisualStyles();
final Set<CyProperty<?>> props = getAllProperties();
// Build the session
final CySession sess = new CySession.Builder().properties(props).appFileListMap(appMap).tables(metadata).networks(networks).networkViews(netViews).visualStyles(styles).viewVisualStyleMap(stylesMap).build();
return sess;
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class CySessionManagerImpl method restoreNetworkSelection.
private void restoreNetworkSelection(final CySession sess, final List<CyNetwork> selectedNets) {
// If the current view/network was not set, set the first selected network as current
if (!selectedNets.isEmpty()) {
final CyNetwork cn = selectedNets.get(0);
final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
appMgr.setCurrentNetwork(cn);
// Also set the current view, if there is one
final CyNetworkViewManager nvMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
final Collection<CyNetworkView> cnViews = nvMgr.getNetworkViews(cn);
final CyNetworkView cv = cnViews.isEmpty() ? null : cnViews.iterator().next();
appMgr.setCurrentNetworkView(cv);
// The selected networks must be set after setting the current one!
appMgr.setSelectedNetworks(selectedNets);
}
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class CySessionManagerImpl method restoreNetworks.
private void restoreNetworks(final CySession sess) {
logger.debug("Restoring networks...");
Set<CyNetwork> networks = sess.getNetworks();
final CyNetworkManager netMgr = serviceRegistrar.getService(CyNetworkManager.class);
for (CyNetwork n : networks) {
netMgr.addNetwork(n, false);
}
}
Aggregations