use of org.knime.core.data.DataColumnDomainCreator in project knime-core by knime.
the class TestDataGenerator method createNominalTargetColumn.
public static TreeTargetNominalColumnData createNominalTargetColumn(final String[] values) {
DataColumnDomainCreator dc = new DataColumnDomainCreator(Arrays.stream(values).distinct().map(s -> new StringCell(s)).toArray(i -> new StringCell[i]));
DataColumnSpecCreator specCreator = new DataColumnSpecCreator("test-target", StringCell.TYPE);
specCreator.setDomain(dc.createDomain());
DataColumnSpec targetSpec = specCreator.createSpec();
TreeTargetColumnDataCreator targetCreator = new TreeTargetNominalColumnDataCreator(targetSpec);
for (int i = 0; i < values.length; i++) {
RowKey rowKey = RowKey.createRowKey((long) i);
targetCreator.add(rowKey, new StringCell(values[i]));
}
return (TreeTargetNominalColumnData) targetCreator.createColumnData();
}
use of org.knime.core.data.DataColumnDomainCreator in project knime-core by knime.
the class AbstractPlotter method createNominalYCoordinate.
/**
* Creates a nominal y axis.
*
* @param values the possible values.
*/
public void createNominalYCoordinate(final Set<DataCell> values) {
DataColumnDomainCreator domainCreator = new DataColumnDomainCreator();
domainCreator.setValues(values);
DataColumnSpecCreator specCreator = new DataColumnSpecCreator("X", StringCell.TYPE);
specCreator.setDomain(domainCreator.createDomain());
Coordinate nominalCoordinate = Coordinate.createCoordinate(specCreator.createSpec());
if (getYAxis() == null) {
Axis yAxis = new Axis(Axis.VERTICAL, getDrawingPaneDimension().width);
setYAxis(yAxis);
}
getYAxis().setCoordinate(nominalCoordinate);
}
use of org.knime.core.data.DataColumnDomainCreator in project knime-core by knime.
the class AbstractPlotter method createNominalXCoordinate.
/**
* Creates a nominal x axis.
*
* @param values the possible values.
*/
public void createNominalXCoordinate(final Set<DataCell> values) {
DataColumnDomainCreator domainCreator = new DataColumnDomainCreator();
domainCreator.setValues(values);
DataColumnSpecCreator specCreator = new DataColumnSpecCreator("X", StringCell.TYPE);
specCreator.setDomain(domainCreator.createDomain());
Coordinate nominalCoordinate = Coordinate.createCoordinate(specCreator.createSpec());
if (getXAxis() == null) {
Axis xAxis = new Axis(Axis.HORIZONTAL, getDrawingPaneDimension().width);
setXAxis(xAxis);
}
getXAxis().setCoordinate(nominalCoordinate);
}
use of org.knime.core.data.DataColumnDomainCreator in project knime-core by knime.
the class AbstractPlotter method createXCoordinate.
/**
* Recalculates the domain of the x axis. If preserve is set to false the
* passed values are taken as min and max no matter was was set before. If
* preserve is set to true (default) the possibly already available min and
* max values are preserved.
*
* @param min the min value
* @param max the max value {@link AbstractPlotter#setPreserve(boolean)}
*/
public void createXCoordinate(final double min, final double max) {
DataColumnDomainCreator xDomainCreator = new DataColumnDomainCreator();
double actualMin = min;
double actualMax = max;
if (getXAxis() != null && getXAxis().getCoordinate() != null && m_preserve) {
if (!(getXAxis().getCoordinate() instanceof NumericCoordinate)) {
return;
}
actualMin = Math.min(min, ((NumericCoordinate) getXAxis().getCoordinate()).getMinDomainValue());
actualMax = Math.max(max, ((NumericCoordinate) getXAxis().getCoordinate()).getMaxDomainValue());
}
xDomainCreator.setLowerBound(new DoubleCell(actualMin));
xDomainCreator.setUpperBound(new DoubleCell(actualMax));
DataColumnSpecCreator xSpecCreator = new DataColumnSpecCreator("X", DoubleCell.TYPE);
xSpecCreator.setDomain(xDomainCreator.createDomain());
Coordinate xCoordinate = Coordinate.createCoordinate(xSpecCreator.createSpec());
if (getXAxis() == null) {
Axis xAxis = new Axis(Axis.HORIZONTAL, getDrawingPaneDimension().width);
setXAxis(xAxis);
}
getXAxis().setCoordinate(xCoordinate);
}
use of org.knime.core.data.DataColumnDomainCreator in project knime-core by knime.
the class AbstractPlotter method createYCoordinate.
/**
* Recalculates the domain of the y axis. If preserve is set to false the
* passed values are taken as min and max no matter was was set before. If
* preserve is set to true (default) the possibly already available min and
* max values are preserved.
*
* @param min the min value
* @param max the max value {@link AbstractPlotter#setPreserve(boolean)}
*/
public void createYCoordinate(final double min, final double max) {
DataColumnDomainCreator yDomainCreator = new DataColumnDomainCreator();
double actualMin = min;
double actualMax = max;
if (getYAxis() != null && getYAxis().getCoordinate() != null && m_preserve) {
if (!(getYAxis().getCoordinate() instanceof NumericCoordinate)) {
return;
}
actualMin = Math.min(min, ((NumericCoordinate) getYAxis().getCoordinate()).getMinDomainValue());
actualMax = Math.max(max, ((NumericCoordinate) getYAxis().getCoordinate()).getMaxDomainValue());
}
yDomainCreator.setLowerBound(new DoubleCell(actualMin));
yDomainCreator.setUpperBound(new DoubleCell(actualMax));
DataColumnSpecCreator ySpecCreator = new DataColumnSpecCreator("Y", DoubleCell.TYPE);
ySpecCreator.setDomain(yDomainCreator.createDomain());
Coordinate yCoordinate = Coordinate.createCoordinate(ySpecCreator.createSpec());
if (getYAxis() == null) {
Axis yAxis = new Axis(Axis.VERTICAL, getDrawingPaneDimension().height);
setYAxis(yAxis);
}
getYAxis().setCoordinate(yCoordinate);
}
Aggregations