use of java.awt.Component in project ACS by ACS-Community.
the class AlarmTable method prepareRenderer.
/**
* @see JTable
*/
@Override
public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) {
TableColumn col = getColumnModel().getColumn(vColIndex);
AlarmTableEntry entry = null;
try {
entry = model.getRowEntry(sorter.convertRowIndexToModel(rowIndex));
} catch (Throwable t) {
// This can happen if the entry has been removed by the thread while
// this method runs.
entry = null;
}
if (entry == null) {
return emptyLbl;
}
if (col.getIdentifier().equals(AlarmTableColumn.ICON)) {
if (model.isRowAlarmNew(sorter.convertRowIndexToModel(rowIndex))) {
return AlarmGUIType.fromAlarm(entry).flagRenderer;
} else {
return emptyLbl;
}
} else if (col.getIdentifier().equals(AlarmTableColumn.IS_CHILD)) {
if (entry.isChild()) {
return AlarmTable.reductionRenderer;
} else {
return emptyLbl;
}
} else if (col.getIdentifier().equals(AlarmTableColumn.IS_PARENT)) {
if (entry.isParent()) {
return AlarmTable.hasReducedNodesRenderer;
} else {
return emptyLbl;
}
}
Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
if (entry.getAlarmId().equals(selectedAlarmId)) {
Font f = c.getFont();
Font bold = f.deriveFont(Font.BOLD);
c.setFont(bold);
}
colorizeCell(c, entry);
if (c instanceof JComponent) {
JComponent jc = (JComponent) c;
if (((AlarmTableModel) model).getCellContent(sorter.convertRowIndexToModel(rowIndex), convertColumnIndexToModel(vColIndex)) == null) {
jc.setToolTipText(null);
} else {
jc.setToolTipText("<HTML>" + ((AlarmTableModel) model).getCellContent(sorter.convertRowIndexToModel(rowIndex), convertColumnIndexToModel(vColIndex)));
}
}
return c;
}
use of java.awt.Component in project ACS by ACS-Community.
the class UndocumentedAlarmTable method prepareRenderer.
/**
* @see JTable
*/
public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) {
TableColumn col = getColumnModel().getColumn(vColIndex);
AlarmData entry = null;
try {
entry = model.getRowEntry(sorter.convertRowIndexToModel(rowIndex));
} catch (Throwable t) {
// This can happen if the entry has been removed by the thread while
// this method runs.
entry = null;
}
if (entry == null) {
return new JLabel();
}
Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
colorizeCell(c, entry);
if (c instanceof JComponent) {
JComponent jc = (JComponent) c;
if (((UndocAlarmTableModel) model).getValueAt(sorter.convertRowIndexToModel(rowIndex), convertColumnIndexToModel(vColIndex)) == null) {
jc.setToolTipText(null);
} else {
jc.setToolTipText("<HTML>" + ((UndocAlarmTableModel) model).getValueAt(sorter.convertRowIndexToModel(rowIndex), convertColumnIndexToModel(vColIndex)));
}
}
return c;
}
use of java.awt.Component in project EnrichmentMapApp by BaderLab.
the class ColumnHeaderRankOptionRenderer method getTableCellRendererComponent.
@Override
public Component getTableCellRendererComponent(JTable table, final Object value, boolean isSelected, boolean hasFocus, int row, int col) {
// Convert RankingOption to display String
String text = null;
if (value instanceof RankingOption) {
RankingOption rankingOption = (RankingOption) value;
text = rankingOption.getTableHeaderText();
} else if (value instanceof RankOptionErrorHeader) {
RankOptionErrorHeader headerValue = (RankOptionErrorHeader) value;
text = headerValue.getRankingOption().getTableHeaderText();
}
// Use the default renderer to paint the header nicely (with sort arrows)
JTableHeader header = table.getTableHeader();
TableCellRenderer delegate = table.getTableHeader().getDefaultRenderer();
Component component = delegate.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, col);
// Create the panel
JButton button = new JButton("Sort");
SwingUtil.makeSmall(button);
if (isAquaLAF())
button.putClientProperty("JButton.buttonType", "gradient");
button.addActionListener(e -> menuButtonClicked(table, button));
JPanel buttonPanel = new JPanel(new BorderLayout());
buttonPanel.add(button, BorderLayout.CENTER);
buttonPanel.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
buttonPanel.setForeground(header.getForeground());
buttonPanel.setBackground(header.getBackground());
JPanel panel = new JPanel(new BorderLayout());
panel.setForeground(header.getForeground());
panel.setBackground(header.getBackground());
panel.add(component, BorderLayout.CENTER);
panel.add(buttonPanel, BorderLayout.NORTH);
if (value instanceof RankOptionErrorHeader) {
JLabel icon = new JLabel(IconManager.ICON_TIMES_CIRCLE);
icon.setForeground(Color.RED.darker());
icon.setFont(iconManager.getIconFont(13.0f));
icon.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
icon.setOpaque(false);
panel.add(icon, BorderLayout.WEST);
}
// Add mouse listener
if (mouseListener != null) {
header.removeMouseListener(mouseListener);
}
header.addMouseListener(mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int col = header.columnAtPoint(e.getPoint());
if (col == colIndex)
if (e.getY() <= button.getHeight())
button.doClick();
else
sortColumn(table);
else
sortOrder = null;
}
});
return panel;
}
use of java.awt.Component in project EnrichmentMapApp by BaderLab.
the class HeatMapMainPanel method showExportMenu.
private void showExportMenu(ActionEvent event) {
JPopupMenu menu = new JPopupMenu();
menu.add(txtActionFactory.create(table));
menu.add(pdfActionFactory.create(table));
Component c = (Component) event.getSource();
menu.show(c, 0, c.getHeight());
}
use of java.awt.Component in project EnrichmentMapApp by BaderLab.
the class ControlPanel method getEmViewCombo.
JComboBox<CyNetworkView> getEmViewCombo() {
if (emViewCombo == null) {
emViewCombo = new JComboBox<>();
emViewCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof CyNetworkView)
this.setText(NetworkUtil.getTitle((CyNetworkView) value));
else
this.setText("-- Select EnrichmentMap View --");
return this;
}
});
}
return emViewCombo;
}
Aggregations