Search in sources :

Example 1 with AutoCompleteSymbolFilter

use of cbit.vcell.parser.AutoCompleteSymbolFilter in project vcell by virtualcell.

the class GeometrySubVolumeTableModel method setGeometry.

/**
 * Sets the geometry property (cbit.vcell.geometry.Geometry) value.
 * @param geometry The new value for the property.
 * @see #getGeometry
 */
public void setGeometry(Geometry geometry) {
    if (fieldGeometry == geometry) {
        return;
    }
    Geometry oldValue = fieldGeometry;
    if (oldValue != null) {
        oldValue.getGeometrySpec().removePropertyChangeListener(this);
        for (SubVolume sv : oldValue.getGeometrySpec().getSubVolumes()) {
            sv.removePropertyChangeListener(this);
        }
    }
    fieldGeometry = geometry;
    if (fieldGeometry != null) {
        fieldGeometry.getGeometrySpec().addPropertyChangeListener(this);
        for (SubVolume sv : fieldGeometry.getGeometrySpec().getSubVolumes()) {
            sv.addPropertyChangeListener(this);
        }
        autoCompleteSymbolFilter = new AutoCompleteSymbolFilter() {

            public boolean accept(SymbolTableEntry ste) {
                int dimension = fieldGeometry.getDimension();
                if (ste.equals(ReservedVariable.X) || dimension > 1 && ste.equals(ReservedVariable.Y) || dimension > 2 && ste.equals(ReservedVariable.Z)) {
                    return true;
                }
                return false;
            }

            public boolean acceptFunction(String funcName) {
                return true;
            }
        };
    }
    firePropertyChange("geometry", oldValue, fieldGeometry);
}
Also used : Geometry(cbit.vcell.geometry.Geometry) AutoCompleteSymbolFilter(cbit.vcell.parser.AutoCompleteSymbolFilter) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) SubVolume(cbit.vcell.geometry.SubVolume) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume)

Example 2 with AutoCompleteSymbolFilter

use of cbit.vcell.parser.AutoCompleteSymbolFilter in project vcell by virtualcell.

the class ReactionRule method getAutoCompleteSymbolFilter.

public AutoCompleteSymbolFilter getAutoCompleteSymbolFilter() {
    AutoCompleteSymbolFilter stef = new AutoCompleteSymbolFilter() {

        public boolean accept(SymbolTableEntry ste) {
            if (ste instanceof StructureSize) {
                if (((StructureSize) ste).getStructure() != structure) {
                    return false;
                }
            } else {
                if (structure instanceof Membrane) {
                    Membrane membrane = (Membrane) structure;
                    StructureTopology structTopology = getModel().getStructureTopology();
                    if (ste instanceof SpeciesContext) {
                        Structure entryStructure = ((SpeciesContext) ste).getStructure();
                        if (entryStructure != membrane && entryStructure != structTopology.getInsideFeature(membrane) && entryStructure != structTopology.getOutsideFeature(membrane)) {
                            return false;
                        }
                    } else if (ste instanceof MembraneVoltage) {
                        if (((MembraneVoltage) ste).getMembrane() != membrane) {
                            return false;
                        }
                    }
                } else {
                    if (ste instanceof SpeciesContext) {
                        Structure entryStructure = ((SpeciesContext) ste).getStructure();
                        if (entryStructure != structure) {
                            return false;
                        }
                    } else if (ste instanceof MembraneVoltage) {
                        return false;
                    }
                }
            }
            return true;
        }

        public boolean acceptFunction(String funcName) {
            return true;
        }
    };
    return stef;
}
Also used : AutoCompleteSymbolFilter(cbit.vcell.parser.AutoCompleteSymbolFilter) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) StructureTopology(cbit.vcell.model.Model.StructureTopology) MembraneVoltage(cbit.vcell.model.Membrane.MembraneVoltage) StructureSize(cbit.vcell.model.Structure.StructureSize)

Example 3 with AutoCompleteSymbolFilter

use of cbit.vcell.parser.AutoCompleteSymbolFilter in project vcell by virtualcell.

the class ReactionStep method getAutoCompleteSymbolFilter.

public AutoCompleteSymbolFilter getAutoCompleteSymbolFilter() {
    AutoCompleteSymbolFilter stef = new AutoCompleteSymbolFilter() {

        public boolean accept(SymbolTableEntry ste) {
            if (ste instanceof StructureSize) {
                if (((StructureSize) ste).getStructure() != structure) {
                    return false;
                }
            } else {
                if (structure instanceof Membrane) {
                    Membrane membrane = (Membrane) structure;
                    StructureTopology structTopology = getModel().getStructureTopology();
                    if (ste instanceof SpeciesContext) {
                        Structure entryStructure = ((SpeciesContext) ste).getStructure();
                        if (entryStructure != membrane && entryStructure != structTopology.getInsideFeature(membrane) && entryStructure != structTopology.getOutsideFeature(membrane)) {
                            // return false;
                            return true;
                        }
                    } else if (ste instanceof MembraneVoltage) {
                        if (((MembraneVoltage) ste).getMembrane() != membrane) {
                            return false;
                        }
                    }
                } else {
                    // structure is a compartment
                    if (ste instanceof SpeciesContext) {
                        Structure entryStructure = ((SpeciesContext) ste).getStructure();
                        if (entryStructure != structure) {
                            // return false;
                            return true;
                        }
                    } else if (ste instanceof MembraneVoltage) {
                        return false;
                    }
                }
            }
            return true;
        }

        public boolean acceptFunction(String funcName) {
            return true;
        }
    };
    return stef;
}
Also used : AutoCompleteSymbolFilter(cbit.vcell.parser.AutoCompleteSymbolFilter) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) StructureTopology(cbit.vcell.model.Model.StructureTopology) MembraneVoltage(cbit.vcell.model.Membrane.MembraneVoltage) StructureSize(cbit.vcell.model.Structure.StructureSize)

Example 4 with AutoCompleteSymbolFilter

use of cbit.vcell.parser.AutoCompleteSymbolFilter in project vcell by virtualcell.

the class OutputFunctionContext method getAutoCompleteSymbolFilter.

public AutoCompleteSymbolFilter getAutoCompleteSymbolFilter() {
    AutoCompleteSymbolFilter stef = new AutoCompleteSymbolFilter() {

        public boolean accept(SymbolTableEntry ste) {
            MathDescription math = getSimulationOwner().getMathDescription();
            Variable var = math.getVariable(ste.getName());
            return (!(var instanceof InsideVariable || var instanceof OutsideVariable));
        }

        public boolean acceptFunction(String funcName) {
            return true;
        }
    };
    return stef;
}
Also used : AutoCompleteSymbolFilter(cbit.vcell.parser.AutoCompleteSymbolFilter) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) ReservedVariable(cbit.vcell.math.ReservedVariable) InsideVariable(cbit.vcell.math.InsideVariable) OutsideVariable(cbit.vcell.math.OutsideVariable) Variable(cbit.vcell.math.Variable) MathDescription(cbit.vcell.math.MathDescription) OutsideVariable(cbit.vcell.math.OutsideVariable) InsideVariable(cbit.vcell.math.InsideVariable)

Example 5 with AutoCompleteSymbolFilter

use of cbit.vcell.parser.AutoCompleteSymbolFilter in project vcell by virtualcell.

the class OutputFunctionContext method getAutoCompleteSymbolFilter.

public AutoCompleteSymbolFilter getAutoCompleteSymbolFilter(final Domain functionDomain) {
    AutoCompleteSymbolFilter stef = new AutoCompleteSymbolFilter() {

        public boolean accept(SymbolTableEntry ste) {
            if (simulationOwner.getGeometry().getDimension() > 0) {
                if (functionDomain == null) {
                    return true;
                }
                if (ste.getName().endsWith(InsideVariable.INSIDE_VARIABLE_SUFFIX) || ste.getName().endsWith(OutsideVariable.OUTSIDE_VARIABLE_SUFFIX)) {
                    return false;
                }
                if (ste instanceof ReservedVariable) {
                    return true;
                }
                if (ste instanceof AnnotatedFunction) {
                    return functionDomain.compareEqual(((AnnotatedFunction) ste).getDomain());
                }
                if (ste instanceof Variable) {
                    Variable var = (Variable) ste;
                    if (var.getDomain() == null) {
                        return true;
                    }
                    GeometryClass gc = simulationOwner.getGeometry().getGeometryClass(functionDomain.getName());
                    GeometryClass vargc = simulationOwner.getGeometry().getGeometryClass(var.getDomain().getName());
                    if (gc instanceof SurfaceClass && vargc instanceof SubVolume) {
                        if (((SurfaceClass) gc).isAdjacentTo((SubVolume) vargc)) {
                            return true;
                        } else {
                            return false;
                        }
                    } else {
                        return var.getDomain().compareEqual(functionDomain);
                    }
                }
            }
            return true;
        }

        public boolean acceptFunction(String funcName) {
            return true;
        }
    };
    return stef;
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) AutoCompleteSymbolFilter(cbit.vcell.parser.AutoCompleteSymbolFilter) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) ReservedVariable(cbit.vcell.math.ReservedVariable) ReservedVariable(cbit.vcell.math.ReservedVariable) InsideVariable(cbit.vcell.math.InsideVariable) OutsideVariable(cbit.vcell.math.OutsideVariable) Variable(cbit.vcell.math.Variable) SurfaceClass(cbit.vcell.geometry.SurfaceClass) SubVolume(cbit.vcell.geometry.SubVolume)

Aggregations

AutoCompleteSymbolFilter (cbit.vcell.parser.AutoCompleteSymbolFilter)5 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)5 SubVolume (cbit.vcell.geometry.SubVolume)2 InsideVariable (cbit.vcell.math.InsideVariable)2 OutsideVariable (cbit.vcell.math.OutsideVariable)2 ReservedVariable (cbit.vcell.math.ReservedVariable)2 Variable (cbit.vcell.math.Variable)2 MembraneVoltage (cbit.vcell.model.Membrane.MembraneVoltage)2 StructureTopology (cbit.vcell.model.Model.StructureTopology)2 StructureSize (cbit.vcell.model.Structure.StructureSize)2 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)1 Geometry (cbit.vcell.geometry.Geometry)1 GeometryClass (cbit.vcell.geometry.GeometryClass)1 SurfaceClass (cbit.vcell.geometry.SurfaceClass)1 MathDescription (cbit.vcell.math.MathDescription)1