org.knime.core.data.renderer
Class SetOfRendererFamilies

java.lang.Object
  extended by org.knime.core.data.renderer.SetOfRendererFamilies
All Implemented Interfaces:
ListCellRenderer, TableCellRenderer, DataValueRenderer, DataValueRendererFamily

public class SetOfRendererFamilies
extends Object
implements DataValueRendererFamily

Container for DataValueRendererFamily that is by itself a renderer family. This class is used in DataType when all available native renderer are gathered and returned as DataValueRendererFamily.

Note:This is a helper class that shouldn't be any useful for you.

Author:
Bernd Wiswedel, University of Konstanz

Field Summary
 
Fields inherited from interface org.knime.core.data.renderer.DataValueRenderer
PROPERTY_PREFERRED_RENDERER
 
Constructor Summary
SetOfRendererFamilies(List<DataValueRendererFamily> fams)
          Constructs a new set from a list of renderer families given in a list.
 
Method Summary
 boolean accepts(DataColumnSpec spec)
          Is this renderer instance able to render the content of the column given by spec.
 boolean accepts(String desc, DataColumnSpec spec)
          Is the renderer with the given description able to render the content of spec.
 String getDescription()
          Get a description for this renderer implementation.
 Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
          
 Dimension getPreferredSize()
          Get the dimension which the renderer component will preferably occupy.
 Component getRendererComponent(Object val)
          Get a component that visualizes a given object.
 String[] getRendererDescriptions()
          Get a "unique" description for all renderer that are available in this family.
 Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
          
 void setActiveRenderer(String desc)
          Set the currently active renderer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SetOfRendererFamilies

public SetOfRendererFamilies(List<DataValueRendererFamily> fams)
Constructs a new set from a list of renderer families given in a list. The active renderer will be the first one that is available.

Parameters:
fams - All renderer in a list (type DataValueRendererFamily)
Throws:
IllegalArgumentException - If list is empty
NullPointerException - If argument is null
ClassCastException - If list contains unexpected classes.
Method Detail

getRendererDescriptions

public String[] getRendererDescriptions()
Get a "unique" description for all renderer that are available in this family.

Specified by:
getRendererDescriptions in interface DataValueRendererFamily
Returns:
The Descriptions of all renderer that can be used here.

setActiveRenderer

public void setActiveRenderer(String desc)
Set the currently active renderer. The argument must be an element of whatever is returned in getRendererDescription(). If it is not this method won't do anything.

Specified by:
setActiveRenderer in interface DataValueRendererFamily
Parameters:
desc - The ID of the renderer to be used.

getDescription

public 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.

Specified by:
getDescription in interface DataValueRenderer
Returns:
A description for this renderer.

getPreferredSize

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

Specified by:
getPreferredSize in interface DataValueRenderer
Returns:
Size of the component being rendered.

getTableCellRendererComponent

public Component getTableCellRendererComponent(JTable table,
                                               Object value,
                                               boolean isSelected,
                                               boolean hasFocus,
                                               int row,
                                               int column)

Specified by:
getTableCellRendererComponent in interface TableCellRenderer

getListCellRendererComponent

public Component getListCellRendererComponent(JList list,
                                              Object value,
                                              int index,
                                              boolean isSelected,
                                              boolean cellHasFocus)

Specified by:
getListCellRendererComponent in interface ListCellRenderer

getRendererComponent

public 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.

Specified by:
getRendererComponent in interface DataValueRenderer
Parameters:
val - The value to render
Returns:
A component displaying the content of val.

accepts

public boolean accepts(String desc,
                       DataColumnSpec spec)
Is the renderer with the given description able to render the content of spec.

Specified by:
accepts in interface DataValueRendererFamily
Parameters:
desc - The description of the renderer.
spec - The column spec to check.
Returns:
If the renderer can render the column with the given spec.
See Also:
DataValueRenderer.accepts(DataColumnSpec)

accepts

public 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.

Specified by:
accepts in interface DataValueRenderer
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.