Search in sources :

Example 6 with SimulationOwner

use of cbit.vcell.solver.SimulationOwner in project vcell by virtualcell.

the class SimulationEditor method prepareToEdit.

/**
 * Comment
 * @param simulation not null
 * @param parent
 * @throws ChomboInvalidGeometryException
 * @throws NullPointerException
 */
public void prepareToEdit(Simulation simulation, Component parent) throws ChomboInvalidGeometryException {
    Objects.requireNonNull(simulation);
    try {
        Simulation clonedSimulation = (Simulation) BeanUtils.cloneSerializable(simulation);
        clonedSimulation.refreshDependencies();
        getMathOverridesPanel1().setMathOverrides(clonedSimulation == null ? null : clonedSimulation.getMathOverrides());
        getMeshTabPanel().setSimulation(parent, clonedSimulation);
        SolverTaskDescriptionAdvancedPanel stdap = getSolverTaskDescriptionAdvancedPanel1();
        {
            SimulationOwner so = simulation.getSimulationOwner();
            UnitInfo unitInfo = so.getUnitInfo();
            stdap.setUnitInfo(unitInfo);
        }
        stdap.setSolverTaskDescription(clonedSimulation == null ? null : clonedSimulation.getSolverTaskDescription());
        boolean shouldMeshBeEnabled = false;
        MeshSpecification meshSpec = clonedSimulation.getMeshSpecification();
        if (meshSpec != null && meshSpec.getGeometry() != null && meshSpec.getGeometry().getDimension() > 0) {
            shouldMeshBeEnabled = true;
        }
        if (!shouldMeshBeEnabled) {
            getJTabbedPane1().remove(getMeshTabPanel());
        }
        setClonedSimulation(clonedSimulation);
    } catch (ChomboInvalidGeometryException exc) {
        // if this happens, sim is not allowed to edit
        exc.printStackTrace(System.out);
        throw exc;
    } catch (Throwable exc) {
        exc.printStackTrace(System.out);
        JOptionPane.showMessageDialog(this, "Could not initialize simulation editor\n" + exc.getMessage(), "Error:", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : SimulationOwner(cbit.vcell.solver.SimulationOwner) UnitInfo(cbit.vcell.solver.SimulationOwner.UnitInfo) Simulation(cbit.vcell.solver.Simulation) SolverTaskDescriptionAdvancedPanel(cbit.vcell.solver.ode.gui.SolverTaskDescriptionAdvancedPanel) ChomboInvalidGeometryException(cbit.vcell.geometry.ChomboInvalidGeometryException) MeshSpecification(cbit.vcell.solver.MeshSpecification)

Example 7 with SimulationOwner

use of cbit.vcell.solver.SimulationOwner in project vcell by virtualcell.

the class SimulationListPanel method initConnections.

/**
 * Initializes connections
 * @exception java.lang.Exception The exception description.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initConnections() throws java.lang.Exception {
    // user code begin {1}
    // user code end
    getNewButton().addActionListener(ivjEventHandler);
    getEditButton().addActionListener(ivjEventHandler);
    getDeleteButton().addActionListener(ivjEventHandler);
    getRunButton().addActionListener(ivjEventHandler);
    // getPythonResultsButton().addActionListener(ivjEventHandler);
    getNativeResultsButton().addActionListener(ivjEventHandler);
    getMoreActionsButton().addActionListener(ivjEventHandler);
    getScrollPaneTable().addPropertyChangeListener(ivjEventHandler);
    getOutputFunctionsPanel().addPropertyChangeListener(ivjEventHandler);
    getScrollPaneTable().getSelectionModel().addListSelectionListener(ivjEventHandler);
    DefaultScrollTableCellRenderer renderer = new DefaultScrollTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (value instanceof OutputTimeSpec) {
                SimulationWorkspace sw = getSimulationWorkspace();
                SimulationOwner so = sw.getSimulationOwner();
                UnitInfo unitInfo = so.getUnitInfo();
                Objects.requireNonNull(unitInfo);
                OutputTimeSpec ots = (OutputTimeSpec) value;
                String text = ots.describe(unitInfo);
                setText(text);
            } else if (value instanceof Double) {
                setText(value + "");
            }
            boolean bFinitVolumeRerun = false;
            if (value instanceof SolverDescription) {
                SolverDescription solverDescription = (SolverDescription) value;
                try {
                    if (FINITEVOLUME_CUTTOFF != null && solverDescription.equals(SolverDescription.FiniteVolume)) /*Compiled Solver*/
                    {
                        SimulationStatus simStatus = getSimulationWorkspace().getSimulationStatus(getSimulationListTableModel1().getValueAt(row));
                        if (simStatus.getHasData()) {
                            int statusIndex = 0;
                            while (simStatus.getJobStatus(statusIndex) != null) {
                                if (simStatus.getJobStatus(statusIndex).getEndDate().compareTo(FINITEVOLUME_CUTTOFF) > 0) {
                                    bFinitVolumeRerun = true;
                                    break;
                                }
                                statusIndex++;
                            }
                        }
                    }
                } catch (Exception e) {
                    // ignore, let table cell render anyway
                    e.printStackTrace();
                }
                setText(solverDescription.getShortDisplayLabel());
                setToolTipText(solverDescription.getDisplayLabel());
            } else {
                setToolTipText(getText());
            }
            if (bFinitVolumeRerun) {
                setText(getText() + (bFinitVolumeRerun ? "(*)" : ""));
                setToolTipText(getToolTipText() + (bFinitVolumeRerun ? " (data regenerated using FiniteVolumeStandalone)" : ""));
            }
            return this;
        }
    };
    getScrollPaneTable().setDefaultRenderer(OutputTimeSpec.class, renderer);
    getScrollPaneTable().setDefaultRenderer(Double.class, renderer);
    getScrollPaneTable().setDefaultRenderer(String.class, renderer);
    getScrollPaneTable().setDefaultRenderer(SolverDescription.class, renderer);
    getScrollPaneTable().setDefaultEditor(OutputTimeSpec.class, new DefaultCellEditor(new JTextField()));
    getScrollPaneTable().setDefaultRenderer(SimulationStatus.class, new DefaultScrollTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            Object obj = getSimulationStatusDisplay(row);
            if (obj instanceof JProgressBar) {
                return (JProgressBar) obj;
            }
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (value instanceof SimulationStatus) {
                setText(obj.toString());
                String details = ((SimulationStatus) value).getDetails();
                setToolTipText(details);
            }
            return this;
        }
    });
}
Also used : SolverDescription(cbit.vcell.solver.SolverDescription) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) PropertyVetoException(java.beans.PropertyVetoException) IOException(java.io.IOException) DefaultCellEditor(javax.swing.DefaultCellEditor) SimulationOwner(cbit.vcell.solver.SimulationOwner) UnitInfo(cbit.vcell.solver.SimulationOwner.UnitInfo) OutputTimeSpec(cbit.vcell.solver.OutputTimeSpec) SimulationStatus(cbit.vcell.server.SimulationStatus) JTable(javax.swing.JTable) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) Component(java.awt.Component)

Example 8 with SimulationOwner

use of cbit.vcell.solver.SimulationOwner in project vcell by virtualcell.

the class SimulationWorkspace method setSimulationOwner.

/**
 * Insert the method's description here.
 * Creation date: (6/3/2004 2:40:41 AM)
 */
public void setSimulationOwner(SimulationOwner newSimulationOwner) {
    if (newSimulationOwner == simulationOwner) {
        return;
    }
    SimulationOwner oldSimulationOwner = simulationOwner;
    if (oldSimulationOwner != null) {
        oldSimulationOwner.removePropertyChangeListener(this);
    }
    if (newSimulationOwner != null) {
        newSimulationOwner.addPropertyChangeListener(this);
    }
    simulationOwner = newSimulationOwner;
    setSimulations(simulationOwner == null ? null : getSimulationOwner().getSimulations());
    firePropertyChange(PropertyConstants.PROPERTY_NAME_SIMULATION_OWNER, oldSimulationOwner, newSimulationOwner);
}
Also used : SimulationOwner(cbit.vcell.solver.SimulationOwner)

Example 9 with SimulationOwner

use of cbit.vcell.solver.SimulationOwner in project vcell by virtualcell.

the class IssuePanel method invokeHyperlink.

private void invokeHyperlink(Issue issue) {
    if (selectionManager != null) {
        // followHyperlink is no-op if selectionManger null, so no point in proceeding if it is
        IssueContext issueContext = issue.getIssueContext();
        IssueSource object = issue.getSource();
        if (object instanceof DecoratedIssueSource) {
            DecoratedIssueSource dis = (DecoratedIssueSource) object;
            dis.activateView(selectionManager);
        } else if (object instanceof Parameter) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.BIOMODEL_PARAMETERS_NODE, ActiveViewID.parameters_functions), new Object[] { object });
        } else if (object instanceof StructureMapping) {
            StructureMapping structureMapping = (StructureMapping) object;
            StructureMappingNameScope structureMappingNameScope = (StructureMappingNameScope) structureMapping.getNameScope();
            SimulationContext simulationContext = ((SimulationContextNameScope) (structureMappingNameScope.getParent())).getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
        } else if (object instanceof SpatialObject) {
            SpatialObject spatialObject = (SpatialObject) object;
            SimulationContext simulationContext = spatialObject.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.spatial_objects), new Object[] { object });
        } else if (object instanceof SpatialProcess) {
            SpatialProcess spatialProcess = (SpatialProcess) object;
            SimulationContext simulationContext = spatialProcess.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.spatial_processes), new Object[] { object });
        } else if (object instanceof GeometryContext.UnmappedGeometryClass) {
            UnmappedGeometryClass unmappedGeometryClass = (UnmappedGeometryClass) object;
            SimulationContext simulationContext = unmappedGeometryClass.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
        } else if (object instanceof MicroscopeMeasurement) {
            SimulationContext simulationContext = ((MicroscopeMeasurement) object).getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.microscope_measuremments), new Object[] { object });
        } else if (object instanceof BioEvent) {
            BioEvent be = (BioEvent) object;
            SimulationContext simulationContext = be.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.events), new Object[] { object });
        } else if (object instanceof OutputFunctionIssueSource) {
            SimulationOwner simulationOwner = ((OutputFunctionIssueSource) object).getOutputFunctionContext().getSimulationOwner();
            if (simulationOwner instanceof SimulationContext) {
                SimulationContext simulationContext = (SimulationContext) simulationOwner;
                followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.SIMULATIONS_NODE, ActiveViewID.output_functions), new Object[] { ((OutputFunctionIssueSource) object).getAnnotatedFunction() });
            } else if (simulationOwner instanceof MathModel) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_OUTPUT_FUNCTIONS_NODE, ActiveViewID.math_output_functions), new Object[] { ((OutputFunctionIssueSource) object).getAnnotatedFunction() });
            }
        } else if (object instanceof Simulation) {
            Simulation simulation = (Simulation) object;
            SimulationOwner simulationOwner = simulation.getSimulationOwner();
            if (simulationOwner instanceof SimulationContext) {
                SimulationContext simulationContext = (SimulationContext) simulationOwner;
                followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.SIMULATIONS_NODE, ActiveViewID.simulations), new Object[] { simulation });
            } else if (simulationOwner instanceof MathModel) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE, ActiveViewID.math_simulations), new Object[] { simulation });
            }
        } else if (object instanceof GeometryContext) {
            setActiveView(new ActiveView(((GeometryContext) object).getSimulationContext(), DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition));
        } else if (object instanceof Structure) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.STRUCTURES_NODE, ActiveViewID.structures), new Object[] { object });
        } else if (object instanceof MolecularType) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE, ActiveViewID.structures), new Object[] { object });
        } else if (object instanceof ReactionStep) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] { object });
        } else if (object instanceof ReactionRule) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] { object });
        } else if (object instanceof SpeciesContextSpec) {
            SpeciesContextSpec scs = (SpeciesContextSpec) object;
            ActiveView av = new ActiveView(scs.getSimulationContext(), DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.species_settings);
            followHyperlink(av, new Object[] { object });
        } else if (object instanceof ReactionCombo) {
            ReactionCombo rc = (ReactionCombo) object;
            followHyperlink(new ActiveView(rc.getReactionContext().getSimulationContext(), DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.reaction_setting), new Object[] { ((ReactionCombo) object).getReactionSpec() });
        } else if (object instanceof SpeciesContext) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species), new Object[] { object });
        } else if (object instanceof RbmObservable) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.OBSERVABLES_NODE, ActiveViewID.observables), new Object[] { object });
        } else if (object instanceof MathDescription) {
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE, ActiveViewID.generated_math), new Object[] {object});
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
        } else if (object instanceof SpeciesPattern) {
            // if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
            // SpeciesContext thing = (SpeciesContext)issue.getIssueContext().getContextObject(ContextType.SpeciesContext);
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species), new Object[] {thing});
            // }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
            // ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] {thing});
            // }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
            // RbmObservable thing = (RbmObservable)issue.getIssueContext().getContextObject(ContextType.RbmObservable);
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.OBSERVABLES_NODE, ActiveViewID.observables), new Object[] {thing});
            // } else {
            System.err.println("SpeciesPattern object missing a proper issue context.");
        // }
        } else if (object instanceof SimulationContext) {
            SimulationContext sc = (SimulationContext) object;
            IssueCategory ic = issue.getCategory();
            switch(ic) {
                case RbmNetworkConstraintsBad:
                    NetworkConstraints nc = sc.getNetworkConstraints();
                    if (issue.getMessage() == SimulationContext.IssueInsufficientMolecules) {
                        NetworkConstraintsEntity nce = new NetworkConstraintsEntity(NetworkConstraintsTableModel.sMaxMoleculesName, NetworkConstraintsTableModel.sValueType, nc.getMaxMoleculesPerSpecies() + "");
                        followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { nce });
                    } else {
                        NetworkConstraintsEntity nce = new NetworkConstraintsEntity(NetworkConstraintsTableModel.sMaxIterationName, NetworkConstraintsTableModel.sValueType, nc.getMaxIteration() + "");
                        followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { nce });
                    }
                    break;
                default:
                    followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { object });
                    break;
            }
        } else if (object instanceof Geometry) {
            if (issueContext.hasContextType(ContextType.SimContext)) {
                SimulationContext simContext = (SimulationContext) issueContext.getContextObject(ContextType.SimContext);
                followHyperlink(new ActiveView(simContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition), new Object[] { object });
            } else if (issueContext.hasContextType(ContextType.MathModel)) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_GEOMETRY_NODE, ActiveViewID.math_geometry), new Object[] { object });
            } else if (issueContext.hasContextType(ContextType.MathDescription)) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition), new Object[] { object });
            }
        } else {
            System.err.println("unknown object type in IssuePanel.invokeHyperlink(): " + object.getClass() + ", context type: " + issueContext.getContextType());
        }
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) IssueCategory(org.vcell.util.Issue.IssueCategory) MathDescription(cbit.vcell.math.MathDescription) NetworkConstraintsEntity(org.vcell.model.rbm.common.NetworkConstraintsEntity) SpeciesContext(cbit.vcell.model.SpeciesContext) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) StructureMapping(cbit.vcell.mapping.StructureMapping) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) StructureMappingNameScope(cbit.vcell.mapping.StructureMapping.StructureMappingNameScope) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) UnmappedGeometryClass(cbit.vcell.mapping.GeometryContext.UnmappedGeometryClass) SimulationOwner(cbit.vcell.solver.SimulationOwner) DecoratedIssueSource(cbit.vcell.client.desktop.DecoratedIssueSource) IssueSource(org.vcell.util.Issue.IssueSource) OutputFunctionIssueSource(cbit.vcell.solver.OutputFunctionContext.OutputFunctionIssueSource) OutputFunctionIssueSource(cbit.vcell.solver.OutputFunctionContext.OutputFunctionIssueSource) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) IssueContext(org.vcell.util.IssueContext) UnmappedGeometryClass(cbit.vcell.mapping.GeometryContext.UnmappedGeometryClass) MicroscopeMeasurement(cbit.vcell.mapping.MicroscopeMeasurement) GeometryContext(cbit.vcell.mapping.GeometryContext) Structure(cbit.vcell.model.Structure) ReactionCombo(cbit.vcell.mapping.ReactionSpec.ReactionCombo) ReactionRule(cbit.vcell.model.ReactionRule) DecoratedIssueSource(cbit.vcell.client.desktop.DecoratedIssueSource) RbmObservable(cbit.vcell.model.RbmObservable) SimulationContextNameScope(cbit.vcell.mapping.SimulationContext.SimulationContextNameScope) SimulationContext(cbit.vcell.mapping.SimulationContext) MolecularType(org.vcell.model.rbm.MolecularType) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) ReactionStep(cbit.vcell.model.ReactionStep) Parameter(cbit.vcell.model.Parameter) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) BioEvent(cbit.vcell.mapping.BioEvent) NetworkConstraints(org.vcell.model.rbm.NetworkConstraints)

Aggregations

SimulationOwner (cbit.vcell.solver.SimulationOwner)9 SimulationContext (cbit.vcell.mapping.SimulationContext)4 Simulation (cbit.vcell.solver.Simulation)4 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)3 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)3 Hashtable (java.util.Hashtable)3 MathDescription (cbit.vcell.math.MathDescription)2 SimulationTask (cbit.vcell.messaging.server.SimulationTask)2 OutputContext (cbit.vcell.simdata.OutputContext)2 UnitInfo (cbit.vcell.solver.SimulationOwner.UnitInfo)2 BioModel (cbit.vcell.biomodel.BioModel)1 LocalVCSimulationDataIdentifier (cbit.vcell.client.ClientSimManager.LocalVCSimulationDataIdentifier)1 TopLevelWindowManager (cbit.vcell.client.TopLevelWindowManager)1 DecoratedIssueSource (cbit.vcell.client.desktop.DecoratedIssueSource)1 ActiveView (cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView)1 ClientDocumentManager (cbit.vcell.clientdb.ClientDocumentManager)1 FieldDataIdentifierSpec (cbit.vcell.field.FieldDataIdentifierSpec)1 ChomboInvalidGeometryException (cbit.vcell.geometry.ChomboInvalidGeometryException)1 Geometry (cbit.vcell.geometry.Geometry)1 GeometryClass (cbit.vcell.geometry.GeometryClass)1