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);
}
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);
}
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());
}
}
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);
}
}
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);
}
Aggregations