use of cbit.image.DisplayAdapterService in project vcell by virtualcell.
the class PDEDataViewer method makeSurfaceMovie.
private void makeSurfaceMovie(final SurfaceCanvas surfaceCanvas, final int varTotalNumIndices, final String movieDataVarName, final DisplayAdapterService movieDAS, final VCDataIdentifier movieVCDataIdentifier) {
final SurfaceMovieSettingsPanel smsp = new SurfaceMovieSettingsPanel();
final double[] timePoints = getPdeDataContext().getTimePoints();
final int surfaceWidth = surfaceCanvas.getWidth();
final int surfaceHeight = surfaceCanvas.getHeight();
smsp.init(surfaceWidth, surfaceHeight, timePoints);
while (true) {
if (PopupGenerator.showComponentOKCancelDialog(this, smsp, "Movie Settings for var " + movieDataVarName) != JOptionPane.OK_OPTION) {
return;
}
long movieSize = (smsp.getTotalFrames() * surfaceWidth * surfaceHeight * 3);
// raw data size;
long rawDataSize = (smsp.getTotalFrames() * varTotalNumIndices * 8);
if (movieSize + rawDataSize > 50000000) {
final String YES_RESULT = "Yes";
String result = PopupGenerator.showWarningDialog(this, "Movie processing will require at least " + (movieSize + rawDataSize) / 1000000 + " mega-bytes of memory.\nMovie size will be " + (movieSize >= 1000000 ? movieSize / 1000000 + " mega-bytes." : movieSize / 1000.0 + " kilo-bytes.") + " Continue?", new String[] { YES_RESULT, "No" }, YES_RESULT);
if (result != null && result.equals(YES_RESULT)) {
break;
}
} else {
break;
}
}
final int beginTimeIndex = smsp.getBeginTimeIndex();
final int endTimeIndex = smsp.getEndTimeIndex();
final int step = smsp.getSkipParameter() + 1;
final String[] varNames = new String[] { movieDataVarName };
int[] allIndices = new int[varTotalNumIndices];
for (int i = 0; i < allIndices.length; i++) {
allIndices[i] = i;
}
final TimeSeriesJobSpec timeSeriesJobSpec = new TimeSeriesJobSpec(varNames, new int[][] { allIndices }, null, timePoints[beginTimeIndex], step, timePoints[endTimeIndex], VCDataJobID.createVCDataJobID(getDataViewerManager().getUser(), true));
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put(StringKey_timeSeriesJobSpec, timeSeriesJobSpec);
AsynchClientTask task1 = new TimeSeriesDataRetrievalTask("Retrieving data for variable '" + movieDataVarName + "'", PDEDataViewer.this, getPdeDataContext());
AsynchClientTask task2 = new AsynchClientTask("select a file", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
VCFileChooser fileChooser = new VCFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setMultiSelectionEnabled(false);
fileChooser.addChoosableFileFilter(FileFilters.FILE_FILTER_MOV);
// Set the default file filter...
fileChooser.setFileFilter(FileFilters.FILE_FILTER_MOV);
// remove all selector
fileChooser.removeChoosableFileFilter(fileChooser.getAcceptAllFileFilter());
fileChooser.setDialogTitle("Saving surface movie");
File selectedFile = null;
while (true) {
if (fileChooser.showSaveDialog(PDEDataViewer.this) != JFileChooser.APPROVE_OPTION) {
return;
}
selectedFile = fileChooser.getSelectedFile();
if (!selectedFile.getName().endsWith(".mov")) {
selectedFile = new File(selectedFile.getAbsolutePath() + ".mov");
}
if (selectedFile.exists()) {
final String YES_RESULT = "Yes";
String result = PopupGenerator.showWarningDialog(PDEDataViewer.this, "Overwrite exisitng file:\n" + selectedFile.getAbsolutePath() + "?", new String[] { YES_RESULT, "No" }, YES_RESULT);
if (result != null && result.equals(YES_RESULT)) {
break;
}
} else {
break;
}
}
hashTable.put("selectedFile", selectedFile);
}
};
AsynchClientTask task3 = new AsynchClientTask("create movie", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
File selectedFile = (File) hashTable.get("selectedFile");
if (selectedFile == null) {
return;
}
TSJobResultsNoStats tsJobResultsNoStats = (TSJobResultsNoStats) hashTable.get(StringKey_timeSeriesJobResults);
double[][] timeSeries = tsJobResultsNoStats.getTimesAndValuesForVariable(movieDataVarName);
int[] singleFrame = new int[surfaceWidth * surfaceHeight];
BufferedImage bufferedImage = new BufferedImage(surfaceWidth, surfaceHeight, BufferedImage.TYPE_3BYTE_BGR);
Graphics2D g2D = bufferedImage.createGraphics();
VideoMediaChunk[] chunks = new VideoMediaChunk[tsJobResultsNoStats.getTimes().length];
VideoMediaSample sample;
int sampleDuration = 0;
int timeScale = smsp.getFramesPerSecond();
int bitsPerPixel = 32;
DisplayAdapterService das = new DisplayAdapterService(movieDAS);
int[][] origSurfacesColors = surfaceCanvas.getSurfacesColors();
DataInfoProvider dataInfoProvider = getPDEDataContextPanel1().getDataInfoProvider();
FileDataContainerManager fileDataContainerManager = new FileDataContainerManager();
try {
try {
for (int t = 0; t < tsJobResultsNoStats.getTimes().length; t++) {
getClientTaskStatusSupport().setMessage("Creating Movie... Progress " + NumberUtils.formatNumber(100.0 * ((double) t / (double) tsJobResultsNoStats.getTimes().length), 3) + "%");
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
for (int index = 1; index < timeSeries.length; index++) {
double v = timeSeries[index][t];
if ((dataInfoProvider == null || dataInfoProvider.isDefined(index - 1)) && !Double.isNaN(v) && !Double.isInfinite(v)) {
min = Math.min(min, v);
max = Math.max(max, v);
}
}
das.setValueDomain(new Range(min, max));
if (das.getAutoScale()) {
das.setActiveScaleRange(new Range(min, max));
}
int[][] surfacesColors = new int[surfaceCanvas.getSurfaceCollection().getSurfaceCount()][];
for (int i = 0; i < surfaceCanvas.getSurfaceCollection().getSurfaceCount(); i += 1) {
Surface surface = surfaceCanvas.getSurfaceCollection().getSurfaces(i);
surfacesColors[i] = new int[surface.getPolygonCount()];
for (int j = 0; j < surface.getPolygonCount(); j += 1) {
int membIndex = meshRegionSurfaces.getMembraneIndexForPolygon(i, j);
surfacesColors[i][j] = das.getColorFromValue(timeSeries[membIndex + 1][t]);
}
}
surfaceCanvas.setSurfacesColors(surfacesColors);
surfaceCanvas.paintImmediately(0, 0, surfaceWidth, surfaceHeight);
surfaceCanvas.paint(g2D);
bufferedImage.getRGB(0, 0, surfaceWidth, surfaceHeight, singleFrame, 0, surfaceWidth);
sampleDuration = 1;
sample = FormatSpecificSpecs.getVideoMediaSample(surfaceWidth, surfaceHeight * varNames.length, sampleDuration, false, FormatSpecificSpecs.CODEC_JPEG, 1.0f, singleFrame);
chunks[t] = new VideoMediaChunk(sample, fileDataContainerManager);
}
} finally {
surfaceCanvas.setSurfacesColors(origSurfacesColors);
surfaceCanvas.paintImmediately(0, 0, surfaceWidth, surfaceHeight);
}
MediaTrack videoTrack = new MediaTrack(chunks);
MediaMovie newMovie = new MediaMovie(videoTrack, videoTrack.getDuration(), timeScale);
newMovie.addUserDataEntry(new UserDataEntry("cpy", "\u00A9" + (new GregorianCalendar()).get(Calendar.YEAR) + ", UCHC"));
newMovie.addUserDataEntry(new UserDataEntry("des", "Dataset name: " + movieVCDataIdentifier.getID()));
newMovie.addUserDataEntry(new UserDataEntry("cmt", "Time range: " + timePoints[beginTimeIndex] + " - " + timePoints[endTimeIndex]));
for (int k = 0; k < varNames.length; k++) {
// pad with 0 if k < 10
String entryType = "v" + (k < 10 ? "0" : "") + k;
UserDataEntry entry = new UserDataEntry(entryType, "Variable name: " + varNames[k] + " min: " + das.getValueDomain().getMin() + " max: " + das.getValueDomain().getMax());
newMovie.addUserDataEntry(entry);
}
getClientTaskStatusSupport().setMessage("Writing Movie to disk...");
FileOutputStream fos = new FileOutputStream(selectedFile);
DataOutputStream movieOutput = new DataOutputStream(new BufferedOutputStream(fos));
MediaMethods.writeMovie(movieOutput, newMovie);
movieOutput.close();
fos.close();
} finally {
fileDataContainerManager.closeAllAndDelete();
}
}
};
ClientTaskDispatcher.dispatch(this, hash, new AsynchClientTask[] { task1, task2, task3 }, true, true, null);
}
use of cbit.image.DisplayAdapterService in project vcell by virtualcell.
the class PDEDataViewer method updateDataValueSurfaceViewer0.
// private AsynchClientTask[] getDataVlaueSurfaceViewerTasks(){
// AsynchClientTask createDataValueSurfaceViewerTask = new AsynchClientTask("Create surface viewer...",AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
// @Override
// public void run(Hashtable<String, Object> hashTable) throws Exception {
// if(getDataValueSurfaceViewer().getSurfaceCollectionDataInfoProvider() == null){
// createDataValueSurfaceViewer(getClientTaskStatusSupport());
// }
// }
// };
//
// AsynchClientTask updateDataValueSurfaceViewerTask = new AsynchClientTask("Update surface viewer...",AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
// @Override
// public void run(Hashtable<String, Object> hashTable) throws Exception {
// updateDataValueSurfaceViewer0();
// }
// };
//
// AsynchClientTask resetDataValueSurfaceViewerTask = new AsynchClientTask("Reset tab...",AsynchClientTask.TASKTYPE_SWING_NONBLOCKING,false,false) {
// @Override
// public void run(Hashtable<String, Object> hashTable) throws Exception {
// if(getDataValueSurfaceViewer().getSurfaceCollectionDataInfoProvider() == null){
// viewDataTabbedPane.setSelectedIndex(0);
// }
// }
// };
// return new AsynchClientTask[] {createDataValueSurfaceViewerTask,updateDataValueSurfaceViewerTask,resetDataValueSurfaceViewerTask};
// }
// private Timer dataValueSurfaceTimer;
// //private boolean bPdeIsParamScan=false;
// private void updateDataValueSurfaceViewer(){
// // if((dataValueSurfaceTimer = ClientTaskDispatcher.getBlockingTimer(this,getPdeDataContext(),null,dataValueSurfaceTimer,new ActionListener() {@Override public void actionPerformed(ActionEvent e2) {updateDataValueSurfaceViewer();}}))!=null){
// // return;
// // }
// if(bSkipSurfaceCalc){
// return;
// }
// if(getDataValueSurfaceViewer().getSurfaceCollectionDataInfoProvider() == null){
// if((dataValueSurfaceTimer = ClientTaskDispatcher.getBlockingTimer(this,getPdeDataContext(),null,dataValueSurfaceTimer,new ActionListener() {@Override public void actionPerformed(ActionEvent e2) {updateDataValueSurfaceViewer();}}))!=null){
// return;
// }
// ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), getDataVlaueSurfaceViewerTasks(),true,true,null);
// }else{
// try{
// updateDataValueSurfaceViewer0();
// }catch(Exception e){
// e.printStackTrace();
// DialogUtils.showErrorDialog(this, e.getMessage());
// }
// }
// }
/**
* Insert the method's description here.
* Creation date: (9/25/2005 2:00:05 PM)
*/
private void updateDataValueSurfaceViewer0() {
// viewDataTabbedPane.addTab(CurrentView.SURFACE_VIEW.title, getDataValueSurfaceViewer());
if (viewDataTabbedPane.getSelectedIndex() != CurrentView.SURFACE_VIEW.ordinal()) {
return;
}
// SurfaceColors and DataValues
if (getDataValueSurfaceViewer().getSurfaceCollectionDataInfo() == null) {
// happens with PostProcessingImageData version of PDEDataViewer
return;
}
SurfaceCollection surfaceCollection = getDataValueSurfaceViewer().getSurfaceCollectionDataInfo().getSurfaceCollection();
DisplayAdapterService das = getPDEDataContextPanel1().getdisplayAdapterService1();
final int[][] surfaceColors = new int[surfaceCollection.getSurfaceCount()][];
final double[][] surfaceDataValues = new double[surfaceCollection.getSurfaceCount()][];
boolean bMembraneVariable = getPdeDataContext().getDataIdentifier().getVariableType().equals(VariableType.MEMBRANE);
RecodeDataForDomainInfo recodeDataForDomainInfo = getPDEDataContextPanel1().getRecodeDataForDomainInfo();
double[] membraneValues = (recodeDataForDomainInfo.isRecoded() ? recodeDataForDomainInfo.getRecodedDataForDomain() : getPdeDataContext().getDataValues());
for (int i = 0; i < surfaceCollection.getSurfaceCount(); i += 1) {
Surface surface = surfaceCollection.getSurfaces(i);
surfaceColors[i] = new int[surface.getPolygonCount()];
surfaceDataValues[i] = new double[surface.getPolygonCount()];
for (int j = 0; j < surface.getPolygonCount(); j += 1) {
int membraneIndexForPolygon = meshRegionSurfaces.getMembraneIndexForPolygon(i, j);
if (bMembraneVariable) {
surfaceDataValues[i][j] = membraneValues[membraneIndexForPolygon];
} else {
// get membrane region index from membrane index
surfaceDataValues[i][j] = membraneValues[getPdeDataContext().getCartesianMesh().getMembraneRegionIndex(membraneIndexForPolygon)];
}
surfaceColors[i][j] = das.getColorFromValue(surfaceDataValues[i][j]);
}
}
DataValueSurfaceViewer.SurfaceCollectionDataInfoProvider svdp = new DataValueSurfaceViewer.SurfaceCollectionDataInfoProvider() {
private DisplayAdapterService updatedDAS = new DisplayAdapterService(getPDEDataContextPanel1().getdisplayAdapterService1());
private String updatedVariableName = getPdeDataContext().getVariableName();
private double updatedTimePoint = getPdeDataContext().getTimePoint();
private double[] updatedVariableValues = getPdeDataContext().getDataValues();
private VCDataIdentifier updatedVCDataIdentifier = getPdeDataContext().getVCDataIdentifier();
public void makeMovie(SurfaceCanvas surfaceCanvas) {
makeSurfaceMovie(surfaceCanvas, updatedVariableValues.length, updatedVariableName, updatedDAS, updatedVCDataIdentifier);
}
public double getValue(int surfaceIndex, int polygonIndex) {
return updatedVariableValues[meshRegionSurfaces.getMembraneIndexForPolygon(surfaceIndex, polygonIndex)];
}
public String getValueDescription(int surfaceIndex, int polygonIndex) {
return updatedVariableName;
}
public int[][] getSurfacePolygonColors() {
return surfaceColors;
}
public Coordinate getCentroid(int surfaceIndex, int polygonIndex) {
return getPdeDataContext().getCartesianMesh().getMembraneElements()[meshRegionSurfaces.getMembraneIndexForPolygon(surfaceIndex, polygonIndex)].getCentroid();
}
public float getArea(int surfaceIndex, int polygonIndex) {
return getPdeDataContext().getCartesianMesh().getMembraneElements()[meshRegionSurfaces.getMembraneIndexForPolygon(surfaceIndex, polygonIndex)].getArea();
}
public Vect3d getNormal(int surfaceIndex, int polygonIndex) {
return getPdeDataContext().getCartesianMesh().getMembraneElements()[meshRegionSurfaces.getMembraneIndexForPolygon(surfaceIndex, polygonIndex)].getNormal();
}
public int getMembraneIndex(int surfaceIndex, int polygonIndex) {
return meshRegionSurfaces.getMembraneIndexForPolygon(surfaceIndex, polygonIndex);
}
public Color getROIHighlightColor() {
return new Color(getPDEDataContextPanel1().getdisplayAdapterService1().getSpecialColors()[cbit.image.DisplayAdapterService.FOREGROUND_HIGHLIGHT_COLOR_OFFSET]);
}
@Override
public boolean isMembrIndexInVarDomain(int membrIndex) {
return (getPDEDataContextPanel1().getRecodeDataForDomainInfo() != null ? getPDEDataContextPanel1().getRecodeDataForDomainInfo().isIndexInDomain(membrIndex) : true);
}
// public void showComponentInFrame(Component comp,String title){
// PDEDataViewer.this.showComponentInFrame(comp,title);
// }
public void plotTimeSeriesData(int[][] indices, boolean bAllTimes, boolean bTimeStats, boolean bSpaceStats) throws DataAccessException {
double[] timePoints = getPdeDataContext().getTimePoints();
double beginTime = (bAllTimes ? timePoints[0] : updatedTimePoint);
double endTime = (bAllTimes ? timePoints[timePoints.length - 1] : beginTime);
String[] varNames = new String[indices.length];
for (int i = 0; i < varNames.length; i += 1) {
varNames[i] = updatedVariableName;
}
TimeSeriesJobSpec timeSeriesJobSpec = new TimeSeriesJobSpec(varNames, indices, beginTime, 1, endTime, bSpaceStats, bTimeStats, VCDataJobID.createVCDataJobID(getDataViewerManager().getUser(), true));
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put(StringKey_timeSeriesJobSpec, timeSeriesJobSpec);
AsynchClientTask task1 = new TimeSeriesDataRetrievalTask("Retrieve data", PDEDataViewer.this, getPdeDataContext());
AsynchClientTask task2 = new AsynchClientTask("Showing surface", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
TSJobResultsSpaceStats tsJobResultsSpaceStats = (TSJobResultsSpaceStats) hashTable.get(StringKey_timeSeriesJobResults);
plotSpaceStats(tsJobResultsSpaceStats);
}
};
ClientTaskDispatcher.dispatch(PDEDataViewer.this, hash, new AsynchClientTask[] { task1, task2 }, true, true, null);
}
};
getDataValueSurfaceViewer().setSurfaceCollectionDataInfoProvider(svdp);
}
use of cbit.image.DisplayAdapterService in project vcell by virtualcell.
the class PDEDataContextPanel method colorMembraneCurvesPrivate.
/**
* Insert the method's description here.
* Creation date: (10/26/00 4:49:39 PM)
*/
private void colorMembraneCurvesPrivate(java.util.Hashtable<SampledCurve, int[]> curvesAndMembraneIndexes, MeshDisplayAdapter meshDisplayAdapter) {
DisplayAdapterService das = getdisplayAdapterService1();
if (curvesAndMembraneIndexes != null) {
java.util.Enumeration<SampledCurve> keysEnum = curvesAndMembraneIndexes.keys();
while (keysEnum.hasMoreElements()) {
SampledCurve curve = keysEnum.nextElement();
int[] membraneIndexes = curvesAndMembraneIndexes.get(curve);
double[] membraneValues = null;
if (membraneIndexes != null && getPdeDataContext().getDataValues() != null && getPdeDataContext().getDataIdentifier() != null) {
membraneValues = meshDisplayAdapter.getDataValuesForMembraneIndexes(membraneIndexes, (recodeDataForDomainInfo.isRecoded ? recodeDataForDomainInfo.getRecodedDataForDomain() : getPdeDataContext().getDataValues()), getPdeDataContext().getDataIdentifier().getVariableType());
}
if (membraneValues != null) {
int[] valueColors = new int[membraneValues.length];
for (int i = 0; i < membraneValues.length; i += 1) {
valueColors[i] = das.getColorFromValue(membraneValues[i]);
}
getImagePlaneManagerPanel().getCurveRenderer().renderPropertySegmentColors(curve, valueColors);
getImagePlaneManagerPanel().getCurveRenderer().renderPropertySegmentIndexes(curve, membraneIndexes);
} else {
getImagePlaneManagerPanel().getCurveRenderer().renderPropertySegmentColors(curve, null);
getImagePlaneManagerPanel().getCurveRenderer().renderPropertySegmentIndexes(curve, null);
}
}
}
}
use of cbit.image.DisplayAdapterService in project vcell by virtualcell.
the class RasterExporter method makePLYWithTexData.
public ExportOutput[] makePLYWithTexData(OutputContext outputContext, JobRequest jobRequest, User user, DataServerImpl dataServerImpl, ExportSpecs exportSpecs, FileDataContainerManager fileDataContainerManager) throws Exception {
String simID = exportSpecs.getVCDataIdentifier().getID();
VCDataIdentifier vcdID = exportSpecs.getVCDataIdentifier();
cbit.vcell.solvers.CartesianMesh mesh = dataServerImpl.getMesh(user, vcdID);
TimeSpecs timeSpecs = exportSpecs.getTimeSpecs();
VariableSpecs variableSpecs = exportSpecs.getVariableSpecs();
Vector<ExportOutput> exportOutV = new Vector<ExportOutput>();
RegionImage regionImage = MeshDisplayAdapter.generateRegionImage(mesh, null);
PLYSpecs plySpecs = (PLYSpecs) exportSpecs.getFormatSpecificSpecs();
DisplayPreferences[] displayPreferences = plySpecs.getDisplayPreferences();
// BitSet bInDomain = null;
// String variableName = variableSpecs.getVariableNames()[0];
// Domain varDomain = null;
// DataIdentifier[] dataIdentifiers = dataServerImpl.getDataIdentifiers(outputContext, user, vcdID);
// for (int i = 0; i < dataIdentifiers.length; i++) {
// //dataIdentifier.getDomain();
// if(dataIdentifiers[i].getName().equals(variableName)){
// varDomain = dataIdentifiers[i].getDomain();
// break;
// }
// }
// MembraneElement membraneElement = mesh.getMembraneElements()[faceIndex];
// String memSubdomainName = (varDomain==null?null:mesh.getMembraneSubdomainNamefromMemIndex(faceIndex));
// boolean bInDomain = (varDomain==null?true:varDomain.getName().equals(memSubdomainName));
DisplayAdapterService das = new DisplayAdapterService();
StringWriter stringWriter = new StringWriter();
PolyTexHelper imgResults = writeStanfordPolygonTex(regionImage, stringWriter, /*,bInDomain*/
mesh);
// mesh
ExportOutput exportOut = new ExportOutput(true, ".ply", simID.toString(), "_memb", fileDataContainerManager);
fileDataContainerManager.append(exportOut.getFileDataContainerID(), stringWriter.toString());
exportOutV.add(exportOut);
// special neighbor annotation image
ExportOutput textImagetOut0 = new ExportOutput(true, ".png", simID.toString(), "_membAnnot", fileDataContainerManager);
fileDataContainerManager.append(textImagetOut0.getFileDataContainerID(), imgResults.specialNeighborImage);
exportOutV.add(textImagetOut0);
for (int varNameIndex = 0; varNameIndex < variableSpecs.getVariableNames().length; varNameIndex++) {
if (das.fetchColorModel(displayPreferences[varNameIndex].getColorMode()) == null) {
if (displayPreferences[varNameIndex].getColorMode().equals(DisplayAdapterService.GRAY)) {
das.addColorModelForValues(DisplayAdapterService.createGrayColorModel(), DisplayAdapterService.createBlueRedSpecialColors(), displayPreferences[varNameIndex].getColorMode());
} else {
das.addColorModelForValues(DisplayAdapterService.createBlueRedColorModel(), DisplayAdapterService.createGraySpecialColors(), displayPreferences[varNameIndex].getColorMode());
// das.setActiveColorModelID("Contrast");
}
}
// BitSet domainValid = (displayPreferences[varNameIndex]==null?null:(displayPreferences[varNameIndex].getDomainValid()==null?null:displayPreferences[varNameIndex].getDomainValid()));
ExportSpecs.setupDisplayAdapterService(displayPreferences[varNameIndex], das, displayPreferences[varNameIndex].getScaleSettings());
for (int j = timeSpecs.getBeginTimeIndex(); j <= timeSpecs.getEndTimeIndex(); j++) {
BufferedImage image = createTextureImage(imgResults.imageSideSize);
int[] imgBuffer = ((DataBufferInt) (image.getRaster().getDataBuffer())).getData();
Arrays.fill(imgBuffer, Integer.MAX_VALUE);
SimDataBlock simDataBlock = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[varNameIndex], timeSpecs.getAllTimes()[j]);
for (int k = 0; k < imgResults.dataIndexes.length; k++) {
if (imgBuffer[k] != Integer.MAX_VALUE) {
System.out.println("texture pixel used twice");
}
double avgVal = 0;
for (int l = 0; l < imgResults.dataIndexes[k].length; l++) {
avgVal += simDataBlock.getData()[imgResults.dataIndexes[k][l]];
}
imgBuffer[k] = das.getColorFromValue(avgVal / imgResults.dataIndexes[k].length);
}
byte[] pngImage = flipPNG(image);
ExportOutput textImagetOut = new ExportOutput(true, ".png", simID.toString(), "_memb_" + variableSpecs.getVariableNames()[varNameIndex] + "_" + j, fileDataContainerManager);
fileDataContainerManager.append(textImagetOut.getFileDataContainerID(), pngImage);
exportOutV.add(textImagetOut);
}
}
ExportOutput[] exportOutputArr = exportOutV.toArray(new ExportOutput[0]);
return exportOutputArr;
}
use of cbit.image.DisplayAdapterService 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);
}
}
Aggregations