use of cbit.rmi.event.ExportEvent in project vcell by virtualcell.
the class ExportServiceImpl method fireExportStarted.
/**
* Insert the method's description here.
* Creation date: (4/1/2001 11:20:45 AM)
* @deprecated
*/
protected void fireExportStarted(long jobID, VCDataIdentifier vcdID, String format) {
User user = null;
Object object = jobRequestIDs.get(new Long(jobID));
if (object != null) {
user = (User) object;
}
ExportEvent event = new ExportEvent(this, jobID, user, vcdID, ExportEvent.EXPORT_START, format, null, null, null, null);
fireExportEvent(event);
}
use of cbit.rmi.event.ExportEvent in project vcell by virtualcell.
the class ExportServiceImpl method fireExportFailed.
/**
* Insert the method's description here.
* Creation date: (4/1/2001 11:20:45 AM)
* @deprecated
*/
protected void fireExportFailed(long jobID, VCDataIdentifier vcdID, String format, String message) {
User user = null;
Object object = jobRequestIDs.get(new Long(jobID));
if (object != null) {
user = (User) object;
}
ExportEvent event = new ExportEvent(this, jobID, user, vcdID, ExportEvent.EXPORT_FAILURE, format, message, null, null, null);
fireExportEvent(event);
}
use of cbit.rmi.event.ExportEvent in project vcell by virtualcell.
the class IMGExporter method main.
public static void main(String[] args) throws Exception {
if (args.length < 7) {
System.out.println("Usage: IMGExporter username userkey simulationkey userdatadir beginTimeIndex endTimeIndex {varName1 varName2 ...}");
System.exit(0);
}
String userName = args[0];
String userKey = args[1];
String SimulationKey = args[2];
String primaryDirStr = args[3];
int beginTimeIndex = Integer.valueOf(args[4]);
int endTimeIndex = Integer.valueOf(args[5]);
String[] varNames = new String[args.length - 6];
if (args.length > 6) {
for (int i = 6; i < args.length; i++) {
varNames[i - 6] = args[i];
}
}
PropertyLoader.loadProperties();
User user = new User(userName, new KeyValue(userKey));
VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(new KeyValue(SimulationKey), user);
VCSimulationDataIdentifier vcdID = new VCSimulationDataIdentifier(vcSimID, 0);
class PrintingExportServiceImpl extends ExportServiceImpl {
public PrintingExportServiceImpl() {
super();
}
@Override
protected void fireExportEvent(ExportEvent event) {
super.fireExportEvent(event);
System.out.println("Event type=" + event.getEventTypeID() + " JobID=" + event.getJobID() + " progress=" + event.getProgress());
}
}
ExportServiceImpl exportServiceImpl = new PrintingExportServiceImpl();
Cachetable cachetable = new Cachetable(10 * Cachetable.minute);
File primaryDir = new File(primaryDirStr);
DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(cachetable, primaryDir, null);
DataServerImpl dataServerImpl = new DataServerImpl(dataSetControllerImpl, exportServiceImpl);
double[] allTimes = dataSetControllerImpl.getDataSetTimes(vcdID);
TimeSpecs timeSpecs = new TimeSpecs(beginTimeIndex, endTimeIndex, allTimes, ExportConstants.TIME_RANGE);
VariableSpecs variableSpecs = new VariableSpecs(varNames, ExportConstants.VARIABLE_MULTI);
GeometrySpecs geometrySpecs = new GeometrySpecs(null, 0, 0, ExportConstants.GEOMETRY_SLICE);
DisplayPreferences displayPreferences = new DisplayPreferences(DisplayAdapterService.BLUERED, new Range(0, 1), DisplayAdapterService.createBlueRedSpecialColors());
MovieSpecs movieSpecs = new MovieSpecs(// /
1000.0, // /
false, // /
new DisplayPreferences[] { displayPreferences }, // /
ExportFormat.FORMAT_JPEG, // /
0, // /
1, // /
1, // /
1, ImagePaneModel.MESH_MODE, FormatSpecificSpecs.CODEC_JPEG, 1.0f, false, FormatSpecificSpecs.PARTICLE_SELECT);
ExportSpecs exportSpecs = new ExportSpecs(vcdID, ExportFormat.QUICKTIME, variableSpecs, timeSpecs, geometrySpecs, movieSpecs, "IMGExporterTest", null);
exportServiceImpl.makeRemoteFile(null, user, dataServerImpl, exportSpecs);
}
use of cbit.rmi.event.ExportEvent in project vcell by virtualcell.
the class FieldDataWindowManager method viewData.
public void viewData(final ExternalDataIdentifier eDI) {
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(getComponent());
if (eDI != null && eDI.equals(currentlyViewedEDI) && childWindowManager != null && childWindowManager.getChildWindowFromContext(eDI) != null) {
childWindowManager.getChildWindowFromContext(eDI).show();
} else {
if (currentlyViewedOutputFunctionViewer != null) {
if (getLocalRequestManager() != null && getLocalRequestManager().getAsynchMessageManager() != null) {
getLocalRequestManager().getAsynchMessageManager().removeDataJobListener(currentlyViewedOutputFunctionViewer.getPDEDataViewer());
}
if (currentlyViewedOutputFunctionViewer != null) {
currentlyViewedOutputFunctionViewer.getPDEDataViewer().getPdeDataContext().removePropertyChangeListener(this);
}
}
if (currentlyViewedOutputFunctionViewer != null) {
ChildWindow childWindow = childWindowManager.getChildWindowFromContext(eDI);
if (childWindow != null) {
childWindow.close();
}
}
currentlyViewedEDI = null;
currentlyViewedOutputFunctionViewer = null;
if (eDI == null) {
return;
}
AsynchClientTask task1 = new AsynchClientTask("retrieve data", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
ClientPDEDataContext newPDEDataContext = getPDEDataContext(eDI, new OutputContext(new AnnotatedFunction[0]));
hashTable.put("newPDEDataContext", newPDEDataContext);
}
};
AsynchClientTask task2 = new AsynchClientTask("show data", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
try {
PDEDataViewer currentlyViewedPDEDV = new PDEDataViewer();
ClientPDEDataContext newPDEDataContext = (ClientPDEDataContext) hashTable.get("newPDEDataContext");
currentlyViewedPDEDV.setPdeDataContext(newPDEDataContext);
newPDEDataContext.addPropertyChangeListener(FieldDataWindowManager.this);
getLocalRequestManager().getAsynchMessageManager().addDataJobListener(currentlyViewedPDEDV);
currentlyViewedOutputFunctionViewer = new OutputFunctionViewer(currentlyViewedPDEDV, FieldDataWindowManager.this, eDI);
DataViewerManager dvm = new DataViewerManager() {
public void dataJobMessage(DataJobEvent event) {
}
public void exportMessage(ExportEvent event) {
}
public void addDataListener(DataListener newListener) {
}
public UserPreferences getUserPreferences() {
return getRequestManager().getUserPreferences();
}
public void removeDataListener(DataListener newListener) {
}
public void startExport(Component requester, OutputContext outputContext, ExportSpecs exportSpecs) {
getLocalRequestManager().startExport(outputContext, requester, exportSpecs);
}
public void simStatusChanged(SimStatusEvent simStatusEvent) {
}
public User getUser() {
return getRequestManager().getDocumentManager().getUser();
}
public RequestManager getRequestManager() {
return FieldDataWindowManager.this.getRequestManager();
}
};
try {
currentlyViewedPDEDV.setDataViewerManager(dvm);
} catch (PropertyVetoException e) {
e.printStackTrace();
}
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(getComponent());
currentlyViewedEDI = eDI;
ChildWindow childWindow = childWindowManager.addChildWindow(currentlyViewedOutputFunctionViewer, currentlyViewedEDI, "Field Data Viewer (" + eDI.getName() + ")");
childWindow.setSize(600, 500);
childWindow.setIsCenteredOnParent();
childWindow.show();
} catch (Exception e) {
if (currentlyViewedOutputFunctionViewer != null) {
if (getLocalRequestManager() != null && getLocalRequestManager().getAsynchMessageManager() != null) {
getLocalRequestManager().getAsynchMessageManager().removeDataJobListener(currentlyViewedOutputFunctionViewer.getPDEDataViewer());
}
if (currentlyViewedOutputFunctionViewer != null) {
currentlyViewedOutputFunctionViewer.getPDEDataViewer().getPdeDataContext().removePropertyChangeListener(FieldDataWindowManager.this);
}
}
throw e;
}
}
};
ClientTaskDispatcher.dispatch(this.getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 }, false);
}
}
use of cbit.rmi.event.ExportEvent 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);
}
}
Aggregations