Search in sources :

Example 1 with PointKinematics

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

the class DefaultScrollTableCellRenderer method getTableCellRendererComponent.

/**
 * Insert the method's description here.
 * Creation date: (3/27/2001 1:07:02 PM)
 * @return java.awt.Component
 * @param table javax.swing.JTable
 * @param value java.lang.Object
 * @param isSelected boolean
 * @param hasFocus boolean
 * @param row int
 * @param column int
 */
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    defaultToolTipText = null;
    super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    defaultToolTipText = getToolTipText();
    setBorder(DEFAULT_GAP);
    if (isSelected) {
        setBackground(table.getSelectionBackground());
        setForeground(table.getSelectionForeground());
    } else {
        if (table instanceof ScrollTable && ((ScrollTable) table).getHoverRow() == row) {
            setBackground(hoverColor);
        } else {
            setBackground(row % 2 == 0 ? table.getBackground() : everyOtherRowColor);
        }
        if (table.getModel() instanceof SpatialProcessTableModel) /* && column == SpatialProcessTableModel.COLUMN_SpatialProcess_SPATIALOBJECTS */
        {
            boolean found = isMatchWithSelectedObject(table, row);
            if (found == true) {
                setBackground(Color.yellow);
            }
        } else if (table.getModel() instanceof SpatialObjectTableModel) /* && column == SpatialObjectTableModel.COLUMN_SpatialObject_NAME */
        {
            boolean found = isMatchWithSelectedProcess(table, row);
            if (found == true) {
                setBackground(Color.yellow);
            }
        }
        setForeground(table.getForeground());
    }
    TableModel tableModel = table.getModel();
    if (bEnableUneditableForeground && (!table.isEnabled() || !tableModel.isCellEditable(row, column))) {
        if (!isSelected) {
            setForeground(uneditableForeground);
        }
    }
    if (value instanceof Double) {
        Double doubleValue = (Double) value;
        setText(nicelyFormattedDouble(doubleValue));
    } else if (value instanceof JComponent) {
        JComponent jc = (JComponent) value;
        if (hasFocus) {
            jc.setBorder(focusHighlightBorder);
        } else {
            jc.setBorder(noFocusBorder);
        }
        return jc;
    }
    if (BioModelEditorRightSideTableModel.ADD_NEW_HERE_TEXT.equals(value)) {
        setText(BioModelEditorRightSideTableModel.ADD_NEW_HERE_HTML);
    } else if (value instanceof ModelProcessEquation && BioModelEditorRightSideTableModel.ADD_NEW_HERE_REACTION_TEXT.equals(((ModelProcessEquation) value).toString())) {
        setText(BioModelEditorRightSideTableModel.ADD_NEW_REACTION_OR_RULE_HTML);
    }
    if (tableModel instanceof BioModelEditorApplicationsTableModel) {
        // for the applications table we show the icons with the app type
        Icon icon = null;
        String toolTipSuffix = "";
        BioModelEditorApplicationsTableModel bmeatm = (BioModelEditorApplicationsTableModel) tableModel;
        SimulationContext simContext = (SimulationContext) (bmeatm.getValueAt(row));
        if (simContext.isRuleBased()) {
            if (simContext.getGeometry().getDimension() == 0) {
                icon = VCellIcons.appRbmNonspIcon;
                toolTipSuffix = "Rule Based / Non spatial";
            }
        } else if (simContext.isStoch()) {
            if (simContext.getGeometry().getDimension() == 0) {
                icon = VCellIcons.appStoNonspIcon;
                toolTipSuffix = "Stochastic / Non spatial";
            } else {
                icon = VCellIcons.appStoSpatialIcon;
                toolTipSuffix = "Stochastic / Spatial";
            }
        } else {
            // deterministic
            if (simContext.getGeometry().getDimension() == 0) {
                icon = VCellIcons.appDetNonspIcon;
                toolTipSuffix = "Deterministic / Non spatial";
            } else {
                icon = VCellIcons.appDetSpatialIcon;
                toolTipSuffix = "Deterministic / Spatial";
            }
        }
        String toolTipPrefix = "Application: ";
        setToolTipText(toolTipPrefix + toolTipSuffix);
        if (column == 0) {
            setIcon(icon);
        } else {
            setIcon(null);
        }
    } else if (column == 2 && tableModel instanceof SpatialProcessTableModel) {
        Icon icon = null;
        SpatialProcess spatialProcess = (SpatialProcess) (((SpatialProcessTableModel) tableModel).getValueAt(row));
        if (spatialProcess instanceof PointLocation) {
            icon = VCellIcons.spatialPointIcon;
        } else if (spatialProcess instanceof PointKinematics) {
            icon = VCellIcons.spatialPointIcon;
        } else if (spatialProcess instanceof SurfaceKinematics) {
            icon = VCellIcons.spatialMembraneIcon;
        } else {
            icon = VCellIcons.spatialVolumeIcon;
        }
        setIcon(icon);
    } else if (tableModel instanceof SortTableModel) {
        // for most other tables we reserve the icon spot to display issues
        DefaultScrollTableCellRenderer.issueRenderer(this, defaultToolTipText, table, row, column, (SortTableModel) tableModel);
    }
    return this;
}
Also used : SortTableModel(org.vcell.util.gui.sorttable.SortTableModel) PointLocation(cbit.vcell.mapping.spatial.processes.PointLocation) SurfaceKinematics(cbit.vcell.mapping.spatial.processes.SurfaceKinematics) JComponent(javax.swing.JComponent) SpatialObjectTableModel(cbit.vcell.client.desktop.biomodel.SpatialObjectTableModel) SimulationContext(cbit.vcell.mapping.SimulationContext) BioModelEditorApplicationsTableModel(cbit.vcell.client.desktop.biomodel.BioModelEditorApplicationsTableModel) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) PointKinematics(cbit.vcell.mapping.spatial.processes.PointKinematics) ModelProcessEquation(cbit.gui.ModelProcessEquation) SpatialProcessTableModel(cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel) Icon(javax.swing.Icon) BioModelEditorRightSideTableModel(cbit.vcell.client.desktop.biomodel.BioModelEditorRightSideTableModel) BioModelEditorApplicationsTableModel(cbit.vcell.client.desktop.biomodel.BioModelEditorApplicationsTableModel) SpatialProcessTableModel(cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel) TableModel(javax.swing.table.TableModel) SortTableModel(org.vcell.util.gui.sorttable.SortTableModel) SpatialObjectTableModel(cbit.vcell.client.desktop.biomodel.SpatialObjectTableModel)

Example 2 with PointKinematics

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

the class DiffEquMathMapping method addSpatialProcesses.

private void addSpatialProcesses(VariableHash varHash, ArrayList<CompartmentSubdomainContext> compartmentSubdomainContexts, ArrayList<MembraneSubdomainContext> membraneSubdomainContexts) throws MathException, MappingException, ExpressionException {
    if (simContext.getGeometry().getDimension() == 0) {
        return;
    }
    // 
    for (SpatialObject spatialObject : simContext.getSpatialObjects()) {
        if (spatialObject instanceof PointObject) {
            PointObject pointObject = (PointObject) spatialObject;
            // 
            // if true, have to solve for this category
            // 
            boolean bPosition = pointObject.isQuantityCategoryEnabled(QuantityCategory.PointPosition);
            boolean bVelocity = pointObject.isQuantityCategoryEnabled(QuantityCategory.PointVelocity);
            boolean bDirection = pointObject.isQuantityCategoryEnabled(QuantityCategory.DirectionToPoint);
            boolean bDistance = pointObject.isQuantityCategoryEnabled(QuantityCategory.PointDistanceMap);
            // 
            // either make a point subdomain, or just define functions.
            // 
            ArrayList<PointLocation> pointLocationProcesses = new ArrayList<PointLocation>();
            ArrayList<PointKinematics> pointKinematicsProcesses = new ArrayList<PointKinematics>();
            for (SpatialProcess spatialProcess : simContext.getSpatialProcesses()) {
                if (spatialProcess instanceof PointLocation && ((PointLocation) spatialProcess).getPointObject() == pointObject) {
                    pointLocationProcesses.add((PointLocation) spatialProcess);
                }
                if (spatialProcess instanceof PointKinematics && ((PointKinematics) spatialProcess).getPointObject() == pointObject) {
                    pointKinematicsProcesses.add((PointKinematics) spatialProcess);
                }
            }
            if (pointLocationProcesses.size() == 1 && pointKinematicsProcesses.size() == 0 && !bVelocity) {
                GeometryClass gc = null;
                PointLocation pointLocation = pointLocationProcesses.get(0);
                if (bPosition) {
                    if (simContext.getGeometry().getDimension() == 1) {
                        SpatialQuantity posXQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointPosition, QuantityComponent.X);
                        LocalParameter posXParam = pointLocation.getParameter(SpatialProcessParameterType.PointPositionX);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(posXParam, gc), getIdentifierSubstitutions(posXParam.getExpression(), posXParam.getUnitDefinition(), gc), gc));
                        Expression posXExp = new Expression(posXParam, pointLocation.getNameScope());
                        Expression xExp = new Expression(simContext.getModel().getReservedSymbolByRole(ReservedSymbolRole.X), simContext.getModel().getNameScope());
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(posXQuantity, gc), getIdentifierSubstitutions(posXExp, posXQuantity.getUnitDefinition(), gc), gc));
                        Expression posX_minus_X = Expression.add(posXExp, Expression.negate(xExp));
                        Expression signum_posX_minus_X = Expression.function(FunctionType.MIN, new Expression(1.0), Expression.function(FunctionType.MAX, Expression.mult(new Expression(1e10), posX_minus_X), new Expression(-1)));
                        if (bDirection) {
                            SpatialQuantity dirXQuantity = pointObject.getSpatialQuantity(QuantityCategory.DirectionToPoint, QuantityComponent.X);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(dirXQuantity, gc), getIdentifierSubstitutions(signum_posX_minus_X, dirXQuantity.getUnitDefinition(), gc), gc));
                        }
                        if (bDistance) {
                            Expression abs_X_minux_posX = Expression.function(FunctionType.ABS, posX_minus_X);
                            SpatialQuantity distanceQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointDistanceMap, QuantityComponent.Scalar);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(distanceQuantity, gc), getIdentifierSubstitutions(abs_X_minux_posX, distanceQuantity.getUnitDefinition(), gc), gc));
                        }
                    }
                    if (simContext.getGeometry().getDimension() == 2) {
                        SpatialQuantity posXQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointPosition, QuantityComponent.X);
                        LocalParameter posXParam = pointLocation.getParameter(SpatialProcessParameterType.PointPositionX);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(posXParam, gc), getIdentifierSubstitutions(posXParam.getExpression(), posXParam.getUnitDefinition(), gc), gc));
                        Expression posXExp = new Expression(posXParam, pointLocation.getNameScope());
                        Expression xExp = new Expression(simContext.getModel().getReservedSymbolByRole(ReservedSymbolRole.X), simContext.getModel().getNameScope());
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(posXQuantity, gc), getIdentifierSubstitutions(new Expression(posXParam, pointLocation.getNameScope()), posXQuantity.getUnitDefinition(), gc), gc));
                        SpatialQuantity posYQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointPosition, QuantityComponent.Y);
                        LocalParameter posYParam = pointLocation.getParameter(SpatialProcessParameterType.PointPositionY);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(posYParam, gc), getIdentifierSubstitutions(posYParam.getExpression(), posYParam.getUnitDefinition(), gc), gc));
                        Expression posYExp = new Expression(posYParam, pointLocation.getNameScope());
                        Expression yExp = new Expression(simContext.getModel().getReservedSymbolByRole(ReservedSymbolRole.Y), simContext.getModel().getNameScope());
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(posYQuantity, gc), getIdentifierSubstitutions(new Expression(posYParam, pointLocation.getNameScope()), posYQuantity.getUnitDefinition(), gc), gc));
                        Expression posX_minux_X = Expression.add(posXExp, Expression.negate(xExp));
                        Expression posY_minux_Y = Expression.add(posYExp, Expression.negate(yExp));
                        Expression DX2 = Expression.mult(posX_minux_X, posX_minux_X);
                        Expression DY2 = Expression.mult(posY_minux_Y, posY_minux_Y);
                        Expression sqrt_DX2_DY2 = Expression.function(FunctionType.SQRT, Expression.add(DX2, DY2));
                        Expression dirX = Expression.div(posX_minux_X, Expression.add(sqrt_DX2_DY2, new Expression(1e-8)));
                        Expression dirY = Expression.div(posY_minux_Y, Expression.add(sqrt_DX2_DY2, new Expression(1e-8)));
                        if (bDirection) {
                            SpatialQuantity dirXQuantity = pointObject.getSpatialQuantity(QuantityCategory.DirectionToPoint, QuantityComponent.X);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(dirXQuantity, gc), getIdentifierSubstitutions(dirX, dirXQuantity.getUnitDefinition(), gc), gc));
                            SpatialQuantity dirYQuantity = pointObject.getSpatialQuantity(QuantityCategory.DirectionToPoint, QuantityComponent.Y);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(dirYQuantity, gc), getIdentifierSubstitutions(dirY, dirYQuantity.getUnitDefinition(), gc), gc));
                        }
                        if (bDistance) {
                            SpatialQuantity distanceQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointDistanceMap, QuantityComponent.Scalar);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(distanceQuantity, gc), getIdentifierSubstitutions(sqrt_DX2_DY2, distanceQuantity.getUnitDefinition(), gc), gc));
                        }
                    }
                    if (simContext.getGeometry().getDimension() == 3) {
                        SpatialQuantity posXQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointPosition, QuantityComponent.X);
                        LocalParameter posXParam = pointLocation.getParameter(SpatialProcessParameterType.PointPositionX);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(posXParam, gc), getIdentifierSubstitutions(posXParam.getExpression(), posXParam.getUnitDefinition(), gc), gc));
                        Expression posXExp = new Expression(posXParam, pointLocation.getNameScope());
                        Expression xExp = new Expression(simContext.getModel().getReservedSymbolByRole(ReservedSymbolRole.X), simContext.getModel().getNameScope());
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(posXQuantity, gc), getIdentifierSubstitutions(new Expression(posXParam, pointLocation.getNameScope()), posXQuantity.getUnitDefinition(), gc), gc));
                        SpatialQuantity posYQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointPosition, QuantityComponent.Y);
                        LocalParameter posYParam = pointLocation.getParameter(SpatialProcessParameterType.PointPositionY);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(posYParam, gc), getIdentifierSubstitutions(posYParam.getExpression(), posYParam.getUnitDefinition(), gc), gc));
                        Expression posYExp = new Expression(posYParam, pointLocation.getNameScope());
                        Expression yExp = new Expression(simContext.getModel().getReservedSymbolByRole(ReservedSymbolRole.Y), simContext.getModel().getNameScope());
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(posYQuantity, gc), getIdentifierSubstitutions(new Expression(posYParam, pointLocation.getNameScope()), posYQuantity.getUnitDefinition(), gc), gc));
                        SpatialQuantity posZQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointPosition, QuantityComponent.Z);
                        LocalParameter posZParam = pointLocation.getParameter(SpatialProcessParameterType.PointPositionZ);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(posZParam, gc), getIdentifierSubstitutions(posZParam.getExpression(), posZParam.getUnitDefinition(), gc), gc));
                        Expression posZExp = new Expression(posZParam, pointLocation.getNameScope());
                        Expression zExp = new Expression(simContext.getModel().getReservedSymbolByRole(ReservedSymbolRole.Z), simContext.getModel().getNameScope());
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(posZQuantity, gc), getIdentifierSubstitutions(new Expression(posZParam, pointLocation.getNameScope()), posZQuantity.getUnitDefinition(), gc), gc));
                        Expression posX_minux_X = Expression.add(posXExp, Expression.negate(xExp));
                        Expression posY_minux_Y = Expression.add(posYExp, Expression.negate(yExp));
                        Expression posZ_minux_Z = Expression.add(posZExp, Expression.negate(zExp));
                        Expression DX2 = Expression.mult(posX_minux_X, posX_minux_X);
                        Expression DY2 = Expression.mult(posY_minux_Y, posY_minux_Y);
                        Expression DZ2 = Expression.mult(posZ_minux_Z, posZ_minux_Z);
                        Expression sqrt_DX2_DY2_DZ2 = Expression.function(FunctionType.SQRT, Expression.add(DX2, DY2, DZ2));
                        Expression dirX = Expression.div(posX_minux_X, Expression.add(sqrt_DX2_DY2_DZ2, new Expression(1e-8)));
                        Expression dirY = Expression.div(posY_minux_Y, Expression.add(sqrt_DX2_DY2_DZ2, new Expression(1e-8)));
                        Expression dirZ = Expression.div(posZ_minux_Z, Expression.add(sqrt_DX2_DY2_DZ2, new Expression(1e-8)));
                        if (bDirection) {
                            SpatialQuantity dirXQuantity = pointObject.getSpatialQuantity(QuantityCategory.DirectionToPoint, QuantityComponent.X);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(dirXQuantity, gc), getIdentifierSubstitutions(dirX, dirXQuantity.getUnitDefinition(), gc), gc));
                            SpatialQuantity dirYQuantity = pointObject.getSpatialQuantity(QuantityCategory.DirectionToPoint, QuantityComponent.Y);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(dirYQuantity, gc), getIdentifierSubstitutions(dirY, dirYQuantity.getUnitDefinition(), gc), gc));
                            SpatialQuantity dirZQuantity = pointObject.getSpatialQuantity(QuantityCategory.DirectionToPoint, QuantityComponent.Z);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(dirZQuantity, gc), getIdentifierSubstitutions(dirZ, dirZQuantity.getUnitDefinition(), gc), gc));
                        }
                        if (bDistance) {
                            SpatialQuantity distanceQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointDistanceMap, QuantityComponent.Scalar);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(distanceQuantity, gc), getIdentifierSubstitutions(sqrt_DX2_DY2_DZ2, distanceQuantity.getUnitDefinition(), gc), gc));
                        }
                    }
                } else {
                    throw new MappingException("PointLocation process defined for pointObject '" + pointObject.getName() + "' but Position not enabled");
                }
            } else if (pointLocationProcesses.size() == 0 && pointKinematicsProcesses.size() == 1) {
                GeometryClass gc = null;
                PointKinematics pointKinematics = pointKinematicsProcesses.get(0);
                if (bPosition && bVelocity) {
                    LocalParameter velXParam = pointKinematics.getParameter(SpatialProcessParameterType.PointVelocityX);
                    LocalParameter iniPosXParam = pointKinematics.getParameter(SpatialProcessParameterType.PointInitialPositionX);
                    SpatialQuantity posXQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointPosition, QuantityComponent.X);
                    SpatialQuantity velXQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointVelocity, QuantityComponent.X);
                    Expression posXExp = new Expression(posXQuantity, simContext.getNameScope());
                    Expression xExp = new Expression(simContext.getModel().getReservedSymbolByRole(ReservedSymbolRole.X), simContext.getModel().getNameScope());
                    Expression posX_minux_X = Expression.add(posXExp, Expression.negate(xExp));
                    LocalParameter velYParam = pointKinematics.getParameter(SpatialProcessParameterType.PointVelocityY);
                    LocalParameter iniPosYParam = pointKinematics.getParameter(SpatialProcessParameterType.PointInitialPositionY);
                    SpatialQuantity posYQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointPosition, QuantityComponent.Y);
                    SpatialQuantity velYQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointVelocity, QuantityComponent.Y);
                    Expression posYExp = new Expression(posYQuantity, simContext.getNameScope());
                    Expression yExp = new Expression(simContext.getModel().getReservedSymbolByRole(ReservedSymbolRole.Y), simContext.getModel().getNameScope());
                    Expression posY_minux_Y = Expression.add(posYExp, Expression.negate(yExp));
                    LocalParameter velZParam = pointKinematics.getParameter(SpatialProcessParameterType.PointVelocityZ);
                    LocalParameter iniPosZParam = pointKinematics.getParameter(SpatialProcessParameterType.PointInitialPositionZ);
                    SpatialQuantity posZQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointPosition, QuantityComponent.Z);
                    SpatialQuantity velZQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointVelocity, QuantityComponent.Z);
                    Expression posZExp = new Expression(posZQuantity, simContext.getNameScope());
                    Expression zExp = new Expression(simContext.getModel().getReservedSymbolByRole(ReservedSymbolRole.Z), simContext.getModel().getNameScope());
                    Expression posZ_minux_Z = Expression.add(posZExp, Expression.negate(zExp));
                    String pointSubdomainName = pointObject.getName();
                    Domain domain = new Domain(pointSubdomainName);
                    PointSubDomain pointSubdomain = new PointSubDomain(pointSubdomainName);
                    mathDesc.addSubDomain(pointSubdomain);
                    if (simContext.getGeometry().getDimension() >= 1) {
                        PointVariable posXVar = new PointVariable(getMathSymbol(posXQuantity, gc), domain);
                        varHash.addVariable(posXVar);
                        Expression initXExp = getIdentifierSubstitutions(new Expression(iniPosXParam, pointKinematics.getNameScope()), iniPosXParam.getUnitDefinition(), gc);
                        Expression rateXExp = getIdentifierSubstitutions(new Expression(velXParam, pointKinematics.getNameScope()), velXParam.getUnitDefinition(), gc);
                        OdeEquation odeX = new OdeEquation(posXVar, initXExp, rateXExp);
                        pointSubdomain.addEquation(odeX);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(iniPosXParam, gc), getIdentifierSubstitutions(new Expression(iniPosXParam.getExpression()), iniPosXParam.getUnitDefinition(), gc), gc));
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velXParam, gc), getIdentifierSubstitutions(new Expression(velXParam.getExpression()), velXParam.getUnitDefinition(), gc), gc));
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velXQuantity, gc), getIdentifierSubstitutions(new Expression(velXParam, pointKinematics.getNameScope()), velXQuantity.getUnitDefinition(), gc), gc));
                        pointSubdomain.setPositionX(getIdentifierSubstitutions(new Expression(posXQuantity, simContext.getNameScope()), posXQuantity.getUnitDefinition(), gc));
                    }
                    if (simContext.getGeometry().getDimension() >= 2) {
                        PointVariable posYVar = new PointVariable(getMathSymbol(posYQuantity, gc), domain);
                        varHash.addVariable(posYVar);
                        Expression initYExp = getIdentifierSubstitutions(new Expression(iniPosYParam, pointKinematics.getNameScope()), iniPosYParam.getUnitDefinition(), gc);
                        Expression rateYExp = getIdentifierSubstitutions(new Expression(velYParam, pointKinematics.getNameScope()), velYParam.getUnitDefinition(), gc);
                        OdeEquation odeY = new OdeEquation(posYVar, initYExp, rateYExp);
                        pointSubdomain.addEquation(odeY);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(iniPosYParam, gc), getIdentifierSubstitutions(new Expression(iniPosYParam.getExpression()), iniPosYParam.getUnitDefinition(), gc), gc));
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velYParam, gc), getIdentifierSubstitutions(new Expression(velYParam.getExpression()), velYParam.getUnitDefinition(), gc), gc));
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velYQuantity, gc), getIdentifierSubstitutions(new Expression(velYParam, pointKinematics.getNameScope()), velYQuantity.getUnitDefinition(), gc), gc));
                        pointSubdomain.setPositionY(getIdentifierSubstitutions(new Expression(posYQuantity, simContext.getNameScope()), posYQuantity.getUnitDefinition(), gc));
                    }
                    if (simContext.getGeometry().getDimension() == 3) {
                        PointVariable posZVar = new PointVariable(getMathSymbol(posZQuantity, gc), domain);
                        varHash.addVariable(posZVar);
                        Expression initZExp = getIdentifierSubstitutions(new Expression(iniPosZParam, pointKinematics.getNameScope()), iniPosZParam.getUnitDefinition(), gc);
                        Expression rateZExp = getIdentifierSubstitutions(new Expression(velZParam, pointKinematics.getNameScope()), velZParam.getUnitDefinition(), gc);
                        OdeEquation odeZ = new OdeEquation(posZVar, initZExp, rateZExp);
                        pointSubdomain.addEquation(odeZ);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(iniPosZParam, gc), getIdentifierSubstitutions(new Expression(iniPosZParam.getExpression()), iniPosZParam.getUnitDefinition(), gc), gc));
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velZParam, gc), getIdentifierSubstitutions(new Expression(velZParam.getExpression()), velZParam.getUnitDefinition(), gc), gc));
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velZQuantity, gc), getIdentifierSubstitutions(new Expression(velZParam, pointKinematics.getNameScope()), velZQuantity.getUnitDefinition(), gc), gc));
                        pointSubdomain.setPositionZ(getIdentifierSubstitutions(new Expression(posZQuantity, simContext.getNameScope()), posZQuantity.getUnitDefinition(), gc));
                    }
                    if (simContext.getGeometry().getDimension() == 1) {
                        Expression signum_posX_minus_X = Expression.function(FunctionType.MIN, new Expression(1.0), Expression.function(FunctionType.MAX, Expression.mult(new Expression(1e10), posX_minux_X), new Expression(-1)));
                        if (bDirection) {
                            SpatialQuantity dirXQuantity = pointObject.getSpatialQuantity(QuantityCategory.DirectionToPoint, QuantityComponent.X);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(dirXQuantity, gc), getIdentifierSubstitutions(signum_posX_minus_X, dirXQuantity.getUnitDefinition(), gc), gc));
                        }
                        if (bDistance) {
                            Expression abs_X_minux_posX = Expression.function(FunctionType.ABS, posX_minux_X);
                            SpatialQuantity distanceQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointDistanceMap, QuantityComponent.Scalar);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(distanceQuantity, gc), getIdentifierSubstitutions(abs_X_minux_posX, distanceQuantity.getUnitDefinition(), gc), gc));
                        }
                    }
                    if (simContext.getGeometry().getDimension() == 2) {
                        Expression DX2 = Expression.mult(posX_minux_X, posX_minux_X);
                        Expression DY2 = Expression.mult(posY_minux_Y, posY_minux_Y);
                        Expression sqrt_DX2_DY2 = Expression.function(FunctionType.SQRT, Expression.add(DX2, DY2));
                        Expression dirX = Expression.div(posX_minux_X, Expression.add(sqrt_DX2_DY2, new Expression(1e-8)));
                        Expression dirY = Expression.div(posY_minux_Y, Expression.add(sqrt_DX2_DY2, new Expression(1e-8)));
                        if (bDirection) {
                            SpatialQuantity dirXQuantity = pointObject.getSpatialQuantity(QuantityCategory.DirectionToPoint, QuantityComponent.X);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(dirXQuantity, gc), getIdentifierSubstitutions(dirX, dirXQuantity.getUnitDefinition(), gc), gc));
                            SpatialQuantity dirYQuantity = pointObject.getSpatialQuantity(QuantityCategory.DirectionToPoint, QuantityComponent.Y);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(dirYQuantity, gc), getIdentifierSubstitutions(dirY, dirYQuantity.getUnitDefinition(), gc), gc));
                        }
                        if (bDistance) {
                            SpatialQuantity distanceQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointDistanceMap, QuantityComponent.Scalar);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(distanceQuantity, gc), getIdentifierSubstitutions(sqrt_DX2_DY2, distanceQuantity.getUnitDefinition(), gc), gc));
                        }
                    }
                    if (simContext.getGeometry().getDimension() == 3) {
                        Expression DX2 = Expression.mult(posX_minux_X, posX_minux_X);
                        Expression DY2 = Expression.mult(posY_minux_Y, posY_minux_Y);
                        Expression DZ2 = Expression.mult(posZ_minux_Z, posZ_minux_Z);
                        Expression sqrt_DX2_DY2_DZ2 = Expression.function(FunctionType.SQRT, Expression.add(DX2, DY2, DZ2));
                        Expression dirX = Expression.div(posX_minux_X, Expression.add(sqrt_DX2_DY2_DZ2, new Expression(1e-8)));
                        Expression dirY = Expression.div(posY_minux_Y, Expression.add(sqrt_DX2_DY2_DZ2, new Expression(1e-8)));
                        Expression dirZ = Expression.div(posZ_minux_Z, Expression.add(sqrt_DX2_DY2_DZ2, new Expression(1e-8)));
                        if (bDirection) {
                            SpatialQuantity dirXQuantity = pointObject.getSpatialQuantity(QuantityCategory.DirectionToPoint, QuantityComponent.X);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(dirXQuantity, gc), getIdentifierSubstitutions(dirX, dirXQuantity.getUnitDefinition(), gc), gc));
                            SpatialQuantity dirYQuantity = pointObject.getSpatialQuantity(QuantityCategory.DirectionToPoint, QuantityComponent.Y);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(dirYQuantity, gc), getIdentifierSubstitutions(dirY, dirYQuantity.getUnitDefinition(), gc), gc));
                            SpatialQuantity dirZQuantity = pointObject.getSpatialQuantity(QuantityCategory.DirectionToPoint, QuantityComponent.Z);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(dirZQuantity, gc), getIdentifierSubstitutions(dirZ, dirZQuantity.getUnitDefinition(), gc), gc));
                        }
                        if (bDistance) {
                            SpatialQuantity distanceQuantity = pointObject.getSpatialQuantity(QuantityCategory.PointDistanceMap, QuantityComponent.Scalar);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(distanceQuantity, gc), getIdentifierSubstitutions(sqrt_DX2_DY2_DZ2, distanceQuantity.getUnitDefinition(), gc), gc));
                        }
                    }
                } else {
                    throw new MappingException(pointKinematics.getDescription() + " process defined for pointObject '" + pointObject.getName() + "' but Position and Velocity not enabled");
                }
            } else {
                throw new MappingException("expecting 1 location or kinematics process for point '" + pointObject.getName() + "'");
            }
        } else if (spatialObject instanceof SurfaceRegionObject) {
            SurfaceRegionObject surfaceRegionObject = (SurfaceRegionObject) spatialObject;
            SubVolume insideSubvolume = surfaceRegionObject.getInsideSubVolume();
            SubVolume outsideSubvolume = surfaceRegionObject.getOutsideSubVolume();
            SurfaceClass surfaceClass = simContext.getGeometry().getGeometrySurfaceDescription().getSurfaceClass(insideSubvolume, outsideSubvolume);
            MembraneSubdomainContext memSubdomainContext = null;
            for (MembraneSubdomainContext context : membraneSubdomainContexts) {
                if (context.surfaceClass == surfaceClass) {
                    memSubdomainContext = context;
                }
            }
            // 
            // if true, have to solve for this category
            // 
            boolean bNormal = surfaceRegionObject.isQuantityCategoryEnabled(QuantityCategory.Normal);
            boolean bVelocity = surfaceRegionObject.isQuantityCategoryEnabled(QuantityCategory.SurfaceVelocity);
            boolean bDistance = surfaceRegionObject.isQuantityCategoryEnabled(QuantityCategory.SurfaceDistanceMap);
            boolean bDirection = surfaceRegionObject.isQuantityCategoryEnabled(QuantityCategory.DirectionToSurface);
            boolean bSize = surfaceRegionObject.isQuantityCategoryEnabled(QuantityCategory.SurfaceSize);
            if (bVelocity) {
                ArrayList<SurfaceKinematics> surfaceKinematicsList = new ArrayList<SurfaceKinematics>();
                for (SpatialProcess spatialProcess : simContext.getSpatialProcesses()) {
                    if (spatialProcess instanceof SurfaceKinematics && ((SurfaceKinematics) spatialProcess).getSurfaceRegionObject() == surfaceRegionObject) {
                        surfaceKinematicsList.add((SurfaceKinematics) spatialProcess);
                    }
                }
                if (surfaceKinematicsList.size() == 1) {
                    SurfaceKinematics surfaceKinematics = surfaceKinematicsList.get(0);
                    if (simContext.getGeometry().getDimension() >= 1) {
                        SpatialQuantity velXQuantity = surfaceRegionObject.getSpatialQuantity(QuantityCategory.SurfaceVelocity, QuantityComponent.X);
                        LocalParameter velXParam = surfaceKinematics.getParameter(SpatialProcessParameterType.SurfaceVelocityX);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velXParam, surfaceClass), getIdentifierSubstitutions(velXParam.getExpression(), velXParam.getUnitDefinition(), surfaceClass), surfaceClass));
                        Expression velXExp = new Expression(velXParam, surfaceKinematics.getNameScope());
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velXQuantity, surfaceClass), getIdentifierSubstitutions(velXExp, velXQuantity.getUnitDefinition(), surfaceClass), surfaceClass));
                        if (bNormal) {
                            SpatialQuantity normXQuantity = surfaceRegionObject.getSpatialQuantity(QuantityCategory.Normal, QuantityComponent.X);
                            Expression normXExp = new Expression(MathFunctionDefinitions.FUNCTION_normalX);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(normXQuantity, surfaceClass), getIdentifierSubstitutions(normXExp, normXQuantity.getUnitDefinition(), surfaceClass), surfaceClass));
                        }
                    }
                    if (simContext.getGeometry().getDimension() >= 2) {
                        SpatialQuantity velYQuantity = surfaceRegionObject.getSpatialQuantity(QuantityCategory.SurfaceVelocity, QuantityComponent.Y);
                        LocalParameter velYParam = surfaceKinematics.getParameter(SpatialProcessParameterType.SurfaceVelocityY);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velYParam, surfaceClass), getIdentifierSubstitutions(velYParam.getExpression(), velYParam.getUnitDefinition(), surfaceClass), surfaceClass));
                        Expression velYExp = new Expression(velYParam, surfaceKinematics.getNameScope());
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velYQuantity, surfaceClass), getIdentifierSubstitutions(velYExp, velYQuantity.getUnitDefinition(), surfaceClass), surfaceClass));
                        if (bNormal) {
                            SpatialQuantity normYQuantity = surfaceRegionObject.getSpatialQuantity(QuantityCategory.Normal, QuantityComponent.Y);
                            Expression normYExp = new Expression(MathFunctionDefinitions.FUNCTION_normalY);
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(normYQuantity, surfaceClass), getIdentifierSubstitutions(normYExp, normYQuantity.getUnitDefinition(), surfaceClass), surfaceClass));
                        }
                    }
                    if (simContext.getGeometry().getDimension() >= 3) {
                        SpatialQuantity velZQuantity = surfaceRegionObject.getSpatialQuantity(QuantityCategory.SurfaceVelocity, QuantityComponent.Z);
                        LocalParameter velZParam = surfaceKinematics.getParameter(SpatialProcessParameterType.SurfaceVelocityZ);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velZParam, surfaceClass), getIdentifierSubstitutions(velZParam.getExpression(), velZParam.getUnitDefinition(), surfaceClass), surfaceClass));
                        Expression velYExp = new Expression(velZParam, surfaceKinematics.getNameScope());
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velZQuantity, surfaceClass), getIdentifierSubstitutions(velYExp, velZQuantity.getUnitDefinition(), surfaceClass), surfaceClass));
                        if (bNormal) {
                            SpatialQuantity normZQuantity = surfaceRegionObject.getSpatialQuantity(QuantityCategory.Normal, QuantityComponent.Z);
                            // MathFunctionDefinitions.FUNCTION_normalZ);
                            Expression normZExp = new Expression("normalZ_not_implemented()");
                            varHash.addVariable(newFunctionOrConstant(getMathSymbol(normZQuantity, surfaceClass), getIdentifierSubstitutions(normZExp, normZQuantity.getUnitDefinition(), surfaceClass), surfaceClass));
                        }
                    }
                } else {
                    throw new MappingException("expecting 1 Surface Kinematics process for Surface Object '" + surfaceRegionObject.getName() + "'");
                }
            }
            if (bSize) {
                SpatialQuantity sizeQuantity = surfaceRegionObject.getSpatialQuantity(QuantityCategory.SurfaceSize, QuantityComponent.Scalar);
                String funcName = MathFunctionDefinitions.Function_regionArea_current.getFunctionName();
                Expression sizeExp = Expression.function(funcName, new Expression[] { new Expression("'" + surfaceClass.getName() + "'") });
                varHash.addVariable(newFunctionOrConstant(getMathSymbol(sizeQuantity, surfaceClass), getIdentifierSubstitutions(sizeExp, sizeQuantity.getUnitDefinition(), surfaceClass), surfaceClass));
            }
            if (bDirection) {
                SpatialQuantity directionXQuantity = surfaceRegionObject.getSpatialQuantity(QuantityCategory.DirectionToSurface, QuantityComponent.X);
                SpatialQuantity directionYQuantity = surfaceRegionObject.getSpatialQuantity(QuantityCategory.DirectionToSurface, QuantityComponent.Y);
                SpatialQuantity directionZQuantity = surfaceRegionObject.getSpatialQuantity(QuantityCategory.DirectionToSurface, QuantityComponent.Z);
                for (SubVolume adjacentSubvolume : surfaceClass.getAdjacentSubvolumes()) {
                    Domain domain = new Domain(adjacentSubvolume);
                    CompartmentSubDomain compSubdomain = mathDesc.getCompartmentSubDomain(adjacentSubvolume.getName());
                    if (simContext.getGeometry().getDimension() >= 1) {
                        String name = adjacentSubvolume.getName() + "_dirX_" + memSubdomainContext.membraneSubdomain.getName();
                        LocalizedDirectionToMembraneQuantity localDirectionXQuantity = addLocalizedDirectionToMembraneQuantity(name, surfaceClass, adjacentSubvolume, QuantityComponent.X);
                        VolVariable distanceVar = new VolVariable(getMathSymbol(localDirectionXQuantity, adjacentSubvolume), domain);
                        varHash.addVariable(distanceVar);
                        ComputeMembraneMetricEquation membraneMetricEquation = new ComputeMembraneMetricEquation(distanceVar, MembraneMetricComponent.directionToMembraneX);
                        membraneMetricEquation.setTargetMembraneName(memSubdomainContext.membraneSubdomain.getName());
                        compSubdomain.addEquation(membraneMetricEquation);
                    }
                    if (simContext.getGeometry().getDimension() >= 2) {
                        String name = adjacentSubvolume.getName() + "_dirY_" + memSubdomainContext.membraneSubdomain.getName();
                        LocalizedDirectionToMembraneQuantity localDirectionYQuantity = addLocalizedDirectionToMembraneQuantity(name, surfaceClass, adjacentSubvolume, QuantityComponent.Y);
                        VolVariable distanceVar = new VolVariable(getMathSymbol(localDirectionYQuantity, adjacentSubvolume), domain);
                        varHash.addVariable(distanceVar);
                        ComputeMembraneMetricEquation membraneMetricEquation = new ComputeMembraneMetricEquation(distanceVar, MembraneMetricComponent.directionToMembraneY);
                        membraneMetricEquation.setTargetMembraneName(memSubdomainContext.membraneSubdomain.getName());
                        compSubdomain.addEquation(membraneMetricEquation);
                    }
                    if (simContext.getGeometry().getDimension() == 3) {
                        String name = adjacentSubvolume.getName() + "_dirZ_" + memSubdomainContext.membraneSubdomain.getName();
                        LocalizedDirectionToMembraneQuantity localDirectionZQuantity = addLocalizedDirectionToMembraneQuantity(name, surfaceClass, adjacentSubvolume, QuantityComponent.Z);
                        VolVariable distanceVar = new VolVariable(getMathSymbol(localDirectionZQuantity, adjacentSubvolume), domain);
                        varHash.addVariable(distanceVar);
                        ComputeMembraneMetricEquation membraneMetricEquation = new ComputeMembraneMetricEquation(distanceVar, MembraneMetricComponent.directionToMembraneZ);
                        membraneMetricEquation.setTargetMembraneName(memSubdomainContext.membraneSubdomain.getName());
                        compSubdomain.addEquation(membraneMetricEquation);
                    }
                }
            }
            if (bDistance) {
                SpatialQuantity distanceQuantity = surfaceRegionObject.getSpatialQuantity(QuantityCategory.SurfaceDistanceMap, QuantityComponent.Scalar);
                for (SubVolume adjacentSubvolume : surfaceClass.getAdjacentSubvolumes()) {
                    String name = adjacentSubvolume.getName() + "_distanceTo_" + memSubdomainContext.membraneSubdomain.getName();
                    LocalizedDistanceToMembraneQuantity localDistanceQuantity = addLocalizedDistanceToMembraneQuantity(name, surfaceClass, adjacentSubvolume);
                    CompartmentSubDomain compSubdomain = mathDesc.getCompartmentSubDomain(adjacentSubvolume.getName());
                    Domain domain = new Domain(adjacentSubvolume);
                    VolVariable distanceVar = new VolVariable(getMathSymbol(localDistanceQuantity, adjacentSubvolume), domain);
                    varHash.addVariable(distanceVar);
                    ComputeMembraneMetricEquation membraneMetricEquation = new ComputeMembraneMetricEquation(distanceVar, MembraneMetricComponent.distanceToMembrane);
                    membraneMetricEquation.setTargetMembraneName(memSubdomainContext.membraneSubdomain.getName());
                    compSubdomain.addEquation(membraneMetricEquation);
                }
            }
        } else if (spatialObject instanceof VolumeRegionObject) {
            VolumeRegionObject volumeRegionObject = (VolumeRegionObject) spatialObject;
            SubVolume subvolume = volumeRegionObject.getSubVolume();
            boolean bCentroid = volumeRegionObject.isQuantityCategoryEnabled(QuantityCategory.DirectionToSurface);
            boolean bSize = volumeRegionObject.isQuantityCategoryEnabled(QuantityCategory.VolumeSize);
            boolean bVelocity = volumeRegionObject.isQuantityCategoryEnabled(QuantityCategory.InteriorVelocity);
            if (bVelocity) {
                ArrayList<VolumeKinematics> volumeKinematicsList = new ArrayList<VolumeKinematics>();
                for (SpatialProcess spatialProcess : simContext.getSpatialProcesses()) {
                    if (spatialProcess instanceof VolumeKinematics && ((VolumeKinematics) spatialProcess).getVolumeRegionObject() == volumeRegionObject) {
                        volumeKinematicsList.add((VolumeKinematics) spatialProcess);
                    }
                }
                if (volumeKinematicsList.size() == 1) {
                    VolumeKinematics volumeKinematics = volumeKinematicsList.get(0);
                    if (simContext.getGeometry().getDimension() >= 1) {
                        SpatialQuantity velXQuantity = volumeRegionObject.getSpatialQuantity(QuantityCategory.InteriorVelocity, QuantityComponent.X);
                        LocalParameter velXParam = volumeKinematics.getParameter(SpatialProcessParameterType.InternalVelocityX);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velXParam, subvolume), getIdentifierSubstitutions(velXParam.getExpression(), velXParam.getUnitDefinition(), subvolume), subvolume));
                        Expression velXExp = new Expression(velXParam, volumeKinematics.getNameScope());
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velXQuantity, subvolume), getIdentifierSubstitutions(velXExp, velXQuantity.getUnitDefinition(), subvolume), subvolume));
                    }
                    if (simContext.getGeometry().getDimension() >= 2) {
                        SpatialQuantity velYQuantity = volumeRegionObject.getSpatialQuantity(QuantityCategory.InteriorVelocity, QuantityComponent.Y);
                        LocalParameter velYParam = volumeKinematics.getParameter(SpatialProcessParameterType.InternalVelocityY);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velYParam, subvolume), getIdentifierSubstitutions(velYParam.getExpression(), velYParam.getUnitDefinition(), subvolume), subvolume));
                        Expression velYExp = new Expression(velYParam, volumeKinematics.getNameScope());
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velYQuantity, subvolume), getIdentifierSubstitutions(velYExp, velYQuantity.getUnitDefinition(), subvolume), subvolume));
                    }
                    if (simContext.getGeometry().getDimension() == 3) {
                        SpatialQuantity velZQuantity = volumeRegionObject.getSpatialQuantity(QuantityCategory.InteriorVelocity, QuantityComponent.Z);
                        LocalParameter velZParam = volumeKinematics.getParameter(SpatialProcessParameterType.InternalVelocityZ);
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velZParam, subvolume), getIdentifierSubstitutions(velZParam.getExpression(), velZParam.getUnitDefinition(), subvolume), subvolume));
                        Expression velZExp = new Expression(velZParam, volumeKinematics.getNameScope());
                        varHash.addVariable(newFunctionOrConstant(getMathSymbol(velZQuantity, subvolume), getIdentifierSubstitutions(velZExp, velZQuantity.getUnitDefinition(), subvolume), subvolume));
                    }
                } else {
                    throw new MappingException("expecting 1 Volume Kinematics process for Volume Object '" + volumeRegionObject.getName() + "'");
                }
            }
            if (bSize) {
                SpatialQuantity sizeQuantity = volumeRegionObject.getSpatialQuantity(QuantityCategory.VolumeSize, QuantityComponent.Scalar);
                String funcName = MathFunctionDefinitions.Function_regionVolume_current.getFunctionName();
                Expression sizeExp = Expression.function(funcName, new Expression[] { new Expression("'" + subvolume.getName() + "'") });
                varHash.addVariable(newFunctionOrConstant(getMathSymbol(sizeQuantity, subvolume), getIdentifierSubstitutions(sizeExp, sizeQuantity.getUnitDefinition(), subvolume), subvolume));
            }
            if (bCentroid) {
                throw new MappingException(QuantityCategory.Centroid.description + " not yet implemented in math generation");
            }
        }
    }
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) PointLocation(cbit.vcell.mapping.spatial.processes.PointLocation) SurfaceClass(cbit.vcell.geometry.SurfaceClass) VolumeKinematics(cbit.vcell.mapping.spatial.processes.VolumeKinematics) ArrayList(java.util.ArrayList) PointSubDomain(cbit.vcell.math.PointSubDomain) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) PointObject(cbit.vcell.mapping.spatial.PointObject) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) SubVolume(cbit.vcell.geometry.SubVolume) ComputeMembraneMetricEquation(cbit.vcell.math.ComputeMembraneMetricEquation) SpatialQuantity(cbit.vcell.mapping.spatial.SpatialObject.SpatialQuantity) VolumeRegionObject(cbit.vcell.mapping.spatial.VolumeRegionObject) VolVariable(cbit.vcell.math.VolVariable) SurfaceKinematics(cbit.vcell.mapping.spatial.processes.SurfaceKinematics) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) OdeEquation(cbit.vcell.math.OdeEquation) Expression(cbit.vcell.parser.Expression) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) PointKinematics(cbit.vcell.mapping.spatial.processes.PointKinematics) PointVariable(cbit.vcell.math.PointVariable) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) SubDomain(cbit.vcell.math.SubDomain) PointSubDomain(cbit.vcell.math.PointSubDomain) Domain(cbit.vcell.math.Variable.Domain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) SurfaceRegionObject(cbit.vcell.mapping.spatial.SurfaceRegionObject)

Example 3 with PointKinematics

use of cbit.vcell.mapping.spatial.processes.PointKinematics 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)

Example 4 with PointKinematics

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

the class SimulationContext method createPointKinematics.

public PointKinematics createPointKinematics(PointObject pointObject) {
    String pointProcName = "pproc_0";
    while (getSpatialProcess(pointProcName) != null) {
        pointProcName = TokenMangler.getNextEnumeratedToken(pointProcName);
    }
    PointKinematics pointKinematics = new PointKinematics(pointProcName, this);
    pointKinematics.setPointObject(pointObject);
    try {
        addSpatialProcess(pointKinematics);
    } catch (PropertyVetoException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
    return pointKinematics;
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) PointKinematics(cbit.vcell.mapping.spatial.processes.PointKinematics)

Example 5 with PointKinematics

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

the class Xmlproducer method getXML.

public Element getXML(SpatialProcess[] spatialProcesses) throws XmlParseException {
    Element spatialProcessesElement = new Element(XMLTags.SpatialProcessesTag);
    for (SpatialProcess spatialProcess : spatialProcesses) {
        Element spatialProcessElement = new Element(XMLTags.SpatialProcessTag);
        spatialProcessElement.setAttribute(XMLTags.NameAttrTag, mangle(spatialProcess.getName()));
        if (spatialProcess instanceof PointKinematics) {
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessTypeAttrTag, XMLTags.SpatialProcessTypeAttrValue_PointKinematics);
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessPointObjectAttrTag, ((PointKinematics) spatialProcess).getPointObject().getName());
        } else if (spatialProcess instanceof PointLocation) {
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessTypeAttrTag, XMLTags.SpatialProcessTypeAttrValue_PointLocation);
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessPointObjectAttrTag, ((PointLocation) spatialProcess).getPointObject().getName());
        } else if (spatialProcess instanceof SurfaceKinematics) {
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessTypeAttrTag, XMLTags.SpatialProcessTypeAttrValue_SurfaceKinematics);
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessSurfaceObjectAttrTag, ((SurfaceKinematics) spatialProcess).getSurfaceRegionObject().getName());
        } else if (spatialProcess instanceof VolumeKinematics) {
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessTypeAttrTag, XMLTags.SpatialProcessTypeAttrValue_VolumeKinematics);
            spatialProcessElement.setAttribute(XMLTags.SpatialProcessVolumeObjectAttrTag, ((VolumeKinematics) spatialProcess).getVolumeRegionObject().getName());
        } else {
            throw new RuntimeException("spatialProcess type " + spatialProcess.getClass().getSimpleName() + " not yet supported for persistence.");
        }
        LocalParameter[] parameters = spatialProcess.getParameters();
        for (LocalParameter parm : parameters) {
            if (parm.getExpression() != null) {
                Element tempparameter = new Element(XMLTags.ParameterTag);
                // Get parameter attributes
                tempparameter.setAttribute(XMLTags.NameAttrTag, mangle(parm.getName()));
                tempparameter.setAttribute(XMLTags.ParamRoleAttrTag, spatialProcess.getParameterType(parm).getRoleXmlName());
                VCUnitDefinition unit = parm.getUnitDefinition();
                if (unit != null) {
                    tempparameter.setAttribute(XMLTags.VCUnitDefinitionAttrTag, unit.getSymbol());
                }
                tempparameter.addContent(mangleExpression(parm.getExpression()));
                spatialProcessElement.addContent(tempparameter);
            }
        }
        spatialProcessesElement.addContent(spatialProcessElement);
    }
    System.out.println(XmlUtil.xmlToString(spatialProcessesElement));
    return spatialProcessesElement;
}
Also used : LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) PointLocation(cbit.vcell.mapping.spatial.processes.PointLocation) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) SurfaceKinematics(cbit.vcell.mapping.spatial.processes.SurfaceKinematics) VolumeKinematics(cbit.vcell.mapping.spatial.processes.VolumeKinematics) Element(org.jdom.Element) PointKinematics(cbit.vcell.mapping.spatial.processes.PointKinematics)

Aggregations

PointKinematics (cbit.vcell.mapping.spatial.processes.PointKinematics)6 PointLocation (cbit.vcell.mapping.spatial.processes.PointLocation)5 SpatialProcess (cbit.vcell.mapping.spatial.processes.SpatialProcess)5 SurfaceKinematics (cbit.vcell.mapping.spatial.processes.SurfaceKinematics)5 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)3 PointObject (cbit.vcell.mapping.spatial.PointObject)3 SurfaceRegionObject (cbit.vcell.mapping.spatial.SurfaceRegionObject)3 VolumeRegionObject (cbit.vcell.mapping.spatial.VolumeRegionObject)3 VolumeKinematics (cbit.vcell.mapping.spatial.processes.VolumeKinematics)3 SpatialObjectTableModel (cbit.vcell.client.desktop.biomodel.SpatialObjectTableModel)2 SpatialProcessTableModel (cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel)2 SpatialObject (cbit.vcell.mapping.spatial.SpatialObject)2 Expression (cbit.vcell.parser.Expression)2 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)2 PropertyVetoException (java.beans.PropertyVetoException)2 ArrayList (java.util.ArrayList)2 Icon (javax.swing.Icon)2 Element (org.jdom.Element)2 ModelProcessEquation (cbit.gui.ModelProcessEquation)1 BioModelEditorApplicationsTableModel (cbit.vcell.client.desktop.biomodel.BioModelEditorApplicationsTableModel)1