use of org.knime.core.data.property.ColorModelRange in project knime-core by knime.
the class ColorExtractNodeModel method extractColorTable.
private DataTable extractColorTable(final DataTableSpec colorSpec) throws InvalidSettingsException {
// first column has column handler (convention in ColorHandlerPO)
ColorHandler clrHdl = colorSpec.getColumnSpec(0).getColorHandler();
final ColorModel model = clrHdl.getColorModel();
if (model.getClass() == ColorModelNominal.class) {
ColorModelNominal nom = (ColorModelNominal) model;
return extractColorTable(nom);
} else if (model.getClass() == ColorModelRange.class) {
ColorModelRange range = (ColorModelRange) model;
return extractColorTable(range);
} else {
throw new InvalidSettingsException("Unknown ColorModel class: " + model.getClass());
}
}
use of org.knime.core.data.property.ColorModelRange in project knime-core by knime.
the class ColorManager2NodeModel method createRangeColorHandler.
private static final ColorHandler createRangeColorHandler(final DataCell lower, final DataCell upper, final Map<DataCell, ColorAttr> map) {
assert map.size() == 2;
Color c0 = map.get(MIN_VALUE).getColor();
Color c1 = map.get(MAX_VALUE).getColor();
double d0 = Double.NaN;
if (lower != null && !lower.isMissing() && lower.getType().isCompatible(DoubleValue.class)) {
d0 = ((DoubleValue) lower).getDoubleValue();
}
double d1 = Double.NaN;
if (upper != null && !upper.isMissing() && upper.getType().isCompatible(DoubleValue.class)) {
d1 = ((DoubleValue) upper).getDoubleValue();
}
return new ColorHandler(new ColorModelRange(d0, c0, d1, c1));
}
Aggregations