org.knime.core.data.property
Class ColorHandler

java.lang.Object
  extended by org.knime.core.data.property.ColorHandler
All Implemented Interfaces:
PropertyHandler

public final class ColorHandler
extends Object
implements PropertyHandler

Final ColorHandler implementation as container which forwards color requests for a DataCell to its underlying ColorHandler.ColorModel. The ColorModel can be loaded and saved from Config object.

Author:
Thomas Gabriel, University of Konstanz

Nested Class Summary
(package private) static interface ColorHandler.ColorModel
          Interface allowing requests for ColorAttr by DataCell.
 
Constructor Summary
ColorHandler(ColorHandler.ColorModel model)
          Create new color handler with the given ColorModel.
 
Method Summary
 boolean equals(Object obj)
          
 ColorAttr getColorAttr(DataCell dc)
          Returns a ColorAttr object as specified by the content of the given DataCell.
 int hashCode()
          
static ColorHandler load(ConfigRO config)
          Reads the color model settings from the given Config, inits a new ColorModel, and returns a new ColorHandler.
 void save(ConfigWO config)
          Saves the underlying ColorModel to the given Config by adding the ColorModel class as String and calling ColorHandler.ColorModel.save(ConfigWO) within the model.
 String toString()
          Returns a String summary of the underlying ColorHandler.ColorModel.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ColorHandler

public ColorHandler(ColorHandler.ColorModel model)
Create new color handler with the given ColorModel.

Parameters:
model - the color model which has the color settings
Throws:
IllegalArgumentException - if the model is null
Method Detail

getColorAttr

public ColorAttr getColorAttr(DataCell dc)
Returns a ColorAttr object as specified by the content of the given DataCell. Requests are forwarded to the underlying ColorModel. If no ColorAttr is assigned to the given dc, this method returns the ColorAttr.DEFAULT as default color, but never null.

Parameters:
dc - DataCell used to generate color
Returns:
a ColorAttr object assigned to the given cell
See Also:
ColorAttr.DEFAULT

save

public void save(ConfigWO config)
Saves the underlying ColorModel to the given Config by adding the ColorModel class as String and calling ColorHandler.ColorModel.save(ConfigWO) within the model.

Parameters:
config - color settings are saved to
Throws:
NullPointerException - if the config is null

load

public static ColorHandler load(ConfigRO config)
                         throws InvalidSettingsException
Reads the color model settings from the given Config, inits a new ColorModel, and returns a new ColorHandler.

Parameters:
config - read color settings from
Returns:
a new ColorHandler object created with the color model settings read from config
Throws:
InvalidSettingsException - if either the class or color model settings could not be read
NullPointerException - if the config is null

toString

public String toString()
Returns a String summary of the underlying ColorHandler.ColorModel.

Overrides:
toString in class Object
Returns:
a String summary of the ColorModel

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object


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.