Search in sources :

Example 1 with VisualLexicon

use of org.cytoscape.view.model.VisualLexicon in project EnrichmentMapApp by BaderLab.

the class EMStyleBuilder method setNodeChart.

@SuppressWarnings({ "rawtypes", "unchecked" })
private void setNodeChart(VisualStyle vs, CyCustomGraphics2<?> chart) {
    VisualLexicon lexicon = renderingEngineManager.getDefaultVisualLexicon();
    VisualProperty customPaint1 = lexicon.lookup(CyNode.class, "NODE_CUSTOMGRAPHICS_1");
    if (customPaint1 != null)
        vs.setDefaultValue(customPaint1, chart);
}
Also used : BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) VisualLexicon(org.cytoscape.view.model.VisualLexicon) LineTypeVisualProperty(org.cytoscape.view.presentation.property.LineTypeVisualProperty) VisualProperty(org.cytoscape.view.model.VisualProperty)

Example 2 with VisualLexicon

use of org.cytoscape.view.model.VisualLexicon in project cytoscape-api by cytoscape.

the class AbstractRenderingEngineTest method testLexicon.

@Test
public void testLexicon() throws Exception {
    final VisualLexicon lexicon = engine.getVisualLexicon();
    assertNotNull(lexicon);
    assertEquals(numberOfVP, lexicon.getAllVisualProperties().size());
}
Also used : VisualLexicon(org.cytoscape.view.model.VisualLexicon) Test(org.junit.Test)

Example 3 with VisualLexicon

use of org.cytoscape.view.model.VisualLexicon 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 4 with VisualLexicon

use of org.cytoscape.view.model.VisualLexicon in project EnrichmentMapApp by BaderLab.

the class FilterNodesEdgesTask method filterNodes.

private void filterNodes(Set<CyNode> nodes, TaskMonitor taskMonitor) {
    CyNetwork net = networkView.getModel();
    for (CyNode n : net.getNodeList()) {
        if (cancelled)
            return;
        final View<CyNode> nv = networkView.getNodeView(n);
        if (nv == null)
            // Should never happen!
            continue;
        boolean filteredIn = nodes.contains(n);
        VisualLexicon lexicon = renderingEngineManager.getDefaultVisualLexicon();
        VisualProperty<?> customGraphics1 = lexicon.lookup(CyNode.class, "NODE_CUSTOMGRAPHICS_1");
        // Don't forget to remove all previous locked values first!
        nv.clearValueLock(NODE_VISIBLE);
        nv.clearValueLock(NODE_TRANSPARENCY);
        nv.clearValueLock(NODE_BORDER_TRANSPARENCY);
        nv.clearValueLock(NODE_LABEL_TRANSPARENCY);
        if (customGraphics1 != null)
            nv.clearValueLock(customGraphics1);
        if (filteredIn) {
            if (filterMode == FilterMode.SELECT)
                net.getRow(n).set(CyNetwork.SELECTED, true);
        } else {
            switch(filterMode) {
                case HIDE:
                    net.getRow(n).set(CyNetwork.SELECTED, false);
                    nv.setLockedValue(NODE_VISIBLE, false);
                    break;
                case HIGHLIGHT:
                    nv.setLockedValue(NODE_TRANSPARENCY, FILTERED_OUT_NODE_TRANSPARENCY);
                    nv.setLockedValue(NODE_BORDER_TRANSPARENCY, FILTERED_OUT_NODE_TRANSPARENCY);
                    nv.setLockedValue(NODE_LABEL_TRANSPARENCY, 0);
                    if (customGraphics1 != null)
                        nv.setLockedValue(customGraphics1, NullCustomGraphics.getNullObject());
                    break;
                case SELECT:
                    net.getRow(n).set(CyNetwork.SELECTED, false);
                    break;
            }
        }
    }
}
Also used : VisualLexicon(org.cytoscape.view.model.VisualLexicon) CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode)

Aggregations

VisualLexicon (org.cytoscape.view.model.VisualLexicon)4 BasicVisualLexicon (org.cytoscape.view.presentation.property.BasicVisualLexicon)2 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 ChartType (org.baderlab.csplugins.enrichmentmap.style.ChartType)1 NetworkViewRenderer (org.cytoscape.application.NetworkViewRenderer)1 CyNetwork (org.cytoscape.model.CyNetwork)1 CyNode (org.cytoscape.model.CyNode)1 CyNetworkView (org.cytoscape.view.model.CyNetworkView)1 VisualProperty (org.cytoscape.view.model.VisualProperty)1 CyCustomGraphics2 (org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2)1 LineTypeVisualProperty (org.cytoscape.view.presentation.property.LineTypeVisualProperty)1 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)1 ChartPanel (org.jfree.chart.ChartPanel)1 Test (org.junit.Test)1