Search in sources :

Example 66 with MolecularType

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);
            }
        }
    }
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) MolecularComponent(org.vcell.model.rbm.MolecularComponent) ComponentStateDefinition(org.vcell.model.rbm.ComponentStateDefinition)

Example 67 with MolecularType

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);
}
Also used : ActionEvent(java.awt.event.ActionEvent) SpeciesPatternLargeShape(cbit.vcell.graph.SpeciesPatternLargeShape) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) JSeparator(javax.swing.JSeparator) MolecularTypeLargeShape(cbit.vcell.graph.MolecularTypeLargeShape) JMenuItem(javax.swing.JMenuItem) Structure(cbit.vcell.model.Structure) MolecularComponentLargeShape(cbit.vcell.graph.MolecularComponentLargeShape) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) ComponentStatePattern(org.vcell.model.rbm.ComponentStatePattern) Point(java.awt.Point) JPopupMenu(javax.swing.JPopupMenu) MolecularType(org.vcell.model.rbm.MolecularType) Graphics(java.awt.Graphics) MolecularTypeSmallShape(cbit.vcell.graph.MolecularTypeSmallShape) ActionListener(java.awt.event.ActionListener) TreePath(javax.swing.tree.TreePath) ComponentStateLargeShape(cbit.vcell.graph.MolecularComponentLargeShape.ComponentStateLargeShape) RbmElementAbstract(org.vcell.model.rbm.RbmElementAbstract) Icon(javax.swing.Icon) ZoomShapeIcon(cbit.vcell.graph.gui.ZoomShapeIcon) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) JMenu(javax.swing.JMenu)

Example 68 with MolecularType

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;
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) RbmObservable(cbit.vcell.model.RbmObservable) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 69 with MolecularType

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;
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) MolecularComponent(org.vcell.model.rbm.MolecularComponent) BioModelNode(cbit.vcell.desktop.BioModelNode)

Example 70 with MolecularType

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);
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) ArrayList(java.util.ArrayList) ModelProcess(cbit.vcell.model.ModelProcess) SpeciesContext(cbit.vcell.model.SpeciesContext) RelationshipObject(org.vcell.relationship.RelationshipObject) Conversion(org.vcell.pathway.Conversion) MolecularType(org.vcell.model.rbm.MolecularType) PhysicalEntity(org.vcell.pathway.PhysicalEntity)

Aggregations

MolecularType (org.vcell.model.rbm.MolecularType)78 SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)25 MolecularComponent (org.vcell.model.rbm.MolecularComponent)23 Structure (cbit.vcell.model.Structure)20 ArrayList (java.util.ArrayList)20 ReactionRule (cbit.vcell.model.ReactionRule)19 SpeciesContext (cbit.vcell.model.SpeciesContext)19 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)16 PropertyVetoException (java.beans.PropertyVetoException)15 ComponentStateDefinition (org.vcell.model.rbm.ComponentStateDefinition)15 RbmObservable (cbit.vcell.model.RbmObservable)14 List (java.util.List)13 RbmModelContainer (cbit.vcell.model.Model.RbmModelContainer)12 Point (java.awt.Point)12 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)12 BioPaxObject (org.vcell.pathway.BioPaxObject)11 RelationshipObject (org.vcell.relationship.RelationshipObject)11 BioModelNode (cbit.vcell.desktop.BioModelNode)10 ModelException (cbit.vcell.model.ModelException)10 ParticleMolecularType (cbit.vcell.math.ParticleMolecularType)9