Search in sources :

Example 66 with SpeciesPattern

use of org.vcell.model.rbm.SpeciesPattern in project vcell by virtualcell.

the class IssuePanel method invokeHyperlink.

private void invokeHyperlink(Issue issue) {
    if (selectionManager != null) {
        // followHyperlink is no-op if selectionManger null, so no point in proceeding if it is
        IssueContext issueContext = issue.getIssueContext();
        IssueSource object = issue.getSource();
        if (object instanceof DecoratedIssueSource) {
            DecoratedIssueSource dis = (DecoratedIssueSource) object;
            dis.activateView(selectionManager);
        } else if (object instanceof Parameter) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.BIOMODEL_PARAMETERS_NODE, ActiveViewID.parameters_functions), new Object[] { object });
        } else if (object instanceof StructureMapping) {
            StructureMapping structureMapping = (StructureMapping) object;
            StructureMappingNameScope structureMappingNameScope = (StructureMappingNameScope) structureMapping.getNameScope();
            SimulationContext simulationContext = ((SimulationContextNameScope) (structureMappingNameScope.getParent())).getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
        } else if (object instanceof SpatialObject) {
            SpatialObject spatialObject = (SpatialObject) object;
            SimulationContext simulationContext = spatialObject.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.spatial_objects), new Object[] { object });
        } else if (object instanceof SpatialProcess) {
            SpatialProcess spatialProcess = (SpatialProcess) object;
            SimulationContext simulationContext = spatialProcess.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.spatial_processes), new Object[] { object });
        } else if (object instanceof GeometryContext.UnmappedGeometryClass) {
            UnmappedGeometryClass unmappedGeometryClass = (UnmappedGeometryClass) object;
            SimulationContext simulationContext = unmappedGeometryClass.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
        } else if (object instanceof MicroscopeMeasurement) {
            SimulationContext simulationContext = ((MicroscopeMeasurement) object).getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.microscope_measuremments), new Object[] { object });
        } else if (object instanceof BioEvent) {
            BioEvent be = (BioEvent) object;
            SimulationContext simulationContext = be.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.events), new Object[] { object });
        } else if (object instanceof OutputFunctionIssueSource) {
            SimulationOwner simulationOwner = ((OutputFunctionIssueSource) object).getOutputFunctionContext().getSimulationOwner();
            if (simulationOwner instanceof SimulationContext) {
                SimulationContext simulationContext = (SimulationContext) simulationOwner;
                followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.SIMULATIONS_NODE, ActiveViewID.output_functions), new Object[] { ((OutputFunctionIssueSource) object).getAnnotatedFunction() });
            } else if (simulationOwner instanceof MathModel) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_OUTPUT_FUNCTIONS_NODE, ActiveViewID.math_output_functions), new Object[] { ((OutputFunctionIssueSource) object).getAnnotatedFunction() });
            }
        } else if (object instanceof Simulation) {
            Simulation simulation = (Simulation) object;
            SimulationOwner simulationOwner = simulation.getSimulationOwner();
            if (simulationOwner instanceof SimulationContext) {
                SimulationContext simulationContext = (SimulationContext) simulationOwner;
                followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.SIMULATIONS_NODE, ActiveViewID.simulations), new Object[] { simulation });
            } else if (simulationOwner instanceof MathModel) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE, ActiveViewID.math_simulations), new Object[] { simulation });
            }
        } else if (object instanceof GeometryContext) {
            setActiveView(new ActiveView(((GeometryContext) object).getSimulationContext(), DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition));
        } else if (object instanceof Structure) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.STRUCTURES_NODE, ActiveViewID.structures), new Object[] { object });
        } else if (object instanceof MolecularType) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE, ActiveViewID.structures), new Object[] { object });
        } else if (object instanceof ReactionStep) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] { object });
        } else if (object instanceof ReactionRule) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] { object });
        } else if (object instanceof SpeciesContextSpec) {
            SpeciesContextSpec scs = (SpeciesContextSpec) object;
            ActiveView av = new ActiveView(scs.getSimulationContext(), DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.species_settings);
            followHyperlink(av, new Object[] { object });
        } else if (object instanceof ReactionCombo) {
            ReactionCombo rc = (ReactionCombo) object;
            followHyperlink(new ActiveView(rc.getReactionContext().getSimulationContext(), DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.reaction_setting), new Object[] { ((ReactionCombo) object).getReactionSpec() });
        } else if (object instanceof SpeciesContext) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species), new Object[] { object });
        } else if (object instanceof RbmObservable) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.OBSERVABLES_NODE, ActiveViewID.observables), new Object[] { object });
        } else if (object instanceof MathDescription) {
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE, ActiveViewID.generated_math), new Object[] {object});
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
        } else if (object instanceof SpeciesPattern) {
            // if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
            // SpeciesContext thing = (SpeciesContext)issue.getIssueContext().getContextObject(ContextType.SpeciesContext);
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species), new Object[] {thing});
            // }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
            // ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] {thing});
            // }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
            // RbmObservable thing = (RbmObservable)issue.getIssueContext().getContextObject(ContextType.RbmObservable);
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.OBSERVABLES_NODE, ActiveViewID.observables), new Object[] {thing});
            // } else {
            System.err.println("SpeciesPattern object missing a proper issue context.");
        // }
        } else if (object instanceof SimulationContext) {
            SimulationContext sc = (SimulationContext) object;
            IssueCategory ic = issue.getCategory();
            switch(ic) {
                case RbmNetworkConstraintsBad:
                    NetworkConstraints nc = sc.getNetworkConstraints();
                    if (issue.getMessage() == SimulationContext.IssueInsufficientMolecules) {
                        NetworkConstraintsEntity nce = new NetworkConstraintsEntity(NetworkConstraintsTableModel.sMaxMoleculesName, NetworkConstraintsTableModel.sValueType, nc.getMaxMoleculesPerSpecies() + "");
                        followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { nce });
                    } else {
                        NetworkConstraintsEntity nce = new NetworkConstraintsEntity(NetworkConstraintsTableModel.sMaxIterationName, NetworkConstraintsTableModel.sValueType, nc.getMaxIteration() + "");
                        followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { nce });
                    }
                    break;
                default:
                    followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { object });
                    break;
            }
        } else if (object instanceof Geometry) {
            if (issueContext.hasContextType(ContextType.SimContext)) {
                SimulationContext simContext = (SimulationContext) issueContext.getContextObject(ContextType.SimContext);
                followHyperlink(new ActiveView(simContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition), new Object[] { object });
            } else if (issueContext.hasContextType(ContextType.MathModel)) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_GEOMETRY_NODE, ActiveViewID.math_geometry), new Object[] { object });
            } else if (issueContext.hasContextType(ContextType.MathDescription)) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition), new Object[] { object });
            }
        } else {
            System.err.println("unknown object type in IssuePanel.invokeHyperlink(): " + object.getClass() + ", context type: " + issueContext.getContextType());
        }
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) IssueCategory(org.vcell.util.Issue.IssueCategory) MathDescription(cbit.vcell.math.MathDescription) NetworkConstraintsEntity(org.vcell.model.rbm.common.NetworkConstraintsEntity) SpeciesContext(cbit.vcell.model.SpeciesContext) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) StructureMapping(cbit.vcell.mapping.StructureMapping) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) StructureMappingNameScope(cbit.vcell.mapping.StructureMapping.StructureMappingNameScope) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) UnmappedGeometryClass(cbit.vcell.mapping.GeometryContext.UnmappedGeometryClass) SimulationOwner(cbit.vcell.solver.SimulationOwner) DecoratedIssueSource(cbit.vcell.client.desktop.DecoratedIssueSource) IssueSource(org.vcell.util.Issue.IssueSource) OutputFunctionIssueSource(cbit.vcell.solver.OutputFunctionContext.OutputFunctionIssueSource) OutputFunctionIssueSource(cbit.vcell.solver.OutputFunctionContext.OutputFunctionIssueSource) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) IssueContext(org.vcell.util.IssueContext) UnmappedGeometryClass(cbit.vcell.mapping.GeometryContext.UnmappedGeometryClass) MicroscopeMeasurement(cbit.vcell.mapping.MicroscopeMeasurement) GeometryContext(cbit.vcell.mapping.GeometryContext) Structure(cbit.vcell.model.Structure) ReactionCombo(cbit.vcell.mapping.ReactionSpec.ReactionCombo) ReactionRule(cbit.vcell.model.ReactionRule) DecoratedIssueSource(cbit.vcell.client.desktop.DecoratedIssueSource) RbmObservable(cbit.vcell.model.RbmObservable) SimulationContextNameScope(cbit.vcell.mapping.SimulationContext.SimulationContextNameScope) SimulationContext(cbit.vcell.mapping.SimulationContext) MolecularType(org.vcell.model.rbm.MolecularType) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) ReactionStep(cbit.vcell.model.ReactionStep) Parameter(cbit.vcell.model.Parameter) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) BioEvent(cbit.vcell.mapping.BioEvent) NetworkConstraints(org.vcell.model.rbm.NetworkConstraints)

Example 67 with SpeciesPattern

use of org.vcell.model.rbm.SpeciesPattern in project vcell by virtualcell.

the class MolecularTypePropertiesPanel method deleteFromTree.

public void deleteFromTree() {
    Object obj = molecularTypeTree.getLastSelectedPathComponent();
    if (obj == null || !(obj instanceof BioModelNode)) {
        return;
    }
    BioModelNode selectedNode = (BioModelNode) obj;
    TreeNode parent = selectedNode.getParent();
    if (!(parent instanceof BioModelNode)) {
        return;
    }
    BioModelNode parentNode = (BioModelNode) parent;
    Object selectedUserObject = selectedNode.getUserObject();
    if (selectedUserObject instanceof MolecularComponent) {
        MolecularComponent mc = (MolecularComponent) selectedUserObject;
        Object userObject = parentNode.getUserObject();
        if (userObject instanceof MolecularType) {
            MolecularType mt = (MolecularType) userObject;
            // detailed verifications will be done there, to see if they are being used in reactions, species, observables
            if (!mc.getComponentStateDefinitions().isEmpty()) {
                String[] options = { "OK" };
                String errMsg = mc.getDisplayType() + " '<b>" + mc.getDisplayName() + "</b>' cannot be deleted because it contains explicit States.";
                errMsg += "<br>Please delete each individual State first.";
                errMsg += "<br><br>Detailed usage information will be provided at that time to help you decide.";
                errMsg = "<html>" + errMsg + "</html>";
                JOptionPane.showOptionDialog(this.getParent().getParent(), errMsg, "Delete " + mc.getDisplayType(), JOptionPane.NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
                return;
            }
            // we find and display component usage information to help the user decide
            Map<String, Pair<Displayable, SpeciesPattern>> usedHere = new LinkedHashMap<String, Pair<Displayable, SpeciesPattern>>();
            bioModel.getModel().getRbmModelContainer().findComponentUsage(mt, mc, usedHere);
            if (!usedHere.isEmpty()) {
                String errMsg = mc.dependenciesToHtml(usedHere);
                errMsg += "<br><br>Delete anyway?";
                errMsg = "<html>" + errMsg + "</html>";
                int dialogButton = JOptionPane.YES_NO_OPTION;
                int returnCode = JOptionPane.showConfirmDialog(this.getParent().getParent(), errMsg, "Delete " + mc.getDisplayType(), dialogButton);
                if (returnCode == JOptionPane.YES_OPTION) {
                    // keep this code in sync with MolecularTypeTableModel.setValueAt
                    if (bioModel.getModel().getRbmModelContainer().delete(mt, mc) == true) {
                        mt.removeMolecularComponent(mc);
                    }
                } else {
                    return;
                }
            } else {
                if (bioModel.getModel().getRbmModelContainer().delete(mt, mc) == true) {
                    mt.removeMolecularComponent(mc);
                }
            }
        }
    } else if (selectedUserObject instanceof ComponentStateDefinition) {
        ComponentStateDefinition csd = (ComponentStateDefinition) selectedUserObject;
        Object userObject = parentNode.getUserObject();
        if (!(userObject instanceof MolecularComponent)) {
            System.out.println("Unexpected parent in tree hierarchy for " + ComponentStateDefinition.typeName + " " + csd.getDisplayName() + "!");
            return;
        }
        MolecularComponent mc = (MolecularComponent) userObject;
        TreeNode grandParent = parentNode.getParent();
        BioModelNode grandParentNode = (BioModelNode) grandParent;
        userObject = grandParentNode.getUserObject();
        if (!(userObject instanceof MolecularType)) {
            System.out.println("Unexpected parent in tree hierarchy for " + mc.getDisplayType() + " " + mc.getDisplayName() + "!");
            return;
        }
        MolecularType mt = (MolecularType) userObject;
        Map<String, Pair<Displayable, SpeciesPattern>> usedHere = new LinkedHashMap<String, Pair<Displayable, SpeciesPattern>>();
        bioModel.getModel().getRbmModelContainer().findStateUsage(mt, mc, csd, usedHere);
        if (!usedHere.isEmpty()) {
            String errMsg = csd.dependenciesToHtml(usedHere);
            errMsg += "<br><br>Delete anyway?";
            errMsg = "<html>" + errMsg + "</html>";
            int dialogButton = JOptionPane.YES_NO_OPTION;
            int returnCode = JOptionPane.showConfirmDialog(this.getParent().getParent(), errMsg, "Delete " + ComponentStateDefinition.typeName, dialogButton);
            if (returnCode == JOptionPane.YES_OPTION) {
                // keep this code in sync with MolecularTypeTableModel.setValueAt
                if (bioModel.getModel().getRbmModelContainer().delete(mt, mc, csd) == true) {
                    // this stays
                    mc.deleteComponentStateDefinition(csd);
                }
            } else {
                return;
            }
        } else {
            if (bioModel.getModel().getRbmModelContainer().delete(mt, mc, csd) == true) {
                // this stays
                mc.deleteComponentStateDefinition(csd);
            }
        }
    // mc.deleteComponentStateDefinition(csd);
    }
}
Also used : Displayable(org.vcell.util.Displayable) BioModelNode(cbit.vcell.desktop.BioModelNode) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) Point(java.awt.Point) LinkedHashMap(java.util.LinkedHashMap) ComponentStateDefinition(org.vcell.model.rbm.ComponentStateDefinition) MolecularType(org.vcell.model.rbm.MolecularType) MolecularComponent(org.vcell.model.rbm.MolecularComponent) TreeNode(javax.swing.tree.TreeNode) RelationshipObject(org.vcell.relationship.RelationshipObject) BioPaxObject(org.vcell.pathway.BioPaxObject) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) ActionMap(javax.swing.ActionMap) InputMap(javax.swing.InputMap) Pair(org.vcell.util.Pair)

Example 68 with SpeciesPattern

use of org.vcell.model.rbm.SpeciesPattern 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 69 with SpeciesPattern

use of org.vcell.model.rbm.SpeciesPattern in project vcell by virtualcell.

the class ObservablePropertiesPanel method addSpeciesPattern.

public void addSpeciesPattern() {
    SpeciesPattern sp = new SpeciesPattern();
    observable.addSpeciesPattern(sp);
    final TreePath path = observableTreeModel.findObjectPath(null, sp);
    observableTree.setSelectionPath(path);
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            observableTree.scrollPathToVisible(path);
            int h = SpeciesPatternLargeShape.defaultHeight;
            Rectangle r = new Rectangle(0, observable.getSpeciesPatternList().size() * h, 20, h);
            // scroll up to the newly added SP
            scrollPane.getViewport().scrollRectToVisible(r);
        }
    });
}
Also used : TreePath(javax.swing.tree.TreePath) Rectangle(java.awt.Rectangle) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 70 with SpeciesPattern

use of org.vcell.model.rbm.SpeciesPattern in project vcell by virtualcell.

the class ObservablePropertiesPanel method updateShape.

private void updateShape() {
    spsList.clear();
    int maxXOffset = xOffsetInitial;
    int maxYOffset = 88 + SpeciesPatternLargeShape.defaultHeight;
    if (observable != null && observable.getSpeciesPatternList() != null && observable.getSpeciesPatternList().size() > 0) {
        for (int i = 0; i < observable.getSpeciesPatternList().size(); i++) {
            SpeciesPattern sp = observable.getSpeciesPatternList().get(i);
            SpeciesPatternLargeShape sps = new SpeciesPatternLargeShape(xOffsetInitial, 8 + (SpeciesPatternLargeShape.defaultHeight + GraphConstants.ObservableDisplay_ReservedSpaceForNameOnYAxis) * i, 80, sp, shapePanel, observable, issueManager);
            spsList.add(sps);
            int xOffset = sps.getRightEnd();
            maxXOffset = Math.max(maxXOffset, xOffset);
        }
        maxYOffset = Math.max(maxYOffset, 8 + (80 + GraphConstants.ObservableDisplay_ReservedSpaceForNameOnYAxis) * observable.getSpeciesPatternList().size() + SpeciesPatternLargeShape.defaultHeight);
    }
    Dimension preferredSize = new Dimension(maxXOffset + 200, maxYOffset);
    shapePanel.setPreferredSize(preferredSize);
    splitPaneHorizontal.repaint();
}
Also used : Dimension(java.awt.Dimension) SpeciesPatternLargeShape(cbit.vcell.graph.SpeciesPatternLargeShape) Point(java.awt.Point) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Aggregations

SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)93 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)39 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)30 MolecularType (org.vcell.model.rbm.MolecularType)25 RbmObservable (cbit.vcell.model.RbmObservable)22 SpeciesContext (cbit.vcell.model.SpeciesContext)22 Structure (cbit.vcell.model.Structure)22 Point (java.awt.Point)18 ReactionRule (cbit.vcell.model.ReactionRule)16 ArrayList (java.util.ArrayList)16 ComponentStatePattern (org.vcell.model.rbm.ComponentStatePattern)16 Graphics (java.awt.Graphics)13 PropertyVetoException (java.beans.PropertyVetoException)13 SpeciesPatternLargeShape (cbit.vcell.graph.SpeciesPatternLargeShape)12 ProductPattern (cbit.vcell.model.ProductPattern)12 ReactantPattern (cbit.vcell.model.ReactantPattern)12 Dimension (java.awt.Dimension)12 ComponentStateDefinition (org.vcell.model.rbm.ComponentStateDefinition)12 Model (cbit.vcell.model.Model)11 ModelException (cbit.vcell.model.ModelException)11