org.knime.base.node.viz.property.color
Class ColorManager2NodeModel

java.lang.Object
  extended by org.knime.core.node.NodeModel
      extended by org.knime.base.node.viz.property.color.ColorManager2NodeModel

 class ColorManager2NodeModel
extends NodeModel

Model used to set colors either based on the nominal values or ranges (bounds) retrieved from the DataColumnSpec. The created ColorHandler is then set in the column spec.

Author:
Thomas Gabriel, University of Konstanz
See Also:
ColorManager2NodeDialogPane

Field Summary
(package private) static int INPORT
          Keeps port number for the single input port.
(package private) static String IS_NOMINAL
          Type of color setting.
(package private) static NodeLogger LOGGER
          Logger for this package.
(package private) static String MAX_COLOR
          The maximum column value for range color settings.
(package private) static String MIN_COLOR
          The minimum column value for range color settings.
(package private) static int OUTPORT
          Keeps port number for the single input port.
(package private) static String SELECTED_COLUMN
          Keeps the selected column.
(package private) static String VALUES
          The nominal column values.
 
Constructor Summary
ColorManager2NodeModel()
          Creates a new model for mapping colors.
 
Method Summary
protected  PortObjectSpec[] configure(PortObjectSpec[] inSpecs)
          Configure method for general port types.
protected  PortObject[] execute(PortObject[] data, ExecutionContext exec)
          Is invoked during the node's execution to make the color settings.
(package private) static DataTableSpec getOutSpec(DataTableSpec spec, String columnName, ColorHandler colorHdl)
          Appends the given ColorHandler to the given DataTableSpec for the given column.
protected  void loadInternals(File nodeInternDir, ExecutionMonitor exec)
          Load internals into the derived NodeModel.
protected  void loadValidatedSettingsFrom(NodeSettingsRO settings)
          Load color settings.
protected  void reset()
          Override this function in the derived model and reset your NodeModel.
protected  void saveInternals(File nodeInternDir, ExecutionMonitor exec)
          Save internals of the derived NodeModel.
protected  void saveSettingsTo(NodeSettingsWO settings)
          Save color settings.
protected  void validateSettings(NodeSettingsRO settings)
          Validate the color settings, that are, column name must be available, as well as, a color model either nominal or range that contains a color mapping, from each possible value to a color or from min and max value to color, respectively.
 
Methods inherited from class org.knime.core.node.NodeModel
addWarningListener, configure, continueLoop, execute, executeModel, getInHiLiteHandler, getLoopEndNode, getLoopStartNode, getNrInPorts, getNrOutPorts, getOutHiLiteHandler, getWarningMessage, notifyViews, notifyWarningListeners, peekFlowVariableDouble, peekFlowVariableInt, peekFlowVariableString, peekScopeVariableDouble, peekScopeVariableInt, peekScopeVariableString, pushFlowVariableDouble, pushFlowVariableInt, pushFlowVariableString, pushScopeVariableDouble, pushScopeVariableInt, pushScopeVariableString, removeWarningListener, setInHiLiteHandler, setWarningMessage, stateChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

static final NodeLogger LOGGER
Logger for this package.


INPORT

static final int INPORT
Keeps port number for the single input port.

See Also:
Constant Field Values

OUTPORT

static final int OUTPORT
Keeps port number for the single input port.

See Also:
Constant Field Values

SELECTED_COLUMN

static final String SELECTED_COLUMN
Keeps the selected column.

See Also:
Constant Field Values

VALUES

static final String VALUES
The nominal column values.

See Also:
Constant Field Values

MIN_COLOR

static final String MIN_COLOR
The minimum column value for range color settings.

See Also:
Constant Field Values

MAX_COLOR

static final String MAX_COLOR
The maximum column value for range color settings.

See Also:
Constant Field Values

IS_NOMINAL

static final String IS_NOMINAL
Type of color setting.

See Also:
Constant Field Values
Constructor Detail

ColorManager2NodeModel

public ColorManager2NodeModel()
Creates a new model for mapping colors. The model has one input and two outputs.

Method Detail

execute

protected PortObject[] execute(PortObject[] data,
                               ExecutionContext exec)
                        throws CanceledExecutionException
Is invoked during the node's execution to make the color settings.

Overrides:
execute in class NodeModel
Parameters:
data - the input data array
exec - the execution monitor
Returns:
the same input data table whereby the RowKeys contain color info now
Throws:
CanceledExecutionException - if user canceled execution

getOutSpec

static final DataTableSpec getOutSpec(DataTableSpec spec,
                                      String columnName,
                                      ColorHandler colorHdl)
Appends the given ColorHandler to the given DataTableSpec for the given column. If the spec already contains a ColorHandler, it will be removed and replaced by the new one.

Parameters:
spec - to which the ColorHandler is appended
columnName - for this column
colorHdl - ColorHandler
Returns:
a new spec with ColorHandler

configure

protected PortObjectSpec[] configure(PortObjectSpec[] inSpecs)
                              throws InvalidSettingsException
Description copied from class: NodeModel
Configure method for general port types. The argument specs represent the input object specs and are guaranteed to be subclasses of the PortObjectSpecs that are defined through the PortTypes given in the constructor. Similarly, the returned output specs need to comply with their port types spec class (otherwise an error is reported by the framework). They may also be null.

For a general description of the configure method refer to the description of the specialized NodeModel.configure(DataTableSpec[]) methods as it addresses more use cases.

Overrides:
configure in class NodeModel
Parameters:
inSpecs - the input specs passed to the output port
Returns:
the same as the input spec
Throws:
InvalidSettingsException - if a column is not available

loadValidatedSettingsFrom

protected void loadValidatedSettingsFrom(NodeSettingsRO settings)
                                  throws InvalidSettingsException
Load color settings.

Specified by:
loadValidatedSettingsFrom in class NodeModel
Parameters:
settings - Used to read color settings from.
Throws:
InvalidSettingsException - If a color property with the settings is invalid.
See Also:
NodeModel.saveSettingsTo(NodeSettingsWO), NodeModel.validateSettings(NodeSettingsRO)

saveSettingsTo

protected void saveSettingsTo(NodeSettingsWO settings)
Save color settings.

Specified by:
saveSettingsTo in class NodeModel
Parameters:
settings - Used to write color settings into.
See Also:
NodeModel.loadValidatedSettingsFrom(NodeSettingsRO), NodeModel.validateSettings(NodeSettingsRO)

validateSettings

protected void validateSettings(NodeSettingsRO settings)
                         throws InvalidSettingsException
Validate the color settings, that are, column name must be available, as well as, a color model either nominal or range that contains a color mapping, from each possible value to a color or from min and max value to color, respectively.

Specified by:
validateSettings in class NodeModel
Parameters:
settings - Color settings to validate.
Throws:
InvalidSettingsException - If a color property read from the settings is invalid.
See Also:
NodeModel.saveSettingsTo(NodeSettingsWO), NodeModel.loadValidatedSettingsFrom(NodeSettingsRO)

reset

protected void reset()
Override this function in the derived model and reset your NodeModel. All components should unregister themselves from any observables (at least from the hilite handler right now). All internally stored data structures should be released. User settings should not be deleted/reset though.

Specified by:
reset in class NodeModel

loadInternals

protected void loadInternals(File nodeInternDir,
                             ExecutionMonitor exec)
                      throws IOException,
                             CanceledExecutionException
Load internals into the derived NodeModel. This method is only called if the Node was executed. Read all your internal structures from the given file directory to create your internal data structure which is necessary to provide all node functionalities after the workflow is loaded, e.g. view content and/or hilite mapping.

Specified by:
loadInternals in class NodeModel
Parameters:
nodeInternDir - The directory to read from.
exec - Used to report progress and to cancel the load process.
Throws:
IOException - If an error occurs during reading from this dir.
CanceledExecutionException - If the loading has been canceled.
See Also:
NodeModel.saveInternals(File,ExecutionMonitor)

saveInternals

protected void saveInternals(File nodeInternDir,
                             ExecutionMonitor exec)
                      throws IOException,
                             CanceledExecutionException
Save internals of the derived NodeModel. This method is only called if the Node is executed. Write all your internal structures into the given file directory which are necessary to recreate this model when the workflow is loaded, e.g. view content and/or hilite mapping.

Specified by:
saveInternals in class NodeModel
Parameters:
nodeInternDir - The directory to write into.
exec - Used to report progress and to cancel the save process.
Throws:
IOException - If an error occurs during writing to this dir.
CanceledExecutionException - If the saving has been canceled.
See Also:
NodeModel.loadInternals(File,ExecutionMonitor)


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.