use of org.vcell.model.rbm.MolecularType in project vcell by virtualcell.
the class MolecularTypeTreeModel method setMolecularType.
public void setMolecularType(MolecularType newValue) {
if (newValue == molecularType) {
return;
}
MolecularType oldValue = molecularType;
if (oldValue != null) {
oldValue.removePropertyChangeListener(this);
for (MolecularComponent molecularComponent : oldValue.getComponentList()) {
molecularComponent.removePropertyChangeListener(this);
for (ComponentStateDefinition componentState : molecularComponent.getComponentStateDefinitions()) {
componentState.removePropertyChangeListener(this);
}
}
}
molecularType = newValue;
populateTree();
if (newValue != null) {
newValue.addPropertyChangeListener(this);
for (MolecularComponent molecularComponent : newValue.getComponentList()) {
molecularComponent.addPropertyChangeListener(this);
for (ComponentStateDefinition componentState : molecularComponent.getComponentStateDefinitions()) {
componentState.addPropertyChangeListener(this);
}
}
}
}
use of org.vcell.model.rbm.MolecularType in project vcell by virtualcell.
the class ObservablePropertiesPanel method showPopupMenu.
private void showPopupMenu(MouseEvent e, PointLocationInShapeContext locationContext) {
if (popupFromShapeMenu == null) {
popupFromShapeMenu = new JPopupMenu();
}
if (popupFromShapeMenu.isShowing()) {
return;
}
boolean bDelete = false;
boolean bAdd = false;
boolean bEdit = false;
boolean bRename = false;
popupFromShapeMenu.removeAll();
Point mousePoint = e.getPoint();
final Object deepestShape = locationContext.getDeepestShape();
final RbmElementAbstract selectedObject;
if (deepestShape == null) {
selectedObject = null;
// when cursor is outside any species pattern we offer to add a new one
System.out.println("outside");
popupFromShapeMenu.add(getAddSpeciesPatternFromShapeMenuItem());
} else if (deepestShape instanceof ComponentStateLargeShape) {
System.out.println("inside state");
if (((ComponentStateLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((ComponentStateLargeShape) deepestShape).getComponentStatePattern();
} else {
return;
}
} else if (deepestShape instanceof MolecularComponentLargeShape) {
System.out.println("inside component");
if (((MolecularComponentLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((MolecularComponentLargeShape) deepestShape).getMolecularComponentPattern();
} else {
return;
}
} else if (deepestShape instanceof MolecularTypeLargeShape) {
System.out.println("inside molecule");
if (((MolecularTypeLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((MolecularTypeLargeShape) deepestShape).getMolecularTypePattern();
} else {
return;
}
} else if (deepestShape instanceof SpeciesPatternLargeShape) {
System.out.println("inside species pattern");
if (((SpeciesPatternLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((SpeciesPatternLargeShape) deepestShape).getSpeciesPattern();
} else {
return;
}
} else {
selectedObject = null;
System.out.println("inside something else?");
return;
}
if (selectedObject instanceof SpeciesPattern) {
getAddFromShapeMenu().setText(VCellErrorMessages.AddMolecularTypes);
getAddFromShapeMenu().removeAll();
for (final MolecularType mt : bioModel.getModel().getRbmModelContainer().getMolecularTypeList()) {
JMenuItem menuItem = new JMenuItem(mt.getName());
Graphics gc = splitPaneHorizontal.getGraphics();
Icon icon = new MolecularTypeSmallShape(4, 4, mt, null, gc, mt, null, issueManager);
menuItem.setIcon(icon);
getAddFromShapeMenu().add(menuItem);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularTypePattern molecularTypePattern = new MolecularTypePattern(mt);
((SpeciesPattern) selectedObject).addMolecularTypePattern(molecularTypePattern);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
}
});
}
});
}
JMenu compartmentMenuItem = new JMenu("Specify structure (for all)");
compartmentMenuItem.removeAll();
for (final Structure struct : bioModel.getModel().getStructures()) {
JMenuItem menuItem = new JMenuItem(struct.getName());
compartmentMenuItem.add(menuItem);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String nameStruct = e.getActionCommand();
Structure struct = bioModel.getModel().getStructure(nameStruct);
observable.setStructure(struct);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// repaint tree
observableTreeModel.populateTree();
// observableTree.scrollPathToVisible(path); // scroll back up to show the observable
}
});
}
});
}
JMenuItem deleteMenuItem = new JMenuItem("Delete Species Pattern");
deleteMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// observable.getSpeciesPatternList().remove((SpeciesPattern)selectedObject);
observable.removeSpeciesPattern((SpeciesPattern) selectedObject);
final TreePath path = observableTreeModel.findObjectPath(null, observable);
observableTree.setSelectionPath(path);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// repaint tree
observableTreeModel.populateTree();
// scroll back up to show the observable
observableTree.scrollPathToVisible(path);
}
});
}
});
popupFromShapeMenu.add(deleteMenuItem);
popupFromShapeMenu.add(new JSeparator());
popupFromShapeMenu.add(getAddFromShapeMenu());
popupFromShapeMenu.add(compartmentMenuItem);
} else if (selectedObject instanceof MolecularTypePattern) {
MolecularTypePattern mtp = (MolecularTypePattern) selectedObject;
String moveRightMenuText = "Move <b>" + "right" + "</b>";
moveRightMenuText = "<html>" + moveRightMenuText + "</html>";
JMenuItem moveRightMenuItem = new JMenuItem(moveRightMenuText);
Icon icon = VCellIcons.moveRightIcon;
moveRightMenuItem.setIcon(icon);
moveRightMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularTypePattern from = (MolecularTypePattern) selectedObject;
SpeciesPattern sp = locationContext.sps.getSpeciesPattern();
sp.shiftRight(from);
observableTreeModel.populateTree();
}
});
popupFromShapeMenu.add(moveRightMenuItem);
String moveLeftMenuText = "Move <b>" + "left" + "</b>";
moveLeftMenuText = "<html>" + moveLeftMenuText + "</html>";
JMenuItem moveLeftMenuItem = new JMenuItem(moveLeftMenuText);
icon = VCellIcons.moveLeftIcon;
moveLeftMenuItem.setIcon(icon);
moveLeftMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularTypePattern from = (MolecularTypePattern) selectedObject;
SpeciesPattern sp = locationContext.sps.getSpeciesPattern();
sp.shiftLeft(from);
observableTreeModel.populateTree();
}
});
popupFromShapeMenu.add(moveLeftMenuItem);
popupFromShapeMenu.add(new JSeparator());
String deleteMenuText = "Delete <b>" + mtp.getMolecularType().getName() + "</b>";
deleteMenuText = "<html>" + deleteMenuText + "</html>";
JMenuItem deleteMenuItem = new JMenuItem(deleteMenuText);
deleteMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularTypePattern mtp = (MolecularTypePattern) selectedObject;
SpeciesPattern sp = locationContext.sps.getSpeciesPattern();
sp.removeMolecularTypePattern(mtp);
}
});
popupFromShapeMenu.add(deleteMenuItem);
} else if (selectedObject instanceof MolecularComponentPattern) {
manageComponentPatternFromShape(selectedObject, locationContext, ShowWhat.ShowBond);
bDelete = false;
} else if (selectedObject instanceof ComponentStatePattern) {
MolecularComponentPattern mcp = ((ComponentStateLargeShape) deepestShape).getMolecularComponentPattern();
manageComponentPatternFromShape(mcp, locationContext, ShowWhat.ShowState);
}
if (bRename) {
popupFromShapeMenu.add(getRenameFromShapeMenuItem());
}
if (bDelete) {
popupFromShapeMenu.add(getDeleteFromShapeMenuItem());
}
if (bEdit) {
popupFromShapeMenu.add(getEditFromShapeMenuItem());
}
if (bAdd) {
popupFromShapeMenu.add(new JSeparator());
popupFromShapeMenu.add(getAddFromShapeMenu());
}
popupFromShapeMenu.show(e.getComponent(), mousePoint.x, mousePoint.y);
}
use of org.vcell.model.rbm.MolecularType in project vcell by virtualcell.
the class ObservableTableModel method isCellEditable.
public boolean isCellEditable(int row, int columnIndex) {
Column col = Column.values()[columnIndex];
if (col == Column.name) {
return true;
}
RbmObservable o = getValueAt(row);
if (o == null) {
return false;
}
if (col == Column.structure) {
return false;
}
if (col == Column.type) {
return true;
}
if (col == Column.depiction) {
return false;
}
final List<SpeciesPattern> spList = o.getSpeciesPatternList();
for (SpeciesPattern sp : spList) {
final List<MolecularTypePattern> mtpList = sp.getMolecularTypePatterns();
for (MolecularTypePattern mtp : mtpList) {
MolecularType mt = mtp.getMolecularType();
if (mt.getComponentList().size() != 0) {
return false;
}
}
}
return true;
}
use of org.vcell.model.rbm.MolecularType in project vcell by virtualcell.
the class ObservableTreeModel method createMolecularTypePatternNode.
private BioModelNode createMolecularTypePatternNode(MolecularTypePattern molecularTypePattern) {
MolecularType molecularType = molecularTypePattern.getMolecularType();
BioModelNode node = new BioModelNode(molecularTypePattern, true);
for (MolecularComponent mc : molecularType.getComponentList()) {
if (bShowDetails || molecularTypePattern.getMolecularComponentPattern(mc).isbVisible()) {
BioModelNode n = createMolecularComponentPatternNode(molecularTypePattern.getMolecularComponentPattern(mc));
if (n != null) {
node.add(n);
}
}
}
return node;
}
use of org.vcell.model.rbm.MolecularType in project vcell by virtualcell.
the class PhysiologyRelationshipTableModel method refreshData.
private void refreshData() {
ArrayList<PhysiologyRelationshipTableRow> pathwayObjectList = new ArrayList<PhysiologyRelationshipTableRow>();
if (bioModel != null) {
HashSet<RelationshipObject> relationshipObjects = null;
if (bioModelEntityObject != null) {
relationshipObjects = bioModel.getRelationshipModel().getRelationshipObjects(bioModelEntityObject);
}
List<PhysiologyRelationshipTableRow> allPathwayObjectList = new ArrayList<PhysiologyRelationshipTableRow>();
for (BioPaxObject bpObject1 : bioModel.getPathwayModel().getBiopaxObjects()) {
if ((bpObject1 instanceof PhysicalEntity && (bioModelEntityObject == null || bioModelEntityObject instanceof SpeciesContext)) || (bpObject1 instanceof Conversion && (bioModelEntityObject == null || bioModelEntityObject instanceof ModelProcess)) || (bpObject1 instanceof PhysicalEntity && (bioModelEntityObject == null || bioModelEntityObject instanceof MolecularType))) {
PhysiologyRelationshipTableRow entityRow = new PhysiologyRelationshipTableRow(bpObject1);
if (relationshipObjects != null) {
for (RelationshipObject ro : relationshipObjects) {
if (ro.getBioPaxObject() == entityRow.getBioPaxObject()) {
entityRow.setSelected(true);
break;
}
}
}
if (!bShowLinkOnly || entityRow.selected) {
allPathwayObjectList.add(entityRow);
}
}
}
if (searchText == null || searchText.length() == 0) {
pathwayObjectList.addAll(allPathwayObjectList);
} else {
for (PhysiologyRelationshipTableRow rs : allPathwayObjectList) {
BioPaxObject bpObject = rs.getBioPaxObject();
String lowerCaseSearchText = searchText.toLowerCase();
if (getLabel(bpObject).toLowerCase().contains(lowerCaseSearchText) || getType(bpObject).toLowerCase().contains(lowerCaseSearchText)) {
pathwayObjectList.add(rs);
}
}
}
}
setData(pathwayObjectList);
GuiUtils.flexResizeTableColumns(ownerTable);
}
Aggregations