Search in sources :

Example 6 with NetworkViewRenderer

use of org.cytoscape.application.NetworkViewRenderer 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 7 with NetworkViewRenderer

use of org.cytoscape.application.NetworkViewRenderer in project EnrichmentMapApp by BaderLab.

the class LegendPanel method updateNodeChartPanel.

private void updateNodeChartPanel(Collection<EMDataSet> dataSets, EnrichmentMap map) {
    JPanel p = getNodeChartPanel();
    chartLegendPanel.removeAll();
    CyNetworkView netView = options.getNetworkView();
    VisualStyle style = netView != null ? visualMappingManager.getVisualStyle(netView) : null;
    NetworkViewRenderer renderer = applicationManager.getCurrentNetworkViewRenderer();
    if (renderer == null)
        renderer = applicationManager.getDefaultNetworkViewRenderer();
    VisualLexicon lexicon = renderer.getRenderingEngineFactory(NetworkViewRenderer.DEFAULT_CONTEXT).getVisualLexicon();
    VisualProperty<?> vp = lexicon.lookup(CyNode.class, "NODE_CUSTOMGRAPHICS_1");
    Object cg = vp != null ? style.getDefaultValue(vp) : null;
    ChartType chartType = options.getChartOptions() != null ? options.getChartOptions().getType() : null;
    if (chartType != null && cg instanceof CyCustomGraphics2 && dataSets != null && dataSets.size() > 1) {
        ChartPanel chart = createChartPanel(dataSets);
        if (chart != null) {
            JLabel titleLabel = new JLabel("" + options.getChartOptions().getData());
            titleLabel.setHorizontalAlignment(JLabel.CENTER);
            makeSmall(titleLabel);
            chartLegendPanel.add(chart, BorderLayout.CENTER);
            chartLegendPanel.add(titleLabel, BorderLayout.SOUTH);
        }
        p.setVisible(true);
    } else {
        p.setVisible(false);
    }
    p.revalidate();
}
Also used : JPanel(javax.swing.JPanel) CyCustomGraphics2(org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2) BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) VisualLexicon(org.cytoscape.view.model.VisualLexicon) ChartPanel(org.jfree.chart.ChartPanel) JLabel(javax.swing.JLabel) ChartType(org.baderlab.csplugins.enrichmentmap.style.ChartType) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) CyNetworkView(org.cytoscape.view.model.CyNetworkView) NetworkViewRenderer(org.cytoscape.application.NetworkViewRenderer)

Example 8 with NetworkViewRenderer

use of org.cytoscape.application.NetworkViewRenderer in project cytoscape-impl by cytoscape.

the class BirdsEyeViewPanel method update.

public final void update() {
    final Dimension currentPanelSize = getSize();
    getPresentationPanel().setSize(currentPanelSize);
    getPresentationPanel().setPreferredSize(currentPanelSize);
    if (engine == null) {
        final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
        final NetworkViewRenderer renderer = applicationManager.getNetworkViewRenderer(networkView.getRendererId());
        final RenderingEngineFactory<CyNetwork> bevFactory = renderer.getRenderingEngineFactory(NetworkViewRenderer.BIRDS_EYE_CONTEXT);
        engine = bevFactory.createRenderingEngine(getPresentationPanel(), networkView);
    }
    repaint();
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyNetwork(org.cytoscape.model.CyNetwork) Dimension(java.awt.Dimension) NetworkViewRenderer(org.cytoscape.application.NetworkViewRenderer)

Example 9 with NetworkViewRenderer

use of org.cytoscape.application.NetworkViewRenderer in project cytoscape-impl by cytoscape.

the class NetworkCollectionHelper method init.

void init() {
    final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
    final CyRootNetworkManager rootNetMgr = serviceRegistrar.getService(CyRootNetworkManager.class);
    // initialize the network Collection
    name2RootMap = getRootNetworkMap();
    final List<String> rootNames = new ArrayList<>();
    rootNames.addAll(name2RootMap.keySet());
    if (!rootNames.isEmpty()) {
        sort(rootNames);
        rootNames.add(0, CREATE_NEW_COLLECTION_STRING);
    }
    rootNetworkList = new ListSingleSelection<>(rootNames);
    final CyNetwork net = appMgr != null ? appMgr.getCurrentNetwork() : null;
    final CyRootNetwork rootNet = net != null ? rootNetMgr.getRootNetwork(net) : null;
    final String rootNetName = rootNet != null ? rootNet.getRow(rootNet).get(CyRootNetwork.NAME, String.class) : CREATE_NEW_COLLECTION_STRING;
    if (rootNames.contains(rootNetName))
        rootNetworkList.setSelectedValue(rootNetName);
    else if (rootNames.contains(CREATE_NEW_COLLECTION_STRING))
        rootNetworkList.setSelectedValue(CREATE_NEW_COLLECTION_STRING);
    if (rootNet != null)
        targetColumnList = getTargetColumns(rootNet);
    else
        targetColumnList = new ListSingleSelection<>();
    // initialize renderer list
    final List<NetworkViewRenderer> renderers = new ArrayList<>();
    final Set<NetworkViewRenderer> rendererSet = appMgr.getNetworkViewRendererSet();
    // so the combo-box does not appear to the user, since there is nothing to select anyway.
    if (rendererSet.size() > 1) {
        renderers.addAll(rendererSet);
        Collections.sort(renderers, new Comparator<NetworkViewRenderer>() {

            @Override
            public int compare(NetworkViewRenderer r1, NetworkViewRenderer r2) {
                return r1.toString().compareToIgnoreCase(r2.toString());
            }
        });
    }
    rendererList = new ListSingleSelection<>(renderers);
    final NetworkViewRenderer defViewRenderer = appMgr.getDefaultNetworkViewRenderer();
    if (defViewRenderer != null && renderers.contains(defViewRenderer))
        rendererList.setSelectedValue(defViewRenderer);
}
Also used : CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) CyApplicationManager(org.cytoscape.application.CyApplicationManager) ListSingleSelection(org.cytoscape.work.util.ListSingleSelection) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork) NetworkViewRenderer(org.cytoscape.application.NetworkViewRenderer)

Example 10 with NetworkViewRenderer

use of org.cytoscape.application.NetworkViewRenderer in project cytoscape-impl by cytoscape.

the class NetworkViewMediator method render.

/**
 * Create a visualization container and add presentation to it.
 */
private final void render(final CyNetworkView view) {
    invokeOnEDT(() -> {
        // If already registered in this manager, do not render.
        if (getNetworkViewMainPanel().isRendered(view))
            return;
        NetworkViewRenderer renderer = null;
        final String rendererId = view.getRendererId();
        final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
        if (rendererId != null)
            renderer = appMgr.getNetworkViewRenderer(rendererId);
        if (renderer == null)
            renderer = appMgr.getDefaultNetworkViewRenderer();
        final RenderingEngineFactory<CyNetwork> engineFactory = renderer.getRenderingEngineFactory(NetworkViewRenderer.DEFAULT_CONTEXT);
        final RenderingEngineFactory<CyNetwork> thumbnailFactory = renderer.getRenderingEngineFactory(NetworkViewRenderer.THUMBNAIL_CONTEXT);
        final RenderingEngine<CyNetwork> renderingEngine = getNetworkViewMainPanel().addNetworkView(view, engineFactory, thumbnailFactory);
        presentationMap.put(view, renderingEngine);
        final boolean isCurrentView = view.equals(appMgr.getCurrentNetworkView());
        new Thread(() -> {
            serviceRegistrar.getService(RenderingEngineManager.class).addRenderingEngine(renderingEngine);
            if (isCurrentView)
                appMgr.setCurrentRenderingEngine(renderingEngine);
        }).start();
    });
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyNetwork(org.cytoscape.model.CyNetwork) NetworkViewRenderer(org.cytoscape.application.NetworkViewRenderer)

Aggregations

NetworkViewRenderer (org.cytoscape.application.NetworkViewRenderer)15 CyNetwork (org.cytoscape.model.CyNetwork)7 CyApplicationManager (org.cytoscape.application.CyApplicationManager)6 ListSingleSelection (org.cytoscape.work.util.ListSingleSelection)5 CyNetworkViewFactory (org.cytoscape.view.model.CyNetworkViewFactory)4 ArrayList (java.util.ArrayList)3 CyNetworkView (org.cytoscape.view.model.CyNetworkView)3 VisualLexicon (org.cytoscape.view.model.VisualLexicon)3 BasicVisualLexicon (org.cytoscape.view.presentation.property.BasicVisualLexicon)3 HashSet (java.util.HashSet)2 CyEdge (org.cytoscape.model.CyEdge)2 CyNode (org.cytoscape.model.CyNode)2 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)2 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)2 Dimension (java.awt.Dimension)1 Paint (java.awt.Paint)1 LinkedHashSet (java.util.LinkedHashSet)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 ChartType (org.baderlab.csplugins.enrichmentmap.style.ChartType)1