Search in sources :

Example 1 with ShapeModelNominal

use of org.knime.core.data.property.ShapeModelNominal in project knime-core by knime.

the class ShapeManagerNodeModel method execute.

/**
 * Is invoked during the node's execution to make the shape settings.
 *
 * @param data the input data array
 * @param exec the execution monitor
 * @return the same input data table with assigned shapes to one column
 * @throws CanceledExecutionException if user canceled execution
 *
 * @see NodeModel#execute(BufferedDataTable[],ExecutionContext)
 */
@Override
protected PortObject[] execute(final PortObject[] data, final ExecutionContext exec) throws CanceledExecutionException {
    BufferedDataTable inData = (BufferedDataTable) data[INPORT];
    ShapeHandler shapeHandler = new ShapeHandler(new ShapeModelNominal(m_map));
    final DataTableSpec newSpec = appendShapeHandler(inData.getSpec(), m_column, shapeHandler);
    BufferedDataTable changedSpecTable = exec.createSpecReplacerTable(inData, newSpec);
    DataTableSpec modelSpec = new DataTableSpec(newSpec.getColumnSpec(m_column));
    ShapeHandlerPortObject viewPort = new ShapeHandlerPortObject(modelSpec, shapeHandler.toString() + " based on column \"" + m_column + "\"");
    return new PortObject[] { changedSpecTable, viewPort };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) BufferedDataTable(org.knime.core.node.BufferedDataTable) ShapeHandler(org.knime.core.data.property.ShapeHandler) ShapeHandlerPortObject(org.knime.core.node.port.viewproperty.ShapeHandlerPortObject) ShapeHandlerPortObject(org.knime.core.node.port.viewproperty.ShapeHandlerPortObject) PortObject(org.knime.core.node.port.PortObject) ShapeModelNominal(org.knime.core.data.property.ShapeModelNominal)

Example 2 with ShapeModelNominal

use of org.knime.core.data.property.ShapeModelNominal in project knime-core by knime.

the class ShapeManagerNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inPorts) throws InvalidSettingsException {
    // check null column
    if (m_column == null) {
        throw new InvalidSettingsException("No column selected.");
    }
    // check column in spec
    DataTableSpec inSpec = (DataTableSpec) inPorts[INPORT];
    if (!inSpec.containsName(m_column)) {
        throw new InvalidSettingsException("Column " + m_column + " not found.");
    }
    if (m_map.isEmpty()) {
        throw new InvalidSettingsException("No shapes defined to apply.");
    }
    ShapeHandler shapeHandler = new ShapeHandler(new ShapeModelNominal(m_map));
    DataTableSpec outSpec = appendShapeHandler(inSpec, m_column, shapeHandler);
    DataTableSpec modelSpec = new DataTableSpec(outSpec.getColumnSpec(m_column));
    return new DataTableSpec[] { outSpec, modelSpec };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ShapeHandler(org.knime.core.data.property.ShapeHandler) ShapeModelNominal(org.knime.core.data.property.ShapeModelNominal)

Aggregations

DataTableSpec (org.knime.core.data.DataTableSpec)2 ShapeHandler (org.knime.core.data.property.ShapeHandler)2 ShapeModelNominal (org.knime.core.data.property.ShapeModelNominal)2 BufferedDataTable (org.knime.core.node.BufferedDataTable)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1 PortObject (org.knime.core.node.port.PortObject)1 ShapeHandlerPortObject (org.knime.core.node.port.viewproperty.ShapeHandlerPortObject)1