use of no.uib.jsparklines.renderers.JSparklinesMultiIntervalChartTableCellRenderer in project peptide-shaker by compomics.
the class ProteinStructurePanel method setPeptideTableProperties.
/**
* Set up the properties of the peptide table.
*/
private void setPeptideTableProperties() {
peptideTable.getColumn(" ").setMaxWidth(50);
peptideTable.getColumn(" ").setMinWidth(50);
peptideTable.getColumn("PDB").setMinWidth(50);
peptideTable.getColumn("PDB").setMaxWidth(50);
peptideTable.getColumn("Start").setMinWidth(50);
// the validated column
peptideTable.getColumn("").setMaxWidth(30);
peptideTable.getColumn("").setMinWidth(30);
// the selected columns
peptideTable.getColumn(" ").setMaxWidth(30);
peptideTable.getColumn(" ").setMinWidth(30);
// the protein inference column
peptideTable.getColumn("PI").setMaxWidth(37);
peptideTable.getColumn("PI").setMinWidth(37);
peptideTable.getTableHeader().setReorderingAllowed(false);
// set up the peptide inference color map
HashMap<Integer, Color> peptideInferenceColorMap = new HashMap<>();
peptideInferenceColorMap.put(PSParameter.NOT_GROUP, peptideShakerGUI.getSparklineColor());
peptideInferenceColorMap.put(PSParameter.RELATED, Color.YELLOW);
peptideInferenceColorMap.put(PSParameter.RELATED_AND_UNRELATED, Color.ORANGE);
peptideInferenceColorMap.put(PSParameter.UNRELATED, Color.RED);
// set up the peptide inference tooltip map
HashMap<Integer, String> peptideInferenceTooltipMap = new HashMap<>();
peptideInferenceTooltipMap.put(PSParameter.NOT_GROUP, "Unique to a single protein");
peptideInferenceTooltipMap.put(PSParameter.RELATED, "Belongs to a group of related proteins");
peptideInferenceTooltipMap.put(PSParameter.RELATED_AND_UNRELATED, "Belongs to a group of related and unrelated proteins");
peptideInferenceTooltipMap.put(PSParameter.UNRELATED, "Belongs to unrelated proteins");
peptideTable.getColumn("PI").setCellRenderer(new JSparklinesIntegerColorTableCellRenderer(peptideShakerGUI.getSparklineColor(), peptideInferenceColorMap, peptideInferenceTooltipMap));
peptideTable.getColumn("Start").setCellRenderer(new JSparklinesMultiIntervalChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100d, 100d, peptideShakerGUI.getSparklineColor()));
peptideTable.getColumn("PDB").setCellRenderer(new TrueFalseIconRenderer(new ImageIcon(this.getClass().getResource("/icons/pdb.png")), null, "Mapped to PDB Structure", null));
peptideTable.getColumn("").setCellRenderer(new JSparklinesIntegerIconTableCellRenderer(MatchValidationLevel.getIconMap(this.getClass()), MatchValidationLevel.getTooltipMap()));
peptideTable.getColumn(" ").setCellRenderer(new TrueFalseIconRenderer(new ImageIcon(this.getClass().getResource("/icons/star_yellow.png")), new ImageIcon(this.getClass().getResource("/icons/star_grey.png")), new ImageIcon(this.getClass().getResource("/icons/star_grey.png")), "Starred", null, null));
}
use of no.uib.jsparklines.renderers.JSparklinesMultiIntervalChartTableCellRenderer in project peptide-shaker by compomics.
the class ProteinStructurePanel method updatedPeptideSelection.
/**
* Updates the peptide selection according to the currently selected
* protein.
*
* @param proteinIndex the row index of the protein
*/
private void updatedPeptideSelection(int proteinIndex) {
if (proteinIndex != -1) {
this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
DefaultTableModel dm = (DefaultTableModel) peptideTable.getModel();
dm.getDataVector().removeAllElements();
dm.fireTableDataChanged();
long proteinMatchKey = proteinKeys[proteinIndex];
ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinMatchKey);
String proteinAccession = proteinMatch.getLeadingAccession();
peptideTableMap = new HashMap<>();
int index = 0;
long[] peptideKeys = peptideShakerGUI.getIdentificationFeaturesGenerator().getSortedPeptideKeys(proteinMatchKey);
for (long peptideKey : peptideKeys) {
PeptideMatch peptideMatch = peptideShakerGUI.getIdentification().getPeptideMatch(peptideKey);
PSParameter psParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
if (!psParameter.getHidden()) {
// find and add the peptide start and end indexes
StartIndexes startIndexes = new StartIndexes(Arrays.stream(peptideMatch.getPeptide().getProteinMapping().get(proteinAccession)).map(site -> site + 1).boxed().collect(Collectors.toCollection(ArrayList::new)));
int proteinInferenceType = psParameter.getProteinInferenceGroupClass();
// @TODO: should be replaced by a table model!!!
((DefaultTableModel) peptideTable.getModel()).addRow(new Object[] { index + 1, psParameter.getStarred(), proteinInferenceType, peptideShakerGUI.getDisplayFeaturesGenerator().getTaggedPeptideSequence(peptideMatch, true, true, true), startIndexes, false, psParameter.getMatchValidationLevel().getIndex() });
peptideTableMap.put(index + 1, peptideKey);
index++;
}
}
((DefaultTableModel) peptideTable.getModel()).fireTableDataChanged();
String title = PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Peptides (";
IdentificationFeaturesGenerator identificationFeaturesGenerator = peptideShakerGUI.getIdentificationFeaturesGenerator();
int nValidatedPeptides = identificationFeaturesGenerator.getNValidatedPeptides(proteinMatchKey);
int nConfidentPeptides = identificationFeaturesGenerator.getNConfidentPeptides(proteinMatchKey);
int nPeptides = proteinMatch.getPeptideCount();
if (nConfidentPeptides > 0) {
title += nValidatedPeptides + "/" + nPeptides + " - " + nConfidentPeptides + " confident, " + (nValidatedPeptides - nConfidentPeptides) + " doubtful";
} else {
title += nValidatedPeptides + "/" + nPeptides;
}
title += ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING;
((TitledBorder) peptidesPanel.getBorder()).setTitle(title);
peptidesPanel.repaint();
String proteinSequence = peptideShakerGUI.getSequenceProvider().getSequence(proteinAccession);
peptideTable.getColumn("Start").setCellRenderer(new JSparklinesMultiIntervalChartTableCellRenderer(PlotOrientation.HORIZONTAL, (double) proteinSequence.length(), ((double) proteinSequence.length()) / 50, peptideShakerGUI.getSparklineColor()));
((JSparklinesMultiIntervalChartTableCellRenderer) peptideTable.getColumn("Start").getCellRenderer()).showReferenceLine(true, 0.02, Color.BLACK);
((JSparklinesMultiIntervalChartTableCellRenderer) peptideTable.getColumn("Start").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 10);
// select the peptide in the table
if (peptideTable.getRowCount() > 0) {
int peptideRow = 0;
long peptideKey = peptideShakerGUI.getSelectedPeptideKey();
if (peptideKey != NO_KEY) {
peptideRow = getPeptideRow(peptideKey);
}
if (peptideRow != -1) {
peptideTable.setRowSelectionInterval(peptideRow, peptideRow);
peptideTable.scrollRectToVisible(peptideTable.getCellRect(peptideRow, 0, false));
peptideTableKeyReleased(null);
}
}
this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
}
}
Aggregations