Search in sources :

Example 26 with Coordinate

use of org.knime.base.util.coordinate.Coordinate in project knime-core by knime.

the class ScatterPlotter method setXColumn.

/**
 * Sets new x columns and recalculates/repaints.
 *
 * @param xColName name of the new x column to plot
 */
public void setXColumn(final String xColName) {
    setXColName(xColName);
    // tell the headers to display the new column names
    getColHeader().setToolTipText(getXColName());
    // check if the column names set so far are valid
    // this check also checks the y axis
    // if invalid a boolean flag is set in the method for later use
    checkColumns();
    if (m_rowContainer == null) {
        return;
    }
    DataTableSpec tSpec = m_rowContainer.getDataTableSpec();
    int idx = tSpec.findColumnIndex(getXColName());
    if (idx >= 0) {
        Coordinate xCoordinate = Coordinate.createCoordinate(tSpec.getColumnSpec(idx));
        if (xCoordinate == null) {
            m_xIndex = -1;
        } else {
            // check whether the bounds are set properly
            if (!xCoordinate.isNominal()) {
                if (!((NumericCoordinate) xCoordinate).isMinDomainValueSet()) {
                    ((NumericCoordinate) xCoordinate).setMinDomainValue(getXmin());
                }
                if (!((NumericCoordinate) xCoordinate).isMaxDomainValueSet()) {
                    ((NumericCoordinate) xCoordinate).setMaxDomainValue(getXmax());
                }
            }
            getColHeader().setCoordinate(xCoordinate);
            m_xIndex = idx;
        }
    } else {
        // set -1 to indicate an invalid column index
        m_xIndex = -1;
    }
    // redo everything if two columns are available
    if (!m_invalidColumn) {
        updateDotsAndPaint();
    }
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) Coordinate(org.knime.base.util.coordinate.Coordinate) NumericCoordinate(org.knime.base.util.coordinate.NumericCoordinate) NumericCoordinate(org.knime.base.util.coordinate.NumericCoordinate)

Aggregations

Coordinate (org.knime.base.util.coordinate.Coordinate)26 NumericCoordinate (org.knime.base.util.coordinate.NumericCoordinate)17 Point (java.awt.Point)8 DataCell (org.knime.core.data.DataCell)8 DataColumnSpec (org.knime.core.data.DataColumnSpec)8 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)7 DoubleCell (org.knime.core.data.def.DoubleCell)7 DataColumnDomainCreator (org.knime.core.data.DataColumnDomainCreator)6 Axis (org.knime.base.node.viz.plotter.Axis)4 DataRow (org.knime.core.data.DataRow)4 ArrayList (java.util.ArrayList)3 AbstractHistogramVizModel (org.knime.base.node.viz.histogram.datamodel.AbstractHistogramVizModel)3 DotInfo (org.knime.base.node.viz.plotter.scatter.DotInfo)3 DataTableSpec (org.knime.core.data.DataTableSpec)3 StringCell (org.knime.core.data.def.StringCell)3 Dimension (java.awt.Dimension)2 Rectangle (java.awt.Rectangle)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 DataArray (org.knime.base.node.util.DataArray)2