use of cbit.vcell.mapping.BioEvent in project vcell by virtualcell.
the class IssuePanel method invokeHyperlink.
private void invokeHyperlink(Issue issue) {
if (selectionManager != null) {
// followHyperlink is no-op if selectionManger null, so no point in proceeding if it is
IssueContext issueContext = issue.getIssueContext();
IssueSource object = issue.getSource();
if (object instanceof DecoratedIssueSource) {
DecoratedIssueSource dis = (DecoratedIssueSource) object;
dis.activateView(selectionManager);
} else if (object instanceof Parameter) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.BIOMODEL_PARAMETERS_NODE, ActiveViewID.parameters_functions), new Object[] { object });
} else if (object instanceof StructureMapping) {
StructureMapping structureMapping = (StructureMapping) object;
StructureMappingNameScope structureMappingNameScope = (StructureMappingNameScope) structureMapping.getNameScope();
SimulationContext simulationContext = ((SimulationContextNameScope) (structureMappingNameScope.getParent())).getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
} else if (object instanceof SpatialObject) {
SpatialObject spatialObject = (SpatialObject) object;
SimulationContext simulationContext = spatialObject.getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.spatial_objects), new Object[] { object });
} else if (object instanceof SpatialProcess) {
SpatialProcess spatialProcess = (SpatialProcess) object;
SimulationContext simulationContext = spatialProcess.getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.spatial_processes), new Object[] { object });
} else if (object instanceof GeometryContext.UnmappedGeometryClass) {
UnmappedGeometryClass unmappedGeometryClass = (UnmappedGeometryClass) object;
SimulationContext simulationContext = unmappedGeometryClass.getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
} else if (object instanceof MicroscopeMeasurement) {
SimulationContext simulationContext = ((MicroscopeMeasurement) object).getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.microscope_measuremments), new Object[] { object });
} else if (object instanceof BioEvent) {
BioEvent be = (BioEvent) object;
SimulationContext simulationContext = be.getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.events), new Object[] { object });
} else if (object instanceof OutputFunctionIssueSource) {
SimulationOwner simulationOwner = ((OutputFunctionIssueSource) object).getOutputFunctionContext().getSimulationOwner();
if (simulationOwner instanceof SimulationContext) {
SimulationContext simulationContext = (SimulationContext) simulationOwner;
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.SIMULATIONS_NODE, ActiveViewID.output_functions), new Object[] { ((OutputFunctionIssueSource) object).getAnnotatedFunction() });
} else if (simulationOwner instanceof MathModel) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_OUTPUT_FUNCTIONS_NODE, ActiveViewID.math_output_functions), new Object[] { ((OutputFunctionIssueSource) object).getAnnotatedFunction() });
}
} else if (object instanceof Simulation) {
Simulation simulation = (Simulation) object;
SimulationOwner simulationOwner = simulation.getSimulationOwner();
if (simulationOwner instanceof SimulationContext) {
SimulationContext simulationContext = (SimulationContext) simulationOwner;
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.SIMULATIONS_NODE, ActiveViewID.simulations), new Object[] { simulation });
} else if (simulationOwner instanceof MathModel) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE, ActiveViewID.math_simulations), new Object[] { simulation });
}
} else if (object instanceof AssignmentRule) {
AssignmentRule ar = (AssignmentRule) object;
SimulationContext sc = ar.getSimulationContext();
followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.assignmentRules), new Object[] { ar });
} else if (object instanceof RateRule) {
RateRule rr = (RateRule) object;
SimulationContext sc = rr.getSimulationContext();
followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.rateRules), new Object[] { rr });
} else if (object instanceof GeometryContext) {
setActiveView(new ActiveView(((GeometryContext) object).getSimulationContext(), DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition));
} else if (object instanceof Structure) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.STRUCTURES_NODE, ActiveViewID.structures), new Object[] { object });
} else if (object instanceof MolecularType) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE, ActiveViewID.structures), new Object[] { object });
} else if (object instanceof ReactionStep) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] { object });
} else if (object instanceof ReactionRule) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] { object });
} else if (object instanceof SpeciesContextSpec) {
SpeciesContextSpec scs = (SpeciesContextSpec) object;
ActiveView av = new ActiveView(scs.getSimulationContext(), DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.species_settings);
followHyperlink(av, new Object[] { object });
} else if (object instanceof ReactionCombo) {
ReactionCombo rc = (ReactionCombo) object;
followHyperlink(new ActiveView(rc.getReactionContext().getSimulationContext(), DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.reaction_setting), new Object[] { ((ReactionCombo) object).getReactionSpec() });
} else if (object instanceof SpeciesContext) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species), new Object[] { object });
} else if (object instanceof RbmObservable) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.OBSERVABLES_NODE, ActiveViewID.observables), new Object[] { object });
} else if (object instanceof MathDescription) {
// followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE, ActiveViewID.generated_math), new Object[] {object});
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
} else if (object instanceof SpeciesPattern) {
// if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
// SpeciesContext thing = (SpeciesContext)issue.getIssueContext().getContextObject(ContextType.SpeciesContext);
// followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species), new Object[] {thing});
// }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
// ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
// followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] {thing});
// }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
// RbmObservable thing = (RbmObservable)issue.getIssueContext().getContextObject(ContextType.RbmObservable);
// followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.OBSERVABLES_NODE, ActiveViewID.observables), new Object[] {thing});
// } else {
System.err.println("SpeciesPattern object missing a proper issue context.");
// }
} else if (object instanceof SimulationContext) {
SimulationContext sc = (SimulationContext) object;
IssueCategory ic = issue.getCategory();
switch(ic) {
case RbmNetworkConstraintsBad:
NetworkConstraints nc = sc.getNetworkConstraints();
if (issue.getMessage() == SimulationContext.IssueInsufficientMolecules) {
NetworkConstraintsEntity nce = new NetworkConstraintsEntity(NetworkConstraintsTableModel.sMaxMoleculesName, nc.getMaxMoleculesPerSpecies() + "", NetworkTransformer.defaultMaxMoleculesPerSpecies + "");
followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { nce });
} else {
NetworkConstraintsEntity nce = new NetworkConstraintsEntity(NetworkConstraintsTableModel.sMaxIterationName, nc.getMaxIteration() + "", NetworkTransformer.defaultMaxIteration + "");
followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { nce });
}
break;
default:
followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { object });
break;
}
} else if (object instanceof Geometry) {
if (issueContext.hasContextType(ContextType.SimContext)) {
SimulationContext simContext = (SimulationContext) issueContext.getContextObject(ContextType.SimContext);
followHyperlink(new ActiveView(simContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition), new Object[] { object });
} else if (issueContext.hasContextType(ContextType.MathModel)) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_GEOMETRY_NODE, ActiveViewID.math_geometry), new Object[] { object });
} else if (issueContext.hasContextType(ContextType.MathDescription)) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition), new Object[] { object });
}
} else {
System.err.println("unknown object type in IssuePanel.invokeHyperlink(): " + object.getClass() + ", context type: " + issueContext.getContextType());
}
}
}
use of cbit.vcell.mapping.BioEvent in project vcell by virtualcell.
the class AssignmentRulesSummaryTableModel method updateSubdomainComboBox.
private void updateSubdomainComboBox() {
if (steComboBox == null) {
steComboBox = new JComboBox<>();
}
if (simulationContext == null) {
return;
}
SpeciesContext[] scs = simulationContext.getModel().getSpeciesContexts();
ModelParameter[] mps = simulationContext.getModel().getModelParameters();
DefaultComboBoxModel<String> aModel = new DefaultComboBoxModel<>();
for (SpeciesContext sc : scs) {
aModel.addElement(sc.getName());
}
for (ModelParameter mp : mps) {
aModel.addElement(mp.getName());
}
steComboBox.addFocusListener(new java.awt.event.FocusAdapter() {
@Override
public void focusGained(java.awt.event.FocusEvent evt) {
DefaultComboBoxModel<String> aModel = (DefaultComboBoxModel<String>) steComboBox.getModel();
SpeciesContext[] scs = simulationContext.getModel().getSpeciesContexts();
ModelParameter[] mps = simulationContext.getModel().getModelParameters();
for (SpeciesContext sc : scs) {
int position = aModel.getIndexOf(sc.getName());
if (position == -1) {
// element is missing, add it
aModel.addElement(sc.getName());
}
}
for (ModelParameter mp : mps) {
int position = aModel.getIndexOf(mp.getName());
if (position == -1) {
aModel.addElement(mp.getName());
}
}
Set<String> elementsToRemove = new HashSet<>();
for (int i = 0; i < aModel.getSize(); i++) {
String candidate = aModel.getElementAt(i);
SpeciesContext sc = simulationContext.getModel().getSpeciesContext(candidate);
ModelParameter mp = simulationContext.getModel().getModelParameter(candidate);
if (sc == null && mp == null) {
elementsToRemove.add(candidate);
}
if (sc != null && simulationContext.getRateRule(sc) != null) {
elementsToRemove.add(candidate);
continue;
}
if (mp != null && simulationContext.getRateRule(mp) != null) {
elementsToRemove.add(candidate);
continue;
}
if (simulationContext.getBioEvents() == null) {
continue;
}
boolean found = false;
for (BioEvent event : simulationContext.getBioEvents()) {
ArrayList<EventAssignment> eas = event.getEventAssignments();
if (eas == null) {
continue;
}
for (EventAssignment ea : eas) {
if (ea.getTarget() != null && candidate.contentEquals(ea.getTarget().getName())) {
found = true;
break;
}
}
if (found) {
break;
}
}
if (found) {
elementsToRemove.add(candidate);
continue;
}
}
for (String candidate : elementsToRemove) {
aModel.removeElement(candidate);
}
}
});
steComboBox.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
setHorizontalTextPosition(SwingConstants.LEFT);
if (value == null) {
setText("");
} else if (value instanceof String) {
setText((String) value);
} else {
setText(value.toString());
System.out.println("not String");
}
return this;
}
});
steComboBox.setModel(aModel);
ownerTable.getColumnModel().getColumn(COLUMN_ASSIGNMENTRULE_VAR).setCellEditor(new DefaultCellEditor(steComboBox));
}
use of cbit.vcell.mapping.BioEvent in project vcell by virtualcell.
the class EventsSummaryTableModel method propertyChange.
@Override
public void propertyChange(java.beans.PropertyChangeEvent evt) {
super.propertyChange(evt);
// } else
if (evt.getPropertyName().equals("trigger") || evt.getPropertyName().equals("delay") || evt.getPropertyName().equals("eventAssignments")) {
fireTableRowsUpdated(0, getRowCount() - 1);
} else {
if (evt.getPropertyName().equals("bioevents")) {
BioEvent[] oldValue = (BioEvent[]) evt.getOldValue();
if (oldValue != null) {
for (BioEvent be : oldValue) {
be.removePropertyChangeListener(this);
}
}
BioEvent[] newValue = (BioEvent[]) evt.getNewValue();
if (newValue != null) {
for (BioEvent be : newValue) {
be.addPropertyChangeListener(this);
}
}
}
refreshData();
}
}
use of cbit.vcell.mapping.BioEvent in project vcell by virtualcell.
the class EventsSummaryTableModel method computeData.
protected List<BioEvent> computeData() {
if (simulationContext == null || simulationContext.getBioEvents() == null) {
return null;
}
List<BioEvent> bioEventList = new ArrayList<BioEvent>();
for (BioEvent bioEvent : simulationContext.getBioEvents()) {
if (searchText == null || searchText.length() == 0) {
bioEventList.add(bioEvent);
} else {
String lowerCaseSearchText = searchText.toLowerCase();
try {
Expression delayExp = bioEvent.getParameter(BioEventParameterType.TriggerDelay).getExpression();
Expression generatedTriggerExp = bioEvent.generateTriggerExpression();
if (bioEvent.getName().toLowerCase().contains(lowerCaseSearchText) || generatedTriggerExp.infix().toLowerCase().contains(lowerCaseSearchText) || delayExp != null && delayExp.infix().toLowerCase().contains(lowerCaseSearchText)) {
bioEventList.add(bioEvent);
}
} catch (ExpressionException e) {
e.printStackTrace();
throw new RuntimeException(this.getClass().getSimpleName() + ".computeData() error: " + e.getMessage(), e);
}
}
}
return bioEventList;
}
use of cbit.vcell.mapping.BioEvent in project vcell by virtualcell.
the class Xmlproducer method getXML.
// For events in SimulationContext - XML is very similar to math events
public Element getXML(BioEvent[] bioEvents) throws XmlParseException {
Element bioEventsElement = new Element(XMLTags.BioEventsTag);
for (int i = 0; i < bioEvents.length; i++) {
Element eventElement = new Element(XMLTags.BioEventTag);
eventElement.setAttribute(XMLTags.NameAttrTag, mangle(bioEvents[i].getName()));
String triggerType = bioEvents[i].getTriggerType().getXmlName();
// Add atributes
eventElement.setAttribute(XMLTags.BioEventTriggerTypeAttrTag, triggerType);
eventElement.setAttribute(XMLTags.UseValuesFromTriggerTimeAttrTag, Boolean.toString(bioEvents[i].getUseValuesFromTriggerTime()));
// Add BioEvent Parameters
LocalParameter[] parameters = bioEvents[i].getEventParameters();
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, bioEvents[i].getParameterType(parm).getRoleXmlName());
VCUnitDefinition unit = parm.getUnitDefinition();
if (unit != null) {
tempparameter.setAttribute(XMLTags.VCUnitDefinitionAttrTag, unit.getSymbol());
}
tempparameter.addContent(mangleExpression(parm.getExpression()));
// Add the parameter to the general kinetics object
eventElement.addContent(tempparameter);
}
}
ArrayList<BioEvent.EventAssignment> eventAssignmentsList = bioEvents[i].getEventAssignments();
if (eventAssignmentsList != null) {
for (BioEvent.EventAssignment eventAssignment : eventAssignmentsList) {
Element eventAssignmentElement = new Element(XMLTags.EventAssignmentTag);
eventAssignmentElement.setAttribute(XMLTags.EventAssignmentVariableAttrTag, eventAssignment.getTarget().getName());
eventAssignmentElement.addContent(mangleExpression(eventAssignment.getAssignmentExpression()));
eventElement.addContent(eventAssignmentElement);
}
}
bioEventsElement.addContent(eventElement);
}
System.out.println(XmlUtil.xmlToString(bioEventsElement));
return bioEventsElement;
}
Aggregations