Search in sources :

Example 1 with DefaultDataValueRendererFamily

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

the class ExtensibleUtilityFactory method getRendererFamily.

/**
 * {@inheritDoc}
 */
@Override
protected final DataValueRendererFamily getRendererFamily(final DataColumnSpec spec) {
    readRenderersFromExtensionPoint();
    DataValueRenderer[] renderers = new DataValueRenderer[m_renderers.size()];
    int i = 0;
    readPreferredRendererFromPreferences();
    DataValueRendererFactory prefRenderer = getPreferredRenderer();
    DataValueRendererFactory defaultRenderer = getDefaultRenderer();
    if (prefRenderer != null) {
        renderers[i++] = prefRenderer.createRenderer(spec);
    } else if (defaultRenderer != null) {
        renderers[i++] = defaultRenderer.createRenderer(spec);
    }
    for (DataValueRendererFactory fac : m_renderers.values()) {
        if (fac.equals(prefRenderer) || ((prefRenderer == null) && fac.equals(defaultRenderer))) {
            continue;
        }
        renderers[i++] = fac.createRenderer(spec);
    }
    return new DefaultDataValueRendererFamily(renderers);
}
Also used : DataValueRendererFactory(org.knime.core.data.renderer.DataValueRendererFactory) DataValueRenderer(org.knime.core.data.renderer.DataValueRenderer) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) DefaultDataValueRendererFamily(org.knime.core.data.renderer.DefaultDataValueRendererFamily)

Example 2 with DefaultDataValueRendererFamily

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

DefaultDataValueRendererFamily (org.knime.core.data.renderer.DefaultDataValueRendererFamily)2 ArrayList (java.util.ArrayList)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 UtilityFactory (org.knime.core.data.DataValue.UtilityFactory)1 DataValueRenderer (org.knime.core.data.renderer.DataValueRenderer)1 DataValueRendererFactory (org.knime.core.data.renderer.DataValueRendererFactory)1 DataValueRendererFamily (org.knime.core.data.renderer.DataValueRendererFamily)1 SetOfRendererFamilies (org.knime.core.data.renderer.SetOfRendererFamilies)1