use of org.knime.core.data.def.StringCell in project knime-core by knime.
the class SorterNodeDialogPanel method update.
/**
* Updates this panel by removing all current selections from the include
* and exclude list. The include list will contain all column names from the
* include list afterwards and the corresponding sort order for each column.
* If the include list is null, all column names from the
* {@link DataTableSpec} are added to the include list and the sort order is
* set to 'ascending' for each column.
*
* @param spec the spec to retrieve the column names from
* @param incl the list of columns to include
* @param sortOrder ascending/descending order for the included columns
*/
public void update(final DataTableSpec spec, final List<DataCell> incl, final boolean[] sortOrder) {
m_inclMdl.removeAllElements();
m_exclMdl.removeAllElements();
m_sortOrder.removeAllElements();
int interncounter = 0;
if (spec != null) {
m_spec = spec;
if ((incl == null) && (sortOrder == null)) {
for (int i = 0; i < m_spec.getNumColumns(); i++) {
final String c = spec.getColumnSpec(i).getName();
m_inclMdl.addElement(c);
m_sortOrder.add(true);
}
} else {
for (int i = 0; i < m_spec.getNumColumns(); i++) {
final String c = spec.getColumnSpec(i).getName();
if (incl.contains(new StringCell(c))) {
m_inclMdl.addElement(c);
if (sortOrder[interncounter]) {
m_sortOrder.add(true);
} else {
m_sortOrder.add(false);
}
interncounter++;
} else {
m_exclMdl.addElement(c);
}
}
}
repaint();
}
}
use of org.knime.core.data.def.StringCell in project knime-core by knime.
the class Unpivot2NodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
DataTableSpec inSpec = inData[0].getSpec();
String[] retainedColumns = m_retainedColumns.applyTo(inSpec).getIncludes();
String[] valueColumns = m_valueColumns.applyTo(inSpec).getIncludes();
int[] valueColumnIndices = new int[valueColumns.length];
for (int i = 0; i < valueColumnIndices.length; i++) {
valueColumnIndices[i] = inSpec.findColumnIndex(valueColumns[i]);
}
int[] orderColumnIdx = new int[retainedColumns.length];
for (int i = 0; i < orderColumnIdx.length; i++) {
orderColumnIdx[i] = inSpec.findColumnIndex(retainedColumns[i]);
}
final double newRowCnt = inData[0].size() * valueColumns.length;
final boolean enableHilite = m_enableHilite.getBooleanValue();
LinkedHashMap<RowKey, Set<RowKey>> map = new LinkedHashMap<RowKey, Set<RowKey>>();
DataTableSpec outSpec = createOutSpec(inSpec);
BufferedDataContainer buf = exec.createDataContainer(outSpec);
final boolean skipMissings = m_missingValues.getBooleanValue();
for (DataRow row : inData[0]) {
LinkedHashSet<RowKey> set = new LinkedHashSet<RowKey>();
FilterColumnRow crow = new FilterColumnRow(row, orderColumnIdx);
for (int i = 0; i < valueColumns.length; i++) {
String colName = valueColumns[i];
DataCell acell = row.getCell(valueColumnIndices[i]);
if (acell.isMissing() && skipMissings) {
// skip rows containing missing cells (in Value column(s))
continue;
}
RowKey rowKey = RowKey.createRowKey(buf.size());
if (enableHilite) {
set.add(rowKey);
}
DefaultRow drow = new DefaultRow(rowKey, new StringCell(row.getKey().getString()), new StringCell(colName), acell);
buf.addRowToTable(new AppendedColumnRow(rowKey, drow, crow));
exec.checkCanceled();
exec.setProgress(buf.size() / newRowCnt);
}
if (enableHilite) {
map.put(crow.getKey(), set);
}
}
buf.close();
if (enableHilite) {
m_trans.setMapper(new DefaultHiLiteMapper(map));
} else {
m_trans.setMapper(null);
}
return new BufferedDataTable[] { buf.getTable() };
}
use of org.knime.core.data.def.StringCell in project knime-core by knime.
the class GlobalTimerinfoNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
BufferedDataTable result0 = NodeTimer.GLOBAL_TIMER.getGlobalStatsTable(exec);
BufferedDataContainer result1 = exec.createDataContainer(createSpecOut1());
int rowcount = 0;
for (IBundleGroupProvider provider : Platform.getBundleGroupProviders()) {
for (IBundleGroup feature : provider.getBundleGroups()) {
DataRow row = new DefaultRow(new RowKey("Row " + rowcount++), new StringCell(feature.getIdentifier()), new StringCell(feature.getVersion()));
result1.addRowToTable(row);
}
}
result1.close();
return new PortObject[] { result0, result1.getTable() };
}
use of org.knime.core.data.def.StringCell in project knime-core by knime.
the class BoxPlotter method updateOutliers.
/**
* Sets the outliers as dotinfo to the scatterplotter drawing pane to
* make them selectable and hilite-able.
* @param yCoordinate the corresponding y coordinate.
* @param box the box (column).
* @return the mapped outliers for this column.
*/
protected List<DotInfo> updateOutliers(final Coordinate yCoordinate, final Box box) {
int height = getDrawingPaneDimension().height - OFFSET;
List<DotInfo> dotList = new ArrayList<DotInfo>();
int x = box.getX();
String colName = box.getColumnName();
// the mild outliers
Map<Double, Set<RowKey>> mildOutliers = ((BoxPlotDataProvider) getDataProvider()).getMildOutliers().get(colName);
for (Map.Entry<Double, Set<RowKey>> entry : mildOutliers.entrySet()) {
double value = entry.getKey();
for (RowKey key : entry.getValue()) {
int y = (int) getScreenYCoordinate(yCoordinate.calculateMappedValue(new DoubleCell(value), height)) - (OFFSET / 2);
DotInfo dot = new DotInfo(x, y, key, delegateIsHiLit(key), ColorAttr.DEFAULT, 1, 0);
dot.setXDomainValue(new StringCell(colName));
dot.setYDomainValue(new DoubleCell(value));
dot.setShape(ShapeFactory.getShape(ShapeFactory.CIRCLE));
dotList.add(dot);
}
}
// the extreme outliers
Map<Double, Set<RowKey>> extremeOutliers = ((BoxPlotDataProvider) getDataProvider()).getExtremeOutliers().get(colName);
for (Map.Entry<Double, Set<RowKey>> entry : extremeOutliers.entrySet()) {
double value = entry.getKey();
for (RowKey key : entry.getValue()) {
int y = (int) getScreenYCoordinate(yCoordinate.calculateMappedValue(new DoubleCell(value), height)) - (OFFSET / 2);
DotInfo dot = new DotInfo(x, y, key, delegateIsHiLit(key), ColorAttr.DEFAULT, 1, 0);
dot.setShape(ShapeFactory.getShape(ShapeFactory.CROSS));
dot.setXDomainValue(new StringCell(colName));
dot.setYDomainValue(new DoubleCell(value));
dotList.add(dot);
}
}
return dotList;
}
use of org.knime.core.data.def.StringCell in project knime-core by knime.
the class BoxPlotter method updatePaintModel.
/**
* {@inheritDoc}
*/
@Override
public void updatePaintModel() {
if (getDataProvider() == null || ((BoxPlotDataProvider) getDataProvider()).getStatistics() == null) {
m_selectedColumns = null;
return;
}
Map<DataColumnSpec, double[]> statistics = ((BoxPlotDataProvider) getDataProvider()).getStatistics();
DataTableSpec tableSpec = getDataProvider().getDataArray(getDataArrayIdx()).getDataTableSpec();
if (m_selectedColumns == null) {
m_selectedColumns = new LinkedHashSet<String>();
for (DataColumnSpec colName : tableSpec) {
if (colName.getType().isCompatible(DoubleValue.class)) {
m_selectedColumns.add(colName.getName());
}
}
}
((BoxPlotterProperties) getProperties()).updateColumnSelection(tableSpec, m_selectedColumns);
// m_selectedColumns = ((BoxPlotterProperties)getProperties())
// .getColumnFilter().getIncludedColumnList();
Set<DataCell> columns = new LinkedHashSet<DataCell>();
for (String colName : m_selectedColumns) {
int colIdx = tableSpec.findColumnIndex(colName);
if (colIdx >= 0) {
columns.add(new StringCell(colName));
}
}
createNominalXCoordinate(columns);
if (!m_normalize) {
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
for (Map.Entry<DataColumnSpec, double[]> entry : statistics.entrySet()) {
if (!m_selectedColumns.contains(entry.getKey().getName())) {
continue;
}
double[] stats = entry.getValue();
min = Math.min(min, stats[BoxPlotNodeModel.MIN]);
max = Math.max(max, stats[BoxPlotNodeModel.MAX]);
}
setPreserve(false);
if (m_selectedColumns.size() > 0) {
createYCoordinate(min, max);
} else {
// hack to achieve an empty y axis
createNominalYCoordinate(new LinkedHashSet<DataCell>());
}
} else {
createNormalizedCoordinates(statistics);
}
((BoxPlotterProperties) getProperties()).getColumnFilter().update(getDataProvider().getDataArray(getDataArrayIdx()).getDataTableSpec(), false, m_selectedColumns);
updateSize();
}
Aggregations