Search in sources :

Example 16 with IIsotope

use of org.openscience.cdk.interfaces.IIsotope in project mzmine2 by mzmine.

the class ComponentCellRenderer 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 (hasFocus) {
        Border border = null;
        if (isSelected)
            border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder");
        if (border == null)
            border = UIManager.getBorder("Table.focusCellHighlightBorder");
        if (border != null)
            newPanel.setBorder(border);
    }
    if (value != null) {
        if (value instanceof JComponent) {
            newPanel.add((JComponent) value);
        } else {
            JLabel newLabel = new JLabel();
            if (value instanceof IIsotope) {
                IIsotope is = (IIsotope) value;
                newLabel.setText(is.getSymbol());
            } else {
                newLabel.setText(value.toString());
            }
            if (font != null)
                newLabel.setFont(font);
            else if (table.getFont() != null)
                newLabel.setFont(table.getFont());
            newPanel.add(newLabel);
        }
        if (createTooltips)
            newPanel.setToolTipText(value.toString());
    }
    return newPanel;
}
Also used : IIsotope(org.openscience.cdk.interfaces.IIsotope) JPanel(javax.swing.JPanel) Color(java.awt.Color) OverlayLayout(javax.swing.OverlayLayout) JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) Border(javax.swing.border.Border)

Aggregations

IIsotope (org.openscience.cdk.interfaces.IIsotope)16 IMolecularFormula (org.openscience.cdk.interfaces.IMolecularFormula)5 DataPoint (net.sf.mzmine.datamodel.DataPoint)3 ProcessedDataPoint (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint)3 MolecularFormulaRange (org.openscience.cdk.formula.MolecularFormulaRange)3 IChemObjectBuilder (org.openscience.cdk.interfaces.IChemObjectBuilder)3 IOException (java.io.IOException)2 ExtendedIsotopePattern (net.sf.mzmine.datamodel.impl.ExtendedIsotopePattern)2 Isotopes (org.openscience.cdk.config.Isotopes)2 Range (com.google.common.collect.Range)1 Color (java.awt.Color)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Hashtable (java.util.Hashtable)1 JComponent (javax.swing.JComponent)1 JFrame (javax.swing.JFrame)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 OverlayLayout (javax.swing.OverlayLayout)1 Border (javax.swing.border.Border)1