use of no.uib.jsparklines.renderers.JSparklinesIntegerColorTableCellRenderer in project peptide-shaker by compomics.
the class ProteinTableModel method setProteinTableProperties.
/**
* Set up the properties of the protein table.
*
* @param proteinTable the protein table
* @param sparklineColor the sparkline color to use
* @param sparklineColorNotValidated the sparkline color for not validated
* stuffs
* @param parentClass the parent class used to get icons
* @param sparklineColorNotFound the sparkline color for not found stuffs
* @param sparklineColorDoubtful the sparkline color for doubtful
* @param scoreAndConfidenceDecimalFormat the decimal format for score and
* confidence
* @param maxProteinKeyLength the longest protein key to display
*/
public static void setProteinTableProperties(JTable proteinTable, Color sparklineColor, Color sparklineColorNotValidated, Color sparklineColorNotFound, Color sparklineColorDoubtful, DecimalFormat scoreAndConfidenceDecimalFormat, Class parentClass, Integer maxProteinKeyLength) {
// @TODO: find a better location for this method?
// the index column
proteinTable.getColumn(" ").setMaxWidth(50);
proteinTable.getColumn(" ").setMinWidth(50);
proteinTable.getColumn("Chr").setMaxWidth(50);
proteinTable.getColumn("Chr").setMinWidth(50);
try {
proteinTable.getColumn("Confidence").setMaxWidth(90);
proteinTable.getColumn("Confidence").setMinWidth(90);
} catch (IllegalArgumentException w) {
proteinTable.getColumn("Score").setMaxWidth(90);
proteinTable.getColumn("Score").setMinWidth(90);
}
// the validated column
proteinTable.getColumn("").setMaxWidth(30);
proteinTable.getColumn("").setMinWidth(30);
// the selected columns
proteinTable.getColumn(" ").setMaxWidth(30);
proteinTable.getColumn(" ").setMinWidth(30);
// the protein inference column
proteinTable.getColumn("PI").setMaxWidth(37);
proteinTable.getColumn("PI").setMinWidth(37);
// set up the protein inference color map
HashMap<Integer, Color> proteinInferenceColorMap = new HashMap<>();
proteinInferenceColorMap.put(PSParameter.NOT_GROUP, sparklineColor);
proteinInferenceColorMap.put(PSParameter.RELATED, Color.YELLOW);
proteinInferenceColorMap.put(PSParameter.RELATED_AND_UNRELATED, Color.ORANGE);
proteinInferenceColorMap.put(PSParameter.UNRELATED, Color.RED);
// set up the protein inference tooltip map
HashMap<Integer, String> proteinInferenceTooltipMap = new HashMap<>();
proteinInferenceTooltipMap.put(PSParameter.NOT_GROUP, "Single Protein");
proteinInferenceTooltipMap.put(PSParameter.RELATED, "Related Proteins");
proteinInferenceTooltipMap.put(PSParameter.RELATED_AND_UNRELATED, "Related and Unrelated Proteins");
proteinInferenceTooltipMap.put(PSParameter.UNRELATED, "Unrelated Proteins");
proteinTable.getColumn("Accession").setCellRenderer(new HtmlLinksRenderer(TableProperties.getSelectedRowHtmlTagFontColor(), TableProperties.getNotSelectedRowHtmlTagFontColor()));
proteinTable.getColumn("PI").setCellRenderer(new JSparklinesIntegerColorTableCellRenderer(sparklineColor, proteinInferenceColorMap, proteinInferenceTooltipMap));
// use a gray color for no decoy searches
Color nonValidatedColor = sparklineColorNotValidated;
ArrayList<Color> sparklineColors = new ArrayList<>(4);
sparklineColors.add(sparklineColor);
sparklineColors.add(sparklineColorDoubtful);
sparklineColors.add(nonValidatedColor);
sparklineColors.add(sparklineColorNotFound);
JSparklinesArrayListBarChartTableCellRenderer coverageCellRendered = new JSparklinesArrayListBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100.0, sparklineColors, JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType.sumExceptLastNumber);
coverageCellRendered.showNumberAndChart(true, TableProperties.getLabelWidth(), new DecimalFormat("0.00"));
proteinTable.getColumn("Coverage").setCellRenderer(coverageCellRendered);
JSparklinesArrayListBarChartTableCellRenderer peptidesCellRenderer = new JSparklinesArrayListBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100.0, sparklineColors, JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType.sumOfNumbers);
peptidesCellRenderer.showNumberAndChart(true, TableProperties.getLabelWidth(), new DecimalFormat("0"));
proteinTable.getColumn("#Peptides").setCellRenderer(peptidesCellRenderer);
JSparklinesArrayListBarChartTableCellRenderer spectraCellRenderer = new JSparklinesArrayListBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100.0, sparklineColors, JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType.sumOfNumbers);
spectraCellRenderer.showNumberAndChart(true, TableProperties.getLabelWidth(), new DecimalFormat("0"));
proteinTable.getColumn("#Spectra").setCellRenderer(spectraCellRenderer);
JSparklinesBarChartTableCellRenderer spectrumCountingCellRenderer = new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 10.0, sparklineColor);
spectrumCountingCellRenderer.showNumberAndChart(true, TableProperties.getLabelWidth() + 20, new DecimalFormat("0.00E00"));
proteinTable.getColumn("MS2 Quant.").setCellRenderer(spectrumCountingCellRenderer);
JSparklinesBarChartTableCellRenderer mwCellRenderer = new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 10.0, sparklineColor);
mwCellRenderer.showNumberAndChart(true, TableProperties.getLabelWidth());
proteinTable.getColumn("MW").setCellRenderer(mwCellRenderer);
proteinTable.getColumn("Chr").setCellRenderer(new ChromosomeTableCellRenderer(Color.WHITE, Color.BLACK));
try {
proteinTable.getColumn("Confidence").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100.0, sparklineColor));
((JSparklinesBarChartTableCellRenderer) proteinTable.getColumn("Confidence").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 20, scoreAndConfidenceDecimalFormat);
} catch (IllegalArgumentException e) {
proteinTable.getColumn("Score").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100.0, sparklineColor));
((JSparklinesBarChartTableCellRenderer) proteinTable.getColumn("Score").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 20, scoreAndConfidenceDecimalFormat);
}
proteinTable.getColumn("").setCellRenderer(new JSparklinesIntegerIconTableCellRenderer(MatchValidationLevel.getIconMap(parentClass), MatchValidationLevel.getTooltipMap()));
proteinTable.getColumn(" ").setCellRenderer(new TrueFalseIconRenderer(new ImageIcon(parentClass.getResource("/icons/star_yellow.png")), new ImageIcon(parentClass.getResource("/icons/star_grey.png")), new ImageIcon(parentClass.getResource("/icons/star_grey.png")), "Starred", null, null));
// set the preferred size of the accession column
if (maxProteinKeyLength != null) {
Integer width = getPreferredAccessionColumnWidth(proteinTable, proteinTable.getColumn("Accession").getModelIndex(), 6, maxProteinKeyLength);
if (width != null) {
proteinTable.getColumn("Accession").setMinWidth(width);
proteinTable.getColumn("Accession").setMaxWidth(width);
} else {
proteinTable.getColumn("Accession").setMinWidth(15);
proteinTable.getColumn("Accession").setMaxWidth(Integer.MAX_VALUE);
}
}
}
Aggregations