use of org.knime.core.data.property.ColorAttr in project knime-core by knime.
the class ColorManager2DialogNominal method updateWithPalette.
/**
* Apply new colors of a given palette of the selected column.
*
* @param column the selected column
* @param palette the new palette
*/
void updateWithPalette(final String column, final String[] palette) {
Map<DataCell, ColorAttr> map = m_map.get(column);
int i = 0;
ColorAttr color;
for (Object o : m_columnModel.toArray()) {
if (i >= palette.length) {
i = 0;
}
ColorManager2Icon icon = (ColorManager2Icon) o;
color = ColorAttr.getInstance(Color.decode(palette[i]));
icon.setColor(color.getColor());
map.put(icon.getCell(), color);
i++;
}
super.validate();
super.repaint();
}
use of org.knime.core.data.property.ColorAttr in project knime-core by knime.
the class TableRowHeaderView method prepareRenderer.
/**
* Overridden in order to set the correct selection color (depending on
* hilite status).
* {@inheritDoc}
*/
@Override
public Component prepareRenderer(final TableCellRenderer renderer, final int row, final int column) {
if (renderer instanceof DataCellHeaderRenderer) {
final DataCellHeaderRenderer r = (DataCellHeaderRenderer) renderer;
final TableRowHeaderModel model = getModel();
// set proper selection color
boolean isHiLit = model.isHiLit(row);
Color selColor = (isHiLit ? ColorAttr.SELECTED_HILITE : ColorAttr.SELECTED);
setSelectionBackground(selColor);
// this might be ignored anyway if the row is selected ...
if (isHiLit) {
r.setBackground(ColorAttr.HILITE);
} else {
r.setBackground(m_headerBackground);
}
ColorAttr colorAttr = model.getColorAttr(row);
r.setColor(colorAttr.getColor());
}
return super.prepareRenderer(renderer, row, column);
}
use of org.knime.core.data.property.ColorAttr in project knime-core by knime.
the class ScatterPlotter method updateDotsAndPaint.
/*
* takes the data from the private row container and recalculates the dots,
* the coordinates, adjusts sizes and repaints.
*/
private void updateDotsAndPaint() {
getScatterPlotterDrawingPane().clearSelection();
// get the rowInfo from the model
DataArray rowsCont = m_rowContainer;
if (rowsCont != null) {
// and create a new DotInfo array with the rowKeys in the DotInfos.
DotInfo[] newDots = new DotInfo[rowsCont.size()];
for (int r = 0; r < rowsCont.size(); r++) {
DataRow row = rowsCont.getRow(r);
double size = getSize(row);
ColorAttr colorAttr = getColorAttr(row);
newDots[r] = new DotInfo(0, 0, row.getKey(), false, colorAttr, size, r);
}
// now create a new DotInfoArray
DotInfoArray newDotArray = new DotInfoArray(newDots);
// store it in the drawing pane
getScatterPlotterDrawingPane().setDotInfoArray(newDotArray);
// update hilit and colors.
updateDotHiLiting();
// and get the coordinates calculated.
adjustSizes();
calculateCoordinates(newDotArray);
repaint();
}
}
Aggregations