Search in sources :

Example 1 with JSparklinesIntervalChartTableCellRenderer

use of no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer in project peptide-shaker by compomics.

the class SpectrumIdentificationPanel method setTableProperties.

/**
 * Set up the properties of the tables.
 */
private void setTableProperties() {
    // correct the color for the upper right corner
    JPanel spectrumCorner = new JPanel();
    spectrumCorner.setBackground(spectrumTable.getTableHeader().getBackground());
    spectrumTableJScrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, spectrumCorner);
    JPanel idResultsCorner = new JPanel();
    idResultsCorner.setBackground(searchResultsTable.getTableHeader().getBackground());
    idResultsTableJScrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, idResultsCorner);
    peptideShakerJTable.getColumn("  ").setCellRenderer(new JSparklinesIntegerIconTableCellRenderer(MatchValidationLevel.getIconMap(this.getClass()), MatchValidationLevel.getTooltipMap()));
    searchResultsTable.getColumn("  ").setCellRenderer(new JSparklinesIntegerIconTableCellRenderer(MatchValidationLevel.getIconMap(this.getClass()), MatchValidationLevel.getTooltipMap()));
    peptideShakerJTable.getTableHeader().setReorderingAllowed(false);
    spectrumTable.getTableHeader().setReorderingAllowed(false);
    searchResultsTable.getTableHeader().setReorderingAllowed(false);
    spectrumTable.setAutoCreateRowSorter(true);
    // make sure that the user is made aware that the tool is doing something during sorting of the spectrum table
    spectrumTable.getRowSorter().addRowSorterListener(new RowSorterListener() {

        @Override
        public void sorterChanged(RowSorterEvent e) {
            if (e.getType() == RowSorterEvent.Type.SORT_ORDER_CHANGED) {
                peptideShakerGUI.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
                spectrumTable.getTableHeader().setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
                // change the peptide shaker icon to a "waiting version"
                peptideShakerGUI.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker-orange.gif")));
            } else if (e.getType() == RowSorterEvent.Type.SORTED) {
                peptideShakerGUI.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
                spectrumTable.getTableHeader().setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
                // change the peptide shaker icon to a "waiting version"
                peptideShakerGUI.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker.gif")));
            }
        }
    });
    spectrumTable.getTableHeader().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            spectrumTableMouseClicked(e);
        }
    });
    peptideShakerJTable.getColumn(" ").setMinWidth(30);
    peptideShakerJTable.getColumn(" ").setMaxWidth(30);
    peptideShakerJTable.getColumn("  ").setMinWidth(30);
    peptideShakerJTable.getColumn("  ").setMaxWidth(30);
    spectrumTable.getColumn(" ").setMinWidth(50);
    spectrumTable.getColumn(" ").setMaxWidth(50);
    spectrumTable.getColumn("  ").setMinWidth(30);
    spectrumTable.getColumn("  ").setMaxWidth(30);
    spectrumTable.getColumn("Confidence").setMaxWidth(90);
    spectrumTable.getColumn("Confidence").setMinWidth(90);
    searchResultsTable.getColumn(" ").setMinWidth(30);
    searchResultsTable.getColumn(" ").setMaxWidth(30);
    searchResultsTable.getColumn("SE").setMinWidth(37);
    searchResultsTable.getColumn("SE").setMaxWidth(37);
    searchResultsTable.getColumn("Rnk").setMinWidth(37);
    searchResultsTable.getColumn("Rnk").setMaxWidth(37);
    searchResultsTable.getColumn("  ").setMinWidth(30);
    searchResultsTable.getColumn("  ").setMaxWidth(30);
    peptideShakerJTable.getColumn("ID").setMaxWidth(37);
    peptideShakerJTable.getColumn("ID").setMinWidth(37);
    spectrumTable.getColumn("ID").setMaxWidth(37);
    spectrumTable.getColumn("ID").setMinWidth(37);
    peptideShakerJTable.getColumn("Confidence").setMaxWidth(90);
    peptideShakerJTable.getColumn("Confidence").setMinWidth(90);
    searchResultsTable.getColumn("Confidence").setMaxWidth(90);
    searchResultsTable.getColumn("Confidence").setMinWidth(90);
    searchResultsTable.getColumn("Charge").setMaxWidth(90);
    searchResultsTable.getColumn("Charge").setMinWidth(90);
    // set up the psm color map
    HashMap<Integer, java.awt.Color> softwareAgreementColorMap = new HashMap<>();
    // id softwares agree with PTM certainty
    softwareAgreementColorMap.put(AGREEMENT_WITH_MODS, peptideShakerGUI.getSparklineColor());
    // id softwares agree on peptide but not ptm certainty
    softwareAgreementColorMap.put(AGREEMENT, java.awt.Color.CYAN);
    // id softwares don't agree
    softwareAgreementColorMap.put(CONFLICT, java.awt.Color.YELLOW);
    // some id softwares id'ed some didn't
    softwareAgreementColorMap.put(PARTIALLY_MISSING, java.awt.Color.ORANGE);
    // set up the psm tooltip map
    HashMap<Integer, String> idSoftwareTooltipMap = new HashMap<>();
    idSoftwareTooltipMap.put(AGREEMENT_WITH_MODS, "ID Software Agree");
    idSoftwareTooltipMap.put(AGREEMENT, "ID Software Agree - PTM Certainty Issues");
    idSoftwareTooltipMap.put(CONFLICT, "ID Software Disagree");
    idSoftwareTooltipMap.put(PARTIALLY_MISSING, "ID Software(s) Missing");
    peptideShakerJTable.getColumn("ID").setCellRenderer(new JSparklinesIntegerColorTableCellRenderer(java.awt.Color.lightGray, softwareAgreementColorMap, idSoftwareTooltipMap));
    peptideShakerJTable.getColumn("Protein(s)").setCellRenderer(new HtmlLinksRenderer(TableProperties.getSelectedRowHtmlTagFontColor(), TableProperties.getNotSelectedRowHtmlTagFontColor()));
    peptideShakerJTable.getColumn("Confidence").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100d, peptideShakerGUI.getSparklineColor()));
    ((JSparklinesBarChartTableCellRenderer) peptideShakerJTable.getColumn("Confidence").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 20, peptideShakerGUI.getScoreAndConfidenceDecimalFormat());
    searchResultsTable.getColumn("SE").setCellRenderer(new JSparklinesIntegerColorTableCellRenderer(java.awt.Color.lightGray, Advocate.getAdvocateColorMap(), Advocate.getAdvocateToolTipMap()));
    searchResultsTable.getColumn("Confidence").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100d, peptideShakerGUI.getSparklineColor()));
    ((JSparklinesBarChartTableCellRenderer) searchResultsTable.getColumn("Confidence").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 20, peptideShakerGUI.getScoreAndConfidenceDecimalFormat());
    searchResultsTable.getColumn("Charge").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 10d, peptideShakerGUI.getSparklineColor()));
    ((JSparklinesBarChartTableCellRenderer) searchResultsTable.getColumn("Charge").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 30);
    // set up the psm color map
    HashMap<Integer, java.awt.Color> idSoftwareSpectrumLevelColorMap = new HashMap<>();
    // id softwares agree with PTM certainty
    idSoftwareSpectrumLevelColorMap.put(AGREEMENT_WITH_MODS, peptideShakerGUI.getSparklineColor());
    // id softwares agree on peptide but not ptm certainty
    idSoftwareSpectrumLevelColorMap.put(AGREEMENT, java.awt.Color.CYAN);
    // id softwares don't agree
    idSoftwareSpectrumLevelColorMap.put(CONFLICT, java.awt.Color.YELLOW);
    // some id softwares id'ed some didn't
    idSoftwareSpectrumLevelColorMap.put(PARTIALLY_MISSING, java.awt.Color.ORANGE);
    // no psm
    idSoftwareSpectrumLevelColorMap.put(NO_ID, java.awt.Color.lightGray);
    // set up the psm tooltip map
    HashMap<Integer, String> idSoftwareSpectrumLevelTooltipMap = new HashMap<>();
    idSoftwareSpectrumLevelTooltipMap.put(AGREEMENT_WITH_MODS, "ID Software Agree");
    idSoftwareSpectrumLevelTooltipMap.put(AGREEMENT, "ID Software Agree - PTM Certainty Issues");
    idSoftwareSpectrumLevelTooltipMap.put(CONFLICT, "ID Software Disagree");
    idSoftwareSpectrumLevelTooltipMap.put(PARTIALLY_MISSING, "ID Software(s) Missing");
    idSoftwareSpectrumLevelTooltipMap.put(NO_ID, "(No PSM)");
    spectrumTable.getColumn("ID").setCellRenderer(new JSparklinesIntegerColorTableCellRenderer(java.awt.Color.lightGray, idSoftwareSpectrumLevelColorMap, idSoftwareSpectrumLevelTooltipMap));
    spectrumTable.getColumn("m/z").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100d, peptideShakerGUI.getSparklineColor()));
    spectrumTable.getColumn("Charge").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 4d, peptideShakerGUI.getSparklineColor()));
    spectrumTable.getColumn("Int").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 1000d, peptideShakerGUI.getSparklineColor()));
    spectrumTable.getColumn("RT (min)").setCellRenderer(new JSparklinesIntervalChartTableCellRenderer(PlotOrientation.HORIZONTAL, 0d, 1000d, 10d, peptideShakerGUI.getSparklineColor(), peptideShakerGUI.getSparklineColor()));
    ((JSparklinesBarChartTableCellRenderer) spectrumTable.getColumn("m/z").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth());
    ((JSparklinesBarChartTableCellRenderer) spectrumTable.getColumn("Charge").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 30);
    ((JSparklinesBarChartTableCellRenderer) spectrumTable.getColumn("Int").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth());
    ((JSparklinesIntervalChartTableCellRenderer) spectrumTable.getColumn("RT (min)").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() + 5);
    ((JSparklinesIntervalChartTableCellRenderer) spectrumTable.getColumn("RT (min)").getCellRenderer()).showReferenceLine(true, 0.02, java.awt.Color.BLACK);
    spectrumTable.getColumn("Confidence").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100.0, peptideShakerGUI.getSparklineColor()));
    ((JSparklinesBarChartTableCellRenderer) spectrumTable.getColumn("Confidence").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 20, peptideShakerGUI.getScoreAndConfidenceDecimalFormat());
    spectrumTable.getColumn("  ").setCellRenderer(new JSparklinesIntegerIconTableCellRenderer(MatchValidationLevel.getIconMap(this.getClass()), MatchValidationLevel.getTooltipMap()));
    spectrumTable.getColumn("Protein(s)").setCellRenderer(new HtmlLinksRenderer(TableProperties.getSelectedRowHtmlTagFontColor(), TableProperties.getNotSelectedRowHtmlTagFontColor()));
    // set up the table header tooltips
    idSoftwareTableToolTips = new ArrayList<>();
    idSoftwareTableToolTips.add(null);
    idSoftwareTableToolTips.add("Identification Software");
    idSoftwareTableToolTips.add("Validated Peptide Spectrum Matches");
    idSoftwareTableToolTips.add("Unique Pepttide-Spectrum Matches");
    idSoftwareTableToolTips.add("Unassigned Spectra");
    idSoftwareTableToolTips.add("Identificaiton Rate (%)");
    if (peptideShakerGUI.getDisplayParameters().showScores()) {
        spectrumTable.getColumn("Score").setMaxWidth(90);
        spectrumTable.getColumn("Score").setMinWidth(90);
        peptideShakerJTable.getColumn("Score").setMaxWidth(90);
        peptideShakerJTable.getColumn("Score").setMinWidth(90);
        searchResultsTable.getColumn("Score").setMaxWidth(90);
        searchResultsTable.getColumn("Score").setMinWidth(90);
        spectrumTable.getColumn("Score").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100.0, peptideShakerGUI.getSparklineColor()));
        ((JSparklinesBarChartTableCellRenderer) spectrumTable.getColumn("Score").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 20, peptideShakerGUI.getScoreAndConfidenceDecimalFormat());
        peptideShakerJTable.getColumn("Score").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100d, peptideShakerGUI.getSparklineColor()));
        ((JSparklinesBarChartTableCellRenderer) peptideShakerJTable.getColumn("Score").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 20, peptideShakerGUI.getScoreAndConfidenceDecimalFormat());
        searchResultsTable.getColumn("Score").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100d, peptideShakerGUI.getSparklineColor()));
        ((JSparklinesBarChartTableCellRenderer) searchResultsTable.getColumn("Score").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 20, peptideShakerGUI.getScoreAndConfidenceDecimalFormat());
        spectrumTableToolTips = new ArrayList<>();
        spectrumTableToolTips.add(null);
        spectrumTableToolTips.add("ID Software Agreement");
        spectrumTableToolTips.add("Spectrum Title");
        spectrumTableToolTips.add("Precursor m/z");
        spectrumTableToolTips.add("Precursor Charge");
        spectrumTableToolTips.add("Precursor Intensity");
        spectrumTableToolTips.add("Precursor Retention Time in Minutes");
        spectrumTableToolTips.add("Peptide Sequence");
        spectrumTableToolTips.add("Mapping Protein(s)");
        spectrumTableToolTips.add("Peptide Spectrum Match Score");
        spectrumTableToolTips.add("Peptide Spectrum Match Confidence");
        spectrumTableToolTips.add("Validated");
        peptideShakerTableToolTips = new ArrayList<>();
        peptideShakerTableToolTips.add(null);
        peptideShakerTableToolTips.add("ID Software Agreement");
        peptideShakerTableToolTips.add("Peptide Sequence");
        peptideShakerTableToolTips.add("Mapping Protein(s)");
        peptideShakerTableToolTips.add("Peptide Spectrum Match score");
        peptideShakerTableToolTips.add("Peptide Spectrum Match Confidence");
        peptideShakerTableToolTips.add("Validated");
        idResultsTableToolTips = new ArrayList<>();
        idResultsTableToolTips.add("Peptide Rank");
        idResultsTableToolTips.add("Search Engine / Identification Software");
        idResultsTableToolTips.add("Search Engine Rank / Identification Software Rank");
        idResultsTableToolTips.add("Peptide Sequence");
        idResultsTableToolTips.add("Precursor Charge");
        idResultsTableToolTips.add("Peptide Spectrum Match Score");
        idResultsTableToolTips.add("Peptide Spectrum Match Confidence");
        idResultsTableToolTips.add("Validated");
    } else {
        // set up the table header tooltips
        spectrumTableToolTips = new ArrayList<>();
        spectrumTableToolTips.add(null);
        spectrumTableToolTips.add("ID Software Agreement");
        spectrumTableToolTips.add("Spectrum Title");
        spectrumTableToolTips.add("Precursor m/z");
        spectrumTableToolTips.add("Precursor Charge");
        spectrumTableToolTips.add("Precursor Intensity");
        spectrumTableToolTips.add("Precursor Retention Time in Minutes");
        spectrumTableToolTips.add("Peptide Sequence");
        spectrumTableToolTips.add("Mapping Protein(s)");
        spectrumTableToolTips.add("Peptide Spectrum Match Confidence");
        spectrumTableToolTips.add("Validated");
        peptideShakerTableToolTips = new ArrayList<>();
        peptideShakerTableToolTips.add(null);
        peptideShakerTableToolTips.add("ID Software Agreement");
        peptideShakerTableToolTips.add("Peptide Sequence");
        peptideShakerTableToolTips.add("Mapping Protein(s)");
        peptideShakerTableToolTips.add("Peptide Spectrum Match Confidence");
        peptideShakerTableToolTips.add("Validated");
        idResultsTableToolTips = new ArrayList<>();
        idResultsTableToolTips.add("Peptide Rank");
        idResultsTableToolTips.add("Search Engine / Identification Software");
        idResultsTableToolTips.add("Search Engine Rank / Identification Software Rank");
        idResultsTableToolTips.add("Peptide Sequence");
        idResultsTableToolTips.add("Precursor Charge");
        idResultsTableToolTips.add("Peptide Spectrum Match Confidence");
        idResultsTableToolTips.add("Validated");
    }
}
Also used : JPanel(javax.swing.JPanel) MouseEvent(java.awt.event.MouseEvent) HashMap(java.util.HashMap) MouseAdapter(java.awt.event.MouseAdapter) JSparklinesIntegerIconTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntegerIconTableCellRenderer) JSparklinesIntegerColorTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntegerColorTableCellRenderer) JSparklinesIntervalChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer) RowSorterEvent(javax.swing.event.RowSorterEvent) JSparklinesBarChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesBarChartTableCellRenderer) RowSorterListener(javax.swing.event.RowSorterListener) HtmlLinksRenderer(no.uib.jsparklines.extra.HtmlLinksRenderer)

Example 2 with JSparklinesIntervalChartTableCellRenderer

use of no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer in project peptide-shaker by compomics.

the class SpectrumIdentificationPanel method updateSparklines.

/**
 * Update the sparklines.
 */
private void updateSparklines() {
    if (identification != null) {
        SpectrumProvider spectrumProvider = peptideShakerGUI.getSpectrumProvider();
        int maxCharge = peptideShakerGUI.getMetrics().getMaxCharge();
        spectrumTable.getColumn("Charge").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, (double) maxCharge, peptideShakerGUI.getSparklineColor()));
        spectrumTable.getColumn("Int").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, spectrumProvider.getMaxPrecInt(), peptideShakerGUI.getSparklineColor()));
        spectrumTable.getColumn("RT (min)").setCellRenderer(new JSparklinesIntervalChartTableCellRenderer(PlotOrientation.HORIZONTAL, 0.0, (spectrumProvider.getMaxPrecRT() / 60), (spectrumProvider.getMaxPrecRT() / 60) / 50, peptideShakerGUI.getSparklineColor(), peptideShakerGUI.getSparklineColor()));
        ((JSparklinesBarChartTableCellRenderer) spectrumTable.getColumn("Charge").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 30);
        if (spectrumProvider.getMaxPrecInt() > 100000) {
            ((JSparklinesBarChartTableCellRenderer) spectrumTable.getColumn("Int").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() + 20, new DecimalFormat("0.00E00"));
        } else {
            ((JSparklinesBarChartTableCellRenderer) spectrumTable.getColumn("Int").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() + 20);
        }
        ((JSparklinesBarChartTableCellRenderer) spectrumTable.getColumn("Int").getCellRenderer()).setLogScale(true);
        ((JSparklinesIntervalChartTableCellRenderer) spectrumTable.getColumn("RT (min)").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth());
        ((JSparklinesIntervalChartTableCellRenderer) spectrumTable.getColumn("RT (min)").getCellRenderer()).showReferenceLine(true, 0.02, java.awt.Color.BLACK);
    }
}
Also used : DecimalFormat(java.text.DecimalFormat) JSparklinesIntervalChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer) JSparklinesBarChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesBarChartTableCellRenderer) SpectrumProvider(com.compomics.util.experiment.mass_spectrometry.SpectrumProvider)

Example 3 with JSparklinesIntervalChartTableCellRenderer

use of no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer in project peptide-shaker by compomics.

the class ProteinStructurePanel method pdbMatchesJTableMouseReleased.

// GEN-LAST:event_peptideTableMouseReleased
/**
 * Update the PDB structure shown in the Jmol panel.
 *
 * @param evt
 */
private void pdbMatchesJTableMouseReleased(java.awt.event.MouseEvent evt) {
    // GEN-FIRST:event_pdbMatchesJTableMouseReleased
    setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
    boolean loadStructure = true;
    if (pdbMatchesJTable.getSelectedRow() != -1 && currentlyDisplayedPdbFile != null) {
        String tempPdbFile = (String) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), pdbMatchesJTable.getColumn("PDB").getModelIndex());
        if (currentlyDisplayedPdbFile.equalsIgnoreCase(tempPdbFile)) {
            loadStructure = false;
        }
    }
    if (loadStructure) {
        // just a trick to make sure that the users cannot select
        // another row until the selection has been updated
        this.setEnabled(false);
        DefaultTableModel dm = (DefaultTableModel) pdbChainsJTable.getModel();
        dm.getDataVector().removeAllElements();
        dm.fireTableDataChanged();
        // clear the peptide to pdb mappings in the peptide table
        for (int i = 0; i < peptideTable.getRowCount(); i++) {
            peptideTable.setValueAt(false, i, peptideTable.getColumn("PDB").getModelIndex());
        }
        // select the peptide in the table again
        int peptideRow = 0;
        long peptideKey = peptideShakerGUI.getSelectedPeptideKey();
        if (peptideKey != NO_KEY) {
            peptideRow = getPeptideRow(peptideKey);
        }
        if (peptideTable.getRowCount() > 0) {
            peptideTable.setRowSelectionInterval(peptideRow, peptideRow);
            peptideTable.scrollRectToVisible(peptideTable.getCellRect(peptideRow, peptideRow, false));
        }
        // empty the jmol panel
        if (jmolStructureShown) {
            jmolPanel = new JmolPanel();
            pdbPanel.removeAll();
            pdbPanel.add(jmolPanel);
            pdbPanel.revalidate();
            pdbPanel.repaint();
            jmolStructureShown = false;
            currentlyDisplayedPdbFile = null;
            ((TitledBorder) pdbOuterPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Structure" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
            pdbOuterPanel.repaint();
        }
        if (pdbMatchesJTable.getSelectedRow() != -1) {
            currentlyDisplayedPdbFile = (String) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), pdbMatchesJTable.getColumn("PDB").getModelIndex());
            // open protein link in web browser
            if (pdbMatchesJTable.getSelectedColumn() == pdbMatchesJTable.getColumn("PDB").getModelIndex() && evt.getButton() == MouseEvent.BUTTON1 && ((String) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), pdbMatchesJTable.getSelectedColumn())).lastIndexOf("<a href=\"") != -1) {
                String temp = currentlyDisplayedPdbFile.substring(currentlyDisplayedPdbFile.indexOf("\"") + 1);
                currentlyDisplayedPdbFile = temp.substring(0, temp.indexOf("\""));
                this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
                BareBonesBrowserLaunch.openURL(currentlyDisplayedPdbFile);
                this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
            }
            // get the pdb file
            int selectedPdbTableIndex = (Integer) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), 0);
            PdbParameter lParam = uniProtPdb.getPdbs().get(selectedPdbTableIndex - 1);
            chains = lParam.getBlocks();
            // get the protein sequence
            SelfUpdatingTableModel proteinTableModel = (SelfUpdatingTableModel) proteinTable.getModel();
            int proteinIndex = proteinTableModel.getViewIndex(proteinTable.getSelectedRow());
            long proteinKey = proteinKeys[proteinIndex];
            ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinKey);
            String proteinSequence = peptideShakerGUI.getSequenceProvider().getSequence(proteinMatch.getLeadingAccession());
            // add the chain information to the table
            for (int j = 0; j < chains.length; j++) {
                XYDataPoint temp = new XYDataPoint(chains[j].getStartProtein(), chains[j].getEndProtein());
                if (chains[j].getStartProtein() != chains[j].getEndProtein()) {
                    ((DefaultTableModel) pdbChainsJTable.getModel()).addRow(new Object[] { (j + 1), chains[j].getBlock(), temp, (((double) chains[j].getEndProtein() - chains[j].getStartProtein()) / proteinSequence.length()) * 100 });
                }
            }
            ((JSparklinesIntervalChartTableCellRenderer) pdbChainsJTable.getColumn("PDB-Protein").getCellRenderer()).setMaxValue(proteinSequence.length());
            if (pdbChainsJTable.getRowCount() > 0) {
                ((TitledBorder) pdbChainsPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Chains (" + pdbChainsJTable.getRowCount() + ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
            } else {
                ((TitledBorder) pdbChainsPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Chains" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
            }
            pdbChainsPanel.repaint();
            if (pdbChainsJTable.getRowCount() > 0) {
                pdbChainsJTable.setRowSelectionInterval(0, 0);
                pdbChainsJTable.scrollRectToVisible(pdbChainsJTable.getCellRect(0, 0, false));
                pdbChainsJTableMouseReleased(null);
            }
        } else {
            ((TitledBorder) pdbChainsPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Chains" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
            pdbChainsPanel.repaint();
        }
        // give the power back to the user ;)
        this.setEnabled(true);
    } else {
        // open protein link in web browser
        if (pdbMatchesJTable.getSelectedColumn() == pdbMatchesJTable.getColumn("PDB").getModelIndex() && evt.getButton() == MouseEvent.BUTTON1 && ((String) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), pdbMatchesJTable.getSelectedColumn())).lastIndexOf("<a href=\"") != -1) {
            String temp = currentlyDisplayedPdbFile.substring(currentlyDisplayedPdbFile.indexOf("\"") + 1);
            currentlyDisplayedPdbFile = temp.substring(0, temp.indexOf("\""));
            this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
            BareBonesBrowserLaunch.openURL(currentlyDisplayedPdbFile);
            this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        }
    }
    setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
}
Also used : DefaultTableModel(javax.swing.table.DefaultTableModel) TitledBorder(javax.swing.border.TitledBorder) XYDataPoint(no.uib.jsparklines.data.XYDataPoint) SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) JSparklinesIntervalChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer) PdbParameter(com.compomics.util.pdbfinder.pdb.PdbParameter) XYDataPoint(no.uib.jsparklines.data.XYDataPoint)

Example 4 with JSparklinesIntervalChartTableCellRenderer

use of no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer in project peptide-shaker by compomics.

the class ProteinStructurePanel method setPdbTablesProperties.

/**
 * Set up the properties of the PDB and PDB chains tables.
 */
private void setPdbTablesProperties() {
    pdbMatchesJTable.getColumn(" ").setMaxWidth(50);
    pdbChainsJTable.getColumn(" ").setMaxWidth(50);
    pdbMatchesJTable.getColumn("PDB").setMaxWidth(50);
    pdbChainsJTable.getColumn("Chain").setMaxWidth(50);
    pdbMatchesJTable.getColumn(" ").setMinWidth(50);
    pdbChainsJTable.getColumn(" ").setMinWidth(50);
    pdbMatchesJTable.getColumn("PDB").setMinWidth(50);
    pdbChainsJTable.getColumn("Chain").setMinWidth(50);
    pdbMatchesJTable.getColumn("Chains").setMinWidth(100);
    pdbMatchesJTable.getColumn("Chains").setMaxWidth(100);
    pdbMatchesJTable.getTableHeader().setReorderingAllowed(false);
    pdbChainsJTable.getTableHeader().setReorderingAllowed(false);
    pdbChainsJTable.setAutoCreateRowSorter(true);
    pdbMatchesJTable.setAutoCreateRowSorter(true);
    pdbMatchesJTable.getColumn("PDB").setCellRenderer(new HtmlLinksRenderer(TableProperties.getSelectedRowHtmlTagFontColor(), TableProperties.getNotSelectedRowHtmlTagFontColor()));
    pdbMatchesJTable.getColumn("Chains").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 10.0, peptideShakerGUI.getSparklineColor()));
    ((JSparklinesBarChartTableCellRenderer) pdbMatchesJTable.getColumn("Chains").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth());
    pdbChainsJTable.getColumn("Coverage").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100.0, peptideShakerGUI.getSparklineColor()));
    ((JSparklinesBarChartTableCellRenderer) pdbChainsJTable.getColumn("Coverage").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth());
    pdbChainsJTable.getColumn("PDB-Protein").setCellRenderer(new JSparklinesIntervalChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100.0, 10.0, peptideShakerGUI.getSparklineColor()));
    ((JSparklinesIntervalChartTableCellRenderer) pdbChainsJTable.getColumn("PDB-Protein").getCellRenderer()).showReferenceLine(true, 0.02, Color.BLACK);
}
Also used : JSparklinesIntervalChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer) JSparklinesBarChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesBarChartTableCellRenderer) HtmlLinksRenderer(no.uib.jsparklines.extra.HtmlLinksRenderer)

Example 5 with JSparklinesIntervalChartTableCellRenderer

use of no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer in project peptide-shaker by compomics.

the class ModificationsPanel method displayResults.

/**
 * Displays the results.
 */
public void displayResults() {
    progressDialog = new ProgressDialogX(peptideShakerGUI, Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker.gif")), Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker-orange.gif")), true);
    progressDialog.setPrimaryProgressCounterIndeterminate(true);
    progressDialog.setTitle("Updating Data. Please Wait...");
    new Thread(new Runnable() {

        public void run() {
            try {
                progressDialog.setVisible(true);
            } catch (IndexOutOfBoundsException e) {
            // ignore
            }
        }
    }).start();
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            try {
                // now we have data so we can update the RT cell renderers max and min values
                SpectrumProvider spectrumProvider = peptideShakerGUI.getSpectrumProvider();
                selectedPsmsTable.getColumn("RT").setCellRenderer(new JSparklinesIntervalChartTableCellRenderer(PlotOrientation.HORIZONTAL, 0.0, spectrumProvider.getMaxPrecRT(), spectrumProvider.getMaxPrecRT() / 50, peptideShakerGUI.getSparklineColor(), peptideShakerGUI.getSparklineColor()));
                ((JSparklinesIntervalChartTableCellRenderer) selectedPsmsTable.getColumn("RT").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() + 5);
                ((JSparklinesIntervalChartTableCellRenderer) selectedPsmsTable.getColumn("RT").getCellRenderer()).showReferenceLine(true, 0.02, java.awt.Color.BLACK);
                relatedPsmsTable.getColumn("RT").setCellRenderer(new JSparklinesIntervalChartTableCellRenderer(PlotOrientation.HORIZONTAL, 0.0, spectrumProvider.getMaxPrecRT(), spectrumProvider.getMaxPrecRT() / 50, peptideShakerGUI.getSparklineColor(), peptideShakerGUI.getSparklineColor()));
                ((JSparklinesIntervalChartTableCellRenderer) relatedPsmsTable.getColumn("RT").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() + 5);
                ((JSparklinesIntervalChartTableCellRenderer) relatedPsmsTable.getColumn("RT").getCellRenderer()).showReferenceLine(true, 0.02, java.awt.Color.BLACK);
                identification = peptideShakerGUI.getIdentification();
                createPeptideMap(progressDialog);
                DefaultTableModel dm = (DefaultTableModel) modificationJTable.getModel();
                dm.getDataVector().removeAllElements();
                dm.fireTableDataChanged();
                ModificationParameters modificationProfile = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getModificationParameters();
                ArrayList<String> allVariableMods = modificationFactory.getModifications();
                Collections.sort(allVariableMods);
                for (String tempFixed : peptideShakerGUI.getIdentificationParameters().getSearchParameters().getModificationParameters().getFixedModifications()) {
                    allVariableMods.remove(tempFixed);
                }
                for (String modification : allVariableMods) {
                    if (!modification.equalsIgnoreCase(NO_MODIFICATION) && peptideMap.containsKey(modification)) {
                        ((DefaultTableModel) modificationJTable.getModel()).addRow(new Object[] { new Color(modificationProfile.getColor(modification)), modification, peptideMap.get(modification).size() });
                    }
                }
                ((DefaultTableModel) modificationJTable.getModel()).addRow(new Object[] { Color.lightGray, NO_MODIFICATION, peptideMap.get(NO_MODIFICATION).size() });
                ((TitledBorder) modificationLayeredPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Variable Modifications (" + modificationJTable.getRowCount() + ")");
                modificationLayeredPanel.repaint();
                // update the slider tooltips
                SearchParameters searchParameters = peptideShakerGUI.getIdentificationParameters().getSearchParameters();
                double accuracy = (accuracySlider.getValue() / 100.0) * searchParameters.getFragmentIonAccuracy();
                accuracySlider.setToolTipText("Annotation Accuracy: " + Util.roundDouble(accuracy, 2) + " " + searchParameters.getFragmentAccuracyType());
                intensitySlider.setToolTipText("Annotation Level: " + intensitySlider.getValue() + "%");
                int maxCharge = peptideShakerGUI.getMetrics().getMaxCharge();
                ((JSparklinesBarChartTableCellRenderer) selectedPsmsTable.getColumn("Charge").getCellRenderer()).setMaxValue((double) maxCharge);
                ((JSparklinesBarChartTableCellRenderer) relatedPsmsTable.getColumn("Charge").getCellRenderer()).setMaxValue((double) maxCharge);
                // enable the contextual export options
                exportModifiedPeptideProfileJButton.setEnabled(true);
                exportRelatedPeptideProfileJButton.setEnabled(true);
                exportSpectrumJButton.setEnabled(true);
                exportModifiedPsmsJButton.setEnabled(true);
                exportRelatedPsmsJButton.setEnabled(true);
                selectedPeptidesJSplitPane.setDividerLocation(0.5);
                relatedPeptidesJSplitPane.setDividerLocation(0.5);
                peptideShakerGUI.setUpdated(PeptideShakerGUI.MODIFICATIONS_TAB_INDEX, true);
                if (currentModificationRow != -1) {
                    updatePeptideTable(progressDialog);
                }
                progressDialog.setRunFinished();
            } catch (Exception e) {
                peptideShakerGUI.catchException(e);
            }
        }
    });
}
Also used : DefaultTableModel(javax.swing.table.DefaultTableModel) ArrayList(java.util.ArrayList) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) JSparklinesIntervalChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer) SpectrumProvider(com.compomics.util.experiment.mass_spectrometry.SpectrumProvider)

Aggregations

JSparklinesIntervalChartTableCellRenderer (no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer)7 JSparklinesBarChartTableCellRenderer (no.uib.jsparklines.renderers.JSparklinesBarChartTableCellRenderer)4 SpectrumProvider (com.compomics.util.experiment.mass_spectrometry.SpectrumProvider)3 DefaultTableModel (javax.swing.table.DefaultTableModel)3 HashMap (java.util.HashMap)2 TitledBorder (javax.swing.border.TitledBorder)2 HtmlLinksRenderer (no.uib.jsparklines.extra.HtmlLinksRenderer)2 JSparklinesIntegerColorTableCellRenderer (no.uib.jsparklines.renderers.JSparklinesIntegerColorTableCellRenderer)2 JSparklinesIntegerIconTableCellRenderer (no.uib.jsparklines.renderers.JSparklinesIntegerIconTableCellRenderer)2 PeptideMatch (com.compomics.util.experiment.identification.matches.PeptideMatch)1 ProteinMatch (com.compomics.util.experiment.identification.matches.ProteinMatch)1 SpectrumMatch (com.compomics.util.experiment.identification.matches.SpectrumMatch)1 Precursor (com.compomics.util.experiment.mass_spectrometry.spectra.Precursor)1 SelfUpdatingTableModel (com.compomics.util.gui.tablemodels.SelfUpdatingTableModel)1 ProgressDialogX (com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX)1 ModificationParameters (com.compomics.util.parameters.identification.search.ModificationParameters)1 SearchParameters (com.compomics.util.parameters.identification.search.SearchParameters)1 PdbParameter (com.compomics.util.pdbfinder.pdb.PdbParameter)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1