Search in sources :

Example 61 with MathModel

use of cbit.vcell.mathmodel.MathModel in project vcell by virtualcell.

the class SaveDocument method run.

/**
 * Insert the method's description here.
 * Creation date: (5/31/2004 6:04:14 PM)
 * @param hashTable java.util.Hashtable
 * @param clientWorker cbit.vcell.desktop.controls.ClientWorker
 */
public void run(Hashtable<String, Object> hashTable) throws java.lang.Exception {
    long l1 = System.currentTimeMillis();
    DocumentWindowManager documentWindowManager = (DocumentWindowManager) hashTable.get(CommonTask.DOCUMENT_WINDOW_MANAGER.name);
    VCDocument currentDocument = documentWindowManager.getVCDocument();
    DocumentManager documentManager = (DocumentManager) hashTable.get(CommonTask.DOCUMENT_MANAGER.name);
    RequestManager requestManager = (RequestManager) hashTable.get("requestManager");
    boolean bAsNew = hashTable.containsKey("newName");
    String newName = bAsNew ? (String) hashTable.get("newName") : null;
    Simulation[] simulationsToRun = (Simulation[]) hashTable.get("simulations");
    String[] independentSims = null;
    if (simulationsToRun != null && simulationsToRun.length > 0) {
        independentSims = new String[simulationsToRun.length];
        for (int i = 0; i < simulationsToRun.length; i++) {
            independentSims[i] = simulationsToRun[i].getName();
        }
    }
    VCDocument savedDocument = null;
    switch(currentDocument.getDocumentType()) {
        case BIOMODEL_DOC:
            {
                if (bAsNew) {
                    // Substitute Field Func Names-----
                    VersionableTypeVersion originalVersionableTypeVersion = null;
                    if (currentDocument.getVersion() != null) {
                        // From Opened...
                        originalVersionableTypeVersion = new VersionableTypeVersion(VersionableType.BioModelMetaData, currentDocument.getVersion());
                    }
                    documentManager.substituteFieldFuncNames((BioModel) currentDocument, originalVersionableTypeVersion);
                    // --------------------------------
                    savedDocument = documentManager.saveAsNew((BioModel) currentDocument, newName, independentSims);
                } else {
                    savedDocument = documentManager.save((BioModel) currentDocument, independentSims);
                }
                break;
            }
        case MATHMODEL_DOC:
            {
                if (bAsNew) {
                    // Substitute Field Func Names-----
                    VersionableTypeVersion originalVersionableTypeVersion = ((MathModelWindowManager) documentWindowManager).getCopyFromBioModelAppVersionableTypeVersion();
                    if (originalVersionableTypeVersion == null && currentDocument.getVersion() != null) {
                        // From Opened...
                        originalVersionableTypeVersion = new VersionableTypeVersion(VersionableType.MathModelMetaData, currentDocument.getVersion());
                    }
                    documentManager.substituteFieldFuncNames((MathModel) currentDocument, originalVersionableTypeVersion);
                    // --------------------------------
                    savedDocument = documentManager.saveAsNew((MathModel) currentDocument, newName, independentSims);
                } else {
                    savedDocument = documentManager.save((MathModel) currentDocument, independentSims);
                }
                break;
            }
        case GEOMETRY_DOC:
            {
                if (bAsNew) {
                    savedDocument = documentManager.saveAsNew((Geometry) currentDocument, newName);
                } else {
                    savedDocument = documentManager.save((Geometry) currentDocument);
                }
                break;
            }
        default:
            {
                throw new RuntimeException("unexpected document type " + currentDocument.getDocumentType().name());
            }
    }
    documentWindowManager.prepareDocumentToLoad(savedDocument, false);
    hashTable.put(SaveDocument.DOC_KEY, savedDocument);
    // generate PerformanceMonitorEvent
    long l2 = System.currentTimeMillis();
    double duration = ((double) (l2 - l1)) / 1000;
// requestManager.getAsynchMessageManager().reportPerformanceMonitorEvent(
// new PerformanceMonitorEvent(
// this, documentManager.getUser(), new PerformanceData(
// "SaveDocument.run()",
// MessageEvent.SAVING_STAT,
// new PerformanceDataEntry[] {
// new PerformanceDataEntry("document saved", savedDocument.getName()),
// new PerformanceDataEntry("remote call duration", Double.toString(duration))
// }
// )
// )
// );
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) VCDocument(org.vcell.util.document.VCDocument) VersionableTypeVersion(org.vcell.util.document.VersionableTypeVersion) DocumentManager(cbit.vcell.clientdb.DocumentManager) RequestManager(cbit.vcell.client.RequestManager) Simulation(cbit.vcell.solver.Simulation) DocumentWindowManager(cbit.vcell.client.DocumentWindowManager) BioModel(cbit.vcell.biomodel.BioModel)

Example 62 with MathModel

use of cbit.vcell.mathmodel.MathModel in project vcell by virtualcell.

the class VCellBasicCellRenderer method getTreeCellRendererComponent.

/**
 * Insert the method's description here.
 * Creation date: (7/27/2000 6:41:57 PM)
 * @return java.awt.Component
 */
public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    // 
    if (!leaf && expanded) {
        setIcon(fieldFolderOpenIcon);
    } else if (!leaf && !expanded) {
        setIcon(fieldFolderClosedIcon);
    }
    try {
        if (value instanceof BioModelNode) {
            BioModelNode node = (BioModelNode) value;
            boolean bLoaded = false;
            // 
            // Check if node is a SolverResultSetInfo
            // 
            Object userObject = node.getUserObject();
            if (userObject instanceof SimulationInfo) {
                // 
                // Check if node is a SimulationInfo
                // 
                setComponentProperties(component, (SimulationInfo) userObject);
                int maxErrorLevel = getMaxErrorLevel(node);
                if (maxErrorLevel == BioModelNode.ERROR_POSSIBLE) {
                    setIcon(fieldSimulationWarningIcon);
                    component.setToolTipText("Simulation contains possibly invalid results");
                } else if (maxErrorLevel == BioModelNode.ERROR_CONFIRMED) {
                    setIcon(fieldSimulationErrorIcon);
                    component.setToolTipText("Simulation contains invalid results");
                }
            } else if (userObject instanceof String && node.getChildCount() == 0) {
                component.setToolTipText(null);
                component.setText((String) userObject);
            } else if (userObject instanceof BioModelInfo) {
                // 
                // Check if node is a BioModelInfo
                // 
                setComponentProperties(component, (BioModelInfo) userObject);
                bLoaded = isLoaded((BioModelInfo) userObject);
                int maxErrorLevel = getMaxErrorLevel(node);
                if (maxErrorLevel == BioModelNode.ERROR_POSSIBLE) {
                    setIcon(fieldBioModelWarningIcon);
                    component.setToolTipText("BioModel version: Has possibly invalid simulation results");
                } else if (maxErrorLevel == BioModelNode.ERROR_CONFIRMED) {
                    setIcon(fieldBioModelErrorIcon);
                    component.setToolTipText("BioModel version: Has invalid simulation results");
                }
            } else if (userObject instanceof String && node.getChildCount() > 0 && ((BioModelNode) node.getChildAt(0)).getUserObject() instanceof BioModelInfo) {
                // 
                // Check if node is a BioModelName (String), with children (at least one version of biomodel), and if the child is a
                // BioModelInfo node
                // 
                String label = (String) userObject;
                component.setToolTipText("BioModel");
                component.setText(label);
                // 
                // check if child is loaded
                // 
                int maxErrorLevel = BioModelNode.ERROR_NONE;
                for (int i = 0; i < node.getChildCount(); i++) {
                    maxErrorLevel = Math.max(maxErrorLevel, getMaxErrorLevel((BioModelNode) node.getChildAt(i)));
                }
                if (maxErrorLevel == BioModelNode.ERROR_POSSIBLE) {
                    if (!leaf && expanded) {
                        setIcon(fieldFolderOpenWarningIcon);
                    } else if (!leaf && !expanded) {
                        setIcon(fieldFolderClosedWarningIcon);
                    }
                    component.setToolTipText("BioModel: one or more versions may have invalid simulation results");
                } else if (maxErrorLevel == BioModelNode.ERROR_CONFIRMED) {
                    if (!leaf && expanded) {
                        setIcon(fieldFolderOpenErrorIcon);
                    } else if (!leaf && !expanded) {
                        setIcon(fieldFolderClosedErrorIcon);
                    }
                    component.setToolTipText("BioModel: one or more versions have invalid simulation results");
                }
                // 
                for (int i = 0; i < node.getChildCount(); i++) {
                    BioModelInfo bioModelInfo = (BioModelInfo) ((BioModelNode) node.getChildAt(i)).getUserObject();
                    if (isLoaded(bioModelInfo)) {
                        bLoaded = true;
                    }
                }
            } else if (userObject instanceof User && node.getChildCount() > 0 && (((BioModelNode) node.getChildAt(0)).getUserObject() instanceof String) && ((BioModelNode) (node.getChildAt(0).getChildAt(0))).getUserObject() instanceof BioModelInfo) {
                // 
                // Check if node is a User, with at least one child which is a string (BioModel name)
                // and if the child's child is a BioModelInfo node
                // 
                String label = ((User) userObject).getName();
                component.setToolTipText("User Name");
                component.setText(label);
                if (isLoaded((User) userObject)) {
                    bLoaded = true;
                }
            } else if (userObject instanceof MathModelInfo) {
                // 
                // Check if node is a MathModelInfo node
                // 
                setComponentProperties(component, (MathModelInfo) userObject);
                bLoaded = isLoaded((MathModelInfo) userObject);
            } else if (userObject instanceof String && node.getChildCount() > 0 && ((BioModelNode) node.getChildAt(0)).getUserObject() instanceof MathModelInfo) {
                // 
                // Check if node is a MathModel name (String), with children (at least one version of mathmodel), and
                // if the child is a MathModelInfo node
                // 
                String label = (String) userObject;
                component.setToolTipText("Mathematical Model");
                component.setText(label);
                // 
                for (int i = 0; i < node.getChildCount(); i++) {
                    MathModelInfo mathModelInfo = (MathModelInfo) ((BioModelNode) node.getChildAt(i)).getUserObject();
                    if (isLoaded(mathModelInfo)) {
                        bLoaded = true;
                    }
                }
            } else if (userObject instanceof User && node.getChildCount() > 0 && (((BioModelNode) node.getChildAt(0)).getUserObject() instanceof String) && ((BioModelNode) (node.getChildAt(0).getChildAt(0))).getUserObject() instanceof MathModelInfo) {
                // 
                // Check if node is a User, with at least one child which is a string (Mathmodel name)
                // and if the child's child is a MathModelInfo node
                // 
                String label = ((User) userObject).getName();
                component.setToolTipText("User Name");
                component.setText(label);
                if (isLoaded((User) userObject)) {
                    bLoaded = true;
                }
            } else if (userObject instanceof cbit.vcell.geometry.GeometryInfo) {
                // 
                // Check if node is a GeometryInfo
                // 
                setComponentProperties(component, (GeometryInfo) userObject);
                bLoaded = isLoaded((GeometryInfo) userObject);
            } else if (userObject instanceof String && node.getChildCount() > 0 && ((BioModelNode) node.getChildAt(0)).getUserObject() instanceof GeometryInfo) {
                // 
                // Check if node is a Geometry name (String), with children (at least one version of Geometry), and
                // if the child is a GeometryInfo node
                // 
                String label = (String) userObject;
                component.setToolTipText("Geometry");
                component.setText(label);
                // 
                for (int i = 0; i < node.getChildCount(); i++) {
                    GeometryInfo geometryInfo = (GeometryInfo) ((BioModelNode) node.getChildAt(i)).getUserObject();
                    if (isLoaded(geometryInfo)) {
                        bLoaded = true;
                    }
                }
            } else if (userObject instanceof User && node.getChildCount() > 0 && (((BioModelNode) node.getChildAt(0)).getUserObject() instanceof String) && ((BioModelNode) (node.getChildAt(0).getChildAt(0))).getUserObject() instanceof GeometryInfo) {
                // 
                // Check if node is a User, with at least one child which is a string (Geometry name)
                // and if the child's child is a GeometryInfo node
                // 
                String label = ((User) userObject).getName();
                component.setToolTipText("User Name");
                component.setText(label);
                if (isLoaded((User) userObject)) {
                    bLoaded = true;
                }
            } else if (userObject instanceof String && node.getChildCount() > 0) {
                component.setToolTipText(null);
                component.setText((String) userObject);
            // }else if (node.getUserObject() instanceof MathInfo) {
            // setComponentProperties(component,(MathInfo)node.getUserObject());
            } else if (userObject instanceof VCImageInfo) {
                setComponentProperties(component, (VCImageInfo) userObject);
            } else if (userObject instanceof Extent) {
                setComponentProperties(component, (Extent) userObject);
            } else if (userObject instanceof Annotation) {
                setComponentProperties(component, (Annotation) userObject);
            } else if (userObject instanceof MathModel) {
                setComponentProperties(component, (MathModel) userObject);
            } else if (userObject instanceof BioModel) {
                setComponentProperties(component, (BioModel) userObject);
            } else if (userObject instanceof SimulationContext) {
                setComponentProperties(component, (SimulationContext) userObject);
                bLoaded = isLoaded((SimulationContext) userObject);
            } else if (userObject instanceof Simulation) {
                setComponentProperties(component, (Simulation) userObject);
            } else if (userObject instanceof MathDescription) {
                setComponentProperties(component, (MathDescription) userObject);
            } else if (userObject instanceof Geometry) {
                setComponentProperties(component, (Geometry) userObject);
            } else if (userObject instanceof User) {
                setComponentProperties(component, (User) userObject);
            } else {
                setComponentProperties(component, userObject);
            }
            if (selectedFont == null && component.getFont() != null) {
                selectedFont = component.getFont().deriveFont(Font.BOLD);
            }
            if (unselectedFont == null && component.getFont() != null) {
                unselectedFont = component.getFont().deriveFont(Font.PLAIN);
            }
            if (bLoaded) {
                component.setFont(selectedFont);
            } else {
                component.setFont(unselectedFont);
            }
        }
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
    // 
    return component;
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) User(org.vcell.util.document.User) Extent(org.vcell.util.Extent) MathDescription(cbit.vcell.math.MathDescription) BioModelInfo(org.vcell.util.document.BioModelInfo) JLabel(javax.swing.JLabel) MathModelInfo(org.vcell.util.document.MathModelInfo) SimulationContext(cbit.vcell.mapping.SimulationContext) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) GeometryInfo(cbit.vcell.geometry.GeometryInfo) VCImageInfo(cbit.image.VCImageInfo) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 63 with MathModel

use of cbit.vcell.mathmodel.MathModel in project vcell by virtualcell.

the class ClientRequestManager method createDefaultMathModelDocument.

private MathModel createDefaultMathModelDocument() throws Exception {
    Geometry geometry = new Geometry("Untitled", 0);
    MathModel mathModel = createMathModel("Untitled", geometry);
    mathModel.setName("MathModel" + (getMdiManager().getNumCreatedDocumentWindows() + 1));
    return mathModel;
}
Also used : Geometry(cbit.vcell.geometry.Geometry) MathModel(cbit.vcell.mathmodel.MathModel)

Example 64 with MathModel

use of cbit.vcell.mathmodel.MathModel in project vcell by virtualcell.

the class ClientRequestManager method createNewDocument.

/**
 * Insert the method's description here.
 * Creation date: (5/10/2004 3:48:16 PM)
 */
public AsynchClientTask[] createNewDocument(final TopLevelWindowManager requester, final VCDocument.DocumentCreationInfo documentCreationInfo) {
    // throws UserCancelException, Exception {
    /* asynchronous and not blocking any window */
    AsynchClientTask[] taskArray = null;
    final int createOption = documentCreationInfo.getOption();
    switch(documentCreationInfo.getDocumentType()) {
        case BIOMODEL_DOC:
            {
                AsynchClientTask task1 = new AsynchClientTask("creating biomodel", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                    @Override
                    public void run(Hashtable<String, Object> hashTable) throws Exception {
                        BioModel bioModel = createDefaultBioModelDocument(null);
                        hashTable.put("doc", bioModel);
                    }
                };
                taskArray = new AsynchClientTask[] { task1 };
                break;
            }
        case MATHMODEL_DOC:
            {
                if ((createOption == VCDocument.MATH_OPTION_NONSPATIAL) || (createOption == VCDocument.MATH_OPTION_SPATIAL_EXISTS)) {
                    AsynchClientTask task2 = new AsynchClientTask("creating mathmodel", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                        @Override
                        public void run(Hashtable<String, Object> hashTable) throws Exception {
                            Geometry geometry = null;
                            if (createOption == VCDocument.MATH_OPTION_NONSPATIAL) {
                                geometry = new Geometry("Untitled", 0);
                            } else {
                                geometry = (Geometry) hashTable.get(GEOMETRY_KEY);
                            }
                            MathModel mathModel = createMathModel("Untitled", geometry);
                            mathModel.setName("MathModel" + (getMdiManager().getNumCreatedDocumentWindows() + 1));
                            hashTable.put("doc", mathModel);
                        }
                    };
                    if (createOption == VCDocument.MATH_OPTION_SPATIAL_EXISTS) {
                        AsynchClientTask task1 = createSelectDocTask(requester);
                        AsynchClientTask task1b = createSelectLoadGeomTask(requester);
                        taskArray = new AsynchClientTask[] { task1, task1b, task2 };
                    } else {
                        taskArray = new AsynchClientTask[] { task2 };
                    }
                    break;
                } else if (createOption == VCDocument.MATH_OPTION_FROMBIOMODELAPP) {
                    AsynchClientTask task1 = new AsynchClientTask("select biomodel application", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

                        @Override
                        public void run(Hashtable<String, Object> hashTable) throws Exception {
                            // spatial or non-spatial
                            BioModelInfo bioModelInfo = (BioModelInfo) DialogUtils.getDBTreePanelSelection(requester.getComponent(), getMdiManager().getDatabaseWindowManager().getBioModelDbTreePanel(), "Open", "Select BioModel");
                            if (bioModelInfo != null) {
                                // may throw UserCancelException
                                hashTable.put("bioModelInfo", bioModelInfo);
                            }
                        }
                    };
                    AsynchClientTask task2 = new AsynchClientTask("find sim contexts in biomodel application", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                        @Override
                        public void run(Hashtable<String, Object> hashTable) throws Exception {
                            // spatial or non-spatial
                            // Get the simContexts in the corresponding BioModel
                            BioModelInfo bioModelInfo = (BioModelInfo) hashTable.get("bioModelInfo");
                            SimulationContext[] simContexts = getDocumentManager().getBioModel(bioModelInfo).getSimulationContexts();
                            if (simContexts != null) {
                                // may throw UserCancelException
                                hashTable.put("simContexts", simContexts);
                            }
                        }
                    };
                    AsynchClientTask task3 = new AsynchClientTask("create math model from biomodel application", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

                        @Override
                        public void run(Hashtable<String, Object> hashTable) throws Exception {
                            SimulationContext[] simContexts = (SimulationContext[]) hashTable.get("simContexts");
                            String[] simContextNames = new String[simContexts.length];
                            if (simContextNames.length == 0) {
                                throw new RuntimeException("no application is available");
                            } else {
                                for (int i = 0; i < simContexts.length; i++) {
                                    simContextNames[i] = simContexts[i].getName();
                                }
                                Component component = requester.getComponent();
                                // Get the simContext names, so that user can choose which simContext math to import
                                String simContextChoice = (String) PopupGenerator.showListDialog(component, simContextNames, "Please select Application");
                                if (simContextChoice == null) {
                                    throw UserCancelException.CANCEL_DB_SELECTION;
                                }
                                SimulationContext chosenSimContext = null;
                                for (int i = 0; i < simContexts.length; i++) {
                                    if (simContexts[i].getName().equals(simContextChoice)) {
                                        chosenSimContext = simContexts[i];
                                        break;
                                    }
                                }
                                Objects.requireNonNull(chosenSimContext);
                                BioModelInfo bioModelInfo = (BioModelInfo) hashTable.get("bioModelInfo");
                                // Get corresponding mathDesc to create new mathModel and return.
                                String newName = bioModelInfo.getVersion().getName() + "_" + chosenSimContext.getName();
                                MathDescription bioMathDesc = chosenSimContext.getMathDescription();
                                MathDescription newMathDesc = null;
                                newMathDesc = new MathDescription(newName + "_" + (new Random()).nextInt());
                                newMathDesc.setGeometry(bioMathDesc.getGeometry());
                                newMathDesc.read_database(new CommentStringTokenizer(bioMathDesc.getVCML_database()));
                                newMathDesc.isValid();
                                MathModel newMathModel = new MathModel(null);
                                newMathModel.setName(newName);
                                newMathModel.setMathDescription(newMathDesc);
                                hashTable.put("doc", newMathModel);
                            }
                        }
                    };
                    taskArray = new AsynchClientTask[] { task1, task2, task3 };
                    break;
                } else {
                    throw new RuntimeException("Unknown MathModel Document creation option value=" + documentCreationInfo.getOption());
                }
            }
        case GEOMETRY_DOC:
            {
                if (createOption == VCDocument.GEOM_OPTION_1D || createOption == VCDocument.GEOM_OPTION_2D || createOption == VCDocument.GEOM_OPTION_3D) {
                    // analytic
                    AsynchClientTask task1 = new AsynchClientTask("creating analytic geometry", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                        @Override
                        public void run(Hashtable<String, Object> hashTable) throws Exception {
                            Geometry geometry = new Geometry("Geometry" + (getMdiManager().getNumCreatedDocumentWindows() + 1), documentCreationInfo.getOption());
                            geometry.getGeometrySpec().addSubVolume(new AnalyticSubVolume("subdomain0", new Expression(1.0)));
                            geometry.precomputeAll(new GeometryThumbnailImageFactoryAWT());
                            hashTable.put("doc", geometry);
                        }
                    };
                    taskArray = new AsynchClientTask[] { task1 };
                    break;
                }
                if (createOption == VCDocument.GEOM_OPTION_CSGEOMETRY_3D) {
                    // constructed solid geometry
                    AsynchClientTask task1 = new AsynchClientTask("creating constructed solid geometry", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                        @Override
                        public void run(Hashtable<String, Object> hashTable) throws Exception {
                            Geometry geometry = new Geometry("Geometry" + (getMdiManager().getNumCreatedDocumentWindows() + 1), 3);
                            Extent extent = geometry.getExtent();
                            if (extent != null) {
                                // create a CSGPrimitive of type cube and scale it to the 'extent' components. Use this as the default or background CSGObject (subdomain).
                                // This can be considered as the equivalent of subdomain (with expression) 1.0 for analyticSubvolume.
                                // basic cube
                                CSGPrimitive cube = new CSGPrimitive("cube", CSGPrimitive.PrimitiveType.CUBE);
                                // scaled cube
                                double x = extent.getX();
                                double y = extent.getY();
                                double z = extent.getZ();
                                CSGScale scaledCube = new CSGScale("scale", new Vect3d(x / 2.0, y / 2.0, z / 2.0));
                                scaledCube.setChild(cube);
                                // translated scaled cube
                                CSGTranslation translatedScaledCube = new CSGTranslation("translation", new Vect3d(x / 2, y / 2, z / 2));
                                translatedScaledCube.setChild(scaledCube);
                                CSGObject csgObject = new CSGObject(null, "subdomain0", 0);
                                csgObject.setRoot(translatedScaledCube);
                                geometry.getGeometrySpec().addSubVolume(csgObject, false);
                                geometry.precomputeAll(new GeometryThumbnailImageFactoryAWT());
                                hashTable.put("doc", geometry);
                            }
                        }
                    };
                    taskArray = new AsynchClientTask[] { task1 };
                    break;
                } else {
                    throw new RuntimeException("Unknown Geometry Document creation option value=" + documentCreationInfo.getOption());
                }
            }
        default:
            {
                throw new RuntimeException("Unknown default document type: " + documentCreationInfo.getDocumentType());
            }
    }
    return taskArray;
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) MathModel(cbit.vcell.mathmodel.MathModel) SetMathDescription(cbit.vcell.client.task.SetMathDescription) MathDescription(cbit.vcell.math.MathDescription) Extent(org.vcell.util.Extent) CSGPrimitive(cbit.vcell.geometry.CSGPrimitive) CSGScale(cbit.vcell.geometry.CSGScale) GeometryThumbnailImageFactoryAWT(cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT) Random(java.util.Random) Component(java.awt.Component) CSGObject(cbit.vcell.geometry.CSGObject) CSGTranslation(cbit.vcell.geometry.CSGTranslation) Hashtable(java.util.Hashtable) BioModelInfo(org.vcell.util.document.BioModelInfo) SimulationContext(cbit.vcell.mapping.SimulationContext) ProgrammingException(org.vcell.util.ProgrammingException) GeometryException(cbit.vcell.geometry.GeometryException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UtilCancelException(org.vcell.util.UtilCancelException) DataFormatException(java.util.zip.DataFormatException) UserCancelException(org.vcell.util.UserCancelException) Vect3d(cbit.vcell.render.Vect3d) Geometry(cbit.vcell.geometry.Geometry) Expression(cbit.vcell.parser.Expression) BioModel(cbit.vcell.biomodel.BioModel) CommentStringTokenizer(org.vcell.util.CommentStringTokenizer) CSGObject(cbit.vcell.geometry.CSGObject) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume)

Example 65 with MathModel

use of cbit.vcell.mathmodel.MathModel in project vcell by virtualcell.

the class ClientRequestManager method getOpenDesktopDocumentInfos.

public OpenModelInfoHolder[] getOpenDesktopDocumentInfos(boolean bIncludeSimulations) throws DataAccessException {
    Vector<OpenModelInfoHolder> simInfoHolderV = new Vector<OpenModelInfoHolder>();
    for (TopLevelWindowManager tlwm : getMdiManager().getWindowManagers()) {
        if (tlwm instanceof DocumentWindowManager) {
            DocumentWindowManager dwm = (DocumentWindowManager) tlwm;
            VCDocument vcDoc = dwm.getVCDocument();
            // if(vcDoc.getVersion() != null){
            if (vcDoc.getDocumentType() == VCDocumentType.BIOMODEL_DOC) {
                BioModel bioModel = (BioModel) vcDoc;
                // getDocumentManager().getBioModel(vcDoc.getVersion().getVersionKey());
                SimulationContext[] simContexts = bioModel.getSimulationContexts();
                for (int i = 0; i < simContexts.length; i += 1) {
                    if (bIncludeSimulations) {
                        if (simContexts[i].getGeometry() == null) {
                            throw new DataAccessException("Error gathering document info (isCompartmental check failed):\nOpen BioModel document " + bioModel.getName() + " has no Geometry");
                        }
                        Simulation[] sims = simContexts[i].getSimulations();
                        for (int j = 0; j < sims.length; j += 1) {
                            for (int k = 0; k < sims[j].getScanCount(); k += 1) {
                                FieldDataWindowManager.OpenModelInfoHolder simInfoHolder = new FieldDataWindowManager.FDSimBioModelInfo(sims[j].getName(), bioModel.getVersion(), simContexts[i], sims[j].getSimulationInfo(), k, // !sims[j].getSolverTaskDescription().getSolverDescription().hasVariableTimestep(),
                                simContexts[i].getGeometry().getDimension() == 0);
                                simInfoHolderV.add(simInfoHolder);
                            }
                        }
                    } else {
                        FieldDataWindowManager.OpenModelInfoHolder simInfoHolder = new FieldDataWindowManager.FDSimBioModelInfo(null, bioModel.getVersion(), simContexts[i], null, -1, simContexts[i].getGeometry().getDimension() == 0);
                        simInfoHolderV.add(simInfoHolder);
                    }
                }
            } else if (vcDoc.getDocumentType() == VCDocumentType.MATHMODEL_DOC) {
                MathModel mathModel = (MathModel) vcDoc;
                // getDocumentManager().getMathModel(vcDoc.getVersion().getVersionKey());
                if (bIncludeSimulations) {
                    if (mathModel.getMathDescription() == null || mathModel.getMathDescription().getGeometry() == null) {
                        throw new DataAccessException("Error gathering document info (isCompartmental check failed):\nOpen MathModel document " + mathModel.getName() + " has either no MathDescription or no Geometry");
                    }
                    Simulation[] sims = mathModel.getSimulations();
                    for (int i = 0; i < sims.length; i += 1) {
                        for (int k = 0; k < sims[i].getScanCount(); k += 1) {
                            FieldDataWindowManager.OpenModelInfoHolder simInfoHolder = new FieldDataWindowManager.FDSimMathModelInfo(sims[i].getName(), mathModel.getVersion(), mathModel.getMathDescription(), sims[i].getSimulationInfo(), k, // !sims[i].getSolverTaskDescription().getSolverDescription().hasVariableTimestep(),
                            mathModel.getMathDescription().getGeometry().getDimension() == 0);
                            simInfoHolderV.add(simInfoHolder);
                        }
                    }
                } else {
                    FieldDataWindowManager.OpenModelInfoHolder simInfoHolder = new FieldDataWindowManager.FDSimMathModelInfo(null, mathModel.getVersion(), mathModel.getMathDescription(), null, -1, mathModel.getMathDescription().getGeometry().getDimension() == 0);
                    simInfoHolderV.add(simInfoHolder);
                }
            }
        // }
        }
    }
    OpenModelInfoHolder[] simInfoHolderArr = new OpenModelInfoHolder[simInfoHolderV.size()];
    simInfoHolderV.copyInto(simInfoHolderArr);
    return simInfoHolderArr;
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) VCDocument(org.vcell.util.document.VCDocument) OpenModelInfoHolder(cbit.vcell.client.TopLevelWindowManager.OpenModelInfoHolder) SimulationContext(cbit.vcell.mapping.SimulationContext) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) Vector(java.util.Vector) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

MathModel (cbit.vcell.mathmodel.MathModel)70 BioModel (cbit.vcell.biomodel.BioModel)26 Simulation (cbit.vcell.solver.Simulation)24 DataAccessException (org.vcell.util.DataAccessException)21 Geometry (cbit.vcell.geometry.Geometry)20 MathDescription (cbit.vcell.math.MathDescription)20 SimulationContext (cbit.vcell.mapping.SimulationContext)19 XmlParseException (cbit.vcell.xml.XmlParseException)13 MathModelInfo (org.vcell.util.document.MathModelInfo)12 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)11 UserCancelException (org.vcell.util.UserCancelException)11 VCDocument (org.vcell.util.document.VCDocument)11 XMLSource (cbit.vcell.xml.XMLSource)10 ExpressionException (cbit.vcell.parser.ExpressionException)9 File (java.io.File)9 KeyValue (org.vcell.util.document.KeyValue)8 PropertyVetoException (java.beans.PropertyVetoException)7 IOException (java.io.IOException)7 BigString (org.vcell.util.BigString)7 BioModelInfo (org.vcell.util.document.BioModelInfo)7