Search in sources :

Example 31 with CyApplicationManager

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CyApplicationManager(org.cytoscape.application.CyApplicationManager) BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) VisualLexicon(org.cytoscape.view.model.VisualLexicon) NetworkViewRenderer(org.cytoscape.application.NetworkViewRenderer)

Example 32 with CyApplicationManager

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);
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyEventHelper(org.cytoscape.event.CyEventHelper) VisualStyleSetEvent(org.cytoscape.view.vizmap.events.VisualStyleSetEvent) VisualStyle(org.cytoscape.view.vizmap.VisualStyle)

Example 33 with CyApplicationManager

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);
    }
}
Also used : BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) VisualLexicon(org.cytoscape.view.model.VisualLexicon) CyNetwork(org.cytoscape.model.CyNetwork) View(org.cytoscape.view.model.View) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyApplicationManager(org.cytoscape.application.CyApplicationManager) ExecutorService(java.util.concurrent.ExecutorService) CyNetworkView(org.cytoscape.view.model.CyNetworkView) HashSet(java.util.HashSet)

Example 34 with CyApplicationManager

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);
        }
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) VisualLexicon(org.cytoscape.view.model.VisualLexicon) HashMap(java.util.HashMap) VisualPropertyDependency(org.cytoscape.view.vizmap.VisualPropertyDependency)

Example 35 with CyApplicationManager

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);
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) VisualLexicon(org.cytoscape.view.model.VisualLexicon) Set(java.util.Set)

Aggregations

CyApplicationManager (org.cytoscape.application.CyApplicationManager)80 CyNetwork (org.cytoscape.model.CyNetwork)40 CyNetworkView (org.cytoscape.view.model.CyNetworkView)30 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)18 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)16 CyNetworkManager (org.cytoscape.model.CyNetworkManager)14 CyEventHelper (org.cytoscape.event.CyEventHelper)12 CyTable (org.cytoscape.model.CyTable)12 ArrayList (java.util.ArrayList)11 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)10 CyNode (org.cytoscape.model.CyNode)9 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)9 Test (org.junit.Test)9 HashSet (java.util.HashSet)8 CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)8 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)8 TaskIterator (org.cytoscape.work.TaskIterator)8 HashMap (java.util.HashMap)7 CyGroupManager (org.cytoscape.group.CyGroupManager)7 CyTableManager (org.cytoscape.model.CyTableManager)7