Search in sources :

Example 1 with HiLiteHandler

use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.

the class RegressionTreeLearnerNodeView method recreateHiLite.

private void recreateHiLite() {
    HiLiteHandler handler = m_hiLiteHdl;
    if (handler == null) {
        return;
    }
    Set<RowKey> hilited = handler.getHiLitKeys();
    Set<DecisionTreeNode> toHilite = new HashSet<DecisionTreeNode>();
    DecisionTreeNode root = m_graph.getRootNode();
    List<DecisionTreeNode> toProcess = new LinkedList<DecisionTreeNode>();
    if (null != root) {
        toProcess.add(0, root);
    }
    // Traverse the tree breadth first
    while (!toProcess.isEmpty()) {
        DecisionTreeNode curr = toProcess.remove(0);
        // cover any pattern
        if (curr.coveredPattern().isEmpty()) {
            continue;
        }
        if (hilited.containsAll(curr.coveredPattern())) {
            // hilite subtree starting from curr
            toHilite.addAll(getSubtree(curr));
        } else {
            for (int i = 0; i < curr.getChildCount(); i++) {
                toProcess.add(0, curr.getChildAt(i));
            }
        }
    }
    m_graph.hiLite(toHilite);
}
Also used : HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) RowKey(org.knime.core.data.RowKey) LinkedList(java.util.LinkedList) DecisionTreeNode(org.knime.base.node.mine.decisiontree2.model.DecisionTreeNode) HashSet(java.util.HashSet)

Example 2 with HiLiteHandler

use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.

the class RegressionTreeLearnerNodeView method modelChangedInUI.

private void modelChangedInUI() {
    assert SwingUtilities.isEventDispatchThread();
    final RegressionTreeLearnerNodeModel nodeModel = getNodeModel();
    HiLiteHandler hdl = nodeModel.getInHiLiteHandler(0);
    String warnMessage = nodeModel.getViewMessage();
    if (warnMessage == null) {
        m_warningLabel.setText(" ");
        m_warningLabel.setVisible(false);
    } else {
        m_warningLabel.setText(warnMessage);
        m_warningLabel.setVisible(true);
    }
    newHiliteHandler(hdl);
    newModel();
}
Also used : HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler)

Example 3 with HiLiteHandler

use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.

the class TreeEnsembleLearnerNodeView method recreateHiLite.

private void recreateHiLite() {
    HiLiteHandler handler = m_hiLiteHdl;
    if (handler == null) {
        return;
    }
    Set<RowKey> hilited = handler.getHiLitKeys();
    Set<DecisionTreeNode> toHilite = new HashSet<DecisionTreeNode>();
    DecisionTreeNode root = m_graph.getRootNode();
    List<DecisionTreeNode> toProcess = new LinkedList<DecisionTreeNode>();
    if (null != root) {
        toProcess.add(0, root);
    }
    // Traverse the tree breadth first
    while (!toProcess.isEmpty()) {
        DecisionTreeNode curr = toProcess.remove(0);
        // cover any pattern
        if (curr.coveredPattern().isEmpty()) {
            continue;
        }
        if (hilited.containsAll(curr.coveredPattern())) {
            // hilite subtree starting from curr
            toHilite.addAll(getSubtree(curr));
        } else {
            for (int i = 0; i < curr.getChildCount(); i++) {
                toProcess.add(0, curr.getChildAt(i));
            }
        }
    }
    m_graph.hiLite(toHilite);
}
Also used : HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) RowKey(org.knime.core.data.RowKey) LinkedList(java.util.LinkedList) DecisionTreeNode(org.knime.base.node.mine.decisiontree2.model.DecisionTreeNode) HashSet(java.util.HashSet)

Example 4 with HiLiteHandler

use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.

the class TreeEnsembleLearnerNodeView method modelChangedInUI.

private void modelChangedInUI() {
    assert SwingUtilities.isEventDispatchThread();
    final MODEL nodeModel = getNodeModel();
    TreeEnsembleModel ensembleModel = nodeModel.getEnsembleModel();
    int nrModels = ensembleModel == null ? 0 : ensembleModel.getNrModels();
    m_nrModelLabel.setText(nrModels + " model(s) in total");
    int min = nrModels == 0 ? 0 : 1;
    m_modelSpinner.setModel(new SpinnerNumberModel(min, min, nrModels, 1));
    HiLiteHandler hdl = nodeModel.getInHiLiteHandler(0);
    String warnMessage = nodeModel.getViewMessage();
    if (warnMessage == null) {
        m_warningLabel.setText(" ");
        m_warningLabel.setVisible(false);
    } else {
        m_warningLabel.setText(warnMessage);
        m_warningLabel.setVisible(true);
    }
    newHiliteHandler(hdl);
    newModel(min - 1);
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) TreeEnsembleModel(org.knime.base.node.mine.treeensemble2.model.TreeEnsembleModel) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler)

Example 5 with HiLiteHandler

use of org.knime.core.node.property.hilite.HiLiteHandler in project knime-core by knime.

the class TreeEnsembleLearnerNodeView2 method modelChangedInUI.

private void modelChangedInUI() {
    assert SwingUtilities.isEventDispatchThread();
    final MODEL nodeModel = getNodeModel();
    TreeEnsembleModel ensembleModel = nodeModel.getEnsembleModel();
    int nrModels = ensembleModel == null ? 0 : ensembleModel.getNrModels();
    m_nrModelLabel.setText(nrModels + " model(s) in total");
    int min = nrModels == 0 ? 0 : 1;
    m_modelSpinner.setModel(new SpinnerNumberModel(min, min, nrModels, 1));
    HiLiteHandler hdl = nodeModel.getInHiLiteHandler(0);
    String warnMessage = nodeModel.getViewMessage();
    if (warnMessage == null) {
        m_warningLabel.setText(" ");
        m_warningLabel.setVisible(false);
    } else {
        m_warningLabel.setText(warnMessage);
        m_warningLabel.setVisible(true);
    }
    newHiliteHandler(hdl);
    newModel(min - 1);
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) TreeEnsembleModel(org.knime.base.node.mine.treeensemble2.model.TreeEnsembleModel) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler)

Aggregations

HiLiteHandler (org.knime.core.node.property.hilite.HiLiteHandler)31 RowKey (org.knime.core.data.RowKey)11 HashSet (java.util.HashSet)7 DataTableSpec (org.knime.core.data.DataTableSpec)4 LinkedList (java.util.LinkedList)3 JTable (javax.swing.JTable)3 ListSelectionModel (javax.swing.ListSelectionModel)3 SpinnerNumberModel (javax.swing.SpinnerNumberModel)3 DecisionTreeNode (org.knime.base.node.mine.decisiontree2.model.DecisionTreeNode)3 DataCell (org.knime.core.data.DataCell)3 DataRow (org.knime.core.data.DataRow)3 DataTable (org.knime.core.data.DataTable)3 DefaultRow (org.knime.core.data.def.DefaultRow)3 BufferedDataTable (org.knime.core.node.BufferedDataTable)3 NodeModel (org.knime.core.node.NodeModel)3 HashMap (java.util.HashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 TreeEnsembleModel (org.knime.base.node.mine.treeensemble2.model.TreeEnsembleModel)2 AbstractPlotter (org.knime.base.node.viz.plotter.AbstractPlotter)2