use of no.uib.jsparklines.renderers.JSparklinesArrayListBarChartTableCellRenderer 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);
}
}
}
use of no.uib.jsparklines.renderers.JSparklinesArrayListBarChartTableCellRenderer in project peptide-shaker by compomics.
the class GOEAPanel method setProteinGoTableProperties.
/**
* Set the properties of the GO protein table.
*/
private void setProteinGoTableProperties() {
proteinTable.getColumn(" ").setMaxWidth(60);
proteinTable.getColumn(" ").setMinWidth(60);
proteinTable.getColumn(" ").setMaxWidth(30);
proteinTable.getColumn(" ").setMinWidth(30);
try {
proteinTable.getColumn("Confidence").setMaxWidth(90);
proteinTable.getColumn("Confidence").setMinWidth(90);
} catch (IllegalArgumentException w) {
proteinTable.getColumn("Score").setMaxWidth(90);
proteinTable.getColumn("Score").setMinWidth(90);
}
// set the preferred size of the accession column
Integer width = ProteinTableModel.getPreferredAccessionColumnWidth(proteinTable, proteinTable.getColumn("Accession").getModelIndex(), 6, peptideShakerGUI.getMetrics().getMaxProteinAccessionLength());
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);
}
proteinTable.getColumn("Accession").setCellRenderer(new HtmlLinksRenderer(TableProperties.getSelectedRowHtmlTagFontColor(), TableProperties.getNotSelectedRowHtmlTagFontColor()));
// use a gray color for no decoy searches
Color nonValidatedColor = peptideShakerGUI.getSparklineColorNonValidated();
if (!peptideShakerGUI.getIdentificationParameters().getFastaParameters().isTargetDecoy()) {
nonValidatedColor = peptideShakerGUI.getUtilitiesUserParameters().getSparklineColorNotFound();
}
ArrayList<Color> sparklineColors = new ArrayList<>();
sparklineColors.add(peptideShakerGUI.getSparklineColor());
sparklineColors.add(peptideShakerGUI.getUtilitiesUserParameters().getSparklineColorDoubtful());
sparklineColors.add(nonValidatedColor);
proteinTable.getColumn("#Peptides").setCellRenderer(new JSparklinesArrayListBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100.0, sparklineColors, JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType.sumOfNumbers));
((JSparklinesArrayListBarChartTableCellRenderer) proteinTable.getColumn("#Peptides").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth(), new DecimalFormat("0"));
proteinTable.getColumn("#Spectra").setCellRenderer(new JSparklinesArrayListBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100.0, sparklineColors, JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType.sumOfNumbers));
((JSparklinesArrayListBarChartTableCellRenderer) proteinTable.getColumn("#Spectra").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth(), new DecimalFormat("0"));
proteinTable.getColumn("MS2 Quant.").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 10.0, peptideShakerGUI.getSparklineColor()));
((JSparklinesBarChartTableCellRenderer) proteinTable.getColumn("MS2 Quant.").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth(), new DecimalFormat("0.00E00"));
try {
proteinTable.getColumn("Confidence").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100.0, peptideShakerGUI.getSparklineColor()));
((JSparklinesBarChartTableCellRenderer) proteinTable.getColumn("Confidence").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 20, peptideShakerGUI.getScoreAndConfidenceDecimalFormat());
} catch (IllegalArgumentException e) {
proteinTable.getColumn("Score").setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100.0, peptideShakerGUI.getSparklineColor()));
((JSparklinesBarChartTableCellRenderer) proteinTable.getColumn("Score").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 20, peptideShakerGUI.getScoreAndConfidenceDecimalFormat());
}
proteinTable.getColumn(" ").setCellRenderer(new JSparklinesIntegerIconTableCellRenderer(MatchValidationLevel.getIconMap(this.getClass()), MatchValidationLevel.getTooltipMap()));
sparklineColors = new ArrayList<>();
sparklineColors.add(peptideShakerGUI.getSparklineColor());
sparklineColors.add(peptideShakerGUI.getUtilitiesUserParameters().getSparklineColorDoubtful());
sparklineColors.add(nonValidatedColor);
sparklineColors.add(peptideShakerGUI.getUtilitiesUserParameters().getSparklineColorNotFound());
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);
// make sure that the user is made aware that the tool is doing something during sorting of the protein table
proteinTable.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));
proteinTable.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));
proteinTable.getTableHeader().setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
// change the peptide shaker icon back to the normal version
peptideShakerGUI.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker.gif")));
}
}
});
}
Aggregations