Skip to content

Commit

Permalink
using new DataCell style of KNIME 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dietzc committed Oct 21, 2015
1 parent cffd64f commit 8eb477a
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 53 deletions.
7 changes: 4 additions & 3 deletions org.knime.knip.cellprofiler/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ Bundle-SymbolicName: org.knime.knip.cellprofiler;singleton:=true
Bundle-ManifestVersion: 2
Bundle-Version: 0.2.0.qualifier
Bundle-Vendor: Broad Institute / University of Konstanz
Require-Bundle: org.knime.base;bundle-version="[3.0.0,4.0.0)",
org.knime.knip.base;bundle-version="[1.4.0,1.5.0)",
Require-Bundle: org.knime.knip.base;bundle-version="[1.4.0,1.5.0)",
org.eclipse.ui;bundle-version="3.107.0",
imagej-common;bundle-version="0.12.0",
imglib2;bundle-version="2.2.0",
org.apache.commons.lang3;bundle-version="3.2.1",
scijava-common;bundle-version="2.36.0",
org.knime.knip.core;bundle-version="1.4.0",
imagej-ops;bundle-version="0.22.0"
imagej-ops;bundle-version="0.22.0",
org.knime.core;bundle-version="3.0.0",
org.knime.base;bundle-version="3.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: knip_cellprofiler.jar,
lib/knime-bridge-0.0.1-SNAPSHOT.jar,
Expand Down
11 changes: 11 additions & 0 deletions org.knime.knip.cellprofiler/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,15 @@
</renderer>
</dataValue>
</extension>
<extension
point="org.knime.core.DataType">
<DataType
cellClass="org.knime.knip.cellprofiler.data.CellProfilerCell"
factoryClass="org.knime.knip.cellprofiler.data.CellProfilerCellFactory">
<serializer
cellClass="org.knime.knip.cellprofiler.data.CellProfilerCell"
serializerClass="org.knime.knip.cellprofiler.data.CellProfilerCellSerializer">
</serializer>
</DataType>
</extension>
</plugin>
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
package org.knime.knip.cellprofiler.data;

import java.io.IOException;

import org.knime.core.data.DataCell;
import org.knime.core.data.DataCellDataInput;
import org.knime.core.data.DataCellDataOutput;
import org.knime.core.data.DataCellSerializer;
import org.knime.core.data.DataType;
import org.knime.core.data.DataValue;

/**
* {@link DataCell} storing {@link CellProfilerContent}
Expand All @@ -18,13 +12,10 @@
*/
public class CellProfilerCell extends DataCell implements CellProfilerValue {

public static final DataType TYPE = DataType
.getType(CellProfilerCell.class);
public static final DataType TYPE = DataType.getType(CellProfilerCell.class);

private static final long serialVersionUID = 6042209678689675852L;

private static final CellProfilerCellSerializer SERIALIZER = new CellProfilerCellSerializer();

private CellProfilerContent m_content;

public CellProfilerCell(final CellProfilerContent cellProfilerContent) {
Expand All @@ -34,14 +25,6 @@ public CellProfilerCell(final CellProfilerContent cellProfilerContent) {
m_content = cellProfilerContent;
}

public static final Class<? extends DataValue> getPreferredValueClass() {
return CellProfilerValue.class;
}

public static final DataCellSerializer<CellProfilerCell> getCellSerializer() {
return SERIALIZER;
}

@Override
public CellProfilerContent getCellProfilerContent() {
return m_content;
Expand All @@ -65,36 +48,4 @@ public int hashCode() {
return m_content.hashCode();
}

private static final class CellProfilerCellSerializer implements
DataCellSerializer<CellProfilerCell> {

/**
* {@inheritDoc}
*/
@Override
public void serialize(final CellProfilerCell cell,
final DataCellDataOutput output) throws IOException {
output.writeInt(0); // version
CellProfilerContent cpc = cell.getCellProfilerContent();
cpc.save(output);
}

/**
* {@inheritDoc}
*/
@Override
public CellProfilerCell deserialize(final DataCellDataInput input)
throws IOException {
input.readInt(); // version
CellProfilerContent cpc = null;
try {
cpc = CellProfilerContent.load(input);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Class not found");
}
return new CellProfilerCell(cpc);
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.knime.knip.cellprofiler.data;

import org.knime.core.data.DataCellFactory;
import org.knime.core.data.DataType;

public class CellProfilerCellFactory implements DataCellFactory {

@Override
public DataType getDataType() {
return CellProfilerCell.TYPE;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.knime.knip.cellprofiler.data;

import java.io.IOException;

import org.knime.core.data.DataCellDataInput;
import org.knime.core.data.DataCellDataOutput;
import org.knime.core.data.DataCellSerializer;

public class CellProfilerCellSerializer implements DataCellSerializer<CellProfilerCell> {

/**
* {@inheritDoc}
*/
@Override
public void serialize(final CellProfilerCell cell, final DataCellDataOutput output) throws IOException {
output.writeInt(0); // version
CellProfilerContent cpc = cell.getCellProfilerContent();
cpc.save(output);
}

/**
* {@inheritDoc}
*/
@Override
public CellProfilerCell deserialize(final DataCellDataInput input) throws IOException {
input.readInt(); // version
CellProfilerContent cpc = null;
try {
cpc = CellProfilerContent.load(input);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Class not found");
}
return new CellProfilerCell(cpc);
}

}

0 comments on commit 8eb477a

Please sign in to comment.