Search in sources :

Example 1 with PeakXICComponent

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;
}
Also used : JPanel(javax.swing.JPanel) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) BorderLayout(java.awt.BorderLayout) JLabel(javax.swing.JLabel) Feature(net.sf.mzmine.datamodel.Feature) Border(javax.swing.border.Border) EmptyBorder(javax.swing.border.EmptyBorder) PeakXICComponent(net.sf.mzmine.util.components.PeakXICComponent)

Example 2 with PeakXICComponent

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;
}
Also used : JPanel(javax.swing.JPanel) Color(java.awt.Color) Feature(net.sf.mzmine.datamodel.Feature) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) OverlayLayout(javax.swing.OverlayLayout) CombinedXICComponent(net.sf.mzmine.util.components.CombinedXICComponent) PeakShapeNormalization(net.sf.mzmine.modules.visualization.peaklisttable.PeakShapeNormalization) PeakXICComponent(net.sf.mzmine.util.components.PeakXICComponent)

Aggregations

JPanel (javax.swing.JPanel)2 Feature (net.sf.mzmine.datamodel.Feature)2 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)2 PeakXICComponent (net.sf.mzmine.util.components.PeakXICComponent)2 BorderLayout (java.awt.BorderLayout)1 Color (java.awt.Color)1 JLabel (javax.swing.JLabel)1 OverlayLayout (javax.swing.OverlayLayout)1 Border (javax.swing.border.Border)1 EmptyBorder (javax.swing.border.EmptyBorder)1 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)1 PeakShapeNormalization (net.sf.mzmine.modules.visualization.peaklisttable.PeakShapeNormalization)1 CombinedXICComponent (net.sf.mzmine.util.components.CombinedXICComponent)1