Hi Laura,
Sorry - this is not something I’ve looked into in any real detail, but a few comments to try:
Firstly, in your NodeModel constructor, you have something like:
public TestNodeModel() {
super(new PortType[] { BufferedDataTable.TYPE },
new PortType[] { DistanceMeasurePortObject.TYPE });
}
Which should give you a node with a data table input and a distance measure output port - is that what you wanted? (NB, for future proofing you should use PortTypeRegistry.getInstance().getPortType(DistanceMeasurePortObject.class)
instead of the static ‘TYPE’ method)
Now you need to ensure that you implement the correct configure()
and execute()
methods - in this case you need the methods:
@Override
protected _PortObjectSpec[] configure(PortObjectSpec[] inSpecs) throws InvalidSettingsException {
return new PortObjectSpec[] { new DistanceMeasurePortSpec() };
}
(NB PortObjectSpec[]
as argument and return type) - this is a very simple test implementation which creates an empty port spec, doesnt do any column type checking or anything else - not very interesting!
You also need the correct execute()
method - PortObject[]
as argument and return type
@Override
protected PortObject[] execute(PortObject[] inObjects, ExecutionContext exec) throws Exception {
//TODO: Implement!
}
And this is where it gets complicated!
To create a DistanceMeasurePortObject
, it would appear that you need a DistanceMeasureConfig
, and a DistanceMeasure
. You also need to register your new distance measure in the plugin.xml
file as an extension (similar to how you add a new node, but the extension point is org.knime.distmatrix,distanceMeasures
), for which you also need a DistanceMeasureFactory
.
You can get at some of this using the autocomplete in Eclipse, but unfortunately there doesnt appear to be any javadoc or browsable source code. Hopefully someone from KNIME can help with this, as it would be really useful for something I started working on a while back too!
EDIT: There is some documentation here - https://www.knime.com/wiki/distance-measure-developers-guide which may also offer some pointers
Steve