Search in sources :

Example 1 with NodeModel

use of org.knime.core.node.NodeModel in project knime-core by knime.

the class RepositoryFactory method createNode.

/**
 * Creates a new node repository object. Throws an exception, if this fails
 *
 * @param element Configuration element from the contributing plugin
 * @return NodeTemplate object to be used within the repository.
 * @throws IllegalArgumentException If the element is not compatible (e.g.
 *             wrong attributes, or factory class not found)
 */
@SuppressWarnings("unchecked")
public static NodeTemplate createNode(final IConfigurationElement element) {
    // Try to load the node factory class...
    NodeFactory<? extends NodeModel> factory;
    // this ensures that the class is loaded by the correct eclipse
    // classloaders
    GlobalClassCreator.lock.lock();
    try {
        factory = (NodeFactory<? extends NodeModel>) element.createExecutableExtension("factory-class");
    } catch (Throwable e) {
        throw new IllegalArgumentException("Can't load factory class for node: " + element.getAttribute("factory-class"), e);
    } finally {
        GlobalClassCreator.lock.unlock();
    }
    if (factory instanceof DynamicNodeFactory) {
        throw new IllegalArgumentException("Dynamic node factory '" + element.getAttribute("factory-class") + "'" + " registered as normal node factory.");
    }
    String pluginID = element.getDeclaringExtension().getNamespaceIdentifier();
    NodeTemplate node = new NodeTemplate((Class<NodeFactory<? extends NodeModel>>) factory.getClass(), factory.getNodeName(), pluginID);
    node.setAfterID(str(element.getAttribute("after"), ""));
    node.setType(factory.getType());
    if (!Boolean.valueOf(System.getProperty("java.awt.headless", "false"))) {
        // Load images from declaring plugin
        Image icon = ImageRepository.getIconImage(factory);
        node.setIcon(icon);
    }
    node.setCategoryPath(str(element.getAttribute("category-path"), "/"));
    return node;
}
Also used : NodeModel(org.knime.core.node.NodeModel) NodeTemplate(org.knime.workbench.repository.model.NodeTemplate) DynamicNodeTemplate(org.knime.workbench.repository.model.DynamicNodeTemplate) MetaNodeTemplate(org.knime.workbench.repository.model.MetaNodeTemplate) NodeFactory(org.knime.core.node.NodeFactory) DynamicNodeFactory(org.knime.core.node.DynamicNodeFactory) Image(org.eclipse.swt.graphics.Image) DynamicNodeFactory(org.knime.core.node.DynamicNodeFactory)

Example 2 with NodeModel

use of org.knime.core.node.NodeModel in project knime-core by knime.

the class JoinerJoinAnyTest method setUp.

/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    NodeFactory<NodeModel> dummyFactory = (NodeFactory) new VirtualParallelizedChunkPortObjectInNodeFactory(new PortType[0]);
    m_exec = new ExecutionContext(new DefaultNodeProgressMonitor(), new Node(dummyFactory), SingleNodeContainer.MemoryPolicy.CacheOnDisc, new HashMap<Integer, ContainerTable>());
}
Also used : NodeModel(org.knime.core.node.NodeModel) ExecutionContext(org.knime.core.node.ExecutionContext) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) NodeFactory(org.knime.core.node.NodeFactory) HashMap(java.util.HashMap) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) DefaultNodeProgressMonitor(org.knime.core.node.DefaultNodeProgressMonitor) Node(org.knime.core.node.Node) PortType(org.knime.core.node.port.PortType) Before(org.junit.Before)

Example 3 with NodeModel

use of org.knime.core.node.NodeModel in project knime-core by knime.

the class ConditionalBoxPlotNodeView method modelChanged.

/**
 * {@inheritDoc}
 */
@Override
protected void modelChanged() {
    NodeModel model = getNodeModel();
    if (model != null && model instanceof ConditionalBoxPlotNodeModel) {
        ConditionalBoxPlotNodeModel nodemodel = (ConditionalBoxPlotNodeModel) model;
        m_plotter.reset();
        m_plotter.setHiLiteHandler(nodemodel.getInHiLiteHandler(0));
        m_plotter.setAntialiasing(true);
        m_plotter.setDataProvider(nodemodel);
        m_plotter.updatePaintModel();
        m_plotter.fitToScreen();
        boolean hasNumColSpec = nodemodel.hasNumColSpec();
        m_plotter.setNormalizeTabCheckboxEnabled(hasNumColSpec);
        if (!hasNumColSpec) {
            m_plotter.setNormalizeTabCheckboxToolTip("New settings are available. Please reset and execute" + " the node to enable normalization.");
        } else {
            m_plotter.setToolTipText("");
        }
        m_plotter.setNormalizeTabCheckboxSelected(false);
    }
}
Also used : NodeModel(org.knime.core.node.NodeModel)

Example 4 with NodeModel

use of org.knime.core.node.NodeModel in project knime-core by knime.

the class BoxPlotNodeView method modelChanged.

/**
 * {@inheritDoc}
 */
@Override
protected void modelChanged() {
    if (getNodeModel() != null) {
        NodeModel model = getNodeModel();
        m_plotter.reset();
        m_plotter.setHiLiteHandler(model.getInHiLiteHandler(0));
        m_plotter.setAntialiasing(true);
        m_plotter.setDataProvider((DataProvider) model);
        m_plotter.updatePaintModel();
        m_plotter.fitToScreen();
    }
}
Also used : NodeModel(org.knime.core.node.NodeModel)

Example 5 with NodeModel

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

Aggregations

NodeModel (org.knime.core.node.NodeModel)35 NodeFactory (org.knime.core.node.NodeFactory)11 HashMap (java.util.HashMap)7 Node (org.knime.core.node.Node)7 ExecutionContext (org.knime.core.node.ExecutionContext)6 PortType (org.knime.core.node.port.PortType)6 Before (org.junit.Before)5 DefaultNodeProgressMonitor (org.knime.core.node.DefaultNodeProgressMonitor)5 VirtualParallelizedChunkPortObjectInNodeFactory (org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory)5 LinkedHashMap (java.util.LinkedHashMap)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 DataProvider (org.knime.base.node.viz.plotter.DataProvider)3 HiLiteHandler (org.knime.core.node.property.hilite.HiLiteHandler)3 IContainerObject (org.knime.workbench.repository.model.IContainerObject)3 IRepositoryObject (org.knime.workbench.repository.model.IRepositoryObject)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)2 Image (org.eclipse.swt.graphics.Image)2