use of net.sf.mzmine.util.components.PeakXICComponent in project mzmine2 by mzmine.
the class PeakPreviewComboRenderer method getListCellRendererComponent.
public Component getListCellRendererComponent(JList<? extends PeakListRow> combo, PeakListRow value, int index, boolean isSelected, boolean cellHasFocus) {
PeakListRow row = (PeakListRow) value;
if (row == null)
return new JPanel();
Feature peak = row.getPeaks()[0];
String labelText = "#" + row.getID() + " " + MZmineCore.getConfiguration().getMZFormat().format(row.getAverageMZ()) + " m/z ";
JLabel textComponent = new JLabel(labelText);
textComponent.setFont(combo.getFont());
PeakXICComponent shapeComponent = new PeakXICComponent(peak);
shapeComponent.setBorder(null);
JPanel panel = new JPanel(new BorderLayout());
panel.setOpaque(true);
if (isSelected) {
panel.setBackground(combo.getSelectionBackground());
panel.setForeground(combo.getSelectionForeground());
} else {
panel.setBackground(combo.getBackground());
panel.setForeground(combo.getForeground());
}
panel.setEnabled(combo.isEnabled());
Border border = null;
if (cellHasFocus) {
if (isSelected) {
border = UIManager.getBorder("List.focusSelectedCellHighlightBorder");
}
if (border == null) {
border = UIManager.getBorder("List.focusCellHighlightBorder");
}
} else {
border = noFocusBorder;
}
panel.setBorder(border);
panel.add(textComponent, BorderLayout.WEST);
panel.add(shapeComponent, BorderLayout.CENTER);
return panel;
}
use of net.sf.mzmine.util.components.PeakXICComponent in project mzmine2 by mzmine.
the class PeakShapeCellRenderer method getTableCellRendererComponent.
/**
* @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable,
* java.lang.Object, boolean, boolean, int, int)
*/
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JPanel newPanel = new JPanel();
newPanel.setLayout(new OverlayLayout(newPanel));
Color bgColor;
if (isSelected)
bgColor = table.getSelectionBackground();
else
bgColor = table.getBackground();
newPanel.setBackground(bgColor);
if (value instanceof Feature) {
Feature peak = (Feature) value;
double maxHeight = 0;
PeakShapeNormalization norm = parameters.getParameter(PeakListTableParameters.peakShapeNormalization).getValue();
if (norm == null)
norm = PeakShapeNormalization.ROWMAX;
switch(norm) {
case GLOBALMAX:
maxHeight = peakList.getDataPointMaxIntensity();
break;
case ROWMAX:
int rowNumber = peakList.getPeakRowNum(peak);
maxHeight = peakList.getRow(rowNumber).getDataPointMaxIntensity();
break;
default:
maxHeight = peak.getRawDataPointsIntensityRange().upperEndpoint();
break;
}
PeakXICComponent xic = new PeakXICComponent(peak, maxHeight);
newPanel.add(xic);
newPanel.setToolTipText(xic.getToolTipText());
}
if (value instanceof PeakListRow) {
PeakListRow plRow = (PeakListRow) value;
RawDataFile[] dataFiles = peakList.getRawDataFiles();
Feature[] peaks = new Feature[dataFiles.length];
for (int i = 0; i < dataFiles.length; i++) {
peaks[i] = plRow.getPeak(dataFiles[i]);
}
CombinedXICComponent xic = new CombinedXICComponent(peaks, plRow.getID());
newPanel.add(xic);
newPanel.setToolTipText(xic.getToolTipText());
}
return newPanel;
}
Aggregations