Search in sources :

Example 6 with ProgressDialogListener

use of org.vcell.util.ProgressDialogListener in project vcell by virtualcell.

the class WorkflowJGraphProxy method workflowRun.

public void workflowRun() throws Exception {
    ClientTaskStatusSupport progress = new ClientTaskStatusSupport() {

        String message = "";

        int progress = 0;

        @Override
        public void setProgress(int progress) {
            this.progress = progress;
        }

        @Override
        public void setMessage(String message) {
            this.message = message;
        }

        @Override
        public boolean isInterrupted() {
            return false;
        }

        @Override
        public int getProgress() {
            return progress;
        }

        @Override
        public void addProgressDialogListener(ProgressDialogListener progressDialogListener) {
        }
    };
    context.getWorkflow().compute(context, progress);
}
Also used : ProgressDialogListener(org.vcell.util.ProgressDialogListener) ClientTaskStatusSupport(org.vcell.util.ClientTaskStatusSupport)

Example 7 with ProgressDialogListener

use of org.vcell.util.ProgressDialogListener in project vcell by virtualcell.

the class BNGWindowManager method runBioNetGen.

/**
 * Gets the bngOutputPanel property (cbit.vcell.client.bionetgen.BNGOutputPanel) value.
 * @return The bngOutputPanel property value.
 */
public void runBioNetGen(BNGInput bngInput) {
    // Create a hash and put in the details required to run the ClientTaskDispatcher
    Hashtable<String, Object> hash = new Hashtable<String, Object>();
    hash.put(BNG_OUTPUT_PANEL, getBngOutputPanel());
    final BNGExecutorService bngService = BNGExecutorService.getInstance(bngInput, NetworkGenerationRequirements.NoTimeoutMS);
    // Create the AsynchClientTasks : in this case, running the BioNetGen (non-swing) and then displaying the output (swing) tasks.
    AsynchClientTask[] tasksArray = new AsynchClientTask[2];
    tasksArray[0] = new RunBioNetGen(bngService);
    tasksArray[1] = new DisplayBNGOutput();
    // Dispatch the tasks using the ClientTaskDispatcher.
    ClientTaskDispatcher.dispatch(getBngOutputPanel(), hash, tasksArray, false, true, new ProgressDialogListener() {

        public void cancelButton_actionPerformed(EventObject newEvent) {
            try {
                bngService.stopBNG();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) ProgressDialogListener(org.vcell.util.ProgressDialogListener) Hashtable(java.util.Hashtable) DisplayBNGOutput(cbit.vcell.client.task.DisplayBNGOutput) EventObject(java.util.EventObject) BNGExecutorService(cbit.vcell.server.bionetgen.BNGExecutorService) RunBioNetGen(cbit.vcell.client.task.RunBioNetGen) EventObject(java.util.EventObject) IOException(java.io.IOException) UserCancelException(org.vcell.util.UserCancelException)

Example 8 with ProgressDialogListener

use of org.vcell.util.ProgressDialogListener in project vcell by virtualcell.

the class DocumentWindow method startVCellVisIt.

private void startVCellVisIt() {
    AsynchClientTask findVisitTask = new AsynchClientTask("Searching for VisIt...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            try {
                VisitSupport.launchVisTool(VCellConfiguration.getFileProperty(PropertyLoader.visitExe));
            } catch (Exception e) {
                e.printStackTrace();
                OperatingSystemInfo osi = OperatingSystemInfo.getInstance();
                String executableName = ResourceUtil.getExecutableName(VisitSupport.VISIT_EXEC_NAME, false, osi);
                File executableLocation = new ExecutableFinderDialog(DocumentWindow.this, "If VisIt is installed (from " + "https://wci.llnl.gov/codes/visit/" + ") but not in the system path, then press press '" + ExecutableFinderDialog.FIND + "' and navigate to '" + executableName + "'.\nElse please install VisIt, restart VCell, and try again").find(executableName);
                VisitSupport.launchVisTool(executableLocation);
            }
        }
    };
    ProgressDialogListener progressDialogListener = new ProgressDialogListener() {

        @Override
        public void cancelButton_actionPerformed(EventObject newEvent) {
            System.out.println(newEvent);
        }
    };
    // ClientTaskDispatcher.dispatch(requester,           hash,              tasks,                                  customDialog, bShowProgressPopup, bKnowProgress, cancelable, progressDialogListener, bInputBlocking);
    ClientTaskDispatcher.dispatch(DocumentWindow.this, new Hashtable<>(), new AsynchClientTask[] { findVisitTask }, null, true, false, true, progressDialogListener, false);
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) ProgressDialogListener(org.vcell.util.ProgressDialogListener) ExecutableFinderDialog(org.vcell.util.gui.ExecutableFinderDialog) Hashtable(java.util.Hashtable) OperatingSystemInfo(cbit.vcell.resource.OperatingSystemInfo) File(java.io.File) UtilCancelException(org.vcell.util.UtilCancelException) EventObject(java.util.EventObject)

Example 9 with ProgressDialogListener

use of org.vcell.util.ProgressDialogListener in project vcell by virtualcell.

the class ROIMultiPaintManager method smoothUnderlay.

private void smoothUnderlay() {
    AsynchClientTask smoothTask = new AsynchClientTask("Processing Image...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            ClientTaskStatusSupport localClientTaskStatusSupport = new ClientTaskStatusSupport() {

                public void setProgress(int progress) {
                    if (getClientTaskStatusSupport() != null) {
                        getClientTaskStatusSupport().setProgress((int) (.9 * progress));
                    }
                }

                public void setMessage(String message) {
                }

                public boolean isInterrupted() {
                    return (getClientTaskStatusSupport() == null ? false : getClientTaskStatusSupport().isInterrupted());
                }

                public int getProgress() {
                    return 0;
                }

                public void addProgressDialogListener(ProgressDialogListener progressDialogListener) {
                    throw new RuntimeException("not yet implemented");
                }
            };
            enhancedImageDatasetChannels = smoothImageDataset(initImageDataSetChannels, enhanceImageAmount, localClientTaskStatusSupport);
            if (localClientTaskStatusSupport.isInterrupted()) {
                throw UserCancelException.CANCEL_GENERIC;
            }
            localClientTaskStatusSupport.setMessage("Calculating histogram...");
            condensedBinsMapChannels = calculateCondensedBinsChannels0(getImageDataset());
            allPixelValuesRangeChannels = calculateAllPixelValuesRangeChannels0(getImageDataset());
        }
    };
    AsynchClientTask updateDisplayTask = new AsynchClientTask("Updating display...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            if (getClientTaskStatusSupport() != null) {
                getClientTaskStatusSupport().setProgress(100);
            }
            updateUnderlayHistogramDisplay();
        }
    };
    if (calculateCurrentSize() > 2000000) {
        // show update progress only if large
        ClientTaskDispatcher.dispatch(overlayEditorPanelJAI, new Hashtable<String, Object>(), new AsynchClientTask[] { smoothTask, updateDisplayTask }, true, true, null, true);
    } else {
        ClientTaskDispatcher.dispatch(overlayEditorPanelJAI, new Hashtable<String, Object>(), new AsynchClientTask[] { smoothTask, updateDisplayTask });
    }
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) ProgressDialogListener(org.vcell.util.ProgressDialogListener) Hashtable(java.util.Hashtable) ClientTaskStatusSupport(org.vcell.util.ClientTaskStatusSupport)

Example 10 with ProgressDialogListener

use of org.vcell.util.ProgressDialogListener in project vcell by virtualcell.

the class ImageJHelper method vcellSendImage.

public static void vcellSendImage(final Component requester, final PDEDataContext pdeDataContext, SubVolume subvolume, Hashtable<SampledCurve, int[]>[] membraneTables, String description, double[] timePoints, String[] channelDescriptions, int[] colormap) throws Exception {
    // xyz, 1 time, 1 var
    final ImageJConnection[] imageJConnectionArr = new ImageJConnection[1];
    AsynchClientTask sendImageTask = new AsynchClientTask("Send image to ImageJ...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            try {
                ImageJConnection imageJConnection = new ImageJConnection(ExternalCommunicator.IMAGEJ);
                imageJConnectionArr[0] = imageJConnection;
                imageJConnection.openConnection(VCellImageJCommands.vcellSendImage, description);
                // send size of the standard 5 dimensions in this order (width, height, nChannels, nSlices, nFrames)
                ISize xyzSize = pdeDataContext.getCartesianMesh().getISize();
                Extent extent = pdeDataContext.getCartesianMesh().getExtent();
                BasicStackDimensions basicStackDimensions = new BasicStackDimensions(xyzSize.getX(), xyzSize.getY(), xyzSize.getZ(), 1, 1);
                sendData0(imageJConnection, new HyperStackHelper(basicStackDimensions, extent, true, Float.class.getSimpleName(), null, new int[] { subvolume.getHandle() }, timePoints, channelDescriptions, colormap), pdeDataContext.getDataValues(), "'" + pdeDataContext.getVariableName() + "'" + pdeDataContext.getTimePoint());
                sendVolumeDomain0(imageJConnection, pdeDataContext.getCartesianMesh(), null, description);
                sendMembraneOutline(imageJConnection, membraneTables);
            } catch (Exception e) {
                if (e instanceof UserCancelException) {
                    throw e;
                }
                e.printStackTrace();
                hashTable.put("imagejerror", e);
            } finally {
                try {
                    if (imageJConnectionArr[0] != null) {
                        imageJConnectionArr[0].closeConnection();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    };
    ClientTaskDispatcher.dispatch(requester, new Hashtable<>(), new AsynchClientTask[] { sendImageTask }, false, true, new ProgressDialogListener() {

        @Override
        public void cancelButton_actionPerformed(EventObject newEvent) {
            if (imageJConnectionArr[0] != null) {
                imageJConnectionArr[0].closeConnection();
            }
        }
    });
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Extent(org.vcell.util.Extent) Hashtable(java.util.Hashtable) ISize(org.vcell.util.ISize) UserCancelException(org.vcell.util.UserCancelException) IOException(java.io.IOException) UserCancelException(org.vcell.util.UserCancelException) EventObject(java.util.EventObject) ProgressDialogListener(org.vcell.util.ProgressDialogListener)

Aggregations

ProgressDialogListener (org.vcell.util.ProgressDialogListener)15 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)8 File (java.io.File)8 Hashtable (java.util.Hashtable)8 ClientTaskStatusSupport (org.vcell.util.ClientTaskStatusSupport)8 EventObject (java.util.EventObject)7 UserCancelException (org.vcell.util.UserCancelException)4 LocalWorkspace (org.vcell.vmicro.workflow.data.LocalWorkspace)4 UShortImage (cbit.vcell.VirtualMicroscopy.UShortImage)3 IOException (java.io.IOException)3 ImportRawTimeSeriesFromVFrapOp (org.vcell.vmicro.op.ImportRawTimeSeriesFromVFrapOp)3 RunBioNetGen (cbit.vcell.client.task.RunBioNetGen)2 Parameter (cbit.vcell.opt.Parameter)2 BNGExecutorService (cbit.vcell.server.bionetgen.BNGExecutorService)2 PrintWriter (java.io.PrintWriter)2 DataAccessException (org.vcell.util.DataAccessException)2 ImageException (cbit.image.ImageException)1 ROI (cbit.vcell.VirtualMicroscopy.ROI)1 ChildWindowManager (cbit.vcell.client.ChildWindowManager)1 ChildWindow (cbit.vcell.client.ChildWindowManager.ChildWindow)1