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;
}
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();
}
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();
}
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);
}
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();
});
}
Aggregations