use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class VisualMappingManagerImpl method getAllVisualLexicon.
@Override
public Set<VisualLexicon> getAllVisualLexicon() {
final Set<VisualLexicon> set = new LinkedHashSet<>();
final CyApplicationManager appManager = serviceRegistrar.getService(CyApplicationManager.class);
for (final NetworkViewRenderer nvRenderer : appManager.getNetworkViewRendererSet()) {
final VisualLexicon lexicon = nvRenderer.getRenderingEngineFactory(NetworkViewRenderer.DEFAULT_CONTEXT).getVisualLexicon();
if (lexicon != null)
set.add(lexicon);
}
return set;
}
use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class VisualMappingManagerImpl method setVisualStyle.
@Override
public void setVisualStyle(final VisualStyle vs, final CyNetworkView nv) {
if (nv == null)
throw new NullPointerException("Network view is null.");
boolean changed = false;
synchronized (lock) {
if (vs == null) {
changed = network2VisualStyleMap.remove(nv) != null;
} else {
final VisualStyle previousStyle = network2VisualStyleMap.put(nv, vs);
changed = !vs.equals(previousStyle);
}
if (this.visualStyles.contains(vs) == false)
this.visualStyles.add(vs);
}
if (changed) {
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
eventHelper.fireEvent(new VisualStyleSetEvent(this, vs, nv));
final CyApplicationManager appManager = serviceRegistrar.getService(CyApplicationManager.class);
if (appManager != null && nv.equals(appManager.getCurrentNetworkView()))
setCurrentVisualStyle(vs);
}
}
use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class ApplyToNetworkHandler method apply.
@Override
public void apply(final CyRow row, final View<CyNetwork> view) {
final CyNetworkView netView = (CyNetworkView) view;
final Collection<View<CyNode>> nodeViews = netView.getNodeViews();
final Collection<View<CyEdge>> edgeViews = netView.getEdgeViews();
final Collection<View<CyNetwork>> networkViewSet = new HashSet<View<CyNetwork>>();
networkViewSet.add(netView);
// Make sure the dependency maps are up to date
updateDependencyMaps();
// Clear visual properties from all views first
view.clearVisualProperties();
for (final View<?> v : nodeViews) v.clearVisualProperties();
for (final View<?> v : edgeViews) v.clearVisualProperties();
// Get current Visual Lexicon
final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
final VisualLexicon lexicon = appMgr.getCurrentNetworkViewRenderer().getRenderingEngineFactory(NetworkViewRenderer.DEFAULT_CONTEXT).getVisualLexicon();
applyDefaultsInParallel(netView, lexicon.getVisualLexiconNode(BasicVisualLexicon.NODE));
applyDefaultsInParallel(netView, lexicon.getVisualLexiconNode(BasicVisualLexicon.EDGE));
applyDefaultsInParallel(netView, lexicon.getVisualLexiconNode(BasicVisualLexicon.NETWORK));
applyDependencies(netView);
final ExecutorService exe = Executors.newCachedThreadPool();
exe.submit(new ApplyMappingsTask(netView, nodeViews, BasicVisualLexicon.NODE, lexicon));
exe.submit(new ApplyMappingsTask(netView, edgeViews, BasicVisualLexicon.EDGE, lexicon));
exe.submit(new ApplyMappingsTask(netView, networkViewSet, BasicVisualLexicon.NETWORK, lexicon));
try {
exe.shutdown();
exe.awaitTermination(15, TimeUnit.MINUTES);
} catch (Exception ex) {
logger.warn("Create apply operation failed.", ex);
}
}
use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class VisualStyleFactoryImpl method copyDependencies.
@SuppressWarnings({ "rawtypes", "unchecked" })
private void copyDependencies(final VisualStyle original, final VisualStyle copy) {
final Set<VisualPropertyDependency<?>> allDep1 = original.getAllVisualPropertyDependencies();
final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
final VisualLexicon lexicon = appMgr.getCurrentNetworkViewRenderer().getRenderingEngineFactory(NetworkViewRenderer.DEFAULT_CONTEXT).getVisualLexicon();
final Set<VisualPropertyDependency<?>> allDep2 = copy.getAllVisualPropertyDependencies();
final Map<String, VisualPropertyDependency<?>> depMap = new HashMap<>();
for (VisualPropertyDependency<?> dep : allDep2) depMap.put(dep.getIdString(), dep);
for (VisualPropertyDependency<?> dep1 : allDep1) {
try {
VisualPropertyDependency<?> dep2 = depMap.get(dep1.getIdString());
if (dep2 == null) {
// Just in case the new Style does not have this dependency...
dep2 = new VisualPropertyDependency(dep1.getIdString(), dep1.getDisplayName(), dep1.getVisualProperties(), lexicon);
dep2.setDependency(dep1.isDependencyEnabled());
copy.addVisualPropertyDependency(dep2);
} else {
// The new Style probably has the same dependency already;
// in this case, just update the enabled state.
dep2.setDependency(dep1.isDependencyEnabled());
}
} catch (Exception e) {
logger.warn("Cannot copy VisualPropertyDependency " + dep1.getIdString(), e);
}
}
}
use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class DiscreteValueEditor method getSupportedValues.
@SuppressWarnings("unchecked")
private <S extends T> Set<T> getSupportedValues(final VisualProperty<S> vp) {
if (vp == null)
return values;
final CyApplicationManager appMgr = servicesUtil.get(CyApplicationManager.class);
final VisualLexicon lexicon = appMgr.getCurrentNetworkViewRenderer().getRenderingEngineFactory(NetworkViewRenderer.DEFAULT_CONTEXT).getVisualLexicon();
return (Set<T>) lexicon.getSupportedValueRange(vp);
}
Aggregations