use of org.cytoscape.view.presentation.RenderingEngine in project cytoscape-impl by cytoscape.
the class RenderingEngineManagerImpl method removeRenderingEngine.
@Override
public void removeRenderingEngine(final RenderingEngine<?> renderingEngine) {
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
eventHelper.fireEvent(new RenderingEngineAboutToBeRemovedEvent(this, renderingEngine));
synchronized (lock) {
final View<?> viewModel = renderingEngine.getViewModel();
final Collection<RenderingEngine<?>> currentEngines = renderingEngineMap.get(viewModel);
if (currentEngines != null) {
currentEngines.remove(renderingEngine);
}
}
renderingEngine.dispose();
}
use of org.cytoscape.view.presentation.RenderingEngine in project cytoscape-impl by cytoscape.
the class RangeSelectionListener method onUserSelection.
/**
* Indicates that the user has selected a text item within the QuickFind
* Search Box.
*
* @param network the current CyNetwork.
* @param hit hit value chosen by the user.
*/
public void onUserSelection(final CyNetwork network, Hit hit) {
SelectUtil.unselectAllNodes(network);
SelectUtil.unselectAllEdges(network);
// Assemble Hit Objects
final Object[] graphObjects = hit.getAssociatedObjects();
final List list = new ArrayList();
for (int i = 0; i < graphObjects.length; i++) {
list.add(graphObjects[i]);
}
// Fit Selected Content
SwingUtilities.invokeLater(new Runnable() {
public void run() {
final CyNetwork cyNetwork = applicationManager.getCurrentNetwork();
CyNetworkView networkView = applicationManager.getCurrentNetworkView();
GenericIndex index = quickFind.getIndex(cyNetwork);
if (index.getIndexType() == QuickFind.INDEX_NODES) {
SelectUtil.setSelectedNodeState(network, list, true);
final CyNetworkView currentView = applicationManager.getCurrentNetworkView();
if (currentView != null)
currentView.fitSelected();
} else {
SelectUtil.setSelectedEdgeState(network, list, true);
List<CyNode> nodeList = new ArrayList<CyNode>();
for (int i = 0; i < list.size(); i++) {
CyEdge edge = (CyEdge) list.get(i);
CyNode sourceNode = edge.getSource();
CyNode targetNode = edge.getTarget();
nodeList.add(sourceNode);
nodeList.add(targetNode);
}
SelectUtil.setSelectedNodeState(network, nodeList, true);
networkView.fitSelected();
}
// so that node does not take up whole screen.
if (graphObjects.length == 1) {
if (graphObjects[0] instanceof CyNode) {
CyNode node = (CyNode) graphObjects[0];
// Obtain dimensions of current InnerCanvas
RenderingEngine<CyNetwork> engine = applicationManager.getCurrentRenderingEngine();
VisualLexicon lexicon = engine.getVisualLexicon();
Double networkWidth = VisualPropertyUtil.get(lexicon, networkView, "NETWORK_WIDTH", BasicVisualLexicon.NETWORK, Double.class);
Double networkHeight = VisualPropertyUtil.get(lexicon, networkView, "NETWORK_HEIGHT", BasicVisualLexicon.NETWORK, Double.class);
View<CyNode> nodeView = networkView.getNodeView(node);
Double nodeWidth = VisualPropertyUtil.get(lexicon, nodeView, "NODE_WIDTH", BasicVisualLexicon.NODE, Double.class);
Double nodeHeight = VisualPropertyUtil.get(lexicon, nodeView, "NODE_HEIGHT", BasicVisualLexicon.NODE, Double.class);
double width = nodeWidth * NODE_SIZE_MULTIPLER;
double height = nodeHeight * NODE_SIZE_MULTIPLER;
double scaleFactor = Math.min(networkWidth / width, (networkHeight / height));
// TODO: How do we set the zoom in the new API?
// networkView.setZoom(scaleFactor);
}
}
networkView.updateView();
}
});
}
use of org.cytoscape.view.presentation.RenderingEngine in project cytoscape-impl by cytoscape.
the class SessionXGMMLNetworkViewWriter method writeRootElementAtributes.
@Override
protected void writeRootElementAtributes() throws IOException {
writeAttributePair("id", networkView.getSUID());
writeAttributePair("label", getLabel(networkView));
writeAttributePair("cy:view", ObjectTypeMap.toXGMMLBoolean(true));
writeAttributePair("cy:networkId", network.getSUID());
if (visualStyle != null)
writeAttributePair("cy:visualStyle", visualStyle.getTitle());
final RenderingEngineManager renderingEngineMgr = serviceRegistrar.getService(RenderingEngineManager.class);
final Collection<RenderingEngine<?>> renderingEngines = renderingEngineMgr.getRenderingEngines(networkView);
if (renderingEngines != null && !renderingEngines.isEmpty())
writeAttributePair("cy:rendererId", renderingEngines.iterator().next().getRendererId());
}
use of org.cytoscape.view.presentation.RenderingEngine in project EnrichmentMapApp by BaderLab.
the class LegendPanel method getIcon.
@SuppressWarnings({ "unchecked", "rawtypes" })
private Icon getIcon(VisualProperty<?> vp, Object value, CyNetworkView netView) {
if (value == null || netView == null)
return null;
Collection<RenderingEngine<?>> engines = engineManager.getRenderingEngines(netView);
RenderingEngine<?> engine = null;
for (RenderingEngine<?> re : engines) {
if (re.getRendererId().equals(netView.getRendererId())) {
engine = re;
break;
}
}
Icon icon = engine != null ? engine.createIcon((VisualProperty) vp, value, LEGEND_ICON_SIZE, LEGEND_ICON_SIZE) : null;
return icon;
}
use of org.cytoscape.view.presentation.RenderingEngine in project cytoscape-impl by cytoscape.
the class GroupIO method getVisualLexicon.
private VisualLexicon getVisualLexicon(final CyNetworkView netView) {
final RenderingEngineManager rendererMgr = groupMgr.getService(RenderingEngineManager.class);
final Collection<RenderingEngine<?>> renderingEngines = rendererMgr.getRenderingEngines(netView);
if (renderingEngines != null && !renderingEngines.isEmpty())
return renderingEngines.iterator().next().getVisualLexicon();
return rendererMgr.getDefaultVisualLexicon();
}
Aggregations