use of org.sbml.jsbml.ext.spatial.Geometry in project vcell by virtualcell.
the class ImportSBMLCommand method run.
@Override
public void run() {
// Read SBML document
SBMLDocument document = null;
try {
document = SBMLReader.read(file);
} catch (XMLStreamException | IOException e) {
e.printStackTrace();
}
// Get SBML geometry
SpatialModelPlugin modelPlugin = (SpatialModelPlugin) document.getModel().getPlugin("spatial");
Geometry geometry = modelPlugin.getGeometry();
SampledField sampledField = geometry.getListOfSampledFields().get(0);
// Parse pixel values to int
String[] imgStringArray = sampledField.getSamples().split(" ");
int[] imgArray = new int[imgStringArray.length];
for (int i = 0; i < imgStringArray.length; i++) {
imgArray[i] = Integer.parseInt(imgStringArray[i]);
}
// Create the image and display
int width = sampledField.getNumSamples1();
int height = sampledField.getNumSamples2();
ArrayImg<UnsignedIntType, IntArray> img = ArrayImgs.unsignedInts(imgArray, width, height);
displayService.createDisplay(img);
}
Aggregations