Search in sources :

Example 16 with HiLiteHandler

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

the class TableNodeModel method setInternalTables.

/**
 * {@inheritDoc}
 */
@Override
public void setInternalTables(final BufferedDataTable[] tables) {
    m_table = tables[0];
    HiLiteHandler inProp = getInHiLiteHandler(INPORT);
    updateView(new UpdateObject(m_table, inProp));
}
Also used : HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler)

Example 17 with HiLiteHandler

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

the class TableNodeModel method execute.

/**
 * Called when new data is available. Accesses the input data table and the
 * property handler, sets them in the {@link TableContentModel} and starts
 * event firing to inform listeners. Do not call this method separately, it
 * is invoked by this model's node.
 *
 * @param data the data table at the (single) input port, wrapped in a
 *            one-dimensional array
 * @param exec the execution monitor
 * @return an empty table
 *
 * @see NodeModel#execute(BufferedDataTable[],ExecutionContext)
 */
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] data, final ExecutionContext exec) {
    m_table = data[0];
    HiLiteHandler inProp = getInHiLiteHandler(INPORT);
    updateView(new UpdateObject(m_table, inProp));
    return new BufferedDataTable[0];
}
Also used : HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) BufferedDataTable(org.knime.core.node.BufferedDataTable)

Example 18 with HiLiteHandler

use of org.knime.core.node.property.hilite.HiLiteHandler 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)

Example 19 with HiLiteHandler

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

the class AutoHiLiteNodeFactory method createNodeModel.

/**
 * {@inheritDoc}
 */
@Override
public NodeModel createNodeModel() {
    return new NodeModel(1, 1) {

        private SettingsModelBoolean m_smClearHiLites = createClearHilitesModel();

        /**
         * {@inheritDoc}
         */
        @Override
        protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
            return inSpecs;
        }

        /**
         * {@inheritDoc}
         */
        @Override
        protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
            if (m_smClearHiLites.getBooleanValue()) {
                getInHiLiteHandler(0).fireClearHiLiteEvent();
            }
            final Set<RowKey> keys = new HashSet<RowKey>();
            final HiLiteHandler hlh = getInHiLiteHandler(0);
            long counter = 0;
            long numOfRows = inData[0].size();
            for (final DataRow row : inData[0]) {
                keys.add(row.getKey());
                if (keys.size() == NUMBER_OF_ROWS_HILITED_AT_ONCE) {
                    exec.setProgress(++counter * NUMBER_OF_ROWS_HILITED_AT_ONCE / (double) numOfRows, "HiLiting all rows...");
                    hlh.fireHiLiteEvent(keys);
                    keys.clear();
                }
            }
            hlh.fireHiLiteEvent(keys);
            // wait for hilite to propagate
            ViewUtils.invokeAndWaitInEDT(() -> {
            });
            return inData;
        }

        @Override
        protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
        }

        @Override
        protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
        }

        @Override
        protected void saveSettingsTo(final NodeSettingsWO settings) {
            m_smClearHiLites.saveSettingsTo(settings);
        }

        @Override
        protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
            m_smClearHiLites.validateSettings(settings);
        }

        @Override
        protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
            m_smClearHiLites.loadSettingsFrom(settings);
        }

        @Override
        protected void reset() {
        // no op
        }
    };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) RowKey(org.knime.core.data.RowKey) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) DataRow(org.knime.core.data.DataRow) SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) NodeModel(org.knime.core.node.NodeModel) ExecutionContext(org.knime.core.node.ExecutionContext) BufferedDataTable(org.knime.core.node.BufferedDataTable) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) File(java.io.File) HashSet(java.util.HashSet)

Example 20 with HiLiteHandler

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

the class WebResourceController method getWizardPageInternal.

/**
 * Crates the wizard page for a given node id. Throws exception if no wizard page available.
 *
 * @param subnodeID the node id for the subnode to retrieve the wizard page for
 * @return The wizard page for the given node id
 */
@SuppressWarnings("rawtypes")
protected WizardPageContent getWizardPageInternal(final NodeID subnodeID) {
    if (subnodeID == null) {
        LOGGER.error("No node ID supplied for creating wizard page");
        return null;
    }
    final WorkflowManager manager = m_manager;
    assert manager.isLockedByCurrentThread();
    // int currentSubnodeIDSuffix = m_promptedSubnodeIDSuffixes.peek();
    // final NodeID subNodeID = toNodeID(currentSubnodeIDSuffix);
    SubNodeContainer subNC = manager.getNodeContainer(subnodeID, SubNodeContainer.class, true);
    WorkflowManager subWFM = subNC.getWorkflowManager();
    Map<NodeID, WizardNode> wizardNodeMap = subWFM.findNodes(WizardNode.class, NOT_HIDDEN_FILTER, false);
    LinkedHashMap<NodeIDSuffix, WizardNode> resultMap = new LinkedHashMap<NodeIDSuffix, WizardNode>();
    // LinkedHashMap<NodeIDSuffix, WizardNode> errorMap = new LinkedHashMap<NodeIDSuffix, WizardNode>();
    LinkedHashMap<NodeIDSuffix, WizardPageNodeInfo> infoMap = new LinkedHashMap<NodeIDSuffix, WizardPageNodeInfo>();
    Set<HiLiteHandler> initialHiliteHandlerSet = new HashSet<HiLiteHandler>();
    for (Map.Entry<NodeID, WizardNode> entry : wizardNodeMap.entrySet()) {
        NodeContainer nc = subWFM.getNodeContainer(entry.getKey());
        if ((nc instanceof SingleNodeContainer) && ((SingleNodeContainer) nc).isInactive()) {
            // skip nodes in inactive branches
            continue;
        }
        NodeID.NodeIDSuffix idSuffix = NodeID.NodeIDSuffix.create(manager.getID(), entry.getKey());
        WizardPageNodeInfo nodeInfo = new WizardPageNodeInfo();
        nodeInfo.setNodeName(nc.getName());
        nodeInfo.setNodeAnnotation(nc.getNodeAnnotation().toString());
        nodeInfo.setNodeState(nc.getInternalState());
        nodeInfo.setNodeMessage(nc.getNodeMessage());
        infoMap.put(idSuffix, nodeInfo);
        if (EXECUTED.equals(nc.getInternalState())) {
            // regular viewable nodes need to be executed
            resultMap.put(idSuffix, entry.getValue());
        }
        for (int i = 0; i < nc.getNrInPorts() - 1; i++) {
            HiLiteHandler hiLiteHandler = ((NodeModel) entry.getValue()).getInHiLiteHandler(i);
            if (hiLiteHandler != null) {
                initialHiliteHandlerSet.add(hiLiteHandler);
            }
        }
    }
    NodeID.NodeIDSuffix pageID = NodeID.NodeIDSuffix.create(manager.getID(), subWFM.getID());
    String pageLayout = subNC.getLayoutJSONString();
    if (StringUtils.isEmpty(pageLayout)) {
        try {
            pageLayout = LayoutUtil.createDefaultLayout(resultMap);
        } catch (IOException ex) {
            LOGGER.error("Default page layout could not be created: " + ex.getMessage(), ex);
        }
    }
    Set<HiLiteHandler> knownHiLiteHandlers = new HashSet<HiLiteHandler>();
    Set<HiLiteTranslator> knownTranslators = new HashSet<HiLiteTranslator>();
    Set<HiLiteManager> knownManagers = new HashSet<HiLiteManager>();
    for (HiLiteHandler initialHandler : initialHiliteHandlerSet) {
        getHiLiteTranslators(initialHandler, knownHiLiteHandlers, knownTranslators, knownManagers);
    }
    List<HiLiteTranslator> translatorList = knownTranslators.size() > 0 ? new ArrayList<HiLiteTranslator>(knownTranslators) : null;
    List<HiLiteManager> managerList = knownManagers.size() > 0 ? new ArrayList<HiLiteManager>(knownManagers) : null;
    WizardPageContent page = new WizardPageContent(pageID, resultMap, pageLayout, translatorList, managerList);
    page.setInfoMap(infoMap);
    return page;
}
Also used : HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) NodeIDSuffix(org.knime.core.node.workflow.NodeID.NodeIDSuffix) LinkedHashMap(java.util.LinkedHashMap) NodeModel(org.knime.core.node.NodeModel) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) HiLiteTranslator(org.knime.core.node.property.hilite.HiLiteTranslator) IOException(java.io.IOException) HiLiteManager(org.knime.core.node.property.hilite.HiLiteManager) WizardNode(org.knime.core.node.wizard.WizardNode) NodeIDSuffix(org.knime.core.node.workflow.NodeID.NodeIDSuffix) WizardPageNodeInfo(org.knime.core.node.workflow.WebResourceController.WizardPageContent.WizardPageNodeInfo) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

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