Search in sources :

Example 1 with SetOfRendererFamilies

use of org.knime.core.data.renderer.SetOfRendererFamilies 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

ArrayList (java.util.ArrayList)1 UtilityFactory (org.knime.core.data.DataValue.UtilityFactory)1 DataValueRendererFamily (org.knime.core.data.renderer.DataValueRendererFamily)1 DefaultDataValueRendererFamily (org.knime.core.data.renderer.DefaultDataValueRendererFamily)1 SetOfRendererFamilies (org.knime.core.data.renderer.SetOfRendererFamilies)1