use of org.knime.core.data.renderer.DataValueRenderer in project knime-core by knime.
the class TableContentView method fitCellSizeToRenderer.
/**
* Sets the preferred column width and returns the maximum of the
* preferred row heights according to each column's renderer.
* This method should only be called when the table is built up from
* scratch.
* @return the best initial row height (this must be set elsewhere)
*/
int fitCellSizeToRenderer() {
TableColumnModel colModel = getColumnModel();
int bestRowHeight = 16;
for (Enumeration<TableColumn> enu = colModel.getColumns(); enu.hasMoreElements(); ) {
TableColumn col = enu.nextElement();
TableCellRenderer renderer = col.getCellRenderer();
if (renderer instanceof DataValueRenderer) {
if (getRowCount() > 0) {
prepareRenderer(renderer, 0, col.getModelIndex());
}
Dimension p = ((DataValueRenderer) renderer).getPreferredSize();
int prefHeight = p.height;
int colWidth = p.width;
if (col.getWidth() < colWidth) {
col.setPreferredWidth(colWidth);
}
bestRowHeight = Math.max(bestRowHeight, prefHeight);
}
}
return bestRowHeight;
}
use of org.knime.core.data.renderer.DataValueRenderer 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);
}
Aggregations