use of cbit.vcell.model.Structure in project vcell by virtualcell.
the class BioModelEditor method setRightBottomPanelOnSelection.
@Override
protected void setRightBottomPanelOnSelection(Object[] selections) {
if (selections == null) {
return;
}
JComponent bottomComponent = rightBottomEmptyPanel;
int destComponentIndex = DocumentEditorTabID.object_properties.ordinal();
boolean bShowInDatabaseProperties = false;
boolean bShowPathway = false;
if (selections.length == 1) {
Object singleSelection = selections[0];
if (singleSelection instanceof ReactionStep) {
bottomComponent = getReactionPropertiesPanel();
} else if (singleSelection instanceof ReactionRule) {
bottomComponent = getReactionRulePropertiesPanel();
} else if (singleSelection instanceof SpeciesContext) {
bottomComponent = getSpeciesPropertiesPanel();
} else if (singleSelection instanceof MolecularType) {
bottomComponent = getMolecularTypePropertiesPanel();
} else if (singleSelection instanceof RbmObservable) {
bottomComponent = getObservablePropertiesPanel();
} else if (singleSelection instanceof Structure) {
bottomComponent = getStructurePropertiesPanel();
getStructurePropertiesPanel().setModel(bioModel.getModel());
} else if (singleSelection instanceof Parameter) {
bottomComponent = getParameterPropertiesPanel();
} else if (singleSelection instanceof SimulationContext) {
bottomComponent = getApplicationPropertiesPanel();
} else if (singleSelection instanceof ParameterEstimationTask) {
bottomComponent = parameterEstimationTaskPropertiesPanel;
} else if (singleSelection instanceof Product || singleSelection instanceof Reactant) {
bottomComponent = getReactionParticipantPropertiesPanel();
} else if (singleSelection instanceof BioModelInfo) {
bShowInDatabaseProperties = true;
bottomComponent = bioModelMetaDataPanel;
} else if (singleSelection instanceof MathModelInfo) {
bShowInDatabaseProperties = true;
bottomComponent = mathModelMetaDataPanel;
} else if (singleSelection instanceof GeometryInfo) {
bShowInDatabaseProperties = true;
bottomComponent = geometryMetaDataPanel;
} else if (singleSelection instanceof SpeciesContextSpec) {
bottomComponent = getSpeciesContextSpecPanel();
} else if (singleSelection instanceof ReactionSpec) {
bottomComponent = getKineticsTypeTemplatePanel();
} else if (singleSelection instanceof ReactionRuleSpec) {
//
bottomComponent = getReactionRuleSpecPropertiesPanel();
} else if (singleSelection instanceof BioModelsNetModelInfo) {
bShowInDatabaseProperties = true;
bottomComponent = getBioModelsNetPropertiesPanel();
} else if (singleSelection instanceof Simulation) {
bottomComponent = getSimulationSummaryPanel();
} else if (singleSelection instanceof DataSymbol) {
bottomComponent = getDataSymbolsSpecPanel();
} else if (singleSelection instanceof BioEvent) {
bottomComponent = getEventPanel();
} else if (singleSelection instanceof SpatialObject) {
bottomComponent = getSpatialObjectPropertyPanel();
} else if (singleSelection instanceof SpatialProcess) {
bottomComponent = getSpatialProcessPropertyPanel();
} else if (singleSelection instanceof BioPaxObject) {
bottomComponent = bioPaxObjectPropertiesPanel;
} else if (singleSelection instanceof BioModel || singleSelection instanceof VCMetaData) {
bottomComponent = bioModelEditorAnnotationPanel;
} else if (singleSelection instanceof PathwayData) {
bShowPathway = true;
bottomComponent = getBioModelEditorPathwayPanel();
} else if (singleSelection instanceof Model) {
} else if (singleSelection instanceof RuleParticipantSignature) {
bottomComponent = getReactionRuleParticipantSignaturePropertiesPanel();
} else if (singleSelection instanceof CSGObject) {
bottomComponent = csgObjectPropertiesPanel;
csgObjectPropertiesPanel.setSimulationContext(getSelectedSimulationContext());
} else if (singleSelection instanceof DocumentEditorTreeFolderNode) {
DocumentEditorTreeFolderClass folderClass = ((DocumentEditorTreeFolderNode) singleSelection).getFolderClass();
if ((folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) && !(singleSelection instanceof ReactionRule)) {
bottomComponent = getReactionPropertiesPanel();
} else if ((folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) && (singleSelection instanceof ReactionRule)) {
bottomComponent = getReactionRulePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.STRUCTURES_NODE) {
bottomComponent = getStructurePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.SPECIES_NODE) {
bottomComponent = getSpeciesPropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE) {
bottomComponent = getMolecularTypePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.OBSERVABLES_NODE) {
bottomComponent = getObservablePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.APPLICATIONS_NODE) {
bottomComponent = getApplicationsPropertiesPanel();
getApplicationsPropertiesPanel().setBioModel(bioModel);
} else if (folderClass == DocumentEditorTreeFolderClass.PARAMETER_ESTIMATION_NODE) {
bottomComponent = parameterEstimationTaskPropertiesPanel;
}
}
}
if (bShowPathway) {
for (destComponentIndex = 0; destComponentIndex < rightBottomTabbedPane.getTabCount(); destComponentIndex++) {
if (rightBottomTabbedPane.getComponentAt(destComponentIndex) == bottomComponent) {
break;
}
}
String tabTitle = "Pathway Preview";
if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
rightBottomTabbedPane.addTab(tabTitle, new TabCloseIcon(), bottomComponent);
}
} else if (bShowInDatabaseProperties) {
for (destComponentIndex = 0; destComponentIndex < rightBottomTabbedPane.getTabCount(); destComponentIndex++) {
Component c = rightBottomTabbedPane.getComponentAt(destComponentIndex);
if (c == bioModelMetaDataPanel || c == mathModelMetaDataPanel || c == geometryMetaDataPanel || c == getBioModelsNetPropertiesPanel()) {
break;
}
}
if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
rightBottomTabbedPane.addTab(DATABASE_PROPERTIES_TAB_TITLE, new TabCloseIcon(), bottomComponent);
}
}
if (rightBottomTabbedPane.getComponentAt(destComponentIndex) != bottomComponent) {
bottomComponent.setBorder(GuiConstants.TAB_PANEL_BORDER);
rightBottomTabbedPane.setComponentAt(destComponentIndex, bottomComponent);
rightSplitPane.repaint();
}
if (rightBottomTabbedPane.getSelectedComponent() != bottomComponent) {
rightBottomTabbedPane.setSelectedComponent(bottomComponent);
}
}
use of cbit.vcell.model.Structure in project vcell by virtualcell.
the class BioModelEditorModelPanel method deleteButtonPressed.
private void deleteButtonPressed() {
try {
ArrayList<Object> deleteList = new ArrayList<Object>();
int selectedIndex = tabbedPane.getSelectedIndex();
if (selectedIndex == ModelPanelTabID.reaction_diagram.ordinal()) {
deleteList.addAll(Arrays.asList(reactionCartoonEditorPanel.getReactionCartoon().getSelectedObjects()));
// } else if (selectedIndex == ModelPanelTabID.structure_diagram.ordinal()) {
// deleteList.addAll(Arrays.asList(cartoonEditorPanel.getStructureCartoon().getSelectedObjects()));
} else {
computeCurrentSelectedTable();
int[] rows = currentSelectedTable.getSelectedRows();
if (rows == null || rows.length == 0) {
return;
}
if (currentSelectedTable == speciesTable) {
for (int r : rows) {
if (r < speciesTableModel.getRowCount()) {
SpeciesContext speciesContext = speciesTableModel.getValueAt(r);
if (speciesContext != null) {
deleteList.add(speciesContext);
}
}
}
} else if (currentSelectedTable == molecularTypeTable) {
// TODO: delete stuff
for (int r : rows) {
if (r < molecularTypeTableModel.getRowCount()) {
MolecularType mt = molecularTypeTableModel.getValueAt(r);
if (mt != null) {
deleteList.add(mt);
}
}
}
} else if (currentSelectedTable == observablesTable) {
for (int r : rows) {
if (r < observableTableModel.getRowCount()) {
RbmObservable o = observableTableModel.getValueAt(r);
if (o != null) {
deleteList.add(o);
}
}
}
} else if (currentSelectedTable == structuresTable) {
for (int r : rows) {
if (r < structureTableModel.getRowCount()) {
Structure rowValue = structureTableModel.getValueAt(r);
if (rowValue instanceof Feature || rowValue instanceof Membrane) {
deleteList.add(rowValue);
}
}
}
} else if (currentSelectedTable == reactionsTable) {
for (int r : rows) {
if (r < reactionTableModel.getRowCount()) {
ModelProcess reaction = reactionTableModel.getValueAt(r);
if (reaction != null) {
deleteList.add(reaction);
}
}
}
}
}
if (deleteList.size() == 0) {
return;
}
StringBuilder deleteListText = new StringBuilder();
for (Object object : deleteList) {
if (object instanceof SpeciesContext) {
deleteListText.append("Species\t'" + ((SpeciesContext) object).getName() + "'\n");
} else if (object instanceof MolecularType) {
deleteListText.append(((MolecularType) object).getDisplayType() + "\t'" + ((MolecularType) object).getDisplayName() + "'\n");
} else if (object instanceof RbmObservable) {
deleteListText.append("Observable\t'" + ((RbmObservable) object).getName() + "'\n");
} else if (object instanceof ReactionStep) {
deleteListText.append("Reaction\t'" + ((ReactionStep) object).getName() + "'\n");
} else if (object instanceof ReactionRule) {
deleteListText.append("Reaction rule\t'" + ((ReactionRule) object).getName() + "'\n");
} else if (object instanceof Structure) {
deleteListText.append("Structure\t'" + ((Structure) object).getName() + "'\n");
}
}
// TODO: once we display reaction rules in the carton editor panel we'll have to change the way we delete reaction rules
if (deleteList.get(0) instanceof SpeciesContext || deleteList.get(0) instanceof ReactionStep) {
try {
ArrayList<SpeciesContext> speciesContextArrList = new ArrayList<SpeciesContext>();
ArrayList<ReactionStep> reactionStepArrList = new ArrayList<ReactionStep>();
for (Object obj : deleteList) {
if (obj instanceof SpeciesContext) {
speciesContextArrList.add((SpeciesContext) obj);
} else if (obj instanceof ReactionStep) {
reactionStepArrList.add((ReactionStep) obj);
} else {
throw new Exception("Unexpected delete object " + obj.getClass().getName());
}
}
ReactionCartoonTool.deleteReactionsAndSpecies(reactionCartoonEditorPanel, reactionStepArrList.toArray(new ReactionStep[0]), speciesContextArrList.toArray(new SpeciesContext[0]));
} catch (UserCancelException uce) {
return;
}
return;
} else {
String confirm = DialogUtils.showOKCancelWarningDialog(this, "Deleting", "You are going to delete the following:\n\n" + deleteListText + "\n Continue?");
if (confirm.equals(UserMessage.OPTION_CANCEL)) {
return;
}
for (Object object : deleteList) {
if (object instanceof ReactionRule) {
ReactionRule rr = (ReactionRule) object;
bioModel.getModel().getRbmModelContainer().removeReactionRule(rr);
} else if (object instanceof MolecularType) {
Map<String, Pair<Displayable, SpeciesPattern>> usedHere = new LinkedHashMap<String, Pair<Displayable, SpeciesPattern>>();
MolecularType mt = (MolecularType) object;
if (!bioModel.getModel().getRbmModelContainer().isDeleteAllowed(mt, usedHere)) {
String errMsg = mt.getDisplayType() + " <b>'" + mt + "'</b> cannot be deleted because it's already being used by:<br>";
final int MaxListSize = 7;
int count = 0;
for (String key : usedHere.keySet()) {
System.out.println(key);
if (count >= MaxListSize) {
errMsg += "<br> ... and more.";
break;
}
Pair<Displayable, SpeciesPattern> o = usedHere.get(key);
Displayable e = o.one;
SpeciesPattern sp = o.two;
errMsg += "<br> - " + e.getDisplayType().toLowerCase() + " <b>" + e.getDisplayName() + "</b>";
errMsg += ", " + sp.getDisplayType().toLowerCase() + " " + " <b>" + sp.getDisplayName() + "</b>";
count++;
}
errMsg = "<html>" + errMsg + "</html>";
throw new RuntimeException(errMsg);
}
bioModel.getModel().getRbmModelContainer().removeMolecularType(mt);
} else if (object instanceof RbmObservable) {
RbmObservable o = (RbmObservable) object;
bioModel.getModel().getRbmModelContainer().removeObservable(o);
} else {
bioModel.getModel().removeObject(object);
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
DialogUtils.showErrorDialog(this, ex.getMessage());
}
}
use of cbit.vcell.model.Structure in project vcell by virtualcell.
the class StructurePropertiesPanel method setModel.
public void setModel(Model model) {
fieldModel = model;
DefaultComboBoxModel<String> dataModelPos = new DefaultComboBoxModel<String>();
DefaultComboBoxModel<String> dataModelNeg = new DefaultComboBoxModel<String>();
dataModelPos.addElement("");
dataModelNeg.addElement("");
for (Structure s : model.getStructures()) {
if (s instanceof Feature) {
dataModelPos.addElement(s.getName());
dataModelNeg.addElement(s.getName());
}
}
// fill the comboBoxes with feature names from the model.
positiveFeatureComboBox.setModel(dataModelPos);
// if selected structure is a membrane, if it has +ve/-ve feature set, set the comboBox with that selection.
if (structure instanceof Membrane) {
Membrane membrane = (Membrane) structure;
if (fieldModel.getElectricalTopology().getPositiveFeature(membrane) != null) {
positiveFeatureComboBox.setSelectedItem(fieldModel.getElectricalTopology().getPositiveFeature(membrane).getName());
}
}
negativeFeatureComboBox.setModel(dataModelNeg);
if (structure instanceof Membrane) {
Membrane membrane = (Membrane) structure;
if (fieldModel.getElectricalTopology().getNegativeFeature(membrane) != null) {
negativeFeatureComboBox.setSelectedItem(fieldModel.getElectricalTopology().getNegativeFeature(membrane).getName());
}
}
}
use of cbit.vcell.model.Structure in project vcell by virtualcell.
the class StructurePropertiesPanel method setStructure.
/**
* Sets the speciesContext property (cbit.vcell.model.SpeciesContext) value.
* @param speciesContext The new value for the property.
* @see #getSpeciesContext
*/
void setStructure(Structure newValue) {
if (newValue == structure) {
return;
}
Structure oldValue = structure;
if (oldValue != null) {
oldValue.removePropertyChangeListener(eventHandler);
oldValue.getStructureSize().removePropertyChangeListener(eventHandler);
if (oldValue instanceof Membrane) {
((Membrane) oldValue).getMembraneVoltage().removePropertyChangeListener(eventHandler);
}
}
// commit the changes before switch to another structure
changeName();
changeAnnotation();
structure = newValue;
if (newValue != null) {
newValue.addPropertyChangeListener(eventHandler);
newValue.getStructureSize().addPropertyChangeListener(eventHandler);
if (newValue instanceof Membrane) {
((Membrane) newValue).getMembraneVoltage().addPropertyChangeListener(eventHandler);
}
}
updateInterface();
}
use of cbit.vcell.model.Structure in project vcell by virtualcell.
the class InitialConditionsPanel method initialize.
/**
* Initialize the class.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initialize() {
try {
// user code begin {1}
// user code end
setName("InitialConditionsPanel");
setLayout(new BorderLayout());
add(getRadioButtonAndCheckboxPanel(), BorderLayout.NORTH);
add(getScrollPaneTable().getEnclosingScrollPane(), BorderLayout.CENTER);
getScrollPaneTable().getSelectionModel().addListSelectionListener(ivjEventHandler);
getJMenuItemPaste().addActionListener(ivjEventHandler);
getJMenuItemCopy().addActionListener(ivjEventHandler);
getJMenuItemCopyAll().addActionListener(ivjEventHandler);
getJMenuItemPasteAll().addActionListener(ivjEventHandler);
getAmountRadioButton().addActionListener(ivjEventHandler);
getConcentrationRadioButton().addActionListener(ivjEventHandler);
getRandomizeInitCondnCheckbox().addActionListener(ivjEventHandler);
DefaultTableCellRenderer renderer = new DefaultScrollTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setIcon(null);
defaultToolTipText = null;
if (value instanceof Species) {
setText(((Species) value).getCommonName());
defaultToolTipText = getText();
setToolTipText(defaultToolTipText);
} else if (value instanceof SpeciesContext) {
setText(((SpeciesContext) value).getName());
defaultToolTipText = getText();
setToolTipText(defaultToolTipText);
} else if (value instanceof Structure) {
setText(((Structure) value).getName());
defaultToolTipText = getText();
setToolTipText(defaultToolTipText);
} else if (value instanceof ScopedExpression) {
SpeciesContextSpec scSpec = tableModel.getValueAt(row);
VCUnitDefinition unit = null;
if (table.getColumnName(column).equals(SpeciesContextSpecsTableModel.ColumnType.COLUMN_INITIAL.label)) {
SpeciesContextSpecParameter initialConditionParameter = scSpec.getInitialConditionParameter();
unit = initialConditionParameter.getUnitDefinition();
} else if (table.getColumnName(column).equals(SpeciesContextSpecsTableModel.ColumnType.COLUMN_DIFFUSION.label)) {
SpeciesContextSpecParameter diffusionParameter = scSpec.getDiffusionParameter();
unit = diffusionParameter.getUnitDefinition();
}
if (unit != null) {
setHorizontalTextPosition(JLabel.LEFT);
setIcon(new TextIcon("[" + unit.getSymbolUnicode() + "]", DefaultScrollTableCellRenderer.uneditableForeground));
}
int rgb = 0x00ffffff & DefaultScrollTableCellRenderer.uneditableForeground.getRGB();
defaultToolTipText = "<html>" + StringEscapeUtils.escapeHtml4(getText()) + " <font color=#" + Integer.toHexString(rgb) + "> [" + unit.getSymbolUnicode() + "] </font></html>";
setToolTipText(defaultToolTipText);
if (unit != null) {
setText(defaultToolTipText);
}
}
TableModel tableModel = table.getModel();
if (tableModel instanceof SortTableModel) {
DefaultScrollTableCellRenderer.issueRenderer(this, defaultToolTipText, table, row, column, (SortTableModel) tableModel);
setHorizontalTextPosition(JLabel.TRAILING);
}
return this;
}
};
DefaultTableCellRenderer rbmSpeciesShapeDepictionCellRenderer = new DefaultScrollTableCellRenderer() {
SpeciesPatternSmallShape spss = null;
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == tableModel) {
selectedObject = tableModel.getValueAt(row);
}
if (selectedObject != null) {
if (selectedObject instanceof SpeciesContextSpec) {
SpeciesContextSpec scs = (SpeciesContextSpec) selectedObject;
SpeciesContext sc = scs.getSpeciesContext();
// sp may be null for "plain" species contexts
SpeciesPattern sp = sc.getSpeciesPattern();
Graphics panelContext = table.getGraphics();
spss = new SpeciesPatternSmallShape(4, 2, sp, shapeManager, panelContext, sc, isSelected, issueManager);
}
} else {
spss = null;
}
}
setText("");
return this;
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (spss != null) {
spss.paintSelf(g);
}
}
};
getScrollPaneTable().setDefaultRenderer(SpeciesContext.class, renderer);
getScrollPaneTable().setDefaultRenderer(Structure.class, renderer);
getScrollPaneTable().setDefaultRenderer(SpeciesPattern.class, rbmSpeciesShapeDepictionCellRenderer);
getScrollPaneTable().setDefaultRenderer(Species.class, renderer);
getScrollPaneTable().setDefaultRenderer(ScopedExpression.class, renderer);
getScrollPaneTable().setDefaultRenderer(Boolean.class, new ScrollTableBooleanCellRenderer());
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
Aggregations