Search in sources :

Example 6 with ChildWindowManager

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

the class BioModelEditorModelPanel method showDiagramView.

private void showDiagramView() {
    if (tabbedPane.getSelectedIndex() == ModelPanelTabID.reaction_diagram.ordinal()) {
        if (tabbedPane.getComponentAt(ModelPanelTabID.reaction_diagram.ordinal()) != modelPanelTabs[ModelPanelTabID.reaction_diagram.ordinal()].getComponent()) {
            ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(this);
            if (childWindowManager != null) {
                ChildWindow childWindow = childWindowManager.getChildWindowFromContext(this.reactionCartoonEditorPanel);
                if (childWindow != null) {
                    childWindow.setIsCenteredOnParent();
                    childWindow.show();
                }
            }
        }
    }
}
Also used : ChildWindowManager(cbit.vcell.client.ChildWindowManager) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow)

Example 7 with ChildWindowManager

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

the class BioModelEditorModelPanel method floatDiagramView.

private void floatDiagramView(boolean bFloating) {
    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(this);
    if (bFloating) {
        // 
        // insert dummy panel into tabbed pane, real one is floating now.
        // 
        tabbedPane.setComponentAt(ModelPanelTabID.reaction_diagram.ordinal(), new JPanel());
        // 
        // create new panel to add to client window (and hold the reactionCartoonEditorPanel)
        // 
        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());
        JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
        panel.add(p, BorderLayout.NORTH);
        panel.add(reactionCartoonEditorPanel, BorderLayout.CENTER);
        ChildWindow childWindow = childWindowManager.addChildWindow(panel, reactionCartoonEditorPanel, "model diagram");
        childWindow.setSize(500, 400);
        childWindow.setIsCenteredOnParent();
        childWindow.addChildWindowListener(new ChildWindowListener() {

            public void closing(ChildWindow childWindow) {
                reactionCartoonEditorPanel.setFloatingRequested(false);
            }
        });
        childWindow.show();
    // diagramViewInternalFrame.setFrameIcon(new ImageIcon(getClass().getResource("/images/step.gif")));
    } else {
        if (childWindowManager != null) {
            ChildWindow childWindow = childWindowManager.getChildWindowFromContext(reactionCartoonEditorPanel);
            if (childWindow != null) {
                childWindowManager.closeChildWindow(childWindow);
            }
        }
        tabbedPane.setComponentAt(ModelPanelTabID.reaction_diagram.ordinal(), modelPanelTabs[ModelPanelTabID.reaction_diagram.ordinal()].getComponent());
        tabbedPane.setSelectedIndex(ModelPanelTabID.reaction_diagram.ordinal());
    }
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) ChildWindowManager(cbit.vcell.client.ChildWindowManager) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) ChildWindowListener(cbit.vcell.client.ChildWindowListener)

Example 8 with ChildWindowManager

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

the class ODEDataViewer method showTimePlotMultipleScans.

@Override
public void showTimePlotMultipleScans(DataManager dataManager) {
    String[] selectedVariableNames = getODESolverPlotSpecificationPanel1().getSelectedVariableNames();
    if (selectedVariableNames.length == 0) {
        DialogUtils.showErrorDialog(this, "Please choose one or more variables!");
        return;
    }
    ODETimePlotMultipleScansPanel panel = new ODETimePlotMultipleScansPanel(selectedVariableNames, getSimulation(), dataManager);
    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(this);
    // ChildWindow childWindow = childWindowManager.getChildWindowFromContentPane(panel);
    ChildWindow childWindow = childWindowManager.addChildWindow(panel, panel, "");
    String titleStr = childWindow.getParent().getTitle();
    titleStr = titleStr.substring(0, titleStr.indexOf("("));
    childWindow.setTitle("Parameter scan results time plot for " + titleStr);
    childWindow.setIsCenteredOnParent();
    childWindow.setSize(600, 600);
    childWindow.show();
}
Also used : ChildWindowManager(cbit.vcell.client.ChildWindowManager) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow)

Example 9 with ChildWindowManager

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

the class PDEDataViewer method plotSpaceStats.

void plotSpaceStats(TSJobResultsSpaceStats tsjrss) {
    // Determine if Volume or Membrane
    DataIdentifier[] diArr = getPdeDataContext().getDataIdentifiers();
    boolean bVolume = true;
    for (int i = 0; i < diArr.length; i += 1) {
        if (diArr[i].getName().equals(tsjrss.getVariableNames()[0])) {
            if (diArr[i].getVariableType().equals(VariableType.MEMBRANE) || diArr[i].getVariableType().equals(VariableType.MEMBRANE_REGION)) {
                bVolume = false;
                break;
            }
        }
    }
    SymbolTableEntry[] symbolTableEntries = null;
    if (tsjrss.getVariableNames().length == 1) {
        // max.mean.min,sum
        symbolTableEntries = new SymbolTableEntry[3];
        if (getSimulation() != null && getSimulation().getMathDescription() != null) {
            symbolTableEntries[0] = getSimulation().getMathDescription().getEntry(tsjrss.getVariableNames()[0]);
        } else {
            symbolTableEntries[0] = new SimpleSymbolTable(tsjrss.getVariableNames()).getEntry(tsjrss.getVariableNames()[0]);
        }
        symbolTableEntries[1] = symbolTableEntries[0];
        symbolTableEntries[2] = symbolTableEntries[0];
    }
    SymbolTableEntry[] finalSymbolTableEntries = symbolTableEntries;
    boolean finalBVolume = bVolume;
    PlotPane plotPane = new cbit.plot.gui.PlotPane();
    plotPane.setPlot2D(new SingleXPlot2D(finalSymbolTableEntries, getSimulationModelInfo().getDataSymbolMetadataResolver(), "Time", new String[] { "Max", (tsjrss.getWeightedMean() != null ? "WeightedMean" : "UnweightedMean"), "Min" /*,
				(tsjrss.getWeightedSum() != null?"WeightedSum":"UnweightedSum")*/
    }, new double[][] { tsjrss.getTimes(), tsjrss.getMaximums()[0], (tsjrss.getWeightedMean() != null ? tsjrss.getWeightedMean()[0] : tsjrss.getUnweightedMean()[0]), tsjrss.getMinimums()[0] /*,
				(tsjrss.getWeightedSum() != null?tsjrss.getWeightedSum()[0]:tsjrss.getUnweightedSum()[0])*/
    }, new String[] { "Statistics Plot for " + tsjrss.getVariableNames()[0] + (tsjrss.getTotalSpace() != null ? " (ROI " + (finalBVolume ? "volume" : "area") + "=" + tsjrss.getTotalSpace()[0] + ")" : ""), ReservedVariable.TIME.getName(), "[" + tsjrss.getVariableNames()[0] + "]" }));
    String title = "Statistics: (" + tsjrss.getVariableNames()[0] + ") ";
    if (getSimulationModelInfo() != null) {
        title += getSimulationModelInfo().getContextName() + " " + getSimulationModelInfo().getSimulationName();
    }
    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(PDEDataViewer.this);
    ChildWindow childWindow = childWindowManager.addChildWindow(plotPane, plotPane, title);
    childWindow.setIsCenteredOnParent();
    childWindow.pack();
    childWindow.show();
}
Also used : VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) LocalVCSimulationDataIdentifier(cbit.vcell.client.ClientSimManager.LocalVCSimulationDataIdentifier) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DataIdentifier(cbit.vcell.simdata.DataIdentifier) ChildWindowManager(cbit.vcell.client.ChildWindowManager) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) Point(java.awt.Point) SinglePoint(cbit.vcell.geometry.SinglePoint) SingleXPlot2D(cbit.plot.SingleXPlot2D) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) SimpleSymbolTable(cbit.vcell.parser.SimpleSymbolTable) PlotPane(cbit.plot.gui.PlotPane)

Example 10 with ChildWindowManager

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

the class PDEDataViewer method showTimePlot.

// private static final String PROPERTY_PDEDC = "pdedc";
/**
 * Comment
 */
private void showTimePlot() {
    VariableType varType = getPdeDataContext().getDataIdentifier().getVariableType();
    // Collect all sample curves created by user
    SpatialSelection[] spatialSelectionArr = getPDEDataContextPanel1().fetchSpatialSelections(true, true);
    SpatialSelection[] spatialSelectionArr2 = null;
    if (varType.getVariableDomain().equals(VariableDomain.VARIABLEDOMAIN_VOLUME) || varType.getVariableDomain().equals(VariableDomain.VARIABLEDOMAIN_POSTPROCESSING)) {
        spatialSelectionArr2 = getPDEDataContextPanel1().fetchSpatialSelections(varType, true, true);
    } else {
        spatialSelectionArr2 = getPDEDataContextPanel1().fetchSpatialSelections(varType.equals(VariableType.MEMBRANE) ? VariableType.MEMBRANE_REGION : VariableType.MEMBRANE, true, true);
    }
    final Vector<SpatialSelection> singlePointSSOnly = new Vector<SpatialSelection>();
    final Vector<SpatialSelection> singlePointSSOnly2 = 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 SinglePoint)) {
                singlePointSSOnly.add(spatialSelectionArr[i]);
            }
            if (spatialSelectionArr2[i].isPoint() || (spatialSelectionArr2[i] instanceof SpatialSelectionMembrane && ((SpatialSelectionMembrane) spatialSelectionArr2[i]).getSelectionSource() instanceof SinglePoint)) {
                singlePointSSOnly2.add(spatialSelectionArr2[i]);
            }
        }
    }
    final String varName = getPdeDataContext().getVariableName();
    if (singlePointSSOnly.size() == 0) {
        PopupGenerator.showErrorDialog(this, "No Time sampling points match DataType=" + varType);
        return;
    }
    try {
        int[] indices = null;
        // 
        indices = new int[singlePointSSOnly.size()];
        for (int i = 0; i < singlePointSSOnly.size(); i++) {
            if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
                SpatialSelectionVolume ssv = (SpatialSelectionVolume) singlePointSSOnly.get(i);
                indices[i] = ssv.getIndex(0);
            } else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
                SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) singlePointSSOnly.get(i);
                indices[i] = ssm.getIndex(0);
            }
        }
        double[] timePoints = getPdeDataContext().getTimePoints();
        final TimeSeriesJobSpec tsjs = new TimeSeriesJobSpec(new String[] { varName }, new int[][] { indices }, null, timePoints[0], 1, timePoints[timePoints.length - 1], VCDataJobID.createVCDataJobID(getDataViewerManager().getUser(), true));
        if (!tsjs.getVcDataJobID().isBackgroundTask()) {
            throw new RuntimeException("Use getTimeSeries(...) if not a background job");
        }
        Hashtable<String, Object> hash = new Hashtable<String, Object>();
        hash.put(StringKey_timeSeriesJobSpec, tsjs);
        AsynchClientTask task1 = new TimeSeriesDataRetrievalTask("Retrieving Data for '" + varName + "'...", PDEDataViewer.this, getPdeDataContext());
        AsynchClientTask multiTimePlotHelperTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper multiTimePlotHelper = createMultiTimePlotHelper((ClientPDEDataContext) PDEDataViewer.this.getPdeDataContext(), PDEDataViewer.this.getDataViewerManager().getUser(), getSimulationModelInfo().getDataSymbolMetadataResolver());
                hashTable.put(MULTITPHELPER_TASK_KEY, multiTimePlotHelper);
            }
        };
        AsynchClientTask task2 = new AsynchClientTask("showing time plot for '" + varName + "'", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                TSJobResultsNoStats tsJobResultsNoStats = (TSJobResultsNoStats) hashTable.get(StringKey_timeSeriesJobResults);
                // Make independent Plotviewer that is unaffected by changes (time,var,paramscan) in 'this' PDEDataviewer except to pass-thru OutputContext changes
                PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper multiTimePlotHelper = (PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper) hashTable.get(MULTITPHELPER_TASK_KEY);
                try {
                    PdeTimePlotMultipleVariablesPanel pdeTimePlotPanel = new PdeTimePlotMultipleVariablesPanel(multiTimePlotHelper, singlePointSSOnly, singlePointSSOnly2, tsJobResultsNoStats);
                    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(PDEDataViewer.this);
                    String prefix = "Time Plot (" + getPDEPlotControlPanel1().getPlotVariableJList().getSelectedValue().getVariableType().getTypeName() + ") ";
                    ChildWindow childWindow = childWindowManager.addChildWindow(pdeTimePlotPanel, pdeTimePlotPanel, createContextTitle(PDEDataViewer.this.isPostProcess(), prefix, getPdeDataContext(), getSimulationModelInfo(), getSimulation()));
                    childWindow.getParent().addWindowListener(new WindowAdapter() {

                        @Override
                        public void windowClosing(WindowEvent e) {
                            super.windowClosing(e);
                            multiTimePlotHelper.removeallPropertyChangeListeners();
                        }

                        @Override
                        public void windowClosed(WindowEvent e) {
                            super.windowClosed(e);
                            multiTimePlotHelper.removeallPropertyChangeListeners();
                        }
                    });
                    // childWindow.addChildWindowListener(new ChildWindowListener() {
                    // @Override
                    // public void closing(ChildWindow childWindow) {
                    // multiTimePlotHelper.removeallPropertyChangeListeners();
                    // }
                    // @Override
                    // public void closed(ChildWindow childWindow) {
                    // multiTimePlotHelper.removeallPropertyChangeListeners();
                    // }
                    // });
                    childWindow.setSize(900, 550);
                    childWindow.setIsCenteredOnParent();
                    childWindow.show();
                } catch (Exception e) {
                    e.printStackTrace();
                    multiTimePlotHelper.removeallPropertyChangeListeners();
                }
            }
        };
        // ClientTaskDispatcher.dispatch(this, hash, new AsynchClientTask[] { task1,multiTimePlotHelperTask, task2 }, true, true, null);
        ClientTaskDispatcher.dispatch(this, hash, new AsynchClientTask[] { task1, multiTimePlotHelperTask, task2 }, null, false, false, true, null, false);
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) TimeSeriesJobSpec(org.vcell.util.document.TimeSeriesJobSpec) SpatialSelectionMembrane(cbit.vcell.simdata.SpatialSelectionMembrane) WindowAdapter(java.awt.event.WindowAdapter) SinglePoint(cbit.vcell.geometry.SinglePoint) PdeTimePlotMultipleVariablesPanel(cbit.vcell.simdata.gui.PdeTimePlotMultipleVariablesPanel) SpatialSelection(cbit.vcell.simdata.SpatialSelection) Vector(java.util.Vector) MultiTimePlotHelper(cbit.vcell.simdata.gui.PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper) VariableType(cbit.vcell.math.VariableType) Hashtable(java.util.Hashtable) ChildWindowManager(cbit.vcell.client.ChildWindowManager) 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) SpatialSelectionVolume(cbit.vcell.simdata.SpatialSelectionVolume) MultiTimePlotHelper(cbit.vcell.simdata.gui.PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper) WindowEvent(java.awt.event.WindowEvent) TSJobResultsNoStats(org.vcell.util.document.TSJobResultsNoStats)

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