Search in sources :

Example 16 with SpatialProcess

use of cbit.vcell.mapping.spatial.processes.SpatialProcess in project vcell by virtualcell.

the class SpatialProcessPropertyPanel method setSpatialProcess.

/**
 * Set the SpeciesContextSpec to a new value.
 * @param newValue cbit.vcell.mapping.SpeciesContextSpec
 */
void setSpatialProcess(SpatialProcess newValue) {
    SpatialProcess oldSpatialObject = this.spatialProcess;
    this.spatialProcess = newValue;
    getSpatialProcessParameterTableModel().setSpatialProcess(this.spatialProcess);
}
Also used : SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess)

Example 17 with SpatialProcess

use of cbit.vcell.mapping.spatial.processes.SpatialProcess in project vcell by virtualcell.

the class SpatialProcessPropertyPanel method onSelectedObjectsChange.

@Override
protected void onSelectedObjectsChange(Object[] selectedObjects) {
    SpatialProcess spatialProcess = null;
    if (selectedObjects != null && selectedObjects.length == 1 && selectedObjects[0] instanceof SpatialProcess) {
        spatialProcess = (SpatialProcess) selectedObjects[0];
    }
    setSpatialProcess(spatialProcess);
}
Also used : SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess)

Example 18 with SpatialProcess

use of cbit.vcell.mapping.spatial.processes.SpatialProcess in project vcell by virtualcell.

the class SimContextTable method readAppComponents.

/**
 * readAppComponents : reads the additional simContext components like bioevents/application related flags (for stochastic, at the moment), if present, and sets them on simContext.
 * @param con
 * @param simContext
 * @return
 * @throws SQLException
 * @throws DataAccessException
 * @throws PropertyVetoException
 */
public void readAppComponents(Connection con, SimulationContext simContext, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException, PropertyVetoException {
    try {
        Element appComponentsElement = getAppComponentsElement(con, simContext.getVersion().getVersionKey(), dbSyntax);
        if (appComponentsElement != null) {
            Element appRelatedFlags = appComponentsElement.getChild(XMLTags.ApplicationSpecificFlagsTag);
            if (appRelatedFlags != null) {
                // for now, only reading the 'randomizeInitCondition' attribute, since 'isStoch' and 'isUsingconcentration' are read in by other means; so not messing with those fields of simContext.
                boolean bRandomizeInitCondition = false;
                if ((appRelatedFlags.getAttributeValue(XMLTags.RandomizeInitConditionTag) != null) && (appRelatedFlags.getAttributeValue(XMLTags.RandomizeInitConditionTag).equals("true"))) {
                    bRandomizeInitCondition = true;
                }
                simContext.setRandomizeInitConditions(bRandomizeInitCondition);
            }
            if ((appComponentsElement.getAttributeValue(XMLTags.InsufficientIterationsTag) != null) && (appComponentsElement.getAttributeValue(XMLTags.InsufficientIterationsTag).equals("true"))) {
                simContext.setInsufficientIterations(true);
            } else {
                simContext.setInsufficientIterations(false);
            }
            if ((appComponentsElement.getAttributeValue(XMLTags.InsufficientMaxMoleculesTag) != null) && (appComponentsElement.getAttributeValue(XMLTags.InsufficientMaxMoleculesTag).equals("true"))) {
                simContext.setInsufficientMaxMolecules(true);
            } else {
                simContext.setInsufficientMaxMolecules(false);
            }
            XmlReader xmlReader = new XmlReader(false);
            NetworkConstraints nc = null;
            Element ncElement = appComponentsElement.getChild(XMLTags.RbmNetworkConstraintsTag);
            if (ncElement != null) {
                // one network constraint element
                nc = xmlReader.getAppNetworkConstraints(ncElement, simContext.getModel());
            }
            simContext.setNetworkConstraints(nc);
            // get spatial objects
            Element spatialObjectsElement = appComponentsElement.getChild(XMLTags.SpatialObjectsTag);
            if (spatialObjectsElement != null) {
                SpatialObject[] spatialObjects = xmlReader.getSpatialObjects(simContext, spatialObjectsElement);
                simContext.setSpatialObjects(spatialObjects);
            }
            // get application parameters
            Element appParamsElement = appComponentsElement.getChild(XMLTags.ApplicationParametersTag);
            if (appParamsElement != null) {
                SimulationContextParameter[] appParams = xmlReader.getSimulationContextParams(appParamsElement, simContext);
                simContext.setSimulationContextParameters(appParams);
            }
            // get bioEvents
            Element bioEventsElement = appComponentsElement.getChild(XMLTags.BioEventsTag);
            if (bioEventsElement != null) {
                BioEvent[] bioEvents = xmlReader.getBioEvents(simContext, bioEventsElement);
                simContext.setBioEvents(bioEvents);
            }
            // get spatial processes
            Element spatialProcessesElement = appComponentsElement.getChild(XMLTags.SpatialProcessesTag);
            if (spatialProcessesElement != null) {
                SpatialProcess[] spatialProcesses = xmlReader.getSpatialProcesses(simContext, spatialProcessesElement);
                simContext.setSpatialProcesses(spatialProcesses);
            }
            // get microscope measurements
            Element element = appComponentsElement.getChild(XMLTags.MicroscopeMeasurement);
            if (element != null) {
                xmlReader.getMicroscopeMeasurement(element, simContext);
            }
            // get rate rules
            Element rateRulesElement = appComponentsElement.getChild(XMLTags.RateRulesTag);
            if (rateRulesElement != null) {
                RateRule[] rateRules = xmlReader.getRateRules(simContext, rateRulesElement);
                simContext.setRateRules(rateRules);
            }
            // get reaction rule specs
            Element reactionRuleSpecsElement = appComponentsElement.getChild(XMLTags.ReactionRuleSpecsTag);
            if (reactionRuleSpecsElement != null) {
                ReactionRuleSpec[] reactionRuleSpecs = xmlReader.getReactionRuleSpecs(simContext, reactionRuleSpecsElement);
                simContext.getReactionContext().setReactionRuleSpecs(reactionRuleSpecs);
            }
        }
    } catch (XmlParseException e) {
        e.printStackTrace(System.out);
        throw new DataAccessException("Error retrieving bioevents : " + e.getMessage());
    }
}
Also used : ReactionRuleSpec(cbit.vcell.mapping.ReactionRuleSpec) Element(org.jdom.Element) XmlReader(cbit.vcell.xml.XmlReader) XmlParseException(cbit.vcell.xml.XmlParseException) SimulationContextParameter(cbit.vcell.mapping.SimulationContext.SimulationContextParameter) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) RateRule(cbit.vcell.mapping.RateRule) BioEvent(cbit.vcell.mapping.BioEvent) DataAccessException(org.vcell.util.DataAccessException) NetworkConstraints(org.vcell.model.rbm.NetworkConstraints)

Example 19 with SpatialProcess

use of cbit.vcell.mapping.spatial.processes.SpatialProcess in project vcell by virtualcell.

the class SpatialProcessParameterTableModel method propertyChange.

public void propertyChange(java.beans.PropertyChangeEvent evt) {
    try {
        if (evt.getSource() instanceof SpatialProcess) {
            refreshData();
        }
        if (evt.getSource() == this && evt.getPropertyName().equals(PROPERTY_NAME_SPATIALPROCESS)) {
            SpatialProcess oldValue = (SpatialProcess) evt.getOldValue();
            if (oldValue != null) {
                oldValue.removePropertyChangeListener(this);
                Parameter[] oldParameters = oldValue.getParameters();
                if (oldParameters != null) {
                    for (int i = 0; i < oldParameters.length; i++) {
                        oldParameters[i].removePropertyChangeListener(this);
                    }
                }
            }
            SpatialProcess newValue = (SpatialProcess) evt.getNewValue();
            if (newValue != null) {
                newValue.addPropertyChangeListener(this);
                Parameter[] newParameters = newValue.getParameters();
                if (newParameters != null) {
                    for (int i = 0; i < newParameters.length; i++) {
                        newParameters[i].addPropertyChangeListener(this);
                    }
                }
            }
            refreshData();
        }
        if (evt.getSource() instanceof SpatialProcess) {
            // if parameters changed must update listeners
            if (evt.getPropertyName().equals(SpatialProcess.PROPERTY_NAME_PARAMETERS)) {
                Parameter[] oldParameters = (Parameter[]) evt.getOldValue();
                if (oldParameters != null) {
                    for (int i = 0; i < oldParameters.length; i++) {
                        oldParameters[i].removePropertyChangeListener(this);
                    }
                }
                Parameter[] newParameters = (Parameter[]) evt.getNewValue();
                if (newParameters != null) {
                    for (int i = 0; i < newParameters.length; i++) {
                        newParameters[i].addPropertyChangeListener(this);
                    }
                }
            }
            if (!evt.getPropertyName().equals(SpeciesContextSpec.PARAMETER_NAME_PROXY_PARAMETERS)) {
                // for any change to the SpeciesContextSpec, want to update all.
                // proxy parameters don't affect table
                refreshData();
            }
        }
        if (evt.getSource() instanceof Parameter) {
            refreshData();
        }
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) Parameter(cbit.vcell.model.Parameter) ExpressionException(cbit.vcell.parser.ExpressionException)

Example 20 with SpatialProcess

use of cbit.vcell.mapping.spatial.processes.SpatialProcess in project vcell by virtualcell.

the class DefaultScrollTableCellRenderer method issueRenderer.

public static void issueRenderer(JLabel renderer, String defaultToolTipText, JTable table, int row, int column, SortTableModel tableModel) {
    List<Issue> issueListError = tableModel.getIssues(row, column, Issue.Severity.ERROR);
    List<Issue> issueListWarning = tableModel.getIssues(row, column, Issue.Severity.WARNING);
    Icon icon = null;
    Point mousePosition = table.getMousePosition();
    // hue, saturation, brightness
    Color red = Color.getHSBColor(0f, 0.4f, 1.0f);
    if (issueListError.size() > 0) {
        if (column == 0) {
            icon = VCellIcons.issueErrorIcon;
            if (mousePosition != null && mousePosition.getX() > LEFT_ICON_MARGIN && mousePosition.getX() <= (icon.getIconWidth() + LEFT_ICON_MARGIN)) {
                String tt = Issue.getHtmlIssueMessage(issueListError);
                renderer.setToolTipText(tt);
            } else {
                renderer.setToolTipText(defaultToolTipText);
            }
            // Color.red
            renderer.setBorder(new MatteBorder(1, 1, 1, 0, red));
        } else if (column == table.getColumnCount() - 1) {
            renderer.setBorder(new MatteBorder(1, 0, 1, 1, red));
        } else {
            renderer.setBorder(new MatteBorder(1, 0, 1, 0, red));
        }
    } else if (issueListWarning.size() > 0) {
        if (column == 0) {
            icon = VCellIcons.issueWarningIcon;
            if (mousePosition != null && mousePosition.getX() > LEFT_ICON_MARGIN && mousePosition.getX() <= (icon.getIconWidth() + LEFT_ICON_MARGIN)) {
                renderer.setToolTipText(Issue.getHtmlIssueMessage(issueListWarning));
            } else {
                renderer.setToolTipText(defaultToolTipText);
            }
            renderer.setBorder(new MatteBorder(1, 1, 1, 0, Color.orange));
        } else if (column == table.getColumnCount() - 1) {
            renderer.setBorder(new MatteBorder(1, 0, 1, 1, Color.orange));
        } else {
            renderer.setBorder(new MatteBorder(1, 0, 1, 0, Color.orange));
        }
    } else {
        if (column == 0) {
            icon = VCellIcons.issueGoodIcon;
            // no tooltip for column 0 when we have no issues on that line
            renderer.setToolTipText(null);
        }
        if (column != 0 && defaultToolTipText != null && !defaultToolTipText.isEmpty()) {
            renderer.setToolTipText(defaultToolTipText);
        } else {
            renderer.setToolTipText(null);
        }
        renderer.setBorder(DEFAULT_GAP);
    }
    if (column == 0 && icon != null) {
        // for some tables we combine (concatenate) the issue icon with an entity icon
        if (tableModel instanceof SpatialProcessTableModel) {
            Icon icon2 = null;
            SpatialProcess spatialProcess = (SpatialProcess) (((SpatialProcessTableModel) tableModel).getValueAt(row));
            if (spatialProcess instanceof PointLocation) {
                icon2 = VCellIcons.spatialLocationIcon;
            } else if (spatialProcess instanceof PointKinematics) {
                icon2 = VCellIcons.spatialKinematicsIcon;
            } else if (spatialProcess instanceof SurfaceKinematics) {
                icon2 = VCellIcons.spatialKinematicsIcon;
            } else {
                icon2 = VCellIcons.spatialKinematicsIcon;
            }
            icon = VCellIcons.addIcon(icon, icon2);
        } else if (tableModel instanceof SpatialObjectTableModel) {
            Icon icon2 = null;
            SpatialObject spatialObject = (SpatialObject) (((SpatialObjectTableModel) tableModel).getValueAt(row));
            if (spatialObject instanceof PointObject) {
                icon2 = VCellIcons.spatialPointIcon;
            } else if (spatialObject instanceof SurfaceRegionObject) {
                icon2 = VCellIcons.spatialMembraneIcon;
            } else if (spatialObject instanceof VolumeRegionObject) {
                icon2 = VCellIcons.spatialVolumeIcon;
            } else {
                icon2 = VCellIcons.spatialVolumeIcon;
            }
            icon = VCellIcons.addIcon(icon, icon2);
        }
    }
    renderer.setIcon(icon);
}
Also used : VolumeRegionObject(cbit.vcell.mapping.spatial.VolumeRegionObject) Issue(org.vcell.util.Issue) PointLocation(cbit.vcell.mapping.spatial.processes.PointLocation) SurfaceKinematics(cbit.vcell.mapping.spatial.processes.SurfaceKinematics) Color(java.awt.Color) Point(java.awt.Point) SpatialObjectTableModel(cbit.vcell.client.desktop.biomodel.SpatialObjectTableModel) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) MatteBorder(javax.swing.border.MatteBorder) PointObject(cbit.vcell.mapping.spatial.PointObject) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) PointKinematics(cbit.vcell.mapping.spatial.processes.PointKinematics) Icon(javax.swing.Icon) SpatialProcessTableModel(cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel) SurfaceRegionObject(cbit.vcell.mapping.spatial.SurfaceRegionObject)

Aggregations

SpatialProcess (cbit.vcell.mapping.spatial.processes.SpatialProcess)28 SpatialObject (cbit.vcell.mapping.spatial.SpatialObject)18 SimulationContext (cbit.vcell.mapping.SimulationContext)9 BioEvent (cbit.vcell.mapping.BioEvent)8 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)7 StructureMapping (cbit.vcell.mapping.StructureMapping)7 ReactionStep (cbit.vcell.model.ReactionStep)7 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)6 SimulationContextParameter (cbit.vcell.mapping.SimulationContext.SimulationContextParameter)6 PointObject (cbit.vcell.mapping.spatial.PointObject)6 SurfaceRegionObject (cbit.vcell.mapping.spatial.SurfaceRegionObject)6 VolumeRegionObject (cbit.vcell.mapping.spatial.VolumeRegionObject)6 Element (org.jdom.Element)6 PointKinematics (cbit.vcell.mapping.spatial.processes.PointKinematics)5 PointLocation (cbit.vcell.mapping.spatial.processes.PointLocation)5 ReactionRule (cbit.vcell.model.ReactionRule)5 SpeciesContext (cbit.vcell.model.SpeciesContext)5 NetworkConstraints (org.vcell.model.rbm.NetworkConstraints)5 BioModel (cbit.vcell.biomodel.BioModel)4 Geometry (cbit.vcell.geometry.Geometry)4