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);
}
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()));
}
}
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;
}
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);
}
}
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;
}
Aggregations