org.knime.core.data.renderer
Interface DataValueRenderer

All Superinterfaces:
ListCellRenderer, TableCellRenderer
All Known Subinterfaces:
DataValueRendererFamily
All Known Implementing Classes:
AbstractPainterDataValueRenderer, BitVectorValuePixelRenderer, BitVectorValuePixelRenderer, BitVectorValueStringRenderer, BitVectorValueStringRenderer, ByteVectorValuePixelRenderer, ByteVectorValueStringRenderer, ComplexNumberValueRenderer, DateAndTimeValueRenderer, DefaultDataValueRenderer, DefaultDataValueRendererFamily, DoubleBarRenderer, DoubleGrayValueRenderer, DoubleValueRenderer, IntValueRenderer, LongValueRenderer, MultiLineStringValueRenderer, SetOfRendererFamilies, StringValueRenderer

public interface DataValueRenderer
extends TableCellRenderer, ListCellRenderer

General interface for classes that are able to render special derivatives of DataValue.

This interface extends TableCellRenderer and ListCellRenderer. Thus, it can be easily used in lists and tables. The preferred way of instantiating an object of a renderer is to use a DataValueRendererFamily.

Author:
Bernd Wiswedel, University of Konstanz
See Also:
DataValue, DataValueRendererFamily

Field Summary
static String PROPERTY_PREFERRED_RENDERER
          The property identifier that is read from, for instance the table view to determine which particular renderer (from the set of available renderers to a column) is to be used.
 
Method Summary
 boolean accepts(DataColumnSpec spec)
          Is this renderer instance able to render the content of the column given by spec.
 String getDescription()
          Get a description for this renderer implementation.
 Dimension getPreferredSize()
          Get the dimension which the renderer component will preferably occupy.
 Component getRendererComponent(Object val)
          Get a component that visualizes a given object.
 
Methods inherited from interface javax.swing.table.TableCellRenderer
getTableCellRendererComponent
 
Methods inherited from interface javax.swing.ListCellRenderer
getListCellRendererComponent
 

Field Detail

PROPERTY_PREFERRED_RENDERER

static final String PROPERTY_PREFERRED_RENDERER
The property identifier that is read from, for instance the table view to determine which particular renderer (from the set of available renderers to a column) is to be used. This property should be attached using a DataColumnSpec's domain information and should map to the description string of the renderer. A sample code that sets this property on a newly created double column to use the bar renderer is as follows:
 DataColumnSpecCreator creator = new DataColumnSpecCreator(
          newName, DoubleCell.TYPE);
 creator.setProperties(new DataColumnProperties(
          Collections.singletonMap(
              DataValueRenderer.PROPERTY_PREFERRED_RENDERER, 
              DoubleBarRenderer.DESCRIPTION)));
 creator.setDomain(new DataColumnDomainCreator(
          new DoubleCell(0.0), new DoubleCell(1.0)).createDomain());
 DataColumnSpec spec = creator.createSpec();
 

Keep in mind that setting the preferred renderer to an instance that inherently depends on proper domain information to be available (for instance [0,1]) requires the spec's DataColumnDomain to be set appropriately.

See Also:
Constant Field Values
Method Detail

getDescription

String getDescription()
Get a description for this renderer implementation. It will serve to identify this renderer when the user has the choice of different renderer that are available. Make sure that this description is likely to be unique (if not only one of renderer with this ID is shown as available) and this description is short but "expressive" so that it can be shown as label in menus, for instance.

Returns:
A description for this renderer.

getPreferredSize

Dimension getPreferredSize()
Get the dimension which the renderer component will preferably occupy.

Returns:
Size of the component being rendered.

getRendererComponent

Component getRendererComponent(Object val)
Get a component that visualizes a given object. This object, generally, is a DataCell implementing the underlying DataValue interface. The implementation, however, needs to handle other cases as well, such as null arguments, missing DataCell or generic objects.

Parameters:
val - The value to render
Returns:
A component displaying the content of val.

accepts

boolean accepts(DataColumnSpec spec)
Is this renderer instance able to render the content of the column given by spec. Most implementations will return true here but some may require some properties to be set, for instance a molecule renderer needs to have 2D coordinates in the column.

Note: This method is not used to test whether arbitrary types can be renderer by this renderer instance but rather if the specific runtime column spec (containing the type) is appropriate, for instance contains domain information or certain properties are set.

Parameters:
spec - The column spec to check.
Returns:
true if this renderer can be chosen to render the content of the column.


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.