Search in sources :

Example 6 with RenderingEngine

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();
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) RenderingEngine(org.cytoscape.view.presentation.RenderingEngine) RenderingEngineAboutToBeRemovedEvent(org.cytoscape.view.presentation.events.RenderingEngineAboutToBeRemovedEvent)

Example 7 with RenderingEngine

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();
        }
    });
}
Also used : BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) VisualLexicon(org.cytoscape.view.model.VisualLexicon) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) CyEdge(org.cytoscape.model.CyEdge) View(org.cytoscape.view.model.View) CyNetworkView(org.cytoscape.view.model.CyNetworkView) GenericIndex(org.cytoscape.filter.internal.widgets.autocomplete.index.GenericIndex) RenderingEngine(org.cytoscape.view.presentation.RenderingEngine) ArrayList(java.util.ArrayList) List(java.util.List) CyNode(org.cytoscape.model.CyNode) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 8 with RenderingEngine

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());
}
Also used : RenderingEngine(org.cytoscape.view.presentation.RenderingEngine) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager)

Example 9 with RenderingEngine

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;
}
Also used : RenderingEngine(org.cytoscape.view.presentation.RenderingEngine) VisualProperty(org.cytoscape.view.model.VisualProperty) Icon(javax.swing.Icon)

Example 10 with RenderingEngine

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();
}
Also used : RenderingEngine(org.cytoscape.view.presentation.RenderingEngine) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager)

Aggregations

RenderingEngine (org.cytoscape.view.presentation.RenderingEngine)14 CyNetworkView (org.cytoscape.view.model.CyNetworkView)7 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)6 CyNetwork (org.cytoscape.model.CyNetwork)4 CyNode (org.cytoscape.model.CyNode)4 Dimension (java.awt.Dimension)3 Image (java.awt.Image)3 BufferedImage (java.awt.image.BufferedImage)3 ArrayList (java.util.ArrayList)3 JPanel (javax.swing.JPanel)3 Color (java.awt.Color)2 Graphics2D (java.awt.Graphics2D)2 JWindow (javax.swing.JWindow)2 CyApplicationManager (org.cytoscape.application.CyApplicationManager)2 CyFileFilter (org.cytoscape.io.CyFileFilter)2 CyEdge (org.cytoscape.model.CyEdge)2 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)2 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)2 VisualLexicon (org.cytoscape.view.model.VisualLexicon)2 VisualProperty (org.cytoscape.view.model.VisualProperty)2