Search in sources :

Example 1 with TableContentView

use of org.knime.core.node.tableview.TableContentView in project knime-core by knime.

the class RankCorrelationComputeNodeView method changeRenderer.

private void changeRenderer(final String renderer) {
    TableContentView tcv = m_tableView.getContentTable();
    tcv.changeRenderer(DoubleCell.TYPE, renderer);
    Component c = m_tableView.getCorner(ScrollPaneConstants.UPPER_LEFT_CORNER);
    LegendCornerAll cornerRenderer = null;
    if (c instanceof JTableHeader) {
        JTableHeader corner = (JTableHeader) c;
        TableCellRenderer ren = corner.getDefaultRenderer();
        if (ren instanceof LegendCornerAll) {
            cornerRenderer = (LegendCornerAll) ren;
        }
    }
    if (cornerRenderer != null) {
        if (renderer.equals(ColorRender.DESCRIPTION)) {
            cornerRenderer.setPaintLegend(true);
            // no need to set column header height, done by label UI
            tcv.setColumnWidth(15);
            TableCellRenderer r = m_tableView.getContentTable().getTableHeader().getDefaultRenderer();
            if (r instanceof JLabel) {
                ((JLabel) r).setUI(new VerticalLabelUI());
            }
        } else {
            cornerRenderer.setPaintLegend(false);
            m_tableView.setColumnHeaderViewHeight(16);
            tcv.setColumnWidth(75);
            TableCellRenderer r = m_tableView.getContentTable().getTableHeader().getDefaultRenderer();
            if (r instanceof JLabel) {
                ((JLabel) r).updateUI();
            }
        }
    }
    m_currentRendererID = renderer;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) JTableHeader(javax.swing.table.JTableHeader) JLabel(javax.swing.JLabel) TableContentView(org.knime.core.node.tableview.TableContentView) Component(java.awt.Component) JComponent(javax.swing.JComponent)

Example 2 with TableContentView

use of org.knime.core.node.tableview.TableContentView in project knime-core by knime.

the class TableNodeView method updateTitle.

/**
 * Updates the title of the frame. It prints: "Table (#rows[+] x #cols)". It
 * is invoked each time new rows are inserted (user scrolls down).
 */
protected void updateTitle() {
    final TableContentView view = m_tableView.getContentTable();
    TableContentModel model = view.getContentModel();
    StringBuffer title = new StringBuffer();
    if (model.hasData()) {
        String tableName = model.getTableName();
        if (!tableName.equals("default")) {
            title.append(" \"");
            title.append(tableName);
            title.append("\"");
        }
        title.append(" (");
        int rowCount = model.getRowCount();
        boolean isFinal = model.isRowCountFinal();
        title.append(rowCount);
        title.append(isFinal ? " x " : "+ x ");
        title.append(model.getColumnCount());
        title.append(")");
    } else {
        title.append(" <no data>");
    }
    super.setViewTitleSuffix(title.toString());
}
Also used : TableContentView(org.knime.core.node.tableview.TableContentView) TableContentModel(org.knime.core.node.tableview.TableContentModel)

Example 3 with TableContentView

use of org.knime.core.node.tableview.TableContentView in project knime-core by knime.

the class AbstractCorrelationComputeNodeView method changeRenderer.

/**
 * @param renderer the table's new renderer
 */
protected void changeRenderer(final String renderer) {
    TableContentView tcv = m_tableView.getContentTable();
    tcv.changeRenderer(DoubleCell.TYPE, renderer);
    Component c = m_tableView.getCorner(ScrollPaneConstants.UPPER_LEFT_CORNER);
    LegendCornerAll cornerRenderer = null;
    if (c instanceof JTableHeader) {
        JTableHeader corner = (JTableHeader) c;
        TableCellRenderer ren = corner.getDefaultRenderer();
        if (ren instanceof LegendCornerAll) {
            cornerRenderer = (LegendCornerAll) ren;
        }
    }
    if (cornerRenderer != null) {
        if (renderer.equals(ColorRender.DESCRIPTION)) {
            cornerRenderer.setPaintLegend(true);
            // no need to set column header height, done by label UI
            tcv.setColumnWidth(15);
            TableCellRenderer r = m_tableView.getContentTable().getTableHeader().getDefaultRenderer();
            if (r instanceof JLabel) {
                ((JLabel) r).setUI(new VerticalLabelUI());
            }
            m_tableView.setColumnHeaderViewHeight(-1);
        } else {
            cornerRenderer.setPaintLegend(false);
            m_tableView.setColumnHeaderViewHeight(16);
            tcv.setColumnWidth(75);
            TableCellRenderer r = m_tableView.getContentTable().getTableHeader().getDefaultRenderer();
            if (r instanceof JLabel) {
                ((JLabel) r).updateUI();
            }
        }
    }
    m_currentRendererID = renderer;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) JTableHeader(javax.swing.table.JTableHeader) JLabel(javax.swing.JLabel) TableContentView(org.knime.core.node.tableview.TableContentView) Component(java.awt.Component) JComponent(javax.swing.JComponent)

Example 4 with TableContentView

use of org.knime.core.node.tableview.TableContentView in project knime-core by knime.

the class PMCCNodeView method changeRenderer.

private void changeRenderer(final String renderer) {
    TableContentView tcv = m_tableView.getContentTable();
    tcv.changeRenderer(DoubleCell.TYPE, renderer);
    Component c = m_tableView.getCorner(JScrollPane.UPPER_LEFT_CORNER);
    LegendCornerAll cornerRenderer = null;
    if (c instanceof JTableHeader) {
        JTableHeader corner = (JTableHeader) c;
        TableCellRenderer ren = corner.getDefaultRenderer();
        if (ren instanceof LegendCornerAll) {
            cornerRenderer = (LegendCornerAll) ren;
        }
    }
    if (cornerRenderer != null) {
        if (renderer.equals(ColorRender.DESCRIPTION)) {
            cornerRenderer.setPaintLegend(true);
            // no need to set column header height, done by label UI
            tcv.setColumnWidth(15);
            TableCellRenderer r = m_tableView.getContentTable().getTableHeader().getDefaultRenderer();
            if (r instanceof JLabel) {
                ((JLabel) r).setUI(new VerticalLabelUI());
            }
        } else {
            cornerRenderer.setPaintLegend(false);
            m_tableView.setColumnHeaderViewHeight(16);
            tcv.setColumnWidth(75);
            TableCellRenderer r = m_tableView.getContentTable().getTableHeader().getDefaultRenderer();
            if (r instanceof JLabel) {
                ((JLabel) r).updateUI();
            }
        }
    }
    m_currentRendererID = renderer;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) JTableHeader(javax.swing.table.JTableHeader) JLabel(javax.swing.JLabel) TableContentView(org.knime.core.node.tableview.TableContentView) Component(java.awt.Component) JComponent(javax.swing.JComponent)

Aggregations

TableContentView (org.knime.core.node.tableview.TableContentView)4 Component (java.awt.Component)3 JComponent (javax.swing.JComponent)3 JLabel (javax.swing.JLabel)3 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)3 JTableHeader (javax.swing.table.JTableHeader)3 TableCellRenderer (javax.swing.table.TableCellRenderer)3 TableContentModel (org.knime.core.node.tableview.TableContentModel)1