Search in sources :

Example 56 with TableCellRenderer

use of javax.swing.table.TableCellRenderer in project vcell by virtualcell.

the class BatchRunMSETablePanel method setupTable.

private void setupTable() {
    TableSorter sorter = new TableSorter(mseTableModel);
    table = new StyleTable(sorter);
    table.setCellSelectionEnabled(true);
    sorter.setTableHeader(table.getTableHeader());
    TableColumn nameCol = table.getColumnModel().getColumn(BatchRunMSETableModel.COLUMN_FILE_NAME);
    nameCol.setCellRenderer(new ResultsParamTableRenderer());
    // double precision 6 digits
    TableCellRenderer mseRenderer = new NumericTableCellRenderer();
    for (int i = 1; i < table.getColumnCount(); i++) {
        TableColumn col = table.getColumnModel().getColumn(i);
        col.setPreferredWidth(0);
        col.setCellRenderer(mseRenderer);
    }
    table.addMouseListener(evtHandler);
}
Also used : NumericTableCellRenderer(cbit.vcell.microscopy.gui.NumericTableCellRenderer) TableCellRenderer(javax.swing.table.TableCellRenderer) NumericTableCellRenderer(cbit.vcell.microscopy.gui.NumericTableCellRenderer) StyleTable(org.vcell.util.gui.StyleTable) TableColumn(javax.swing.table.TableColumn)

Example 57 with TableCellRenderer

use of javax.swing.table.TableCellRenderer in project vcell by virtualcell.

the class TableSorter method setTableHeader.

public void setTableHeader(JTableHeader tableHeader) {
    if (this.tableHeader != null) {
        this.tableHeader.removeMouseListener(mouseListener);
        TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer();
        if (defaultRenderer instanceof SortableHeaderRenderer) {
            this.tableHeader.setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer);
        }
    }
    this.tableHeader = tableHeader;
    if (this.tableHeader != null) {
        this.tableHeader.addMouseListener(mouseListener);
        this.tableHeader.setDefaultRenderer(new SortableHeaderRenderer(this.tableHeader.getDefaultRenderer()));
    }
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer)

Example 58 with TableCellRenderer

use of javax.swing.table.TableCellRenderer in project processdash by dtuma.

the class BlameValueTable method getPreferredCellWidth.

private int getPreferredCellWidth(int row, int column) {
    TableCellRenderer cellRenderer = getCellRenderer(row, column);
    Component c = prepareRenderer(cellRenderer, row, column);
    int width = c.getPreferredSize().width + getIntercellSpacing().width;
    return width;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) Component(java.awt.Component)

Example 59 with TableCellRenderer

use of javax.swing.table.TableCellRenderer in project processdash by dtuma.

the class WBSExcelWriter method writeCellsForNodeData.

private void writeCellsForNodeData(HSSFRow row, WBSNode node, TableColumnModel columns) {
    for (int c = 0; c < columns.getColumnCount(); c++) {
        TableColumn col = columns.getColumn(c);
        int columnIndex = col.getModelIndex();
        Object value = data.getValueAt(node, columnIndex);
        TableCellRenderer rend = col.getCellRenderer();
        if (rend == null)
            rend = table.getDefaultRenderer(data.getColumnClass(columnIndex));
        Component comp = rend.getTableCellRendererComponent(table, value, false, false, 99, 99);
        HSSFCell cell = row.createCell(s(c + 1));
        copyCellData(cell, rend, comp, value);
    }
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) HSSFCell(org.apache.poi.hssf.usermodel.HSSFCell) Component(java.awt.Component) TableColumn(javax.swing.table.TableColumn)

Example 60 with TableCellRenderer

use of javax.swing.table.TableCellRenderer in project jgnash by ccavanaugh.

the class ExpandingTable method prepareRenderer.

/**
     * Override prepareRenderer instead of using a custom renderer so the look and feel is preserved
     *
     * @see javax.swing.JTable#prepareRenderer(javax.swing.table.TableCellRenderer, int, int)
     */
@SuppressWarnings("MagicConstant")
@Override
public Component prepareRenderer(final TableCellRenderer renderer, final int row, final int column) {
    Component c = super.prepareRenderer(renderer, row, column);
    if (c instanceof JLabel) {
        if (!defaultSaved.get()) {
            // save the defaults so they can be restored
            defaultForeground = c.getForeground();
            defaultAlignment = ((JLabel) c).getHorizontalAlignment();
            defaultSaved.set(true);
        }
        E object = model.get(row);
        if (column == 0) {
            c.setForeground(defaultForeground);
            ((JLabel) c).setHorizontalAlignment(SwingConstants.LEFT);
            if (object != null) {
                Icon cachedIcon;
                int indent = iconIndent * (model.getVisibleDepth(object) - 1);
                if (model.isParent(object)) {
                    if (model.isExpanded(object)) {
                        String key = "eo" + indent;
                        cachedIcon = iconCache.computeIfAbsent(key, k -> IconUtils.createImageIcon(new IndentedIcon(new Icon[] { expandedIcon, openIcon }, indent, iconSpacing)));
                    } else {
                        String key = "co" + indent;
                        cachedIcon = iconCache.computeIfAbsent(key, k -> IconUtils.createImageIcon(new IndentedIcon(new Icon[] { collapsedIcon, closedIcon }, indent, iconSpacing)));
                    }
                } else {
                    // child without children
                    String key = "el" + indent;
                    cachedIcon = iconCache.computeIfAbsent(key, k -> IconUtils.createImageIcon(new IndentedIcon(new Icon[] { new EmptyIndentedIcon(new Icon[] { expandedIcon }, 0), leafIcon }, indent, iconSpacing)));
                }
                ((JLabel) c).setIcon(cachedIcon);
            }
        } else {
            c.setForeground(defaultForeground);
            ((JLabel) c).setHorizontalAlignment(defaultAlignment);
            ((JLabel) c).setIcon(null);
        }
    }
    return c;
}
Also used : Color(java.awt.Color) EventQueue(java.awt.EventQueue) UIManager(javax.swing.UIManager) ThemeManager(jgnash.ui.ThemeManager) IconUtils(jgnash.ui.util.IconUtils) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Point(java.awt.Point) HashMap(java.util.HashMap) Icon(javax.swing.Icon) KeyAdapter(java.awt.event.KeyAdapter) KeyEvent(java.awt.event.KeyEvent) JTree(javax.swing.JTree) TableCellRenderer(javax.swing.table.TableCellRenderer) Component(java.awt.Component) SwingConstants(javax.swing.SwingConstants) MouseEvent(java.awt.event.MouseEvent) JLabel(javax.swing.JLabel) Map(java.util.Map) Graphics(java.awt.Graphics) MouseAdapter(java.awt.event.MouseAdapter) JTable(javax.swing.JTable) Toolkit(java.awt.Toolkit) JLabel(javax.swing.JLabel) Icon(javax.swing.Icon) Component(java.awt.Component) Point(java.awt.Point)

Aggregations

TableCellRenderer (javax.swing.table.TableCellRenderer)122 TableColumn (javax.swing.table.TableColumn)50 Component (java.awt.Component)47 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)24 JComponent (javax.swing.JComponent)20 JTable (javax.swing.JTable)20 TableColumnModel (javax.swing.table.TableColumnModel)18 JLabel (javax.swing.JLabel)17 JTableHeader (javax.swing.table.JTableHeader)17 MouseEvent (java.awt.event.MouseEvent)11 ColumnInfo (com.intellij.util.ui.ColumnInfo)8 ActionEvent (java.awt.event.ActionEvent)8 JButton (javax.swing.JButton)8 DefaultTableColumnModel (javax.swing.table.DefaultTableColumnModel)8 MouseAdapter (java.awt.event.MouseAdapter)7 TableCellEditor (javax.swing.table.TableCellEditor)7 TableModel (javax.swing.table.TableModel)7 ActionListener (java.awt.event.ActionListener)6 List (java.util.List)6 JPanel (javax.swing.JPanel)6