use of cbit.vcell.model.Structure in project vcell by virtualcell.
the class DBReactionWizardPanel method setStructure.
/**
* Sets the structure property (cbit.vcell.model.Structure) value.
* @param structure The new value for the property.
* @see #getStructure
*/
public void setStructure(Structure structure) {
Structure oldValue = fieldStructure;
fieldStructure = structure;
firePropertyChange("structure", oldValue, structure);
}
use of cbit.vcell.model.Structure in project vcell by virtualcell.
the class DBReactionWizardPanel method setupRX.
/**
* Insert the method's description here.
* Creation date: (8/5/2003 2:50:56 PM)
* @param dbfr cbit.vcell.dictionary.ReactionDescription
*/
private void setupRX(ReactionDescription dbfr) {
resolvedReaction = dbfr;
if (resolvedReaction != null) {
if (speciesAssignmentJCB != null) {
for (int i = 0; i < speciesAssignmentJCB.length; i += 1) {
speciesAssignmentJCB[i].removeActionListener(this);
}
}
if (structureAssignmentJCB != null) {
for (int i = 0; i < structureAssignmentJCB.length; i += 1) {
structureAssignmentJCB[i].removeActionListener(this);
}
}
getReactionCanvas1().setReactionCanvasDisplaySpec(resolvedReaction.toReactionCanvasDisplaySpec());
getRXParticipantsJPanel().removeAll();
// java.awt.Insets zeroInsets = new java.awt.Insets(0,0,0,0);
java.awt.Insets fourInsets = new java.awt.Insets(4, 4, 4, 4);
java.awt.GridBagConstraints gbc = new java.awt.GridBagConstraints();
gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
gbc.insets = fourInsets;
gbc.gridx = 0;
gbc.gridy = 0;
javax.swing.JLabel rxjlabel = new javax.swing.JLabel("RX Elements");
// rxjlabel.setForeground(java.awt.Color.white);
// rxjlabel.setOpaque(true);
// rxjlabel.setBackground(java.awt.Color.white);
getRXParticipantsJPanel().add(rxjlabel, gbc);
// gbc.insets = zeroInsets;
for (int i = 0; i < resolvedReaction.elementCount(); i += 1) {
gbc.gridy = i + 1;
javax.swing.JLabel jlabel = new javax.swing.JLabel(resolvedReaction.getReactionElement(i).getPreferredName() + (resolvedReaction.isFluxReaction() && resolvedReaction.getFluxIndexOutside() == i ? " (Outside)" : "") + (resolvedReaction.isFluxReaction() && resolvedReaction.getFluxIndexInside() == i ? " (Inside)" : ""));
// jlabel.setOpaque(true);
// jlabel.setBackground(java.awt.Color.white);
// jlabel.setForeground(java.awt.Color.black);
getRXParticipantsJPanel().add(jlabel, gbc);
}
// gbc.insets = fourInsets;
gbc.gridx = 1;
gbc.gridy = 0;
speciesAssignmentJCB = new javax.swing.JComboBox[resolvedReaction.elementCount()];
DefaultListCellRenderer speciesListCellRenderer = new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
// TODO Auto-generated method stub
return super.getListCellRendererComponent(list, (value instanceof Species ? "Existing " + ((Species) value).getCommonName() : value), index, isSelected, cellHasFocus);
}
};
javax.swing.JLabel rspjlabel = new javax.swing.JLabel("Assign to Model Species");
// rspjlabel.setForeground(java.awt.Color.white);
// rspjlabel.setOpaque(true);
// rspjlabel.setBackground(java.awt.Color.white);
getRXParticipantsJPanel().add(rspjlabel, gbc);
// getRXParticipantsJPanel().add(new javax.swing.JLabel("Resolve to Model Species"),gbc);
speciesOrder = new Species[getModel().getSpecies().length + 1];
speciesOrder[0] = null;
for (int j = 0; j < getModel().getSpecies().length; j += 1) {
speciesOrder[j + 1] = getModel().getSpecies(j);
}
for (int i = 0; i < resolvedReaction.elementCount(); i += 1) {
javax.swing.JComboBox jcb = new javax.swing.JComboBox();
jcb.setRenderer(speciesListCellRenderer);
speciesAssignmentJCB[i] = jcb;
jcb.addItem("New Species");
for (int j = 1; j < speciesOrder.length; j += 1) {
jcb.addItem(/*"Existing "+*/
speciesOrder[j]);
}
gbc.gridy = i + 1;
getRXParticipantsJPanel().add(jcb, gbc);
jcb.setEnabled(false);
}
gbc.gridx = 2;
gbc.gridy = 0;
structureAssignmentJCB = new javax.swing.JComboBox[resolvedReaction.elementCount()];
DefaultListCellRenderer structureListCellRenderer = new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
// TODO Auto-generated method stub
return super.getListCellRendererComponent(list, (value instanceof Structure ? ((Structure) value).getName() : value), index, isSelected, cellHasFocus);
}
};
javax.swing.JLabel rstjlabel = new javax.swing.JLabel("Assign to Model Compartment");
// rstjlabel.setForeground(java.awt.Color.white);
// rstjlabel.setOpaque(true);
// rstjlabel.setBackground(java.awt.Color.white);
getRXParticipantsJPanel().add(rstjlabel, gbc);
// getRXParticipantsJPanel().add(new javax.swing.JLabel("Resolve to Model Compartment"),gbc);
StructureTopology structTopology = getModel().getStructureTopology();
for (int i = 0; i < resolvedReaction.elementCount(); i += 1) {
javax.swing.JComboBox jcb = new javax.swing.JComboBox();
jcb.setRenderer(structureListCellRenderer);
structureAssignmentJCB[i] = jcb;
if (resolvedReaction.isFluxReaction() && resolvedReaction.isFlux(i) && resolvedReaction.getFluxIndexOutside() == i) {
jcb.addItem(structTopology.getOutsideFeature((Membrane) getStructure()));
jcb.setEnabled(false);
} else if (resolvedReaction.isFluxReaction() && resolvedReaction.isFlux(i) && resolvedReaction.getFluxIndexInside() == i) {
jcb.addItem((structTopology).getInsideFeature((Membrane) getStructure()));
jcb.setEnabled(false);
} else {
jcb.addItem(getStructure());
if (getStructure() instanceof Membrane) {
jcb.addItem(structTopology.getOutsideFeature((Membrane) getStructure()));
jcb.addItem(structTopology.getInsideFeature((Membrane) getStructure()));
} else {
jcb.setEnabled(false);
}
}
gbc.gridy = i + 1;
getRXParticipantsJPanel().add(jcb, gbc);
}
for (int i = 0; i < resolvedReaction.elementCount(); i += 1) {
speciesAssignmentJCB[i].addActionListener(this);
structureAssignmentJCB[i].addActionListener(this);
}
}
}
use of cbit.vcell.model.Structure in project vcell by virtualcell.
the class DBReactionWizardPanel method applySelectedReactionElements.
/**
* Comment
*/
private void applySelectedReactionElements() {
AsynchClientTask getRXSourceModelTask = new AsynchClientTask("Get RX source model", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
// Get the complete original model the user selected reaction is from
Model fromModel = getDocumentManager().getBioModel(resolvedReaction.getVCellBioModelID()).getModel();
// find the user selected ReactionStep in the original model
ReactionStep fromRXStep = null;
ReactionStep[] rxArr = fromModel.getReactionSteps();
for (int i = 0; i < rxArr.length; i++) {
if (rxArr[i].getKey().equals(resolvedReaction.getVCellRXID())) {
fromRXStep = rxArr[i];
break;
}
}
// Create user assignment preferences
BioCartoonTool.UserResolvedRxElements userResolvedRxElements = new BioCartoonTool.UserResolvedRxElements();
userResolvedRxElements.fromSpeciesContextArr = new SpeciesContext[resolvedReaction.elementCount()];
userResolvedRxElements.toSpeciesArr = new Species[resolvedReaction.elementCount()];
userResolvedRxElements.toStructureArr = new Structure[resolvedReaction.elementCount()];
StringBuffer warningsSB = new StringBuffer();
for (int i = 0; i < resolvedReaction.elementCount(); i++) {
System.out.println(resolvedReaction.getOrigSpeciesContextName(i));
userResolvedRxElements.fromSpeciesContextArr[i] = fromModel.getSpeciesContext(resolvedReaction.getOrigSpeciesContextName(i));
userResolvedRxElements.toSpeciesArr[i] = (speciesAssignmentJCB[i].getSelectedItem() instanceof Species ? (Species) speciesAssignmentJCB[i].getSelectedItem() : null);
userResolvedRxElements.toStructureArr[i] = (Structure) structureAssignmentJCB[i].getSelectedItem();
if (userResolvedRxElements.toSpeciesArr[i] != null) {
SpeciesContext fromSpeciesContext = userResolvedRxElements.fromSpeciesContextArr[i];
Species toSpecies = userResolvedRxElements.toSpeciesArr[i];
if (fromSpeciesContext.getSpecies().getDBSpecies() != null && !Compare.isEqualOrNull(toSpecies.getDBSpecies(), fromSpeciesContext.getSpecies().getDBSpecies())) {
warningsSB.append((warningsSB.length() > 0 ? "\n" : "") + "'" + fromSpeciesContext.getSpecies().getCommonName() + "' formal(" + (fromSpeciesContext.getSpecies().getDBSpecies() != null ? fromSpeciesContext.getSpecies().getDBSpecies().getPreferredName() : "null") + ")" + "\nwill be re-assigned to\n" + "'" + toSpecies.getCommonName() + "' formal(" + (toSpecies.getDBSpecies() != null ? toSpecies.getDBSpecies().getPreferredName() : "null") + ")");
}
}
}
if (warningsSB.length() > 0) {
final String proceed = "Add reaction anyway";
final String cancel = "Cancel";
String result = DialogUtils.showWarningDialog(DBReactionWizardPanel.this, "A user choice selected under 'Assign to Model species' will force re-assignment of " + "the formal reference for one of the species in the reaction.\n" + warningsSB, new String[] { proceed, cancel }, cancel);
if (result.equals(cancel)) {
throw UserCancelException.CANCEL_GENERIC;
}
}
hashTable.put("fromRXStep", fromRXStep);
hashTable.put("userResolvedRxElements", userResolvedRxElements);
}
};
AsynchClientTask pasteReactionTask = new AsynchClientTask("Paste reaction", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
// TODO Auto-generated method stub
Model pasteToModel = DBReactionWizardPanel.this.getModel();
Structure pasteToStructure = DBReactionWizardPanel.this.getStructure();
BioCartoonTool.pasteReactionSteps(DBReactionWizardPanel.this, new ReactionStep[] { (ReactionStep) hashTable.get("fromRXStep") }, pasteToModel, pasteToStructure, false, (UserResolvedRxElements) hashTable.get("userResolvedRxElements"), rxPasteInterface);
closeParent();
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { getRXSourceModelTask, pasteReactionTask }, false, false, null, true);
}
use of cbit.vcell.model.Structure in project vcell by virtualcell.
the class IssueTableModel method getSourceObjectPathDescription.
private String getSourceObjectPathDescription(VCDocument vcDocument, Issue issue) {
VCAssert.assertValid(issue);
Object source = issue.getSource();
{
IssueOrigin io = BeanUtils.downcast(IssueOrigin.class, source);
if (io != null) {
return io.getDescription();
}
}
if (vcDocument instanceof BioModel) {
BioModel bioModel = (BioModel) vcDocument;
String description = "";
if (source instanceof SymbolTableEntry) {
if (source instanceof SpeciesContext) {
description = "Model / Species";
} else if (source instanceof RbmObservable) {
description = "Model / Observables";
} else {
description = ((SymbolTableEntry) source).getNameScope().getPathDescription();
}
} else if (source instanceof MolecularType) {
description = "Model / Molecules";
} else if (source instanceof ReactionStep) {
ReactionStep reactionStep = (ReactionStep) source;
description = ((ReactionNameScope) reactionStep.getNameScope()).getPathDescription();
} else if (source instanceof ReactionRule) {
ReactionRule reactionRule = (ReactionRule) source;
description = ((ReactionRuleNameScope) reactionRule.getNameScope()).getPathDescription();
} else if (source instanceof SpeciesPattern) {
// if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
// description = "Model / Species";
// }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
// ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
// description = ((ReactionRuleNameScope)thing.getNameScope()).getPathDescription();
// }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
// description = "Model / Observables";
// } else {
System.err.println("Bad issue context for " + ((SpeciesPattern) source).toString());
description = ((SpeciesPattern) source).toString();
// }
} else if (source instanceof Structure) {
Structure structure = (Structure) source;
description = "Model / " + structure.getTypeName() + "(" + structure.getName() + ")";
} else if (source instanceof StructureMapping) {
StructureMapping structureMapping = (StructureMapping) source;
description = ((StructureMappingNameScope) structureMapping.getNameScope()).getPathDescription();
} else if (source instanceof OutputFunctionIssueSource) {
SimulationContext simulationContext = (SimulationContext) ((OutputFunctionIssueSource) source).getOutputFunctionContext().getSimulationOwner();
description = "App(" + simulationContext.getName() + ") / " + "Simulations" + " / " + "Output Functions";
} else if (source instanceof Simulation) {
Simulation simulation = (Simulation) source;
try {
SimulationContext simulationContext = bioModel.getSimulationContext(simulation);
description = "App(" + simulationContext.getName() + ") / Simulations";
} catch (ObjectNotFoundException e) {
e.printStackTrace();
description = "App(" + "unknown" + ") / Simulations";
}
} else if (source instanceof UnmappedGeometryClass) {
UnmappedGeometryClass unmappedGC = (UnmappedGeometryClass) source;
description = "App(" + unmappedGC.getSimulationContext().getName() + ") / Subdomain(" + unmappedGC.getGeometryClass().getName() + ")";
} else if (source instanceof GeometryContext) {
description = "App(" + ((GeometryContext) source).getSimulationContext().getName() + ")";
} else if (source instanceof ModelOptimizationSpec) {
description = "App(" + ((ModelOptimizationSpec) source).getSimulationContext().getName() + ") / Parameter Estimation";
} else if (source instanceof MicroscopeMeasurement) {
description = "App(" + ((MicroscopeMeasurement) source).getSimulationContext().getName() + ") / Microscope Measurements";
} else if (source instanceof SpatialObject) {
description = "App(" + ((SpatialObject) source).getSimulationContext().getName() + ") / Spatial Objects";
} else if (source instanceof SpatialProcess) {
description = "App(" + ((SpatialProcess) source).getSimulationContext().getName() + ") / Spatial Processes";
} else if (source instanceof SpeciesContextSpec) {
SpeciesContextSpec scs = (SpeciesContextSpec) source;
description = "App(" + scs.getSimulationContext().getName() + ") / Specifications / Species";
} else if (source instanceof ReactionCombo) {
ReactionCombo rc = (ReactionCombo) source;
description = "App(" + rc.getReactionContext().getSimulationContext().getName() + ") / Specifications / Reactions";
} else if (source instanceof RbmModelContainer) {
IssueCategory ic = issue.getCategory();
switch(ic) {
case RbmMolecularTypesTableBad:
description = "Model / " + MolecularType.typeName + "s";
break;
case RbmReactionRulesTableBad:
description = "Model / Reactions";
break;
case RbmObservablesTableBad:
description = "Model / Observables";
break;
case RbmNetworkConstraintsBad:
description = "Network Constrains";
break;
default:
description = "Model";
break;
}
} else if (source instanceof SimulationContext) {
SimulationContext sc = (SimulationContext) source;
IssueCategory ic = issue.getCategory();
switch(ic) {
case RbmNetworkConstraintsBad:
description = "Specifications / Network";
break;
default:
description = "Application";
break;
}
} else if (source instanceof Model) {
description = "Model";
} else if (source instanceof BioEvent) {
return "Protocols / Events";
} else if (source instanceof MathDescription) {
return "Math Description";
} else {
System.err.println("unknown source type in IssueTableModel.getSourceObjectPathDescription(): " + source.getClass());
}
return description;
} else if (vcDocument instanceof MathModel) {
if (source instanceof Geometry) {
return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_GEOMETRY;
} else if (source instanceof OutputFunctionIssueSource) {
return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_OUTPUTFUNCTIONS;
} else if (source instanceof Simulation) {
return "Simulation(" + ((Simulation) source).getName() + ")";
} else {
return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_VCML;
}
} else {
System.err.println("unknown document type in IssueTableModel.getSourceObjectPathDescription()");
return "";
}
}
use of cbit.vcell.model.Structure in project vcell by virtualcell.
the class IssueTableModel method getSourceObjectDescription.
private String getSourceObjectDescription(VCDocument vcDocument, Issue issue) {
if (vcDocument instanceof BioModel) {
Object object = issue.getSource();
{
DecoratedIssueSource dis = BeanUtils.downcast(DecoratedIssueSource.class, object);
if (dis != null) {
return dis.getSourcePath();
}
}
String description = "";
if (object instanceof SymbolTableEntry) {
description = ((SymbolTableEntry) object).getName();
} else if (object instanceof ReactionStep) {
description = ((ReactionStep) object).getName();
} else if (object instanceof ReactionRule) {
description = ((ReactionRule) object).getName();
} else if (object instanceof SpeciesPattern) {
// Object parent = issue.getIssueContext().getContextObject();
// if (parent instanceof SpeciesContext){
// description = ((SpeciesContext)parent).getName();
// }
// if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
// SpeciesContext thing = (SpeciesContext)issue.getIssueContext().getContextObject(ContextType.SpeciesContext);
// description = thing.getName();
// }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
// ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
// description = thing.getName();
// }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
// RbmObservable thing = (RbmObservable)issue.getIssueContext().getContextObject(ContextType.RbmObservable);
// description = thing.getName();
// } else {
System.err.println("Bad issue context for " + ((SpeciesPattern) object).toString());
description = ((SpeciesPattern) object).toString();
// }
} else if (object instanceof MolecularType) {
description = ((MolecularType) object).getName();
} else if (object instanceof MolecularComponent) {
description = ((MolecularComponent) object).getName();
} else if (object instanceof ComponentStateDefinition) {
description = ((ComponentStateDefinition) object).getName();
} else if (object instanceof Structure) {
description = ((Structure) object).getName();
} else if (object instanceof SubDomain) {
description = ((SubDomain) object).getName();
} else if (object instanceof Geometry) {
description = ((Geometry) object).getName();
} else if (object instanceof StructureMapping) {
description = ((StructureMapping) object).getStructure().getName();
} else if (object instanceof OutputFunctionIssueSource) {
description = ((OutputFunctionIssueSource) object).getAnnotatedFunction().getName();
} else if (object instanceof UnmappedGeometryClass) {
description = ((UnmappedGeometryClass) object).getGeometryClass().getName();
} else if (object instanceof MicroscopeMeasurement) {
description = ((MicroscopeMeasurement) object).getName();
} else if (object instanceof SpatialObject) {
description = ((SpatialObject) object).getName();
} else if (object instanceof SpatialProcess) {
description = ((SpatialProcess) object).getName();
} else if (object instanceof GeometryContext) {
description = "Geometry";
} else if (object instanceof ModelOptimizationSpec) {
description = ((ModelOptimizationSpec) object).getParameterEstimationTask().getName();
} else if (object instanceof Simulation) {
description = ((Simulation) object).getName();
} else if (object instanceof SpeciesContextSpec) {
SpeciesContextSpec scs = (SpeciesContextSpec) object;
description = scs.getSpeciesContext().getName();
} else if (object instanceof ReactionCombo) {
ReactionSpec rs = ((ReactionCombo) object).getReactionSpec();
description = rs.getReactionStep().getName();
} else if (object instanceof RbmModelContainer) {
// RbmModelContainer mc = (RbmModelContainer)object;
description = "Rules validator";
} else if (object instanceof SimulationContext) {
SimulationContext sc = (SimulationContext) object;
description = sc.getName();
} else if (object instanceof Model) {
Model m = (Model) object;
description = m.getName();
} else if (object instanceof BioEvent) {
return ((BioEvent) object).getName() + "";
} else if (object instanceof MathDescription) {
return ((MathDescription) object).getName() + "";
} else {
System.err.println("unknown object type in IssueTableModel.getSourceObjectDescription(): " + object.getClass());
}
return description;
} else if (vcDocument instanceof MathModel) {
Object object = issue.getSource();
String description = "";
if (object instanceof Variable) {
description = ((Variable) object).getName();
} else if (object instanceof SubDomain) {
description = ((SubDomain) object).getName();
} else if (object instanceof Geometry) {
description = "Geometry";
} else if (object instanceof OutputFunctionIssueSource) {
description = ((OutputFunctionIssueSource) object).getAnnotatedFunction().getName();
} else if (object instanceof MathDescription) {
return "math";
} else if (object instanceof Simulation) {
return "Simulation " + ((Simulation) object).getName() + "";
}
return description;
} else {
System.err.println("unknown document type in IssueTableModel.getSourceObjectDescription()");
return "";
}
}
Aggregations