Search in sources :

Example 31 with VariableType

use of cbit.vcell.math.VariableType in project vcell by virtualcell.

the class FieldUtilities method substituteFieldFuncNames.

public static void substituteFieldFuncNames(Hashtable<String, ExternalDataIdentifier> oldFieldFuncArgsNameNewID, Hashtable<FieldFunctionArguments, Vector<Expression>> fieldFuncArgsExpHash) throws MathException, ExpressionException {
    Enumeration<FieldFunctionArguments> keyEnum = fieldFuncArgsExpHash.keys();
    FunctionFilter functionFilter = new FieldFunctionFilter();
    while (keyEnum.hasMoreElements()) {
        Vector<Expression> value = fieldFuncArgsExpHash.get(keyEnum.nextElement());
        for (int i = 0; i < value.size(); i++) {
            Expression exp = value.elementAt(i);
            FunctionInvocation[] functionInvocations = exp.getFunctionInvocations(functionFilter);
            for (int j = 0; j < functionInvocations.length; j++) {
                Expression[] arguments = functionInvocations[j].getArguments();
                String oldFieldName = removeLiteralQuotes(arguments[0]);
                if (oldFieldFuncArgsNameNewID.containsKey(oldFieldName)) {
                    String varName = removeLiteralQuotes(arguments[1]);
                    Expression timeExp = arguments[2];
                    VariableType varType = VariableType.UNKNOWN;
                    if (arguments.length > 3) {
                        String vt = removeLiteralQuotes(arguments[3]);
                        varType = VariableType.getVariableTypeFromVariableTypeName(vt);
                    }
                    String newFieldName = oldFieldFuncArgsNameNewID.get(oldFieldName).getName();
                    FieldFunctionArguments newFieldFunctionArguments = new FieldFunctionArguments(newFieldName, varName, timeExp, varType);
                    Expression newFunctionExp = new Expression(newFieldFunctionArguments.infix());
                    exp.substituteInPlace(functionInvocations[j].getFunctionExpression(), newFunctionExp);
                }
            }
        }
    }
}
Also used : FunctionInvocation(cbit.vcell.parser.FunctionInvocation) FunctionFilter(cbit.vcell.parser.Expression.FunctionFilter) VariableType(cbit.vcell.math.VariableType) Expression(cbit.vcell.parser.Expression)

Example 32 with VariableType

use of cbit.vcell.math.VariableType in project vcell by virtualcell.

the class TestingFrameworkWindowManager method compare.

/**
 * Insert the method's description here.
 * Creation date: (1/20/2003 11:52:18 AM)
 * @return boolean
 * @param mathDesc cbit.vcell.math.MathDescription
 */
public void compare(final TestCriteriaNew testCriteria, final SimulationInfo userDefinedRegrSimInfo) {
    final String KEY_MERGEDDATAINFO = "KEY_MERGEDDATAINFO";
    final String KEY_MERGEDDATASETVIEWERCNTRLR = "KEY_MERGEDDATASETVIEWERCNTRLR";
    AsynchClientTask gatherDataTask = new AsynchClientTask("Gathering compare Dta...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            // create the merged data for the simulationInfo in testCriteria and the regression simInfo
            SimulationInfo simInfo = testCriteria.getSimInfo();
            SimulationInfo regrSimInfo = null;
            if (userDefinedRegrSimInfo != null) {
                regrSimInfo = userDefinedRegrSimInfo;
            } else {
                regrSimInfo = testCriteria.getRegressionSimInfo();
            }
            if (regrSimInfo == null) {
                return;
            }
            VCDataIdentifier vcSimId1 = new VCSimulationDataIdentifier(simInfo.getAuthoritativeVCSimulationIdentifier(), 0);
            VCDataIdentifier vcSimId2 = new VCSimulationDataIdentifier(regrSimInfo.getAuthoritativeVCSimulationIdentifier(), 0);
            User user = simInfo.getOwner();
            VCDataIdentifier[] vcIdentifierArray = new VCDataIdentifier[] { vcSimId2, vcSimId1 };
            MergedDataInfo mergedDataInfo = new MergedDataInfo(user, vcIdentifierArray, MergedDataInfo.createDefaultPrefixNames(vcIdentifierArray.length));
            hashTable.put(KEY_MERGEDDATAINFO, mergedDataInfo);
            // get the data manager and wire it up
            // 
            // get all "Data1.XXX" data identifiers ... and remove those which are functions
            // add functions of the form DIFF_XXX = (Data1.XXX - Data2.XXX) for convenience in comparing results.
            // 
            Simulation sim1 = ((ClientDocumentManager) getRequestManager().getDocumentManager()).getSimulation(simInfo);
            Simulation sim2 = ((ClientDocumentManager) getRequestManager().getDocumentManager()).getSimulation(regrSimInfo);
            boolean isSpatial = sim1.isSpatial();
            if (sim2.isSpatial() != isSpatial) {
                throw new RuntimeException("Cannot compare spatial and non-spatial data sets : " + simInfo + "& " + regrSimInfo);
            }
            DataManager mergedDataManager = getRequestManager().getDataManager(null, mergedDataInfo, isSpatial);
            DataManager data1Manager = getRequestManager().getDataManager(null, vcSimId1, isSpatial);
            DataManager data2Manager = getRequestManager().getDataManager(null, vcSimId2, isSpatial);
            Vector<AnnotatedFunction> functionList = new Vector<AnnotatedFunction>();
            AnnotatedFunction[] data1Functions = data1Manager.getFunctions();
            AnnotatedFunction[] existingFunctions = mergedDataManager.getFunctions();
            DataIdentifier[] data1Identifiers = data1Manager.getDataIdentifiers();
            DataIdentifier[] data2Identifiers = data2Manager.getDataIdentifiers();
            for (int i = 0; i < data1Identifiers.length; i++) {
                // 
                // make sure dataIdentifier is not already a function
                // 
                boolean bIsFunction = false;
                for (int j = 0; j < data1Functions.length; j++) {
                    if (data1Identifiers[i].getName().equals(data1Functions[j].getName())) {
                        bIsFunction = true;
                    }
                }
                if (bIsFunction) {
                    continue;
                }
                // 
                // make sure corresponding identifier exists in "Data2"
                // 
                boolean bIsInData2 = false;
                for (int j = 0; j < data2Identifiers.length; j++) {
                    if (data2Identifiers[j].getName().equals(data1Identifiers[i].getName())) {
                        bIsInData2 = true;
                    }
                }
                if (!bIsInData2) {
                    continue;
                }
                // 
                // create "Diff" function
                // 
                String data1Name = "Data1." + data1Identifiers[i].getName();
                String data2Name = "Data2." + data1Identifiers[i].getName();
                String functionName = "DIFF_" + data1Identifiers[i].getName();
                VariableType varType = data1Identifiers[i].getVariableType();
                Expression exp = new Expression(data1Name + "-" + data2Name);
                AnnotatedFunction newFunction = new AnnotatedFunction(functionName, exp, data1Identifiers[i].getDomain(), "", varType, FunctionCategory.OUTPUTFUNCTION);
                // 
                // make sure new "Diff" function isn't already in existing function list.
                // 
                boolean bDiffFunctionAlreadyHere = false;
                for (int j = 0; j < existingFunctions.length; j++) {
                    if (newFunction.getName().equals(existingFunctions[j].getName())) {
                        bDiffFunctionAlreadyHere = true;
                    }
                }
                if (bDiffFunctionAlreadyHere) {
                    continue;
                }
                functionList.add(newFunction);
            }
            OutputContext outputContext = null;
            if (functionList.size() > 0) {
                AnnotatedFunction[] newDiffFunctions = (AnnotatedFunction[]) BeanUtils.getArray(functionList, AnnotatedFunction.class);
                outputContext = new OutputContext(newDiffFunctions);
            }
            MergedDatasetViewerController mergedDatasetViewerCtr = getRequestManager().getMergedDatasetViewerController(outputContext, mergedDataInfo, !isSpatial);
            hashTable.put(KEY_MERGEDDATASETVIEWERCNTRLR, mergedDatasetViewerCtr);
        }
    };
    AsynchClientTask showResultsTask = new AsynchClientTask("Showing Compare Results", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            // make the viewer
            MergedDatasetViewerController mergedDatasetViewerCtr = (MergedDatasetViewerController) hashTable.get(KEY_MERGEDDATASETVIEWERCNTRLR);
            addDataListener(mergedDatasetViewerCtr);
            DataViewer viewer = mergedDatasetViewerCtr.createViewer();
            viewer.setDataViewerManager(TestingFrameworkWindowManager.this);
            addExportListener(viewer);
            VCDataIdentifier vcDataIdentifier = (MergedDataInfo) hashTable.get(KEY_MERGEDDATAINFO);
            ChildWindowManager childWindowManager = TFWFinder.findChildWindowManager(getComponent());
            ChildWindow childWindow = childWindowManager.addChildWindow(viewer, vcDataIdentifier, "Comparing ... " + vcDataIdentifier.getID());
            childWindow.pack();
            // childWindow.setSize(450, 450);
            childWindow.setIsCenteredOnParent();
            childWindow.show();
        }
    };
    ClientTaskDispatcher.dispatch(getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { gatherDataTask, showResultsTask }, false);
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) User(org.vcell.util.document.User) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DataIdentifier(cbit.vcell.simdata.DataIdentifier) ClientDocumentManager(cbit.vcell.clientdb.ClientDocumentManager) MergedDataInfo(cbit.vcell.simdata.MergedDataInfo) DataViewer(cbit.vcell.client.data.DataViewer) Vector(java.util.Vector) MergedDatasetViewerController(cbit.vcell.client.data.MergedDatasetViewerController) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) VariableType(cbit.vcell.math.VariableType) Hashtable(java.util.Hashtable) PDEDataManager(cbit.vcell.simdata.PDEDataManager) ODEDataManager(cbit.vcell.simdata.ODEDataManager) DataManager(cbit.vcell.simdata.DataManager) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) OutputContext(cbit.vcell.simdata.OutputContext) Simulation(cbit.vcell.solver.Simulation) Expression(cbit.vcell.parser.Expression) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 33 with VariableType

use of cbit.vcell.math.VariableType in project vcell by virtualcell.

the class PDEDataViewer method createMultiTimePlotHelper.

// private static class MultiTimePointPropChangeListener implements PropertyChangeListener {
// @Override
// public void propertyChange(PropertyChangeEvent evt) {
// }
// }
private MultiTimePlotHelper createMultiTimePlotHelper(final ClientPDEDataContext copyThisPDEDatacontext, final User user, DataSymbolMetadataResolver argDataSymbolMetadataResolver) throws Exception {
    final ClientPDEDataContext[] copyHolder = new ClientPDEDataContext[1];
    if (PDEDataViewer.this.isPostProcess()) {
        copyHolder[0] = PDEDataViewerPostProcess.createPostProcessPDEDataContext(copyThisPDEDatacontext);
    } else {
        copyHolder[0] = (ClientPDEDataContext) ((PDEDataManager) copyThisPDEDatacontext.getDataManager()).createNewPDEDataManager(copyThisPDEDatacontext.getVCDataIdentifier(), null).getPDEDataContext();
    }
    copyHolder[0].setVariableAndTime(copyThisPDEDatacontext.getDataIdentifier(), copyThisPDEDatacontext.getTimePoint());
    return new PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper() {

        private DataSymbolMetadataResolver dataSymbolMetadataResolver = argDataSymbolMetadataResolver;

        private ArrayList<PropertyChangeListener> myPropertyChangeHolder = new ArrayList<>();

        private ClientPDEDataContext myPdeDataContext = copyHolder[0];

        private VariableType myVariableType = copyThisPDEDatacontext.getDataIdentifier().getVariableType();

        // catch events from 'this' PDEDataViewer and pass with new source
        private PropertyChangeListener myPropertyChangeListener;

        private User myUser = user;

        // List<AnnotatedFunction> myAnnots;
        // access to anonymous outer class
        private PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper multiTimePlotHelperThis = this;

        private PDEPlotControlPanel.IdentifierListCellRenderer myListCellRenderer;

        private AnnotatedFunction[] lastAnnotatedFunctions;

        private PDEPlotControlPanel.FunctionListProvider functionListProvider = new PDEPlotControlPanel.FunctionListProvider() {

            @Override
            public List<AnnotatedFunction> getAnnotatedFunctions() {
                if (myPdeDataContext.getDataManager().getOutputContext() != null && myPdeDataContext.getDataManager().getOutputContext().getOutputFunctions() != null && myPdeDataContext.getDataManager().getOutputContext().getOutputFunctions().length > 0) {
                    return new ArrayList<>(Arrays.asList(myPdeDataContext.getDataManager().getOutputContext().getOutputFunctions()));
                }
                return new ArrayList<>();
            }
        };

        private Comparator<AnnotatedFunction> nameComparator = new Comparator<AnnotatedFunction>() {

            @Override
            public int compare(AnnotatedFunction o1, AnnotatedFunction o2) {
                return o2.getName().compareToIgnoreCase(o1.getName());
            }
        };

        @Override
        public void removeDataJobListener(DataJobListener dataJobListener) {
            PDEDataViewer.this.removeDataJobListener(dataJobListener);
        }

        @Override
        public void addDataJobListener(DataJobListener dataJobListener) {
            PDEDataViewer.this.addDataJobListener(dataJobListener);
        }

        @Override
        public User getUser() {
            return myUser;
        }

        @Override
        public PDEDataContext getPdeDatacontext() {
            return myPdeDataContext;
        }

        @Override
        public DataIdentifier[] getCopyOfDisplayedDataIdentifiers() {
            DataIdentifier[] newData = PDEDataViewer.this.getPDEPlotControlPanel1().getDataIdentifierFilter().accept(DefaultDataIdentifierFilter.ALL, functionListProvider.getAnnotatedFunctions(), myPdeDataContext.getDataIdentifiers()).toArray(new DataIdentifier[0]);
            return DataIdentifier.collectSortedSimilarDataTypes(this.getVariableType(), newData);
        }

        @Override
        public PDEPlotControlPanel.IdentifierListCellRenderer getListCellRenderer() {
            if (myListCellRenderer == null) {
                myListCellRenderer = new PDEPlotControlPanel.IdentifierListCellRenderer(functionListProvider);
            }
            return myListCellRenderer;
        }

        @Override
        public Simulation getsimulation() {
            return PDEDataViewer.this.getSimulation();
        }

        private List<AnnotatedFunction> efficiencyFilter(List<AnnotatedFunction> funcs) {
            ArrayList<AnnotatedFunction> outputfunctions = new ArrayList<>();
            Iterator<AnnotatedFunction> iter = funcs.iterator();
            while (iter.hasNext()) {
                AnnotatedFunction theFunc = iter.next();
                if ((isPostProcess() && theFunc.getFunctionType().equals(VariableType.POSTPROCESSING)) || (!isPostProcess() && !theFunc.getFunctionType().equals(VariableType.POSTPROCESSING))) {
                    outputfunctions.add(theFunc);
                }
            }
            return outputfunctions;
        }

        @Override
        public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener) {
            myPropertyChangeHolder.add(propertyChangeListener);
            if (myPropertyChangeListener == null) {
                myPropertyChangeListener = new PropertyChangeListener() {

                    @Override
                    public void propertyChange(PropertyChangeEvent evt) {
                        if (evt.getSource() == PDEDataViewer.this && evt.getPropertyName().equals(PDEDataContext.PROP_PDE_DATA_CONTEXT)) {
                            // List<AnnotatedFunction> currentOutputFunctions = functionListProvider.getAnnotatedFunctions();
                            // currentOutputFunctions = efficiencyFilter(currentOutputFunctions);
                            // currentOutputFunctions.sort(nameComparator);
                            List<AnnotatedFunction> newOutputFunctions0 = Arrays.asList(((ClientPDEDataContext) PDEDataViewer.this.getPdeDataContext()).getDataManager().getOutputContext().getOutputFunctions());
                            List<AnnotatedFunction> newOutputFunctions = efficiencyFilter(newOutputFunctions0);
                            newOutputFunctions.sort(nameComparator);
                            if (lastAnnotatedFunctions != null && Compare.isEqualOrNullStrict(lastAnnotatedFunctions, newOutputFunctions.toArray(new AnnotatedFunction[0]))) {
                                return;
                            }
                            lastAnnotatedFunctions = new AnnotatedFunction[newOutputFunctions.size()];
                            for (int i = 0; i < newOutputFunctions.size(); i++) {
                                lastAnnotatedFunctions[i] = new AnnotatedFunction(newOutputFunctions.get(i));
                            }
                            // lastAnnotatedFunctions = newOutputFunctions0.toArray(new AnnotatedFunction[0]);
                            myPdeDataContext.getDataManager().setOutputContext(new OutputContext(newOutputFunctions0.toArray(new AnnotatedFunction[0])));
                            myPdeDataContext.refreshIdentifiers();
                            for (int i = 0; i < myPropertyChangeHolder.size(); i++) {
                                myPropertyChangeHolder.get(i).propertyChange(new PropertyChangeEvent(multiTimePlotHelperThis, SimDataConstants.PROPERTY_NAME_DATAIDENTIFIERS, null, null));
                            }
                        }
                    }
                };
                PDEDataViewer.this.addPropertyChangeListener(myPropertyChangeListener);
            }
        }

        @Override
        public void removeallPropertyChangeListeners() {
            myPropertyChangeHolder.clear();
            if (myPropertyChangeListener != null) {
                PDEDataViewer.this.removePropertyChangeListener(myPropertyChangeListener);
            }
        }

        @Override
        public VariableType getVariableType() {
            return myVariableType;
        }

        // @Override
        // public void addExtraTasks(AsynchClientTask[] moreTasks) {
        // PDEDataViewer.this.addExtraTasks(moreTasks);
        // }
        @Override
        public DataSymbolMetadataResolver getDataSymbolMetadataResolver() {
            return dataSymbolMetadataResolver;
        }
    };
}
Also used : User(org.vcell.util.document.User) 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) PropertyChangeListener(java.beans.PropertyChangeListener) ArrayList(java.util.ArrayList) Comparator(java.util.Comparator) ArrayList(java.util.ArrayList) List(java.util.List) DataJobListener(cbit.rmi.event.DataJobListener) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) MultiTimePlotHelper(cbit.vcell.simdata.gui.PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper) PropertyChangeEvent(java.beans.PropertyChangeEvent) DataSymbolMetadataResolver(cbit.vcell.solver.SimulationModelInfo.DataSymbolMetadataResolver) VariableType(cbit.vcell.math.VariableType) OutputContext(cbit.vcell.simdata.OutputContext) PDEPlotControlPanel(cbit.vcell.simdata.gui.PDEPlotControlPanel) ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext)

Example 34 with VariableType

use of cbit.vcell.math.VariableType 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)

Example 35 with VariableType

use of cbit.vcell.math.VariableType 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)

Aggregations

VariableType (cbit.vcell.math.VariableType)54 CartesianMesh (cbit.vcell.solvers.CartesianMesh)17 DataAccessException (org.vcell.util.DataAccessException)15 File (java.io.File)13 ISize (org.vcell.util.ISize)12 Expression (cbit.vcell.parser.Expression)11 ExternalDataIdentifier (org.vcell.util.document.ExternalDataIdentifier)11 SinglePoint (cbit.vcell.geometry.SinglePoint)10 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)10 Domain (cbit.vcell.math.Variable.Domain)9 ExpressionException (cbit.vcell.parser.ExpressionException)9 DataIdentifier (cbit.vcell.simdata.DataIdentifier)9 ArrayList (java.util.ArrayList)9 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)8 ReservedVariable (cbit.vcell.math.ReservedVariable)8 Variable (cbit.vcell.math.Variable)8 SimDataBlock (cbit.vcell.simdata.SimDataBlock)8 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)8 Hashtable (java.util.Hashtable)8 MathException (cbit.vcell.math.MathException)7