use of cbit.vcell.export.server.ExportFormat in project vcell by virtualcell.
the class ExportSettings method setSelectedFormat.
/**
* Sets the selectedFormat property (int) value.
* @param selectedFormat The new value for the property.
* @see #getSelectedFormat
*/
public void setSelectedFormat(ExportFormat selectedFormat) {
ExportFormat oldValue = fieldSelectedFormat;
fieldSelectedFormat = selectedFormat;
firePropertyChange("selectedFormat", oldValue, selectedFormat);
}
use of cbit.vcell.export.server.ExportFormat in project vcell by virtualcell.
the class FRAPStudyPanel method showMovie.
private void showMovie() {
AsynchClientTask createMovieTask = new AsynchClientTask("Buffering movie data...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
FRAPStudy fStudy = getFrapWorkspace().getWorkingFrapStudy();
if (fStudy == null) {
return;
}
if (fStudy.getMovieURLString() != null && fStudy.getMovieFileString() != null) {
hashTable.put("FrapStudy", fStudy);
return;
}
// create export specs
Simulation sim = null;
if (fStudy.getBioModel() == null || fStudy.getBioModel().getSimulations() == null || fStudy.getBioModel().getSimulations().length < 1) {
return;
} else {
sim = fStudy.getBioModel().getSimulations()[0];
}
FieldFunctionArguments[] fieldFunctionArgs = FieldUtilities.getFieldFunctionArguments(sim.getMathDescription());
FieldDataIdentifierSpec[] fieldDataIdentifierSpecs = new FieldDataIdentifierSpec[fieldFunctionArgs.length];
for (int i = 0; i < fieldDataIdentifierSpecs.length; i++) {
fieldDataIdentifierSpecs[i] = new FieldDataIdentifierSpec(fieldFunctionArgs[i], fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier());
}
ExternalDataIdentifier timeSeriesExtDataID = fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier();
ExternalDataIdentifier maskExtDataID = fStudy.getRoiExternalDataInfo().getExternalDataIdentifier();
// add sim
int jobIndex = 0;
SimulationJob simJob = new SimulationJob(sim, jobIndex, fieldDataIdentifierSpecs);
VCDataIdentifier[] dataIDs = new VCDataIdentifier[] { timeSeriesExtDataID, maskExtDataID, simJob.getVCDataIdentifier() };
VCDataIdentifier vcDataId = new MergedDataInfo(LocalWorkspace.getDefaultOwner(), dataIDs, FRAPStudy.VFRAP_DS_PREFIX);
PDEDataManager dataManager = new PDEDataManager(null, getLocalWorkspace().getVCDataManager(), vcDataId);
PDEDataContext pdeDataContext = new ClientPDEDataContext(dataManager);
ExportFormat format = ExportFormat.QUICKTIME;
String[] variableNames = new String[] { NORM_FLUOR_VAR, NORM_SIM_VAR };
VariableSpecs variableSpecs = new VariableSpecs(variableNames, ExportConstants.VARIABLE_MULTI);
// int endTimeIndex = (int)Math.round(sim.getSolverTaskDescription().getTimeBounds().getEndingTime()/((UniformOutputTimeSpec)sim.getSolverTaskDescription().getOutputTimeSpec()).getOutputTimeStep());
int endTimeIndex = getFRAPSimDataViewerPanel().getOriginalDataViewer().getPdeDataContext().getTimePoints().length - 1;
TimeSpecs timeSpecs = new TimeSpecs(0, endTimeIndex, pdeDataContext.getTimePoints(), ExportConstants.TIME_RANGE);
int geoMode = ExportConstants.GEOMETRY_SLICE;
GeometrySpecs geometrySpecs = new GeometrySpecs(null, Coordinate.Z_AXIS, 0, geoMode);
// 10s
double duration = 10000;
DisplayPreferences pref1 = new DisplayPreferences("BlueRed", new Range(0.01, 1.1), DisplayAdapterService.createBlueRedSpecialColors());
DisplayPreferences pref2 = new DisplayPreferences("BlueRed", new Range(0.01, 1.1), DisplayAdapterService.createBlueRedSpecialColors());
DisplayPreferences[] displayPref = new DisplayPreferences[] { pref1, pref2 };
int imageScale = 1;
int membraneScale = 1;
int scaleMode = ImagePaneModel.MESH_MODE;
// the default setting in MediaSettingsPanel.
int volVarMemOutlineThickness = 1;
MovieSpecs mSpec = new MovieSpecs(duration, true, displayPref, ExportFormat.QUICKTIME, ExportConstants.NO_MIRRORING, volVarMemOutlineThickness, imageScale, membraneScale, scaleMode, FormatSpecificSpecs.CODEC_JPEG, 1.0f, /*lossless*/
false, FormatSpecificSpecs.PARTICLE_NONE);
// mSpec.setViewZoom(1);
ExportSpecs exSpecs = new ExportSpecs(vcDataId, format, variableSpecs, timeSpecs, geometrySpecs, mSpec, fStudy.getName(), null);
// pass the request
ExportEvent exportEvt = ((VirtualFrapWindowManager) getFlourDataViewer().getDataViewerManager()).startExportMovie(exSpecs, outputContext, this.getClientTaskStatusSupport());
hashTable.put("ExportEvt", exportEvt);
hashTable.put("FrapStudy", fStudy);
}
};
AsynchClientTask showMovieTask = new AsynchClientTask("Showing movie ...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
ExportEvent exportEvt = (ExportEvent) hashTable.get("ExportEvt");
FRAPStudy fStudy = (FRAPStudy) hashTable.get("FrapStudy");
// show movie if successfully exported
if (exportEvt != null) {
final String fileURLString = System.getProperty(PropertyLoader.exportBaseURLProperty) + exportEvt.getJobID() + ".mov";
final String fileString = System.getProperty(PropertyLoader.exportBaseDirInternalProperty) + exportEvt.getJobID() + ".mov";
fStudy.setMovieURLString(fileURLString);
fStudy.setMovieFileString(fileString);
}
showMovieInDialog(fStudy.getMovieURLString(), fStudy.getMovieFileString());
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { createMovieTask, showMovieTask }, true, true, null, true);
}
use of cbit.vcell.export.server.ExportFormat in project vcell by virtualcell.
the class PDEExportDataPanel method startExport.
/**
* Comment
*/
private void startExport() {
if (getExportSettings1().getSelectedFormat() == ExportFormat.QUICKTIME && getJSlider1().getValue() == getJSlider2().getValue()) {
DialogUtils.showWarningDialog(this, "User selected 'begin' and 'end' export times are the same. 'Movie' export format 'begin' and 'end' times must be different");
return;
}
DisplayPreferences[] displayPreferences = null;
@SuppressWarnings("deprecation") Object[] variableSelections = getJListVariables().getSelectedValues();
boolean selectionHasVolumeVariables = false;
boolean selectionHasMembraneVariables = false;
switch(getExportSettings1().getSelectedFormat()) {
case PLY:
case QUICKTIME:
case GIF:
case FORMAT_JPEG:
case ANIMATED_GIF:
{
displayPreferences = new DisplayPreferences[variableSelections.length];
StringBuffer noScaleInfoNames = new StringBuffer();
for (int i = 0; i < displayPreferences.length; i++) {
BitSet domainValid = null;
try {
if (dataInfoProvider != null) {
DataIdentifier varSelectionDataIdnetDataIdentifier = null;
for (int j = 0; j < dataInfoProvider.getPDEDataContext().getDataIdentifiers().length; j++) {
if (dataInfoProvider.getPDEDataContext().getDataIdentifiers()[j].getName().equals(variableSelections[i])) {
varSelectionDataIdnetDataIdentifier = dataInfoProvider.getPDEDataContext().getDataIdentifiers()[j];
}
}
if (varSelectionDataIdnetDataIdentifier != null) {
selectionHasVolumeVariables = selectionHasVolumeVariables || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.VOLUME) || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.POSTPROCESSING) || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.VOLUME_REGION);
selectionHasMembraneVariables = selectionHasMembraneVariables || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.MEMBRANE) || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.MEMBRANE_REGION);
CartesianMesh cartesianMesh = dataInfoProvider.getPDEDataContext().getCartesianMesh();
int dataLength = cartesianMesh.getDataLength(varSelectionDataIdnetDataIdentifier.getVariableType());
domainValid = new BitSet(dataLength);
domainValid.clear();
for (int j = 0; j < dataLength; j++) {
if (dataInfoProvider.isDefined(varSelectionDataIdnetDataIdentifier, j)) {
domainValid.set(j);
}
}
} else {
throw new Exception("No DataIdentifer found for variable name '" + variableSelections[i] + "'");
}
}
} catch (Exception e) {
e.printStackTrace();
DialogUtils.showErrorDialog(this, "Error during domain evaluation:\n" + e.getMessage());
return;
}
displayPreferences[i] = new DisplayPreferences(getDisplayAdapterService().getDisplayPreferences((String) variableSelections[i]), domainValid);
if (!getDisplayAdapterService().hasStateID((String) variableSelections[i])) {
noScaleInfoNames.append("--- " + (String) variableSelections[i] + "\n");
}
}
break;
}
case CSV:
{
// check for membrane variables... warn for 3D geometry...
// one gets the whole nine yards by index, not generally useful... except for a few people like Boris :)
boolean mbVars = false;
DataIdentifier[] dataIDs = getPdeDataContext().getDataIdentifiers();
for (int i = 0; i < variableSelections.length; i++) {
String varName = (String) variableSelections[i];
for (int j = 0; j < dataIDs.length; j++) {
if (dataIDs[j].getName().equals(varName) && dataIDs[j].getVariableType().equals(VariableType.MEMBRANE)) {
mbVars = true;
break;
}
}
}
if (mbVars && getPdeDataContext().getCartesianMesh().getGeometryDimension() == 3 && getJRadioButtonSlice().isSelected()) {
String choice = PopupGenerator.showWarningDialog(this, getDataViewerManager().getUserPreferences(), UserMessage.warn_exportMembraneData3D, null);
if (choice.equals(UserMessage.OPTION_CANCEL)) {
// user canceled
return;
}
}
getExportSettings1().setSimulationSelector(createSimulationSelector());
getExportSettings1().setIsCSVExport(true);
break;
}
case NRRD:
case IMAGEJ:
case UCD:
case VTK_IMAGE:
case VTK_UNSTRUCT:
break;
default:
break;
}
;
if (getJRadioButtonROI().isSelected() && getROISelections().getSelectedIndex() == -1) {
PopupGenerator.showErrorDialog(this, "To export selections, you must select at least one item from the ROI selection list");
}
getExportSettings1().setTimeSpecs(new TimeSpecs(getJSlider1().getValue(), getJSlider2().getValue(), getPdeDataContext().getTimePoints(), ExportConstants.TIME_RANGE));
getExportSettings1().setDisplayPreferences(displayPreferences, Arrays.asList(variableSelections).toArray(new String[0]), viewZoom);
getExportSettings1().setSliceCount(FormatSpecificSpecs.getSliceCount(getJRadioButtonFull().isSelected(), getNormalAxis(), getPdeDataContext().getCartesianMesh()));
getExportSettings1().setImageSizeCalculationInfo(getPdeDataContext().getCartesianMesh(), getNormalAxis());
getExportSettings1().setIsSmoldyn(isSmoldyn);
ExportFormat format = getSelectedFormat();
if (format.equals(ExportFormat.PLY)) {
getExportSettings1().setFormatSpecificSpecs(new PLYSpecs(true, displayPreferences));
}
if (format.requiresFollowOn()) {
Frame theFrame = JOptionPane.getFrameForComponent(this);
boolean okToExport = getExportSettings1().showFormatSpecificDialog(theFrame, selectionHasVolumeVariables, selectionHasMembraneVariables);
if (!okToExport) {
return;
}
}
if (format.equals(ExportFormat.IMAGEJ)) {
// export nrrd for imagej direct, the we'll send to imagej from vcell client
getExportSettings1().setFormatSpecificSpecs(new RasterSpecs(ExportConstants.NRRD_SINGLE, false));
}
// determine of sim result is from local (quick) run or on server.
final OutputContext outputContext = ((ClientPDEDataContext) getPdeDataContext()).getDataManager().getOutputContext();
final ExportSpecs exportSpecs = getExportSpecs();
boolean isLocalSimResult = false;
VCDataIdentifier vcId = exportSpecs.getVCDataIdentifier();
if (vcId instanceof LocalVCDataIdentifier) {
isLocalSimResult = true;
}
// find out if smoldyn export choice is 'particle' - not available at this time
boolean isParticle = false;
if (getExportSettings1().getFormatSpecificSpecs() instanceof ImageSpecs) {
isParticle = ((ImageSpecs) getExportSettings1().getFormatSpecificSpecs()).getParticleMode() == FormatSpecificSpecs.PARTICLE_SELECT;
} else if (getExportSettings1().getFormatSpecificSpecs() instanceof MovieSpecs) {
isParticle = ((MovieSpecs) getExportSettings1().getFormatSpecificSpecs()).getParticleMode() == FormatSpecificSpecs.PARTICLE_SELECT;
}
if (isLocalSimResult && isParticle) {
DialogUtils.showErrorDialog(this, "Particle export for Smoldyn particles unavailable in local data at this time.");
return;
}
// pass the export request down the line; non-blocking call
if (!isLocalSimResult) {
// for sims that ran on server, do as before.
getDataViewerManager().startExport(this, outputContext, exportSpecs);
} else {
final String SOURCE_FILE_KEY = "SOURCE_FILE_KEY";
final String DESTINATION_FILE_KEY = "DEESTINATION_FILE_KEY";
AsynchClientTask localExportTast = new AsynchClientTask("Start Local Export", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
try {
File primaryDir = ResourceUtil.getLocalRootDir();
User usr = User.tempUser;
File usrDir = new File(primaryDir.getAbsolutePath(), usr.getName());
System.setProperty(PropertyLoader.exportBaseDirInternalProperty, usrDir.getAbsolutePath() + File.separator);
System.setProperty(PropertyLoader.exportBaseURLProperty, usrDir.toURI().toURL().toString());
DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(null, primaryDir, null);
ExportServiceImpl localExportServiceImpl = new ExportServiceImpl();
DataServerImpl dataServerImpl = new DataServerImpl(dataSetControllerImpl, localExportServiceImpl);
ExportEvent localExportEvent = dataServerImpl.makeRemoteFile(outputContext, usr, exportSpecs);
File sourceFile = new File(usrDir, new File((new URL(localExportEvent.getLocation()).getPath())).getName());
hashTable.put(SOURCE_FILE_KEY, sourceFile);
} catch (Exception e) {
throw new Exception("Unable to export local sim results data : " + e.getMessage(), e);
}
}
};
AsynchClientTask localSaveTask = new AsynchClientTask("Start Local Export", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
File sourceFile = (File) hashTable.get(SOURCE_FILE_KEY);
JFileChooser jFileChooser = new JFileChooser();
jFileChooser.setSelectedFile(new File(sourceFile.getName()));
if (jFileChooser.showSaveDialog(PDEExportDataPanel.this) == JFileChooser.APPROVE_OPTION) {
File destinationFile = jFileChooser.getSelectedFile();
if (destinationFile.exists()) {
final String OVERWRITE = "Overwrite";
final String CANCEL = "Cancel";
String response = DialogUtils.showWarningDialog(PDEExportDataPanel.this, "OK to Overwrite " + destinationFile.getAbsolutePath() + "?", new String[] { OVERWRITE, CANCEL }, OVERWRITE);
if (response == null || !response.equals(OVERWRITE)) {
return;
}
}
hashTable.put(DESTINATION_FILE_KEY, destinationFile);
}
}
};
AsynchClientTask localDeleteTempTask = new AsynchClientTask("Start Local Export", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING, false, false) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
File sourceFile = (File) hashTable.get(SOURCE_FILE_KEY);
File destinationFile = (File) hashTable.get(DESTINATION_FILE_KEY);
if (sourceFile != null && sourceFile.exists()) {
try {
if (destinationFile != null) {
copyFile(sourceFile, destinationFile);
}
} finally {
sourceFile.delete();
}
}
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { localExportTast, localSaveTask, localDeleteTempTask }, false, true, null);
}
}
use of cbit.vcell.export.server.ExportFormat in project vcell by virtualcell.
the class ExportSettings method showFormatSpecificDialog.
/**
* Comment
*/
@SuppressWarnings("incomplete-switch")
public boolean showFormatSpecificDialog(Frame reference, boolean selectionHasVolumeVars, boolean selectionHasMembraneVars) {
JDialog dialogToShow = null;
setClosedOK(false);
ExportFormat format = getSelectedFormat();
VCAssert.assertTrue(format.requiresFollowOn(), "Follow on dialog required");
switch(format) {
case CSV:
dialogToShow = getJDialogASCIISettings(reference);
break;
case QUICKTIME:
case ANIMATED_GIF:
dialogToShow = getJDialogMediaSettings(reference, getSelectedFormat(), selectionHasVolumeVars, selectionHasMembraneVars, "Movie");
break;
case GIF:
case FORMAT_JPEG:
dialogToShow = getJDialogMediaSettings(reference, getSelectedFormat(), selectionHasVolumeVars, selectionHasMembraneVars, "Image");
break;
case NRRD:
dialogToShow = getJDialogRasterSettings(reference);
break;
}
dialogToShow.pack();
BeanUtils.centerOnComponent(dialogToShow, reference);
LWJDialogDecorator.decoratorFor(dialogToShow);
// modal; blocks until OK'd or closed
dialogToShow.setVisible(true);
return isClosedOK();
}
Aggregations