use of org.vcell.model.rbm.ComponentStateDefinition in project vcell by virtualcell.
the class SpeciesPropertiesPanel method manageComponentPatternFromShape.
public void manageComponentPatternFromShape(final RbmElementAbstract selectedObject, PointLocationInShapeContext locationContext, ShowWhat showWhat) {
popupFromShapeMenu.removeAll();
final MolecularComponentPattern mcp = (MolecularComponentPattern) selectedObject;
final MolecularComponent mc = mcp.getMolecularComponent();
// ------------------------------------------------------------------- State
if (showWhat == ShowWhat.ShowState && mc.getComponentStateDefinitions().size() != 0) {
String prefix = "State: ";
final Map<String, String> itemMap = new LinkedHashMap<String, String>();
// itemList.add(ComponentStatePattern.strAny); // any is not an option for state
String csdCurrentName;
for (final ComponentStateDefinition csd : mc.getComponentStateDefinitions()) {
csdCurrentName = "";
if (mcp.getComponentStatePattern() != null && !mcp.getComponentStatePattern().isAny()) {
ComponentStateDefinition csdCurrent = mcp.getComponentStatePattern().getComponentStateDefinition();
csdCurrentName = csdCurrent.getName();
}
String name = csd.getName();
if (name.equals(csdCurrentName)) {
// currently selected menu item is shown in bold
name = "<html>" + prefix + "<b>" + name + "</b></html>";
} else {
name = "<html>" + prefix + name + "</html>";
}
itemMap.put(name, csd.getName());
}
for (String name : itemMap.keySet()) {
JMenuItem menuItem = new JMenuItem(name);
popupFromShapeMenu.add(menuItem);
menuItem.setIcon(VCellIcons.rbmComponentStateIcon);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String key = e.getActionCommand();
String name = itemMap.get(key);
if (name.equals(ComponentStatePattern.strAny)) {
ComponentStatePattern csp = new ComponentStatePattern();
mcp.setComponentStatePattern(csp);
} else {
ComponentStateDefinition csd = mcp.getMolecularComponent().getComponentStateDefinition(name);
if (csd == null) {
throw new RuntimeException("Missing ComponentStateDefinition " + name + " for Component " + mcp.getMolecularComponent().getName());
}
ComponentStatePattern csp = new ComponentStatePattern(csd);
mcp.setComponentStatePattern(csp);
}
}
});
}
}
if (showWhat == ShowWhat.ShowState) {
return;
}
// ---------------------------------------------------------------------------- Bonds
final MolecularTypePattern mtp = locationContext.getMolecularTypePattern();
final SpeciesPattern sp = locationContext.getSpeciesPattern();
JMenu editBondMenu = new JMenu();
final String specifiedString = mcp.getBondType() == BondType.Specified ? "<html><b>" + "Site bond specified" + "</b></html>" : "<html>" + "Site bond specified" + "</html>";
editBondMenu.setText(specifiedString);
editBondMenu.setToolTipText("Specified");
editBondMenu.removeAll();
final Map<String, Bond> itemMap = new LinkedHashMap<String, Bond>();
String noneString = mcp.getBondType() == BondType.None ? "<html><b>" + "Site is unbound" + "</b></html>" : "<html>" + "Site is unbound" + "</html>";
itemMap.put(noneString, null);
// itemMap.put(possibleString, null); // not a valid option for species
if (mtp != null && sp != null) {
List<Bond> bondPartnerChoices = sp.getAllBondPartnerChoices(mtp, mc);
for (Bond b : bondPartnerChoices) {
// if(b.equals(mcp.getBond())) {
// continue; // if the mcp has a bond already we don't offer it
// }
int index = 0;
if (mcp.getBondType() == BondType.Specified) {
index = mcp.getBondId();
} else {
index = sp.nextBondId();
}
itemMap.put(b.toHtmlStringLong(sp, mtp, mc, index), b);
// itemMap.put(b.toHtmlStringLong(sp, index), b);
}
}
int index = 0;
Graphics gc = shapePanel.getGraphics();
for (String name : itemMap.keySet()) {
JMenuItem menuItem = new JMenuItem(name);
if (index == 0) {
menuItem.setIcon(VCellIcons.rbmBondNoneIcon);
menuItem.setToolTipText("None");
popupFromShapeMenu.add(menuItem);
} else {
Bond b = itemMap.get(name);
// clone of the sp, with only the bond of interest
SpeciesPattern spBond = new SpeciesPattern(bioModel.getModel(), sp);
spBond.resetBonds();
spBond.resetStates();
MolecularTypePattern mtpFrom = spBond.getMolecularTypePattern(mtp.getMolecularType().getName(), mtp.getIndex());
MolecularComponentPattern mcpFrom = mtpFrom.getMolecularComponentPattern(mc);
MolecularTypePattern mtpTo = spBond.getMolecularTypePattern(b.molecularTypePattern.getMolecularType().getName(), b.molecularTypePattern.getIndex());
MolecularComponentPattern mcpTo = mtpTo.getMolecularComponentPattern(b.molecularComponentPattern.getMolecularComponent());
spBond.setBond(mtpTo, mcpTo, mtpFrom, mcpFrom);
Icon icon = new SpeciesPatternSmallShape(3, 4, spBond, gc, fieldSpeciesContext, false, issueManager);
((SpeciesPatternSmallShape) icon).setDisplayRequirements(DisplayRequirements.highlightBonds);
menuItem.setIcon(icon);
editBondMenu.add(menuItem);
}
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String name = e.getActionCommand();
BondType btBefore = mcp.getBondType();
if (name.equals(noneString)) {
if (btBefore == BondType.Specified) {
// specified -> not specified
// change the partner to none since this is the only option
mcp.getBond().molecularComponentPattern.setBondType(BondType.None);
mcp.getBond().molecularComponentPattern.setBond(null);
}
mcp.setBondType(BondType.None);
mcp.setBond(null);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
speciesPropertiesTreeModel.populateTree();
}
});
} else {
if (btBefore != BondType.Specified) {
// if we go from a non-specified to a specified we need to find the next available
// bond id, so that we can choose the color for displaying the bond
// a bad bond id, like -1, will crash badly when trying to choose the color
int bondId = sp.nextBondId();
mcp.setBondId(bondId);
} else {
// specified -> specified
// change the old partner to none since it's the only available option, continue using the bond id
mcp.getBond().molecularComponentPattern.setBondType(BondType.None);
mcp.getBond().molecularComponentPattern.setBond(null);
}
mcp.setBondType(BondType.Specified);
Bond b = itemMap.get(name);
mcp.setBond(b);
mcp.getBond().molecularComponentPattern.setBondId(mcp.getBondId());
sp.resolveBonds();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
speciesPropertiesTreeModel.populateTree();
}
});
}
}
});
index++;
}
popupFromShapeMenu.add(editBondMenu);
}
use of org.vcell.model.rbm.ComponentStateDefinition in project vcell by virtualcell.
the class MolecularTypeTableModel method propertyChange.
@Override
public void propertyChange(PropertyChangeEvent evt) {
super.propertyChange(evt);
// if (evt.getSource() == getModel().getRbmModelContainer()) {
if (evt.getSource() == getModel()) {
if (evt.getPropertyName().equals(RbmModelContainer.PROPERTY_NAME_MOLECULAR_TYPE_LIST)) {
refreshData();
List<MolecularType> oldValue = (List<MolecularType>) evt.getOldValue();
for (MolecularType molecularType : oldValue) {
RbmUtils.removePropertyChangeListener(molecularType, this);
}
List<MolecularType> newValue = (List<MolecularType>) evt.getNewValue();
for (MolecularType molecularType : newValue) {
RbmUtils.addPropertyChangeListener(molecularType, this);
}
}
refreshData();
// } else if (evt.getSource() == getModel().getRbmModelContainer().getNetworkConstraints()) {
// if (evt.getPropertyName().equals(NetworkConstraints.PROPERTY_NAME_MAX_STOICHIOMETRY)) {
// fireTableRowsUpdated(0, getRowCount() - 1);
// }
// refreshData();
} else if (evt.getSource() instanceof MolecularType) {
MolecularType mt = (MolecularType) evt.getSource();
int changeRow = getRowIndex(mt);
if (changeRow >= 0) {
fireTableRowsUpdated(changeRow, changeRow);
}
if (evt.getPropertyName().equals(MolecularType.PROPERTY_NAME_COMPONENT_LIST)) {
List<MolecularComponent> oldValue = (List<MolecularComponent>) evt.getOldValue();
if (oldValue != null) {
for (MolecularComponent molecularComponent : oldValue) {
RbmUtils.removePropertyChangeListener(molecularComponent, this);
}
}
List<MolecularComponent> newValue = (List<MolecularComponent>) evt.getNewValue();
if (newValue != null) {
for (MolecularComponent molecularComponent : newValue) {
RbmUtils.addPropertyChangeListener(molecularComponent, this);
}
}
}
refreshData();
} else if (evt.getSource() instanceof MolecularComponent) {
fireTableRowsUpdated(0, getRowCount() - 1);
if (evt.getPropertyName().equals(MolecularComponent.PROPERTY_NAME_COMPONENT_STATE_DEFINITIONS)) {
List<ComponentStateDefinition> oldValue = (List<ComponentStateDefinition>) evt.getOldValue();
if (oldValue != null) {
for (ComponentStateDefinition componentState : oldValue) {
componentState.removePropertyChangeListener(this);
}
}
List<ComponentStateDefinition> newValue = (List<ComponentStateDefinition>) evt.getNewValue();
if (newValue != null) {
for (ComponentStateDefinition componentState : newValue) {
componentState.addPropertyChangeListener(this);
}
}
}
refreshData();
} else if (evt.getSource() instanceof ComponentStateDefinition) {
fireTableRowsUpdated(0, getRowCount() - 1);
refreshData();
}
}
use of org.vcell.model.rbm.ComponentStateDefinition in project vcell by virtualcell.
the class MolecularTypeTableModel method checkInputValue.
@Override
public String checkInputValue(String inputValue, int row, int columnIndex) {
String errMsg = null;
final Column col = Column.values()[columnIndex];
MolecularType selectedMolecularType = getValueAt(row);
switch(col) {
case name:
{
if (!inputValue.equals(TokenMangler.fixTokenStrict(inputValue))) {
errMsg = "'" + inputValue + "' not legal identifier, try '" + TokenMangler.fixTokenStrict(inputValue) + "'.";
errMsg += VCellErrorMessages.PressEscToUndo;
errMsg = "<html>" + errMsg + "</html>";
return errMsg;
}
inputValue = TokenMangler.fixTokenStrict(inputValue);
MolecularType mt = getModel().getRbmModelContainer().getMolecularType(inputValue);
if (mt != null && mt != selectedMolecularType) {
errMsg = mt.getDisplayType() + " '" + inputValue + "' already exists!";
errMsg += VCellErrorMessages.PressEscToUndo;
errMsg = "<html>" + errMsg + "</html>";
return errMsg;
}
break;
}
case bngl_pattern:
{
try {
inputValue = inputValue.trim();
if (inputValue.length() > 0) {
MolecularType mt = RbmUtils.parseMolecularType(inputValue);
MolecularType mt1 = getModel().getRbmModelContainer().getMolecularType(mt.getName());
if (mt1 != null && getRowIndex(mt1) != row) {
// molecular type with this name exists already on another row
errMsg = mt.getDisplayType() + " '" + mt.getDisplayName() + "' already exists!";
errMsg += VCellErrorMessages.PressEscToUndo;
errMsg = "<html>" + errMsg + "</html>";
return errMsg;
}
// need to check if any Component we try to delete is not already in use elsewhere
for (MolecularComponent selectedMolecularComponent : selectedMolecularType.getComponentList()) {
if (mt.getMolecularComponent(selectedMolecularComponent.getName()) == null) {
// the user tries to delete this mc
Map<String, Pair<Displayable, SpeciesPattern>> usedHere = new LinkedHashMap<String, Pair<Displayable, SpeciesPattern>>();
bioModel.getModel().getRbmModelContainer().findComponentUsage(selectedMolecularType, selectedMolecularComponent, usedHere);
if (!usedHere.isEmpty()) {
errMsg = selectedMolecularComponent.dependenciesToHtml(usedHere);
errMsg += "<br><br>Deleting and Renaming a Component can be done in the Object Properties tree below.";
errMsg += VCellErrorMessages.PressEscToUndo;
errMsg = "<html>" + errMsg + "</html>";
return errMsg;
}
}
}
// need to check if any State we try to delete is not already in use elsewhere
for (MolecularComponent selectedMolecularComponent : selectedMolecularType.getComponentList()) {
for (ComponentStateDefinition selectedComponentStateDefinition : selectedMolecularComponent.getComponentStateDefinitions()) {
MolecularComponent mc = mt.getMolecularComponent(selectedMolecularComponent.getName());
if (mc.getComponentStateDefinition(selectedComponentStateDefinition.getName()) == null) {
// new list is missing a state which was present in the original
if (!getModel().getRbmModelContainer().isDeleteAllowed(selectedMolecularType, selectedMolecularComponent, selectedComponentStateDefinition)) {
errMsg = "State '" + selectedComponentStateDefinition + "' cannot be deleted because it's already being used.";
errMsg += "<br>Deleting and Renaming a State can be done in the Object Properties tree below.";
errMsg += VCellErrorMessages.PressEscToUndo;
errMsg = "<html>" + errMsg + "</html>";
return errMsg;
}
}
}
}
}
} catch (Exception ex) {
errMsg = ex.getMessage();
errMsg += VCellErrorMessages.PressEscToUndo;
errMsg = "<html>" + errMsg + "</html>";
return errMsg;
}
break;
}
}
return null;
}
use of org.vcell.model.rbm.ComponentStateDefinition in project vcell by virtualcell.
the class MolecularTypeTableModel method setValueAt.
@Override
public void setValueAt(Object value, int row, int column) {
if (getModel() == null || value == null) {
return;
}
String stringValue = ((String) value);
stringValue = stringValue.trim();
if (stringValue.length() == 0) {
return;
}
Column col = Column.values()[column];
try {
MolecularType ourMt = getValueAt(row);
switch(col) {
case name:
{
if (stringValue.equals(ADD_NEW_HERE_TEXT)) {
return;
}
if (ourMt == null) {
// new molecular type in empty row
getModel().getRbmModelContainer().addMolecularType(new MolecularType(stringValue, getModel()), true);
} else {
// rename it
ourMt.setName(stringValue);
}
fireTableRowsUpdated(row, row);
break;
}
case bngl_pattern:
{
MolecularType tempMolecularType = RbmUtils.parseMolecularType(stringValue);
if (ourMt == null) {
// new
getModel().getRbmModelContainer().addMolecularType(tempMolecularType, true);
} else {
// change it
// if it had been renamed
ourMt.setName(tempMolecularType.getName());
// here we add components
for (MolecularComponent tempMc : tempMolecularType.getComponentList()) {
if (ourMt.getMolecularComponent(tempMc.getName()) == null) {
// component not found in the existing molecular type, it's a new component
// add the new component (and its states, if any)
ourMt.addMolecularComponent(tempMc);
getModel().getRbmModelContainer().adjustSpeciesContextPatterns(ourMt, tempMc);
} else {
// existing component being modified (by adding or removing states)
// check for new states added to the existing components
MolecularComponent ourMc = ourMt.getMolecularComponent(tempMc.getName());
for (ComponentStateDefinition tempCsd : tempMc.getComponentStateDefinitions()) {
if (ourMc.getComponentStateDefinition(tempCsd.getName()) == null) {
// state not found in the existing component, it's a new state
ourMc.addComponentStateDefinition(tempCsd);
}
}
// TODO: check for deleted states from existing components
}
}
// TODO: here we delete components
for (MolecularComponent ourMc : ourMt.getComponentList()) {
if (tempMolecularType.getMolecularComponent(ourMc.getName()) == null) {
// ATTENTION! renaming doesn't work here because we can't know the user's mind, we always consider addition + deletion here
if (getModel().getRbmModelContainer().delete(ourMt, ourMc) == true) {
ourMt.removeMolecularComponent(ourMc);
}
}
}
}
fireTableRowsUpdated(row, row);
break;
}
}
} catch (Exception e) {
e.printStackTrace(System.out);
DialogUtils.showErrorDialog(ownerTable, e.getMessage(), e);
}
}
use of org.vcell.model.rbm.ComponentStateDefinition in project vcell by virtualcell.
the class ObservablePropertiesPanel method manageComponentPatternFromShape.
public void manageComponentPatternFromShape(final RbmElementAbstract selectedObject, PointLocationInShapeContext locationContext, ShowWhat showWhat) {
final MolecularComponentPattern mcp = (MolecularComponentPattern) selectedObject;
final MolecularComponent mc = mcp.getMolecularComponent();
popupFromShapeMenu.removeAll();
// ------------------------------------------------------------------- State
if (showWhat == ShowWhat.ShowState && mc.getComponentStateDefinitions().size() != 0) {
String prefix = "State: ";
String csdCurrentName = "";
final Map<String, String> itemMap = new LinkedHashMap<String, String>();
if (mcp.getComponentStatePattern() == null || mcp.getComponentStatePattern().isAny()) {
csdCurrentName = "<html>" + prefix + "<b>" + ComponentStatePattern.strAny + "</b></html>";
} else {
csdCurrentName = "<html>" + prefix + ComponentStatePattern.strAny + "</html>";
}
itemMap.put(csdCurrentName, ComponentStatePattern.strAny);
for (final ComponentStateDefinition csd : mc.getComponentStateDefinitions()) {
csdCurrentName = "";
if (mcp.getComponentStatePattern() != null && !mcp.getComponentStatePattern().isAny()) {
ComponentStateDefinition csdCurrent = mcp.getComponentStatePattern().getComponentStateDefinition();
csdCurrentName = csdCurrent.getName();
}
String name = csd.getName();
if (name.equals(csdCurrentName)) {
// currently selected menu item is shown in bold
name = "<html>" + prefix + "<b>" + name + "</b></html>";
} else {
name = "<html>" + prefix + name + "</html>";
}
itemMap.put(name, csd.getName());
}
for (String name : itemMap.keySet()) {
JMenuItem menuItem = new JMenuItem(name);
popupFromShapeMenu.add(menuItem);
menuItem.setIcon(VCellIcons.rbmComponentStateIcon);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String key = e.getActionCommand();
String name = itemMap.get(key);
if (name.equals(ComponentStatePattern.strAny)) {
ComponentStatePattern csp = new ComponentStatePattern();
mcp.setComponentStatePattern(csp);
} else {
ComponentStateDefinition csd = mcp.getMolecularComponent().getComponentStateDefinition(name);
if (csd == null) {
throw new RuntimeException("Missing ComponentStateDefinition " + name + " for Component " + mcp.getMolecularComponent().getName());
}
ComponentStatePattern csp = new ComponentStatePattern(csd);
mcp.setComponentStatePattern(csp);
}
}
});
}
}
if (showWhat == ShowWhat.ShowState) {
return;
}
// ------------------------------------------------------------------------------------------- Bonds
final MolecularTypePattern mtp = locationContext.getMolecularTypePattern();
final SpeciesPattern sp = locationContext.getSpeciesPattern();
JMenu editBondMenu = new JMenu();
final String specifiedString = mcp.getBondType() == BondType.Specified ? "<html><b>" + "Site bond specified" + "</b></html>" : "<html>" + "Site bond specified" + "</html>";
editBondMenu.setText(specifiedString);
editBondMenu.setToolTipText("Specified");
editBondMenu.removeAll();
final Map<String, Bond> itemMap = new LinkedHashMap<String, Bond>();
// String noneString = "<html>Bond: <b>" + BondType.None.symbol + "</b> " + BondType.None.name() + "</html>";
// String existsString = "<html>Bond: <b>" + BondType.Exists.symbol + "</b> " + BondType.Exists.name() + "</html>";
// String possibleString = "<html>Bond: <b>" + BondType.Possible.symbol + "</b> " + BondType.Possible.name() + "</html>";
String noneString = mcp.getBondType() == BondType.None ? "<html><b>" + "Site is unbound" + "</b></html>" : "<html>" + "Site is unbound" + "</html>";
// Site is bound
String existsString = mcp.getBondType() == BondType.Exists ? "<html><b>" + "Site has external bond" + "</b></html>" : "<html>" + "Site has external bond" + "</html>";
String possibleString = mcp.getBondType() == BondType.Possible ? "<html><b>" + "Site may be bound" + "</b></html>" : "<html>" + "Site may be bound" + "</html>";
itemMap.put(noneString, null);
itemMap.put(existsString, null);
itemMap.put(possibleString, null);
if (mtp != null && sp != null) {
List<Bond> bondPartnerChoices = sp.getAllBondPartnerChoices(mtp, mc);
for (Bond b : bondPartnerChoices) {
// if(b.equals(mcp.getBond())) {
// continue; // if the mcp has a bond already we don't offer it
// }
int index = 0;
if (mcp.getBondType() == BondType.Specified) {
index = mcp.getBondId();
} else {
index = sp.nextBondId();
}
// itemMap.put(b.toHtmlStringLong(mtp, mc, sp, index), b);
itemMap.put(b.toHtmlStringLong(sp, mtp, mc, index), b);
// itemMap.put(b.toHtmlStringLong(sp, index), b);
}
}
int index = 0;
Graphics gc = splitPaneHorizontal.getGraphics();
for (String name : itemMap.keySet()) {
JMenuItem menuItem = new JMenuItem(name);
if (index == 0) {
menuItem.setIcon(VCellIcons.rbmBondNoneIcon);
menuItem.setToolTipText("None");
popupFromShapeMenu.add(menuItem);
} else if (index == 1) {
menuItem.setIcon(VCellIcons.rbmBondExistsIcon);
menuItem.setToolTipText("Exists");
popupFromShapeMenu.add(menuItem);
} else if (index == 2) {
menuItem.setIcon(VCellIcons.rbmBondPossibleIcon);
menuItem.setToolTipText("Possible");
popupFromShapeMenu.add(menuItem);
} else if (index > 2) {
Bond b = itemMap.get(name);
// clone of the sp, with only the bond of interest
SpeciesPattern spBond = new SpeciesPattern(bioModel.getModel(), sp);
spBond.resetBonds();
spBond.resetStates();
MolecularTypePattern mtpFrom = spBond.getMolecularTypePattern(mtp.getMolecularType().getName(), mtp.getIndex());
MolecularComponentPattern mcpFrom = mtpFrom.getMolecularComponentPattern(mc);
MolecularTypePattern mtpTo = spBond.getMolecularTypePattern(b.molecularTypePattern.getMolecularType().getName(), b.molecularTypePattern.getIndex());
MolecularComponentPattern mcpTo = mtpTo.getMolecularComponentPattern(b.molecularComponentPattern.getMolecularComponent());
spBond.setBond(mtpTo, mcpTo, mtpFrom, mcpFrom);
Icon icon = new SpeciesPatternSmallShape(3, 4, spBond, gc, observable, false, issueManager);
((SpeciesPatternSmallShape) icon).setDisplayRequirements(DisplayRequirements.highlightBonds);
menuItem.setIcon(icon);
editBondMenu.add(menuItem);
// } else {
// if(index == 0) {
// menuItem.setForeground(Color.blue);
// }
// popupFromShapeMenu.add(menuItem);
}
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String name = e.getActionCommand();
BondType btBefore = mcp.getBondType();
if (name.equals(noneString)) {
if (btBefore == BondType.Specified) {
// specified -> not specified
// change the partner to possible
mcp.getBond().molecularComponentPattern.setBondType(BondType.Possible);
mcp.getBond().molecularComponentPattern.setBond(null);
}
mcp.setBondType(BondType.None);
mcp.setBond(null);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
observableTreeModel.populateTree();
}
});
} else if (name.equals(existsString)) {
if (btBefore == BondType.Specified) {
// specified -> exists
// change the partner to possible
mcp.getBond().molecularComponentPattern.setBondType(BondType.Possible);
mcp.getBond().molecularComponentPattern.setBond(null);
}
mcp.setBondType(BondType.Exists);
mcp.setBond(null);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
observableTreeModel.populateTree();
}
});
} else if (name.equals(possibleString)) {
if (btBefore == BondType.Specified) {
// specified -> possible
// change the partner to possible
mcp.getBond().molecularComponentPattern.setBondType(BondType.Possible);
mcp.getBond().molecularComponentPattern.setBond(null);
}
mcp.setBondType(BondType.Possible);
mcp.setBond(null);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
observableTreeModel.populateTree();
}
});
} else {
if (btBefore != BondType.Specified) {
// if we go from a non-specified to a specified we need to find the next available
// bond id, so that we can choose the color for displaying the bond
// a bad bond id, like -1, will crash badly when trying to choose the color
int bondId = sp.nextBondId();
mcp.setBondId(bondId);
} else {
// specified -> specified
// change the old partner to possible, continue using the bond id
mcp.getBond().molecularComponentPattern.setBondType(BondType.Possible);
mcp.getBond().molecularComponentPattern.setBond(null);
}
mcp.setBondType(BondType.Specified);
Bond b = itemMap.get(name);
mcp.setBond(b);
mcp.getBond().molecularComponentPattern.setBondId(mcp.getBondId());
sp.resolveBonds();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
observableTreeModel.populateTree();
}
});
}
}
});
index++;
}
popupFromShapeMenu.add(editBondMenu);
}
Aggregations