Search in sources :

Example 61 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class BioModelEditorApplicationPanel method setSimulationContext.

public void setSimulationContext(SimulationContext newValue) {
    if (simulationContext == newValue) {
        return;
    }
    final boolean respondingToSelectionManager = selectionManager.isBusy();
    final Object[] selectedObj = selectionManager.getSelectedObjects();
    SimulationContext oldValue = simulationContext;
    if (oldValue != null) {
        oldValue.removePropertyChangeListener(eventHandler);
    }
    if (newValue != null) {
        newValue.addPropertyChangeListener(eventHandler);
    }
    simulationContext = newValue;
    AsynchClientTask task1 = new AsynchClientTask("loading application", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            simulationContext.getGeometry().precomputeAll(new GeometryThumbnailImageFactoryAWT());
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("showing application", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            applicationGeometryPanel.setSimulationContext(simulationContext);
            applicationSpecificationsPanel.setSimulationContext(simulationContext);
            applicationProtocolsPanel.setSimulationContext(simulationContext);
            applicationSimulationsPanel.setSimulationContext(simulationContext);
            parameterEstimationPanel.setSelectionManager(null);
            showOrHideFittingPanel();
            parameterEstimationPanel.setSelectionManager(selectionManager);
            // showOrHideProtocolsPanel();
            if (respondingToSelectionManager) {
                selectionManager.setSelectedObjects(new Object[0]);
                selectionManager.setSelectedObjects(selectedObj);
            }
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
Also used : GeometryThumbnailImageFactoryAWT(cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) SimulationContext(cbit.vcell.mapping.SimulationContext)

Example 62 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class BioModelEditorApplicationsPanel method getJMenuAppCopyAs.

/**
 * Return the JMenuItemCopy property value.
 * @return javax.swing.JMenuItem
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JMenu getJMenuAppCopyAs() {
    if (menuAppCopyAs == null) {
        try {
            menuAppCopyAs = new javax.swing.JMenu(GuiConstants.MENU_TEXT_APP_COPYAS);
            menuItemAppNonSpatialCopyStochastic = new JMenuItem(GuiConstants.MENU_TEXT_STOCHASTIC_APPLICATION);
            menuItemAppNonSpatialCopyStochastic.setActionCommand(GuiConstants.ACTIONCMD_NON_SPATIAL_COPY_TO_STOCHASTIC_APPLICATION);
            menuItemAppNonSpatialCopyStochastic.addActionListener(eventHandler);
            menuItemNonSpatialCopyDeterministic = new javax.swing.JMenuItem(GuiConstants.MENU_TEXT_DETERMINISTIC_APPLICATION);
            menuItemNonSpatialCopyDeterministic.setActionCommand(GuiConstants.ACTIONCMD_NON_SPATIAL_COPY_TO_DETERMINISTIC_APPLICATION);
            menuItemNonSpatialCopyDeterministic.addActionListener(eventHandler);
            menuItemAppNonSpatialCopyRulebased = new javax.swing.JMenuItem(GuiConstants.MENU_TEXT_RULEBASED_APPLICATION);
            menuItemAppNonSpatialCopyRulebased.setActionCommand(GuiConstants.ACTIONCMD_NON_SPATIAL_COPY_TO_RULEBASED_APPLICATION);
            menuItemAppNonSpatialCopyRulebased.addActionListener(eventHandler);
            menuAppSpatialCopyAsNonSpatial = new JMenu(GuiConstants.MENU_TEXT_NON_SPATIAL_APPLICATION);
            menuItemAppSpatialCopyAsNonSpatialDeterministic = new JMenuItem(GuiConstants.MENU_TEXT_DETERMINISTIC_APPLICATION);
            menuItemAppSpatialCopyAsNonSpatialDeterministic.setActionCommand(GuiConstants.ACTIONCMD_SPATIAL_COPY_TO_NON_SPATIAL_DETERMINISTIC_APPLICATION);
            menuItemAppSpatialCopyAsNonSpatialDeterministic.addActionListener(eventHandler);
            menuItemAppSpatialCopyAsNonSpatialStochastic = new JMenuItem(GuiConstants.MENU_TEXT_STOCHASTIC_APPLICATION);
            menuItemAppSpatialCopyAsNonSpatialStochastic.setActionCommand(GuiConstants.ACTIONCMD_SPATIAL_COPY_TO_NON_SPATIAL_STOCHASTIC_APPLICATION);
            menuItemAppSpatialCopyAsNonSpatialStochastic.addActionListener(eventHandler);
            menuAppSpatialCopyAsNonSpatial.add(menuItemAppSpatialCopyAsNonSpatialDeterministic);
            menuAppSpatialCopyAsNonSpatial.add(menuItemAppSpatialCopyAsNonSpatialStochastic);
            menuAppSpatialCopyAsSpatial = new JMenu(GuiConstants.MENU_TEXT_SPATIAL_APPLICATION);
            menuItemAppSpatialCopyAsSpatialDeterministic = new JMenuItem(GuiConstants.MENU_TEXT_DETERMINISTIC_APPLICATION);
            menuItemAppSpatialCopyAsSpatialDeterministic.setActionCommand(GuiConstants.ACTIONCMD_SPATIAL_COPY_TO_SPATIAL_DETERMINISTIC_APPLICATION);
            menuItemAppSpatialCopyAsSpatialDeterministic.addActionListener(eventHandler);
            menuItemAppSpatialCopyAsSpatialStochastic = new JMenuItem(GuiConstants.MENU_TEXT_STOCHASTIC_APPLICATION);
            menuItemAppSpatialCopyAsSpatialStochastic.setActionCommand(GuiConstants.ACTIONCMD_SPATIAL_COPY_TO_SPATIAL_STOCHASTIC_APPLICATION);
            menuItemAppSpatialCopyAsSpatialStochastic.addActionListener(eventHandler);
            menuAppSpatialCopyAsSpatial.add(menuItemAppSpatialCopyAsSpatialDeterministic);
            menuAppSpatialCopyAsSpatial.add(menuItemAppSpatialCopyAsSpatialStochastic);
        } catch (java.lang.Throwable ivjExc) {
            handleException(ivjExc);
        }
    }
    menuAppCopyAs.removeAll();
    SimulationContext selectedSimContext = getSelectedSimulationContext();
    if (selectedSimContext != null) {
        if (selectedSimContext.getGeometry().getDimension() == 0) {
            menuAppCopyAs.add(menuItemNonSpatialCopyDeterministic);
            menuAppCopyAs.add(menuItemAppNonSpatialCopyStochastic);
            menuAppCopyAs.add(menuItemAppNonSpatialCopyRulebased);
        } else {
            menuAppCopyAs.add(menuAppSpatialCopyAsNonSpatial);
            menuAppCopyAs.add(menuAppSpatialCopyAsSpatial);
        }
    }
    return menuAppCopyAs;
}
Also used : JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) JMenuItem(javax.swing.JMenuItem) SimulationContext(cbit.vcell.mapping.SimulationContext) JMenu(javax.swing.JMenu)

Example 63 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class BioModelEditorApplicationsPanel method deleteButtonPressed.

protected void deleteButtonPressed() {
    int[] rows = table.getSelectedRows();
    if (rows == null || rows.length == 0) {
        return;
    }
    String confirm = PopupGenerator.showOKCancelWarningDialog(this, "Deleting application(s)", "Are you sure you want to delete selected application(s)?");
    if (confirm.equals(UserMessage.OPTION_CANCEL)) {
        return;
    }
    ArrayList<SimulationContext> deleteList = new ArrayList<SimulationContext>();
    for (int r : rows) {
        SimulationContext simContext = tableModel.getValueAt(r);
        if (simContext != null) {
            deleteList.add(simContext);
        }
    }
    try {
        for (SimulationContext sc : deleteList) {
            deleteApplication(sc);
        }
    } catch (PropertyVetoException ex) {
        ex.printStackTrace();
        DialogUtils.showErrorDialog(BioModelEditorApplicationsPanel.this, ex.getMessage());
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ArrayList(java.util.ArrayList) SimulationContext(cbit.vcell.mapping.SimulationContext)

Example 64 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class BioModelEditorApplicationsPanel method compareButtonPressed.

private void compareButtonPressed() {
    int[] rows = table.getSelectedRows();
    if (rows == null || rows.length != 2) {
        return;
    }
    try {
        SimulationContext simContext1 = tableModel.getValueAt(rows[0]);
        SimulationContext simContext2 = tableModel.getValueAt(rows[1]);
        BioModel bioModel = simContext1.getBioModel();
        MathMappingCallback callback = new MathMappingCallback() {

            @Override
            public void setProgressFraction(float fractionDone) {
                Thread.dumpStack();
                System.out.println("---> stdout mathMapping: progress = " + (fractionDone * 100.0) + "% done");
            }

            @Override
            public void setMessage(String message) {
                Thread.dumpStack();
                System.out.println("---> stdout mathMapping: message = " + message);
            }

            @Override
            public boolean isInterrupted() {
                return false;
            }
        };
        simContext1.refreshMathDescription(callback, NetworkGenerationRequirements.ComputeFullStandardTimeout);
        simContext2.refreshMathDescription(callback, NetworkGenerationRequirements.ComputeFullStandardTimeout);
        Xmlproducer xmlProducer = new Xmlproducer(false);
        String simContext1XML = XmlUtil.xmlToString(xmlProducer.getXML(simContext1, bioModel));
        String simContext2XML = XmlUtil.xmlToString(xmlProducer.getXML(simContext2, bioModel));
        DiffConfiguration comparisonSetting = DiffConfiguration.COMPARE_DOCS_OTHER;
        XmlTreeDiff diffTree = XmlHelper.compareMerge(simContext1XML, simContext2XML, comparisonSetting, true);
        String baselineDesc = "application " + simContext1.getName();
        String modifiedDesc = "application " + simContext2.getName();
        TMLPanel comparePanel = new TMLPanel();
        comparePanel.setXmlTreeDiff(diffTree);
        comparePanel.setBaselineVersionDescription(baselineDesc);
        comparePanel.setModifiedVersionDescription(modifiedDesc);
        ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(this);
        String title = "comparing application " + simContext1.getName() + " and " + simContext2.getName();
        ChildWindow childWindow = childWindowManager.addChildWindow(comparePanel, diffTree, title, true);
        childWindow.setSize(new Dimension(600, 600));
        childWindow.show();
    } catch (XmlParseException e) {
        e.printStackTrace();
        DialogUtils.showErrorDialog(this, "failed to compare applications: \n\n" + e.getMessage());
    }
}
Also used : DiffConfiguration(cbit.xml.merge.XmlTreeDiff.DiffConfiguration) MathMappingCallback(cbit.vcell.mapping.SimulationContext.MathMappingCallback) Xmlproducer(cbit.vcell.xml.Xmlproducer) XmlTreeDiff(cbit.xml.merge.XmlTreeDiff) ChildWindowManager(cbit.vcell.client.ChildWindowManager) Dimension(java.awt.Dimension) XmlParseException(cbit.vcell.xml.XmlParseException) SimulationContext(cbit.vcell.mapping.SimulationContext) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) TMLPanel(cbit.xml.merge.gui.TMLPanel) BioModel(cbit.vcell.biomodel.BioModel)

Example 65 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class BioModelEditorApplicationsTableModel method bioModelChange.

@Override
protected void bioModelChange(PropertyChangeEvent evt) {
    super.bioModelChange(evt);
    BioModel oldValue = (BioModel) evt.getOldValue();
    if (oldValue != null) {
        for (SimulationContext simulationContext : oldValue.getSimulationContexts()) {
            simulationContext.removePropertyChangeListener(this);
        }
    }
    BioModel newValue = (BioModel) evt.getNewValue();
    if (newValue != null) {
        for (SimulationContext simulationContext : newValue.getSimulationContexts()) {
            simulationContext.addPropertyChangeListener(this);
        }
    }
}
Also used : BioModel(cbit.vcell.biomodel.BioModel) SimulationContext(cbit.vcell.mapping.SimulationContext)

Aggregations

SimulationContext (cbit.vcell.mapping.SimulationContext)181 BioModel (cbit.vcell.biomodel.BioModel)73 Simulation (cbit.vcell.solver.Simulation)57 MathDescription (cbit.vcell.math.MathDescription)32 Geometry (cbit.vcell.geometry.Geometry)29 PropertyVetoException (java.beans.PropertyVetoException)28 MathModel (cbit.vcell.mathmodel.MathModel)25 Model (cbit.vcell.model.Model)25 KeyValue (org.vcell.util.document.KeyValue)25 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)23 ArrayList (java.util.ArrayList)23 DataAccessException (org.vcell.util.DataAccessException)23 XMLSource (cbit.vcell.xml.XMLSource)22 XmlParseException (cbit.vcell.xml.XmlParseException)22 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)20 Expression (cbit.vcell.parser.Expression)20 ExpressionException (cbit.vcell.parser.ExpressionException)19 SpeciesContext (cbit.vcell.model.SpeciesContext)17 Structure (cbit.vcell.model.Structure)17 IOException (java.io.IOException)17