Search in sources :

Example 56 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class DocumentEditorTreeModel method onActiveViewChange.

private void onActiveViewChange(ActiveView activeView) {
    SimulationContext simulationContext = activeView.getSimulationContext();
    DocumentEditorTreeFolderClass folderClass = activeView.getDocumentEditorTreeFolderClass();
    BioModelNode node = findNode(simulationContext, folderClass);
    if (node != null) {
        selectedBioModelNode = node;
        restoreTreeSelection();
    }
}
Also used : BioModelNode(cbit.vcell.desktop.BioModelNode) SimulationContext(cbit.vcell.mapping.SimulationContext)

Example 57 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class BioModelEditor method treeSelectionChanged.

@Override
protected void treeSelectionChanged() {
    try {
        Object lastSelectedPathComponent = documentEditorTree.getLastSelectedPathComponent();
        if (lastSelectedPathComponent == null || !(lastSelectedPathComponent instanceof BioModelNode)) {
            return;
        }
        BioModelNode selectedNode = (BioModelNode) lastSelectedPathComponent;
        Object selectedObject = selectedNode.getUserObject();
        SimulationContext simulationContext = getSelectedSimulationContext();
        setRightTopPanel(selectedObject, simulationContext);
    } catch (Exception ex) {
        ex.printStackTrace(System.out);
    }
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) CSGObject(cbit.vcell.geometry.CSGObject) BioModelNode(cbit.vcell.desktop.BioModelNode) SimulationContext(cbit.vcell.mapping.SimulationContext) PropertyVetoException(java.beans.PropertyVetoException) UnsupportedOperationException(javax.help.UnsupportedOperationException)

Example 58 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class SpeciesPropertiesTreeModel method findObjectPath.

public TreePath findObjectPath(BioModelNode startNode, Object object) {
    if (startNode == null) {
        startNode = rootNode;
    }
    Object userObject = startNode.getUserObject();
    if (userObject == object) {
        return new TreePath(startNode.getPath());
    }
    for (int i = 0; i < startNode.getChildCount(); i++) {
        BioModelNode childNode = (BioModelNode) startNode.getChildAt(i);
        TreePath path = findObjectPath(childNode, object);
        if (path != null) {
            return path;
        }
    }
    return null;
}
Also used : TreePath(javax.swing.tree.TreePath) BioModelNode(cbit.vcell.desktop.BioModelNode)

Example 59 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class MathModelEditor method popupMenuActionPerformed.

@Override
protected void popupMenuActionPerformed(DocumentEditorPopupMenuAction action, String actionCommand) {
    switch(action) {
        case add_new:
            try {
                Object obj = documentEditorTree.getLastSelectedPathComponent();
                if (obj == null || !(obj instanceof BioModelNode)) {
                    return;
                }
                BioModelNode selectedNode = (BioModelNode) obj;
                Object userObject = selectedNode.getUserObject();
                if (userObject instanceof DocumentEditorTreeFolderNode) {
                    DocumentEditorTreeFolderClass folderClass = ((DocumentEditorTreeFolderNode) userObject).getFolderClass();
                    switch(folderClass) {
                        case MATH_SIMULATIONS_NODE:
                            Object newsim = mathModel.addNewSimulation(SimulationOwner.DEFAULT_SIM_NAME_PREFIX);
                            selectionManager.setSelectedObjects(new Object[] { newsim });
                            break;
                        case MATH_OUTPUT_FUNCTIONS_NODE:
                            break;
                    }
                }
            } catch (Exception ex) {
                DialogUtils.showErrorDialog(this, ex.getMessage());
            }
            break;
    }
}
Also used : DocumentEditorTreeFolderNode(cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderNode) CSGObject(cbit.vcell.geometry.CSGObject) BioModelNode(cbit.vcell.desktop.BioModelNode) DocumentEditorTreeFolderClass(cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass)

Example 60 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class RbmObservableTreeCellRenderer method getTreeCellRendererComponent.

@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    setBorder(null);
    if (value instanceof BioModelNode) {
        BioModelNode node = (BioModelNode) value;
        Object userObject = node.getUserObject();
        obj = userObject;
        String text = null;
        Icon icon = null;
        String toolTip = null;
        if (userObject instanceof RbmObservable) {
            RbmObservable ob = (RbmObservable) userObject;
            text = toHtml(ob);
            toolTip = toHtmlWithTip(ob);
            icon = VCellIcons.rbmObservableIcon;
        } else if (userObject instanceof SpeciesPatternLocal) {
            SpeciesPatternLocal spl = (SpeciesPatternLocal) userObject;
            text = toHtml(spl, true);
            toolTip = toHtmlWithTip(spl, true);
            icon = VCellIcons.rbmProductIcon;
        } else if (userObject instanceof MolecularTypePattern) {
            MolecularTypePattern molecularTypePattern = (MolecularTypePattern) userObject;
            text = toHtml(molecularTypePattern, true);
            toolTip = toHtmlWithTip(molecularTypePattern, true);
            if (owner == null) {
                icon = VCellIcons.rbmMolecularTypeSimpleIcon;
                ;
            } else {
                Graphics gc = owner.getGraphics();
                icon = new MolecularTypeSmallShape(1, 5, molecularTypePattern.getMolecularType(), null, gc, molecularTypePattern.getMolecularType(), null, issueManager);
            }
        } else if (userObject instanceof MolecularComponentPattern) {
            MolecularComponentPattern mcp = (MolecularComponentPattern) userObject;
            text = toHtml(mcp, true);
            toolTip = toHtmlWithTip(mcp, true);
            icon = VCellIcons.rbmComponentGrayIcon;
            if (mcp.getMolecularComponent().getComponentStateDefinitions().size() > 0) {
                icon = VCellIcons.rbmComponentGrayStateIcon;
            }
            if (mcp.isbVisible()) {
                icon = VCellIcons.rbmComponentGreenIcon;
                if (mcp.getMolecularComponent().getComponentStateDefinitions().size() > 0) {
                    icon = VCellIcons.rbmComponentGreenStateIcon;
                }
            }
            ComponentStatePattern csp = mcp.getComponentStatePattern();
            if (csp != null && !csp.isAny()) {
                icon = VCellIcons.rbmComponentGreenIcon;
                if (mcp.getMolecularComponent().getComponentStateDefinitions().size() > 0) {
                    icon = VCellIcons.rbmComponentGreenStateIcon;
                }
            }
            BioModelNode parent = (BioModelNode) ((BioModelNode) value).getParent().getParent().getParent();
            if (parent == null) {
                icon = VCellIcons.rbmComponentErrorIcon;
                return this;
            }
            Object parentObject = parent.getUserObject();
            if (!(parentObject instanceof RbmObservable)) {
                icon = VCellIcons.rbmComponentErrorIcon;
                return this;
            }
            if (hasErrorIssues((RbmObservable) parentObject, mcp, mcp.getMolecularComponent())) {
                icon = VCellIcons.rbmComponentErrorIcon;
            }
        } else if (userObject instanceof StateLocal) {
            StateLocal sl = (StateLocal) userObject;
            text = toHtml(sl, true);
            toolTip = toHtmlWithTip(sl, true);
            icon = VCellIcons.rbmComponentStateIcon;
        } else if (userObject instanceof BondLocal) {
            BondLocal bl = (BondLocal) userObject;
            text = toHtml(bl, sel);
            toolTip = toHtmlWithTip(bl, true);
            icon = VCellIcons.rbmBondIcon;
        } else {
            if (userObject != null) {
                System.out.println(userObject.toString());
                text = userObject.toString();
            } else {
                text = "null user object";
            }
        }
        setText(text);
        setIcon(icon);
        setToolTipText(toolTip == null ? text : toolTip);
    }
    return this;
}
Also used : MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) RbmObservable(cbit.vcell.model.RbmObservable) ComponentStatePattern(org.vcell.model.rbm.ComponentStatePattern) StateLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.StateLocal) BioModelNode(cbit.vcell.desktop.BioModelNode) Graphics(java.awt.Graphics) MolecularTypeSmallShape(cbit.vcell.graph.MolecularTypeSmallShape) SpeciesPatternLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.SpeciesPatternLocal) BondLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.BondLocal) Icon(javax.swing.Icon) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern)

Aggregations

BioModelNode (cbit.vcell.desktop.BioModelNode)82 TreePath (javax.swing.tree.TreePath)22 MolecularComponent (org.vcell.model.rbm.MolecularComponent)17 CSGObject (cbit.vcell.geometry.CSGObject)12 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)11 SimulationContext (cbit.vcell.mapping.SimulationContext)10 MolecularType (org.vcell.model.rbm.MolecularType)10 Point (java.awt.Point)9 Icon (javax.swing.Icon)8 ComponentStateDefinition (org.vcell.model.rbm.ComponentStateDefinition)8 TestSuiteInfoNew (cbit.vcell.numericstest.TestSuiteInfoNew)7 TreeNode (javax.swing.tree.TreeNode)7 DocumentEditorTreeFolderClass (cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass)6 DocumentEditorTreeFolderNode (cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderNode)6 TestCaseNew (cbit.vcell.numericstest.TestCaseNew)6 TestCriteriaNew (cbit.vcell.numericstest.TestCriteriaNew)6 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)6 BioPaxObject (org.vcell.pathway.BioPaxObject)6 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)5 Component (java.awt.Component)5