Search in sources :

Example 1 with SimStatusEvent

use of cbit.vcell.client.server.SimStatusEvent in project vcell by virtualcell.

the class DisplayTimeSeriesOp method displayImageTimeSeries.

public void displayImageTimeSeries(final ImageTimeSeries<? extends Image> imageTimeSeries, final String title, final WindowListener windowListener) throws ImageException, IOException {
    try {
        System.out.println("starting to prepare data for time series viewing");
        final PDEDataViewer pdeDataViewer = new PDEDataViewer();
        DataSetControllerProvider dataSetControllerProvider;
        try {
            dataSetControllerProvider = getDataSetControllerProvider(imageTimeSeries, pdeDataViewer);
        } catch (ImageException | IOException e1) {
            e1.printStackTrace();
            throw new RuntimeException(e1.getMessage(), e1);
        }
        VCDataManager vcDataManager = new VCDataManager(dataSetControllerProvider);
        OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]);
        final VCDataIdentifier vcDataIdentifier = new VCDataIdentifier() {

            public User getOwner() {
                return new User("nouser", null);
            }

            public KeyValue getDataKey() {
                return null;
            }

            public String getID() {
                return "mydata";
            }
        };
        PDEDataManager pdeDataManager = new PDEDataManager(outputContext, vcDataManager, vcDataIdentifier);
        final ClientPDEDataContext myPdeDataContext = new ClientPDEDataContext(pdeDataManager);
        final RequestManager requestManager = new RequestManagerAdapter() {
        };
        final DataViewerManager dataViewerManager = new DataViewerManager() {

            public void dataJobMessage(DataJobEvent event) {
            }

            public void exportMessage(ExportEvent event) {
            }

            public void addDataListener(DataListener newListener) {
            }

            public UserPreferences getUserPreferences() {
                // getRequestManager().getUserPreferences();
                return null;
            }

            public void removeDataListener(DataListener newListener) {
            }

            public void startExport(Component requester, OutputContext outputContext, ExportSpecs exportSpecs) {
            // getLocalRequestManager().startExport(outputContext, FieldDataWindowManager.this, exportSpecs);
            }

            public void simStatusChanged(SimStatusEvent simStatusEvent) {
            }

            public User getUser() {
                return new User("dummy", new KeyValue("123"));
            // return getRequestManager().getDocumentManager().getUser();
            }

            public RequestManager getRequestManager() {
                return requestManager;
            }
        };
        System.out.println("ready to display time series");
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                JFrame jframe = new TopLevelFrame();
                jframe.setTitle(title);
                jframe.getContentPane().add(pdeDataViewer);
                jframe.setSize(1000, 600);
                jframe.setVisible(true);
                if (windowListener != null) {
                    jframe.addWindowListener(windowListener);
                }
                try {
                    pdeDataViewer.setDataViewerManager(dataViewerManager);
                } catch (PropertyVetoException e) {
                    e.printStackTrace();
                }
                pdeDataViewer.setPdeDataContext(myPdeDataContext);
            }
        });
    } catch (InvocationTargetException | InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ImageException(cbit.image.ImageException) User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) ExportEvent(cbit.rmi.event.ExportEvent) ExportSpecs(cbit.vcell.export.server.ExportSpecs) DataSetControllerProvider(cbit.vcell.server.DataSetControllerProvider) RequestManager(cbit.vcell.client.RequestManager) JFrame(javax.swing.JFrame) Component(java.awt.Component) VCDataManager(cbit.vcell.simdata.VCDataManager) IOException(java.io.IOException) OutputContext(cbit.vcell.simdata.OutputContext) InvocationTargetException(java.lang.reflect.InvocationTargetException) PropertyVetoException(java.beans.PropertyVetoException) RequestManagerAdapter(cbit.vcell.client.RequestManagerAdapter) DataViewerManager(cbit.vcell.client.DataViewerManager) DataJobEvent(cbit.rmi.event.DataJobEvent) PDEDataManager(cbit.vcell.simdata.PDEDataManager) SimStatusEvent(cbit.vcell.client.server.SimStatusEvent) ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext) DataListener(cbit.vcell.simdata.DataListener) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) PDEDataViewer(cbit.vcell.client.data.PDEDataViewer)

Example 2 with SimStatusEvent

use of cbit.vcell.client.server.SimStatusEvent 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);
    }
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) ExportEvent(cbit.rmi.event.ExportEvent) ExportSpecs(cbit.vcell.export.server.ExportSpecs) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) OutputContext(cbit.vcell.simdata.OutputContext) PropertyVetoException(java.beans.PropertyVetoException) DataAccessException(org.vcell.util.DataAccessException) UserCancelException(org.vcell.util.UserCancelException) PropertyVetoException(java.beans.PropertyVetoException) DataJobEvent(cbit.rmi.event.DataJobEvent) SimStatusEvent(cbit.vcell.client.server.SimStatusEvent) ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext) DataListener(cbit.vcell.simdata.DataListener) Component(java.awt.Component) PDEDataViewer(cbit.vcell.client.data.PDEDataViewer) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Aggregations

DataJobEvent (cbit.rmi.event.DataJobEvent)2 ExportEvent (cbit.rmi.event.ExportEvent)2 PDEDataViewer (cbit.vcell.client.data.PDEDataViewer)2 SimStatusEvent (cbit.vcell.client.server.SimStatusEvent)2 ExportSpecs (cbit.vcell.export.server.ExportSpecs)2 ClientPDEDataContext (cbit.vcell.simdata.ClientPDEDataContext)2 DataListener (cbit.vcell.simdata.DataListener)2 OutputContext (cbit.vcell.simdata.OutputContext)2 Component (java.awt.Component)2 PropertyVetoException (java.beans.PropertyVetoException)2 ImageException (cbit.image.ImageException)1 ChildWindow (cbit.vcell.client.ChildWindowManager.ChildWindow)1 DataViewerManager (cbit.vcell.client.DataViewerManager)1 RequestManager (cbit.vcell.client.RequestManager)1 RequestManagerAdapter (cbit.vcell.client.RequestManagerAdapter)1 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 DataSetControllerProvider (cbit.vcell.server.DataSetControllerProvider)1 PDEDataManager (cbit.vcell.simdata.PDEDataManager)1 VCDataManager (cbit.vcell.simdata.VCDataManager)1 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)1