Search in sources :

Example 1 with DendrogramNode

use of org.knime.base.node.viz.plotter.dendrogram.DendrogramNode 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 DendrogramNode

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

the class ClusterNode method getDataRows.

/**
 * Puts all data rows of a node in a vector if the node is a leaf. Otherwise
 * the method is invoked with the nodes child nodes. This is a recursive
 * tree traversing method.
 *
 * @param clusterNode the node to get the data rows from.
 * @param rowVector the vector to store the found data rows in.
 */
private void getDataRows(final DendrogramNode clusterNode, final List<DataRow> rowVector) {
    // rekursives auslesen aller data rows
    DendrogramNode subNode1 = clusterNode.getFirstSubnode();
    DendrogramNode subNode2 = clusterNode.getSecondSubnode();
    if (subNode1.isLeaf()) {
        rowVector.add(subNode1.getLeafDataPoint());
    } else {
        getDataRows(subNode1, rowVector);
    }
    if (subNode2.isLeaf()) {
        rowVector.add(subNode2.getLeafDataPoint());
    } else {
        getDataRows(subNode2, rowVector);
    }
}
Also used : DendrogramNode(org.knime.base.node.viz.plotter.dendrogram.DendrogramNode)

Aggregations

DendrogramNode (org.knime.base.node.viz.plotter.dendrogram.DendrogramNode)2 BasicStroke (java.awt.BasicStroke)1 DataArray (org.knime.base.node.util.DataArray)1 DataProvider (org.knime.base.node.viz.plotter.DataProvider)1 BasicDrawingPane (org.knime.base.node.viz.plotter.basic.BasicDrawingPane)1 NodeModel (org.knime.core.node.NodeModel)1