Search in sources :

Example 11 with ChildWindowManager

use of cbit.vcell.client.ChildWindowManager in project vcell by virtualcell.

the class PDEDataViewer method showKymograph.

private void showKymograph() {
    String title = createContextTitle(PDEDataViewer.this.isPostProcess(), "Kymograph: ", getPdeDataContext(), getSimulationModelInfo(), getSimulation());
    final String INDICES_KEY = "INDICES_KEY";
    final String CROSSING_KEY = "CROSSING_KEY";
    final String ACCUM_KEY = "ACCUM_KEY";
    AsynchClientTask multiTimePlotHelperTask = new AsynchClientTask("multiTimePlotHelperTask...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            // Collect all sample curves created by user
            SpatialSelection[] spatialSelectionArr = getPDEDataContextPanel1().fetchSpatialSelections(false, true);
            final Vector<SpatialSelection> lineSSOnly = new Vector<SpatialSelection>();
            if (spatialSelectionArr != null && spatialSelectionArr.length > 0) {
                // 
                for (int i = 0; i < spatialSelectionArr.length; i++) {
                    if (spatialSelectionArr[i].isPoint() || (spatialSelectionArr[i] instanceof SpatialSelectionMembrane && ((SpatialSelectionMembrane) spatialSelectionArr[i]).getSelectionSource() instanceof cbit.vcell.geometry.SinglePoint)) {
                    } else {
                        lineSSOnly.add(spatialSelectionArr[i]);
                    }
                }
            }
            // 
            if (lineSSOnly.size() == 0) {
                throw new Exception("No line samples match DataType=" + getPdeDataContext().getDataIdentifier().getVariableType());
            }
            VariableType varType = getPdeDataContext().getDataIdentifier().getVariableType();
            int[] indices = null;
            int[] crossingMembraneIndices = null;
            double[] accumDistances = null;
            for (int i = 0; i < lineSSOnly.size(); i++) {
                if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
                    SpatialSelectionVolume ssv = (SpatialSelectionVolume) lineSSOnly.get(i);
                    SpatialSelection.SSHelper ssh = ssv.getIndexSamples(0.0, 1.0);
                    indices = ssh.getSampledIndexes();
                    crossingMembraneIndices = ssh.getMembraneIndexesInOut();
                    accumDistances = ssh.getWorldCoordinateLengths();
                } else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
                    SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) lineSSOnly.get(i);
                    SpatialSelection.SSHelper ssh = ssm.getIndexSamples();
                    indices = ssh.getSampledIndexes();
                    accumDistances = ssh.getWorldCoordinateLengths();
                }
            }
            if (indices != null) {
                hashTable.put(INDICES_KEY, indices);
            }
            if (crossingMembraneIndices != null) {
                hashTable.put(CROSSING_KEY, crossingMembraneIndices);
            }
            if (accumDistances != null) {
                hashTable.put(ACCUM_KEY, accumDistances);
            }
            MultiTimePlotHelper multiTimePlotHelper = createMultiTimePlotHelper((ClientPDEDataContext) getPdeDataContext(), getDataViewerManager().getUser(), getSimulationModelInfo().getDataSymbolMetadataResolver());
            hashTable.put(MULTITPHELPER_TASK_KEY, multiTimePlotHelper);
        }
    };
    AsynchClientTask kymographTask = new AsynchClientTask("Kymograph showing...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            KymographPanel kymographPanel = new KymographPanel(PDEDataViewer.this, title, (MultiTimePlotHelper) hashTable.get(MULTITPHELPER_TASK_KEY));
            SymbolTable symbolTable;
            if (getSimulation() != null && getSimulation().getMathDescription() != null) {
                symbolTable = getSimulation().getMathDescription();
            } else {
                symbolTable = new SimpleSymbolTable(new String[] { getPdeDataContext().getDataIdentifier().getName() });
            }
            ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(PDEDataViewer.this);
            ChildWindow childWindow = childWindowManager.addChildWindow(kymographPanel, kymographPanel, title);
            childWindow.setSize(new Dimension(700, 500));
            childWindow.show();
            kymographPanel.initDataManager(getPdeDataContext().getDataIdentifier(), getPdeDataContext().getTimePoints()[0], 1, getPdeDataContext().getTimePoints()[getPdeDataContext().getTimePoints().length - 1], (int[]) hashTable.get(INDICES_KEY), (int[]) hashTable.get(CROSSING_KEY), (double[]) hashTable.get(ACCUM_KEY), true, getPdeDataContext().getTimePoint(), symbolTable);
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { multiTimePlotHelperTask, kymographTask }, null, false, false, true, null, false);
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) SpatialSelectionMembrane(cbit.vcell.simdata.SpatialSelectionMembrane) SpatialSelection(cbit.vcell.simdata.SpatialSelection) SinglePoint(cbit.vcell.geometry.SinglePoint) Vector(java.util.Vector) MultiTimePlotHelper(cbit.vcell.simdata.gui.PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper) VariableType(cbit.vcell.math.VariableType) Hashtable(java.util.Hashtable) SimulationSymbolTable(cbit.vcell.solver.SimulationSymbolTable) SymbolTable(cbit.vcell.parser.SymbolTable) SimpleSymbolTable(cbit.vcell.parser.SimpleSymbolTable) SSHelper(cbit.vcell.simdata.SpatialSelection.SSHelper) ChildWindowManager(cbit.vcell.client.ChildWindowManager) Dimension(java.awt.Dimension) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) Point(java.awt.Point) SinglePoint(cbit.vcell.geometry.SinglePoint) DataAccessException(org.vcell.util.DataAccessException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UserCancelException(org.vcell.util.UserCancelException) SimpleSymbolTable(cbit.vcell.parser.SimpleSymbolTable) SSHelper(cbit.vcell.simdata.SpatialSelection.SSHelper) SpatialSelectionVolume(cbit.vcell.simdata.SpatialSelectionVolume)

Example 12 with ChildWindowManager

use of cbit.vcell.client.ChildWindowManager in project vcell by virtualcell.

the class PDEDataViewer method showSpatialPlot.

/**
 * Comment
 */
private void showSpatialPlot() {
    // check selections
    final SpatialSelection[] sl = getPDEDataContextPanel1().fetchSpatialSelections(false, true);
    if (sl == null) {
        PopupGenerator.showErrorDialog(this, "Nothing selected!");
        return;
    }
    for (int i = 0; i < sl.length; i++) {
        if (sl[i].isPoint()) {
            PopupGenerator.showErrorDialog(this, "One or more selections are single points - no spatial plot will be produced for those selections");
            break;
        }
    }
    final String varName = getPdeDataContext().getVariableName();
    final double timePoint = getPdeDataContext().getTimePoint();
    final SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[1];
    if (getSimulation() != null && getSimulation().getMathDescription() != null) {
        symbolTableEntries[0] = getSimulation().getMathDescription().getEntry(varName);
    }
    if (symbolTableEntries[0] == null) {
        // TODO domain
        Domain domain = null;
        symbolTableEntries[0] = new VolVariable(varName, domain);
    }
    AsynchClientTask task1 = new AsynchClientTask("Retrieving spatial series for variable '" + varName, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            // get plots, ignoring points
            PlotData[] plotDatas = new PlotData[sl.length];
            for (int i = 0; i < sl.length; i++) {
                PlotData plotData = null;
                if (getPdeDataContext() instanceof PDEDataViewerPostProcess.PostProcessDataPDEDataContext) {
                    SpatialSelectionVolume ssVolume = (SpatialSelectionVolume) sl[i];
                    SpatialSelection.SSHelper ssvHelper = ssVolume.getIndexSamples(0.0, 1.0);
                    ssvHelper.initializeValues_VOLUME(getPdeDataContext().getDataValues());
                    double[] values = ssvHelper.getSampledValues();
                    plotData = new PlotData(ssvHelper.getWorldCoordinateLengths(), values);
                } else {
                    plotData = getPdeDataContext().getLineScan(varName, timePoint, sl[i]);
                }
                plotDatas[i] = plotData;
            }
            hashTable.put("plotDatas", plotDatas);
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("Showing spatial plot for variable" + varName, AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            PlotData[] plotDatas = (PlotData[]) hashTable.get("plotDatas");
            for (PlotData plotData : plotDatas) {
                if (plotData != null) {
                    PlotPane plotPane = new PlotPane();
                    Plot2D plot2D = new Plot2D(symbolTableEntries, getSimulationModelInfo().getDataSymbolMetadataResolver(), new String[] { varName }, new PlotData[] { plotData }, new String[] { "Values along curve", "Distance (\u00b5m)", "[" + varName + "]" });
                    plotPane.setPlot2D(plot2D);
                    String title = createContextTitle(PDEDataViewer.this.isPostProcess(), "Spatial Plot:'" + varName + "' ", getPdeDataContext(), getSimulationModelInfo(), getSimulation());
                    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(PDEDataViewer.this);
                    ChildWindow childWindow = childWindowManager.addChildWindow(plotPane, plotPane, title);
                    childWindow.setIsCenteredOnParent();
                    childWindow.pack();
                    childWindow.show();
                // System.out.println("Spatial plot requesting focus.  Result is: "+childWindow.requestFocusInWindow());
                }
            }
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 }, false);
}
Also used : PlotData(cbit.plot.PlotData) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VolVariable(cbit.vcell.math.VolVariable) Hashtable(java.util.Hashtable) PostProcessDataPDEDataContext(cbit.vcell.client.data.PDEDataViewerPostProcess.PostProcessDataPDEDataContext) ChildWindowManager(cbit.vcell.client.ChildWindowManager) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) Point(java.awt.Point) SinglePoint(cbit.vcell.geometry.SinglePoint) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) SpatialSelection(cbit.vcell.simdata.SpatialSelection) SSHelper(cbit.vcell.simdata.SpatialSelection.SSHelper) SpatialSelectionVolume(cbit.vcell.simdata.SpatialSelectionVolume) PlotPane(cbit.plot.gui.PlotPane) SingleXPlot2D(cbit.plot.SingleXPlot2D) Plot2D(cbit.plot.Plot2D) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) Domain(cbit.vcell.math.Variable.Domain)

Example 13 with ChildWindowManager

use of cbit.vcell.client.ChildWindowManager in project vcell by virtualcell.

the class PDEDataViewerPostProcess method activatePanel.

public void activatePanel(boolean bActivate) {
    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(postProcessPDEDataViewer);
    ChildWindow[] childwindows = childWindowManager.getAllChildWindows();
    for (int i = 0; i < childwindows.length; i++) {
        if (childwindows[i].getTitle().startsWith(PDEDataViewer.POST_PROCESS_PREFIX)) {
            // System.out.println("showing "+childwindows[i].getTitle()+" "+childwindows[i].getContentPane().getClass().getName());
            if (bActivate) {
                childwindows[i].show();
            } else {
                childwindows[i].hide();
            }
        }
    }
    if (bActivate) {
        update();
    }
}
Also used : ChildWindowManager(cbit.vcell.client.ChildWindowManager) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow)

Example 14 with ChildWindowManager

use of cbit.vcell.client.ChildWindowManager in project vcell by virtualcell.

the class ReturnBNGOutput method validateConstraints.

private void validateConstraints(BNGOutputSpec outputSpec) {
    ValidateConstraintsPanel panel = new ValidateConstraintsPanel(owner);
    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(owner);
    ChildWindow childWindow = childWindowManager.addChildWindow(panel, panel, "Apply the new constraints?");
    // 320, 160 without the warning line
    Dimension dim = new Dimension(376, 163);
    childWindow.pack();
    panel.setChildWindow(childWindow);
    childWindow.setPreferredSize(dim);
    childWindow.showModal();
    if (panel.getButtonPushed() == ValidateConstraintsPanel.ActionButtons.Apply) {
        System.out.println("pressed APPLY from task");
        TaskCallbackMessage tcm = new TaskCallbackMessage(TaskCallbackStatus.TaskEndAdjustSimulationContextFlagsOnly, "");
        owner.setNewCallbackMessage(tcm);
        String string = "Updating the network constraints with the test values.";
        System.out.println(string);
        owner.updateOutputSpecToSimulationContext(outputSpec);
        sc.getNetworkConstraints().updateConstraintsFromTest();
        tcm = new TaskCallbackMessage(TaskCallbackStatus.Notification, string);
        sc.firePropertyChange("appendToConsole", "", tcm);
        return;
    } else {
        System.out.println("pressed CANCEL from task");
        owner.updateOutputSpecToSimulationContext(null);
        TaskCallbackMessage tcm = new TaskCallbackMessage(TaskCallbackStatus.Clean, "");
        sc.appendToConsole(tcm);
        String string = "The Network constraints were not updated with the test values.";
        tcm = new TaskCallbackMessage(TaskCallbackStatus.Notification, string);
        sc.firePropertyChange("appendToConsole", "", tcm);
        // owner.refreshInterface();
        return;
    }
}
Also used : TaskCallbackMessage(cbit.vcell.mapping.TaskCallbackMessage) ChildWindowManager(cbit.vcell.client.ChildWindowManager) Dimension(java.awt.Dimension) ValidateConstraintsPanel(org.vcell.model.rbm.gui.ValidateConstraintsPanel) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow)

Aggregations

ChildWindowManager (cbit.vcell.client.ChildWindowManager)14 ChildWindow (cbit.vcell.client.ChildWindowManager.ChildWindow)14 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)4 SinglePoint (cbit.vcell.geometry.SinglePoint)4 Dimension (java.awt.Dimension)4 Point (java.awt.Point)4 Hashtable (java.util.Hashtable)4 SpatialSelection (cbit.vcell.simdata.SpatialSelection)3 SpatialSelectionVolume (cbit.vcell.simdata.SpatialSelectionVolume)3 ImageException (cbit.image.ImageException)2 SingleXPlot2D (cbit.plot.SingleXPlot2D)2 PlotPane (cbit.plot.gui.PlotPane)2 MathMappingCallback (cbit.vcell.mapping.SimulationContext.MathMappingCallback)2 TaskCallbackMessage (cbit.vcell.mapping.TaskCallbackMessage)2 VariableType (cbit.vcell.math.VariableType)2 SimpleSymbolTable (cbit.vcell.parser.SimpleSymbolTable)2 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)2 SSHelper (cbit.vcell.simdata.SpatialSelection.SSHelper)2 SpatialSelectionMembrane (cbit.vcell.simdata.SpatialSelectionMembrane)2 MultiTimePlotHelper (cbit.vcell.simdata.gui.PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper)2