Search in sources :

Example 6 with ColorAttr

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();
}
Also used : ColorAttr(org.knime.core.data.property.ColorAttr) DataCell(org.knime.core.data.DataCell)

Example 7 with ColorAttr

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);
}
Also used : Color(java.awt.Color) ColorAttr(org.knime.core.data.property.ColorAttr)

Example 8 with ColorAttr

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();
    }
}
Also used : ColorAttr(org.knime.core.data.property.ColorAttr) DataRow(org.knime.core.data.DataRow) DataArray(org.knime.base.node.util.DataArray)

Aggregations

ColorAttr (org.knime.core.data.property.ColorAttr)8 DataCell (org.knime.core.data.DataCell)6 Color (java.awt.Color)4 DataArray (org.knime.base.node.util.DataArray)3 Point (java.awt.Point)2 ArrayList (java.util.ArrayList)2 DataRow (org.knime.core.data.DataRow)2 LinkedHashMap (java.util.LinkedHashMap)1 DotInfo (org.knime.base.node.viz.plotter.scatter.DotInfo)1 DotInfoArray (org.knime.base.node.viz.plotter.scatter.DotInfoArray)1 ScatterPlotterDrawingPane (org.knime.base.node.viz.plotter.scatter.ScatterPlotterDrawingPane)1 StringCell (org.knime.core.data.def.StringCell)1