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 };
}
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 };
}
Aggregations