use of cbit.image.SourceDataInfo in project vcell by virtualcell.
the class ImageContainerPanel method refreshImage.
/**
* This method was created by a SmartGuide.
*/
public void refreshImage() {
if (getImageContainer() == null) {
getImagePaneScroller().getImagePaneView().clear();
return;
}
try {
int nX = getImageContainer().getDisplayWidth();
int nY = getImageContainer().getDisplayHeight();
int nZ = 1;
SourceDataInfo sourceData = new SourceDataInfo(SourceDataInfo.INT_RGB_TYPE, getImageContainer().getPixels(), new org.vcell.util.Extent(1, 1, 1), new org.vcell.util.Origin(0, 0, 0), getImageContainer().getDataRange(), 0, nX, 1, nY, nX, nZ, nX * nY);
getImagePaneScroller().getImagePaneModel().setSourceData(sourceData);
} catch (Exception e) {
getImagePaneScroller().getImagePaneView().clear();
e.printStackTrace(System.out);
}
}
use of cbit.image.SourceDataInfo in project vcell by virtualcell.
the class GeometryViewer method refreshSourceDataInfo.
/**
* connEtoM2: (Geometry.this --> ImagePlaneManagerPanel1.sourceDataInfo)
* @param value cbit.vcell.geometry.Geometry
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void refreshSourceDataInfo() {
if (getGeometry() == null) {
return;
}
GeometrySpec geometrySpec = getGeometry().getGeometrySpec();
if (geometrySpec.getSampledImage().isDirty()) {
return;
}
VCImage sampledImage = geometrySpec.getSampledImage().getCurrentValue();
try {
SourceDataInfo sdi = new SourceDataInfo(SourceDataInfo.INDEX_TYPE, sampledImage.getPixels(), geometrySpec.getExtent(), geometrySpec.getOrigin(), null, 0, sampledImage.getNumX(), 1, sampledImage.getNumY(), sampledImage.getNumX(), sampledImage.getNumZ(), sampledImage.getNumX() * sampledImage.getNumY());
getImagePlaneManagerPanel1().setSourceDataInfo(sdi);
} catch (ImageException e) {
e.printStackTrace();
DialogUtils.showErrorDialog(this, e.getMessage());
} catch (Exception e) {
e.printStackTrace();
DialogUtils.showErrorDialog(this, e.getMessage(), e);
}
}
use of cbit.image.SourceDataInfo in project vcell by virtualcell.
the class GeometrySummaryPanel method initGeometry.
/**
* Comment
*/
private void initGeometry(Geometry arg1) {
final boolean bSpatial = getGeometry() != null && getGeometry().getDimension() > 0;
getImagePlaneManagerPanel1().setVisible(bSpatial);
getJPanelOrigin().setVisible(bSpatial);
getJPanelSize().setVisible(bSpatial);
if (getGeometry() != null) {
try {
if (getGeometry().getGeometrySpec().getSampledImage().isDirty()) {
return;
}
VCImage vcImage = getGeometry().getGeometrySpec().getSampledImage().getCurrentValue();
byte[] pixels = vcImage.getPixels();
DisplayAdapterService das = new DisplayAdapterService();
das.setActiveScaleRange(new org.vcell.util.Range(0, 255));
das.setValueDomain(new org.vcell.util.Range(0, 255));
das.addColorModelForValues(DisplayAdapterService.createContrastColorModel(), DisplayAdapterService.createGraySpecialColors(), "Contrast");
das.setActiveColorModelID("Contrast");
int[] rgb = new int[pixels.length];
for (int i = 0; i < rgb.length; i += 1) {
rgb[i] = das.getColorFromIndex(pixels[i]);
}
SourceDataInfo sdi = new SourceDataInfo(SourceDataInfo.INT_RGB_TYPE, rgb, getGeometry().getExtent(), getGeometry().getOrigin(), new org.vcell.util.Range(0, 255), 0, vcImage.getNumX(), 1, vcImage.getNumY(), vcImage.getNumX(), vcImage.getNumZ(), vcImage.getNumX() * vcImage.getNumY());
getImagePlaneManagerPanel1().setSourceDataInfo(sdi);
} catch (Exception e) {
PopupGenerator.showErrorDialog(GeometrySummaryPanel.this, e.getMessage(), e);
}
} else {
getImagePlaneManagerPanel1().setSourceDataInfo(null);
}
}
use of cbit.image.SourceDataInfo in project vcell by virtualcell.
the class PDEDataContextPanel method calculateSourceDataInfo.
/**
* Comment
*/
private SourceDataInfo calculateSourceDataInfo(CartesianMesh mesh, double[] sdiData, VariableType sdiVarType, Range newRange) {
SourceDataInfo sdi = null;
//
if (sdiVarType.equals(VariableType.VOLUME) || sdiVarType.equals(VariableType.POSTPROCESSING)) {
// Set data to display
int yIncr = mesh.getSizeX();
int zIncr = mesh.getSizeX() * mesh.getSizeY();
sdi = new SourceDataInfo(SourceDataInfo.RAW_VALUE_TYPE, sdiData, mesh.getExtent(), mesh.getOrigin(), newRange, 0, mesh.getSizeX(), 1, mesh.getSizeY(), yIncr, mesh.getSizeZ(), zIncr);
} else if (sdiVarType.equals(VariableType.VOLUME_REGION)) {
//
double[] expandedVolumeRegionValues = new double[mesh.getSizeX() * mesh.getSizeY() * mesh.getSizeZ()];
double[] volumeRegionDataValues = sdiData;
for (int i = 0; i < expandedVolumeRegionValues.length; i += 1) {
expandedVolumeRegionValues[i] = volumeRegionDataValues[mesh.getVolumeRegionIndex(i)];
}
//
int yIncr = mesh.getSizeX();
int zIncr = mesh.getSizeX() * mesh.getSizeY();
sdi = new SourceDataInfo(SourceDataInfo.RAW_VALUE_TYPE, expandedVolumeRegionValues, mesh.getExtent(), mesh.getOrigin(), newRange, 0, mesh.getSizeX(), 1, mesh.getSizeY(), yIncr, mesh.getSizeZ(), zIncr);
} else {
// Membranes
// Create placeholder SDI with null data
sdi = new SourceDataInfo(SourceDataInfo.RAW_VALUE_TYPE, null, mesh.getExtent(), mesh.getOrigin(), newRange, 0, mesh.getSizeX(), 0, mesh.getSizeY(), 0, mesh.getSizeZ(), 0);
}
if (mesh.isChomboMesh()) {
sdi.setIsChombo(true);
} else if (mesh instanceof CartesianMeshMovingBoundary) {
sdi.setSolverDataType(SolverDataType.MBSData);
}
return sdi;
}
use of cbit.image.SourceDataInfo in project vcell by virtualcell.
the class PDEDataContextPanel method recodeDataForDomain.
public void recodeDataForDomain() {
//
if (getPdeDataContext() == null) {
return;
}
recodeDataForDomain0();
VariableType vt = getPdeDataContext().getDataIdentifier().getVariableType();
// This creates an appropriate volume data data holder for volume data types
// or creates a dummy background for membrane data types
SourceDataInfo recodedSourceDataInfo = calculateSourceDataInfo(getPdeDataContext().getCartesianMesh(), recodeDataForDomainInfo.getRecodedDataForDomain(), getPdeDataContext().getDataIdentifier().getVariableType(), recodeDataForDomainInfo.getRecodedDataRange());
getImagePlaneManagerPanel().setSourceDataInfo(recodedSourceDataInfo);
}
Aggregations