Search in sources :

Example 31 with Component

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;
}
Also used : UndocAlarmTableModel(alma.acsplugins.alarmsystem.gui.undocumented.table.UndocAlarmTableModel) JComponent(javax.swing.JComponent) Component(java.awt.Component) JComponent(javax.swing.JComponent) AlarmTableColumn(alma.acsplugins.alarmsystem.gui.table.AlarmTableModel.AlarmTableColumn) TableColumn(javax.swing.table.TableColumn) Font(java.awt.Font)

Example 32 with Component

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;
}
Also used : JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) JComponent(javax.swing.JComponent) Component(java.awt.Component) TableColumn(javax.swing.table.TableColumn) AlarmData(alma.acsplugins.alarmsystem.gui.undocumented.table.UndocAlarmTableModel.AlarmData)

Example 33 with Component

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;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) JPanel(javax.swing.JPanel) MouseEvent(java.awt.event.MouseEvent) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) RankingOption(org.baderlab.csplugins.enrichmentmap.view.heatmap.RankingOption) JTableHeader(javax.swing.table.JTableHeader) JLabel(javax.swing.JLabel) BorderLayout(java.awt.BorderLayout) Component(java.awt.Component)

Example 34 with Component

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());
}
Also used : Component(java.awt.Component) JPopupMenu(javax.swing.JPopupMenu)

Example 35 with Component

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;
}
Also used : DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) Component(java.awt.Component) JComponent(javax.swing.JComponent) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

Component (java.awt.Component)645 JComponent (javax.swing.JComponent)163 Dimension (java.awt.Dimension)81 JLabel (javax.swing.JLabel)65 JPanel (javax.swing.JPanel)60 Insets (java.awt.Insets)55 Point (java.awt.Point)55 TableCellRenderer (javax.swing.table.TableCellRenderer)47 Container (java.awt.Container)46 JScrollPane (javax.swing.JScrollPane)42 JTable (javax.swing.JTable)36 JButton (javax.swing.JButton)35 BorderLayout (java.awt.BorderLayout)34 GridBagConstraints (java.awt.GridBagConstraints)34 JTextComponent (javax.swing.text.JTextComponent)34 GridBagLayout (java.awt.GridBagLayout)33 Color (java.awt.Color)32 JList (javax.swing.JList)31 TableColumn (javax.swing.table.TableColumn)31 MouseEvent (java.awt.event.MouseEvent)27