use of org.knime.core.data.renderer.DataValueRendererFactory in project knime-core by knime.
the class DataType method getRendererFactories.
/**
* Returns the list of registered renderer factories, using an extension point driven mechanism to collect all
* instances registered with the implemented data value 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.
*
* @return an ordered, non-empty collection of factories.
* @since 2.12
*/
public Collection<DataValueRendererFactory> getRendererFactories() {
Map<String, DataValueRendererFactory> map = new LinkedHashMap<>();
Collection<Class<? extends DataValue>> allValueClasses = new LinkedHashSet<>();
// first value will be the preferred one - if any
allValueClasses.addAll(m_valueClasses);
allValueClasses.addAll(m_adapterValueList);
for (Class<? extends DataValue> cl : allValueClasses) {
UtilityFactory fac = getUtilityFor(cl);
if (!(fac instanceof ExtensibleUtilityFactory)) {
continue;
}
ExtensibleUtilityFactory efac = (ExtensibleUtilityFactory) fac;
// make sure the preferred and default renderers come first
DataValueRendererFactory prefRendererFac = efac.getPreferredRenderer();
if (prefRendererFac != null) {
map.put(prefRendererFac.getId(), prefRendererFac);
}
DataValueRendererFactory defaultRendererFac = efac.getDefaultRenderer();
if (defaultRendererFac != null) {
map.put(defaultRendererFac.getId(), defaultRendererFac);
}
for (DataValueRendererFactory rf : efac.getAvailableRenderers()) {
map.put(rf.getId(), rf);
}
}
if (map.isEmpty()) {
DefaultDataValueRenderer.Factory f = new DefaultDataValueRenderer.Factory();
map.put(f.getId(), f);
}
return map.values();
}
use of org.knime.core.data.renderer.DataValueRendererFactory in project knime-core by knime.
the class ExtensibleUtilityFactory method getDefaultRenderer.
/**
* Returns the default renderer for this data value. If no renderer is registered with the data value (highly
* unlikely) <code>null</code> is returned.
*
* @return a renderer factory or <code>null</code>
*/
public DataValueRendererFactory getDefaultRenderer() {
readRenderersFromExtensionPoint();
String defaultId = CORE_DEFAULT_PREFS.get(getPreferenceKey(), null);
DataValueRendererFactory matchedFactory = m_renderers.get(defaultId);
if (matchedFactory != null) {
return matchedFactory;
} else {
return null;
}
}
use of org.knime.core.data.renderer.DataValueRendererFactory in project knime-core by knime.
the class ExtensibleUtilityFactory method getPreferredRenderer.
/**
* Returns the preferred renderer for this data value. If no preferred renderer is set for the data value,
* <code>null</code> is returned.
*
* @return a renderer factory or <code>null</code>
*/
public DataValueRendererFactory getPreferredRenderer() {
readRenderersFromExtensionPoint();
String prefId = CORE_PREFS.get(getPreferenceKey(), null);
DataValueRendererFactory matchedFactory = m_renderers.get(prefId);
if (matchedFactory != null) {
return matchedFactory;
} else {
return null;
}
}
Aggregations