Search in sources :

Example 1 with DataProvider

use of org.knime.base.node.viz.plotter.DataProvider in project knime-core by knime.

the class HierarchicalClusterNodeView method modelChanged.

/**
 * {@inheritDoc}
 */
@Override
public void modelChanged() {
    if (getNodeModel() == null || ((DataProvider) getNodeModel()).getDataArray(0) == null || ((DataProvider) getNodeModel()).getDataArray(0).size() == 0) {
        return;
    }
    NodeModel model = getNodeModel();
    m_dendroPlotter.reset();
    m_distancePlotter.reset();
    m_dendroPlotter.setHiLiteHandler(model.getInHiLiteHandler(0));
    m_dendroPlotter.setAntialiasing(false);
    m_dendroPlotter.setDataProvider((DataProvider) model);
    m_distancePlotter.setDataProvider((DataProvider) model);
    m_distancePlotter.setHiLiteHandler(model.getInHiLiteHandler(0));
    DendrogramNode rootNode = getNodeModel().getRootNode();
    DataArray distanceTable = ((DataProvider) getNodeModel()).getDataArray(0);
    m_dendroPlotter.setRootNode(rootNode);
    m_distancePlotter.createXCoordinate(((DoubleValue) distanceTable.getDataTableSpec().getColumnSpec(0).getDomain().getLowerBound()).getDoubleValue(), ((DoubleValue) distanceTable.getDataTableSpec().getColumnSpec(0).getDomain().getUpperBound()).getDoubleValue());
    m_distancePlotter.createYCoordinate(((DoubleValue) distanceTable.getDataTableSpec().getColumnSpec(1).getDomain().getLowerBound()).getDoubleValue(), ((DoubleValue) distanceTable.getDataTableSpec().getColumnSpec(1).getDomain().getUpperBound()).getDoubleValue());
    ((BasicDrawingPane) m_distancePlotter.getDrawingPane()).clearPlot();
    m_distancePlotter.addLine(distanceTable, 0, 1, Color.BLACK, new BasicStroke(m_thickness));
    // m_distancePlotter.getXAxis().getCoordinate().setPolicy(
    // DescendingNumericTickPolicyStrategy.getInstance());
    m_distancePlotter.updatePaintModel();
    m_dendroPlotter.updatePaintModel();
}
Also used : DataProvider(org.knime.base.node.viz.plotter.DataProvider) BasicStroke(java.awt.BasicStroke) NodeModel(org.knime.core.node.NodeModel) BasicDrawingPane(org.knime.base.node.viz.plotter.basic.BasicDrawingPane) DendrogramNode(org.knime.base.node.viz.plotter.dendrogram.DendrogramNode) DataArray(org.knime.base.node.util.DataArray)

Example 2 with DataProvider

use of org.knime.base.node.viz.plotter.DataProvider in project knime-core by knime.

the class LinRegLinePlotter method updateSize.

/**
 * First calls super then adapts the regression line.
 */
@Override
public void updateSize() {
    if (getXAxis() == null || getXAxis().getCoordinate() == null || getYAxis() == null || getYAxis().getCoordinate() == null) {
        return;
    }
    super.updateSize();
    DataProvider dataProvider = getDataProvider();
    if (dataProvider == null) {
        return;
    }
    DataArray data = dataProvider.getDataArray(0);
    if (data == null) {
        return;
    }
    LinearRegressionContent params = ((LinRegDataProvider) dataProvider).getParams();
    if (params == null) {
        return;
    }
    double xMin = ((NumericCoordinate) getXAxis().getCoordinate()).getMinDomainValue();
    double xMax = ((NumericCoordinate) getXAxis().getCoordinate()).getMaxDomainValue();
    String xName = getSelectedXColumn().getName();
    String[] temp = ((LinRegDataProvider) dataProvider).getLearningColumns();
    if (temp == null) {
        return;
    }
    List<String> includedCols = Arrays.asList(temp);
    if (!xName.equals(params.getTargetColumnName()) && includedCols.contains(xName)) {
        double yMin = params.getApproximationFor(xName, xMin);
        double yMax = params.getApproximationFor(xName, xMax);
        ((LinRegLineDrawingPane) getDrawingPane()).setLineFirstPoint(getMappedXValue(new DoubleCell(xMin)), getMappedYValue(new DoubleCell(yMin)));
        ((LinRegLineDrawingPane) getDrawingPane()).setLineLastPoint(getMappedXValue(new DoubleCell(xMax)), getMappedYValue(new DoubleCell(yMax)));
    }
}
Also used : DataProvider(org.knime.base.node.viz.plotter.DataProvider) DoubleCell(org.knime.core.data.def.DoubleCell) LinearRegressionContent(org.knime.base.node.mine.regression.linear.LinearRegressionContent) NumericCoordinate(org.knime.base.util.coordinate.NumericCoordinate) DataArray(org.knime.base.node.util.DataArray)

Example 3 with DataProvider

use of org.knime.base.node.viz.plotter.DataProvider in project knime-core by knime.

the class LinRegLinePlotter method updatePaintModel.

/**
 * Retrieves the linear regression params, updates the column selection
 * boxes appropriately and adds the regression line to the scatterplot.
 */
@Override
public void updatePaintModel() {
    DataProvider dataProvider = getDataProvider();
    if (dataProvider == null) {
        return;
    }
    DataArray data = dataProvider.getDataArray(0);
    if (data == null) {
        return;
    }
    LinearRegressionContent params = ((LinRegDataProvider) dataProvider).getParams();
    if (params == null) {
        return;
    }
    // set the target column to fix
    ((LinRegLinePlotterProperties) getProperties()).setTargetColumn(params.getTargetColumnName());
    // get the included columns
    String[] includedCols = ((LinRegDataProvider) dataProvider).getLearningColumns();
    if (includedCols == null) {
        return;
    }
    ((LinRegLinePlotterProperties) getProperties()).setIncludedColumns(includedCols);
    // update the combo boxes
    DataTableSpec spec = data.getDataTableSpec();
    ((LinRegLinePlotterProperties) getProperties()).update(spec);
    super.updatePaintModel();
    double xMin = ((NumericCoordinate) getXAxis().getCoordinate()).getMinDomainValue();
    double xMax = ((NumericCoordinate) getXAxis().getCoordinate()).getMaxDomainValue();
    String xName = getSelectedXColumn().getName();
    List<String> includedList = Arrays.asList(includedCols);
    if (!xName.equals(params.getTargetColumnName()) && includedList.contains(xName)) {
        double yMin = params.getApproximationFor(xName, xMin);
        double yMax = params.getApproximationFor(xName, xMax);
        ((LinRegLineDrawingPane) getDrawingPane()).setLineFirstPoint(getMappedXValue(new DoubleCell(xMin)), getMappedYValue(new DoubleCell(yMin)));
        ((LinRegLineDrawingPane) getDrawingPane()).setLineLastPoint(getMappedXValue(new DoubleCell(xMax)), getMappedYValue(new DoubleCell(yMax)));
        getDrawingPane().repaint();
    }
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) DoubleCell(org.knime.core.data.def.DoubleCell) NumericCoordinate(org.knime.base.util.coordinate.NumericCoordinate) DataArray(org.knime.base.node.util.DataArray) DataProvider(org.knime.base.node.viz.plotter.DataProvider) LinearRegressionContent(org.knime.base.node.mine.regression.linear.LinearRegressionContent)

Example 4 with DataProvider

use of org.knime.base.node.viz.plotter.DataProvider in project knime-core by knime.

the class LiftChartNodeView method modelChanged.

/**
 * {@inheritDoc}
 */
@Override
protected void modelChanged() {
    final NodeModel model = getNodeModel();
    m_liftChart.setDataProvider((DataProvider) model);
    m_gainChart.setDataProvider(new DataProvider() {

        public DataArray getDataArray(final int index) {
            return ((LiftChartNodeModel) model).getDataArray(1);
        }
    });
    m_liftChart.updatePaintModel();
    m_gainChart.updatePaintModel();
}
Also used : DataProvider(org.knime.base.node.viz.plotter.DataProvider) NodeModel(org.knime.core.node.NodeModel) DataArray(org.knime.base.node.util.DataArray)

Example 5 with DataProvider

use of org.knime.base.node.viz.plotter.DataProvider in project knime-core by knime.

the class DefaultVisualizationNodeView method modelChanged.

/**
 * {@inheritDoc}
 */
@Override
protected void modelChanged() {
    NodeModel model = getNodeModel();
    if (model == null) {
        return;
    }
    if (!(model instanceof DataProvider)) {
        throw new IllegalArgumentException("Model must implement the DataProvider " + "interface!");
    }
    DataProvider provider = (DataProvider) model;
    HiLiteHandler hiliteHandler = model.getInHiLiteHandler(0);
    // do not care about antialias
    for (AbstractPlotter plotter : m_plotters) {
        plotter.reset();
        plotter.setHiLiteHandler(hiliteHandler);
        plotter.setDataProvider(provider);
        plotter.updatePaintModel();
    }
}
Also used : DataProvider(org.knime.base.node.viz.plotter.DataProvider) NodeModel(org.knime.core.node.NodeModel) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) AbstractPlotter(org.knime.base.node.viz.plotter.AbstractPlotter)

Aggregations

DataProvider (org.knime.base.node.viz.plotter.DataProvider)8 DataArray (org.knime.base.node.util.DataArray)5 NumericCoordinate (org.knime.base.util.coordinate.NumericCoordinate)4 DoubleCell (org.knime.core.data.def.DoubleCell)4 NodeModel (org.knime.core.node.NodeModel)3 RegressionContent (org.knime.base.node.mine.regression.RegressionContent)2 LinearRegressionContent (org.knime.base.node.mine.regression.linear.LinearRegressionContent)2 DataTableSpec (org.knime.core.data.DataTableSpec)2 BasicStroke (java.awt.BasicStroke)1 Point (java.awt.Point)1 AbstractPlotter (org.knime.base.node.viz.plotter.AbstractPlotter)1 BasicDrawingPane (org.knime.base.node.viz.plotter.basic.BasicDrawingPane)1 DendrogramNode (org.knime.base.node.viz.plotter.dendrogram.DendrogramNode)1 Coordinate (org.knime.base.util.coordinate.Coordinate)1 DataCell (org.knime.core.data.DataCell)1 DataRow (org.knime.core.data.DataRow)1 HiLiteHandler (org.knime.core.node.property.hilite.HiLiteHandler)1