Search in sources :

Example 6 with DataValueRendererFamily

use of org.knime.core.data.renderer.DataValueRendererFamily in project knime-core by knime.

the class TableContentView method getAvailableRenderers.

/**
 * Get the description of all available renderers in a column. The returned
 * array simply contains all description in the
 * <code>DataValueRendererFamily</code> (which should be the default
 * renderer in each column.)
 *
 * @param column the column of interest.
 * @return a new array containing the description of all available renderer
 *         or an empty array to address no available renderer
 * @throws IndexOutOfBoundsException if <code>column</code> violates its
 *         range
 */
public String[] getAvailableRenderers(final int column) {
    final TableColumn tableColumn = getColumnModel().getColumn(column);
    TableCellRenderer curRen = tableColumn.getCellRenderer();
    String[] availRenderer;
    if (curRen instanceof DataValueRendererFamily) {
        DataValueRendererFamily renFamily = (DataValueRendererFamily) curRen;
        availRenderer = renFamily.getRendererDescriptions();
    } else {
        availRenderer = new String[0];
    }
    return availRenderer;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DataValueRendererFamily(org.knime.core.data.renderer.DataValueRendererFamily) TableColumn(javax.swing.table.TableColumn)

Example 7 with DataValueRendererFamily

use of org.knime.core.data.renderer.DataValueRendererFamily in project knime-core by knime.

the class DataType method getRenderer.

/**
 * Returns a family of all renderers that are available for this <code>DataType</code>. The returned
 * {@link org.knime.core.data.renderer.DataValueRendererFamily} will contain all renderers that are supported or
 * available through the compatible {@link org.knime.core.data.DataValue} interfaces. If no renderer was declared by
 * the {@link org.knime.core.data.DataValue} interfaces, this method will make sure that at least a default renderer
 * (using the {@link DataCell#toString()} method) is returned.
 *
 * <p>
 * The {@link DataColumnSpec} is passed to all renderer families retrieved from the underlying
 * {@link UtilityFactory}. Most of the renderer implementations won't need column domain information but some do.
 * For instance a class that renders the double value in the column according to the minimum/maximum values in the
 * {@link DataColumnDomain}.
 *
 * @param spec the column spec to the column for which the renderer will be used
 * @return a family of all renderers that are available for this <code>DataType</code>
 * @deprecated Replaced by {@link #getRendererFactories()}
 */
@Deprecated
public DataValueRendererFamily getRenderer(final DataColumnSpec spec) {
    ArrayList<DataValueRendererFamily> list = new ArrayList<DataValueRendererFamily>();
    // first add the preferred value class, if any
    for (Class<? extends DataValue> cl : m_valueClasses) {
        UtilityFactory fac = getUtilityFor(cl);
        DataValueRendererFamily fam = fac.getRendererFamily(spec);
        if (fam != null) {
            list.add(fam);
        }
    }
    for (Class<? extends DataValue> cl : m_adapterValueList) {
        if (!m_valueClasses.contains(cl)) {
            UtilityFactory fac = getUtilityFor(cl);
            DataValueRendererFamily fam = fac.getRendererFamily(spec);
            if (fam != null) {
                list.add(fam);
            }
        }
    }
    if (list.isEmpty()) {
        list.add(new DefaultDataValueRendererFamily());
    }
    return new SetOfRendererFamilies(list);
}
Also used : UtilityFactory(org.knime.core.data.DataValue.UtilityFactory) SetOfRendererFamilies(org.knime.core.data.renderer.SetOfRendererFamilies) DataValueRendererFamily(org.knime.core.data.renderer.DataValueRendererFamily) DefaultDataValueRendererFamily(org.knime.core.data.renderer.DefaultDataValueRendererFamily) ArrayList(java.util.ArrayList) DefaultDataValueRendererFamily(org.knime.core.data.renderer.DefaultDataValueRendererFamily)

Aggregations

DataValueRendererFamily (org.knime.core.data.renderer.DataValueRendererFamily)7 TableCellRenderer (javax.swing.table.TableCellRenderer)5 TableColumn (javax.swing.table.TableColumn)5 DataColumnSpec (org.knime.core.data.DataColumnSpec)4 DataType (org.knime.core.data.DataType)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 ButtonGroup (javax.swing.ButtonGroup)1 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 JPopupMenu (javax.swing.JPopupMenu)1 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)1 DataCell (org.knime.core.data.DataCell)1 DataTable (org.knime.core.data.DataTable)1 UtilityFactory (org.knime.core.data.DataValue.UtilityFactory)1 DefaultDataValueRendererFamily (org.knime.core.data.renderer.DefaultDataValueRendererFamily)1 SetOfRendererFamilies (org.knime.core.data.renderer.SetOfRendererFamilies)1