Search in sources :

Example 1 with WidthFunction

use of org.baderlab.csplugins.enrichmentmap.style.WidthFunction in project EnrichmentMapApp by BaderLab.

the class EdgeWidthDialog method createButtonPanel.

private JPanel createButtonPanel() {
    JButton restoreDefaultsButton = new JButton("Restore Defaults");
    restoreDefaultsButton.addActionListener(e -> {
        setTextFieldValues(EdgeWidthParams.defaultValues());
    });
    JButton cancelButton = new JButton(new AbstractAction("Cancel") {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    JButton okButton = new JButton(new AbstractAction("OK") {

        @Override
        public void actionPerformed(ActionEvent e) {
            double emLowerWidth = ((Number) emLowerWidthText.getValue()).doubleValue();
            double emUpperWidth = ((Number) emUpperWidthText.getValue()).doubleValue();
            double lessThan100 = ((Number) lessThan100Text.getValue()).doubleValue();
            double lessThan10 = ((Number) lessThan10Text.getValue()).doubleValue();
            double greaterThan = ((Number) greaterThanText.getValue()).doubleValue();
            EdgeWidthParams params = new EdgeWidthParams(emLowerWidth, emUpperWidth, lessThan100, lessThan10, greaterThan);
            params.save(network);
            Task task = new Task() {

                public void run(TaskMonitor taskMonitor) throws Exception {
                    taskMonitor.setTitle("EnrichmentMap");
                    taskMonitor.setStatusMessage("Calculating Post-Analysis Edge Widths");
                    WidthFunction widthFunction = widthFunctionProvider.get();
                    widthFunction.setEdgeWidths(network, prefix, taskMonitor);
                }

                public void cancel() {
                }
            };
            taskManager.execute(new TaskIterator(task));
            dispose();
        }
    });
    JPanel bottomPanel = LookAndFeelUtil.createOkCancelPanel(okButton, cancelButton, restoreDefaultsButton);
    LookAndFeelUtil.setDefaultOkCancelKeyStrokes(getRootPane(), okButton.getAction(), cancelButton.getAction());
    getRootPane().setDefaultButton(okButton);
    return bottomPanel;
}
Also used : JPanel(javax.swing.JPanel) Task(org.cytoscape.work.Task) TaskIterator(org.cytoscape.work.TaskIterator) ActionEvent(java.awt.event.ActionEvent) TaskMonitor(org.cytoscape.work.TaskMonitor) WidthFunction(org.baderlab.csplugins.enrichmentmap.style.WidthFunction) EdgeWidthParams(org.baderlab.csplugins.enrichmentmap.style.WidthFunction.EdgeWidthParams) JButton(javax.swing.JButton) AbstractAction(javax.swing.AbstractAction)

Example 2 with WidthFunction

use of org.baderlab.csplugins.enrichmentmap.style.WidthFunction in project EnrichmentMapApp by BaderLab.

the class PostAnalysisTaskTest method test_4_WidthFunction.

@Test
public void test_4_WidthFunction(@Continuous VisualMappingFunctionFactory cmFactory, EnrichmentMapManager emManager, Provider<WidthFunction> widthFunctionProvider) {
    CyNetworkManager networkManager = mock(CyNetworkManager.class);
    when(networkManager.getNetworkSet()).thenReturn(Collections.singleton(emNetwork));
    mockContinuousMappingFactory(cmFactory);
    EdgeSimilarities edges = TestUtils.getEdgeSimilarities(emNetwork);
    CyEdge sigEdge1 = edges.getEdge("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) TOP8_PLUS100");
    CyEdge sigEdge2 = edges.getEdge("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) TOP1_PLUS100");
    EnrichmentMap map = emManager.getEnrichmentMap(emNetwork.getSUID());
    assertNotNull(map);
    WidthFunction widthFunction = widthFunctionProvider.get();
    widthFunction.setEdgeWidths(emNetwork, "EM1_", null);
    String widthCol = Columns.EDGE_WIDTH_FORMULA_COLUMN.with("EM1_", null);
    double sigWidth1 = emNetwork.getRow(sigEdge1).get(widthCol, Double.class);
    assertEquals(8.0, sigWidth1, 0.0);
    double sigWidth2 = emNetwork.getRow(sigEdge2).get(widthCol, Double.class);
    assertEquals(1.0, sigWidth2, 0.0);
}
Also used : CyNetworkManager(org.cytoscape.model.CyNetworkManager) WidthFunction(org.baderlab.csplugins.enrichmentmap.style.WidthFunction) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) EdgeSimilarities(org.baderlab.csplugins.enrichmentmap.EdgeSimilarities) CyEdge(org.cytoscape.model.CyEdge) Test(org.junit.Test)

Aggregations

WidthFunction (org.baderlab.csplugins.enrichmentmap.style.WidthFunction)2 ActionEvent (java.awt.event.ActionEvent)1 AbstractAction (javax.swing.AbstractAction)1 JButton (javax.swing.JButton)1 JPanel (javax.swing.JPanel)1 EdgeSimilarities (org.baderlab.csplugins.enrichmentmap.EdgeSimilarities)1 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)1 EdgeWidthParams (org.baderlab.csplugins.enrichmentmap.style.WidthFunction.EdgeWidthParams)1 CyEdge (org.cytoscape.model.CyEdge)1 CyNetworkManager (org.cytoscape.model.CyNetworkManager)1 Task (org.cytoscape.work.Task)1 TaskIterator (org.cytoscape.work.TaskIterator)1 TaskMonitor (org.cytoscape.work.TaskMonitor)1 Test (org.junit.Test)1