Search in sources :

Example 31 with BioModelNode

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

the class CSGObjectPropertiesPanel method selectClickPath.

private void selectClickPath(MouseEvent e) {
    Point mousePoint = e.getPoint();
    TreePath clickPath = csgObjectTree.getPathForLocation(mousePoint.x, mousePoint.y);
    if (clickPath == null) {
        return;
    }
    Object rightClickNode = clickPath.getLastPathComponent();
    if (rightClickNode == null || !(rightClickNode instanceof BioModelNode)) {
        return;
    }
    TreePath[] selectedPaths = csgObjectTree.getSelectionPaths();
    if (selectedPaths == null || selectedPaths.length == 0) {
        return;
    }
    boolean bFound = false;
    for (TreePath tp : selectedPaths) {
        if (tp.equals(clickPath)) {
            bFound = true;
            break;
        }
    }
    if (!bFound) {
        csgObjectTree.setSelectionPath(clickPath);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) CSGObject(cbit.vcell.geometry.CSGObject) BioModelNode(cbit.vcell.desktop.BioModelNode) Point(java.awt.Point)

Example 32 with BioModelNode

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

the class CSGObjectPropertiesPanel method createCsgObjectTree.

private void createCsgObjectTree() {
    csgObjectTreeModel = new CSGObjectTreeModel();
    csgObjectTree = new JTree(csgObjectTreeModel) {

        @Override
        public boolean isPathEditable(TreePath path) {
            Object object = path.getLastPathComponent();
            return object instanceof BioModelNode;
        }
    };
    csgObjectTree.setEditable(true);
    csgObjectTreeCellRenderer = new CSGObjectTreeCellRenderer();
    csgObjectTree.setCellRenderer(csgObjectTreeCellRenderer);
    csgObjectTreeCellEditor = new CSGObjectTreeCellEditor(csgObjectTree);
    csgObjectTree.setCellEditor(csgObjectTreeCellEditor);
    csgObjectTree.addMouseListener(eventHandler);
    int rowHeight = csgObjectTree.getRowHeight();
    if (rowHeight < 10) {
        rowHeight = 20;
    }
    csgObjectTree.setRowHeight(rowHeight + 2);
    csgObjectTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    ToolTipManager.sharedInstance().registerComponent(csgObjectTree);
    csgObjectTree.addTreeSelectionListener(eventHandler);
    csgObjectTree.addMouseListener(eventHandler);
}
Also used : JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) CSGObject(cbit.vcell.geometry.CSGObject) BioModelNode(cbit.vcell.desktop.BioModelNode) Point(java.awt.Point)

Example 33 with BioModelNode

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

the class CSGObjectPropertiesPanel method addNode.

private boolean addNode(CSGNode newCsgNode) {
    if (newCsgNode == null) {
        return false;
    }
    Object obj = csgObjectTree.getLastSelectedPathComponent();
    if (obj == null || !(obj instanceof BioModelNode)) {
        return false;
    }
    BioModelNode selectedNode = (BioModelNode) obj;
    Object selectedUserObject = selectedNode.getUserObject();
    if (selectedUserObject == csgObject) {
        csgObject.setRoot(newCsgNode);
        return true;
    }
    if (selectedUserObject instanceof CSGSetOperator) {
        CSGSetOperator csgSetOperator = (CSGSetOperator) selectedUserObject;
        csgSetOperator.addChild(newCsgNode);
        return true;
    }
    if (selectedUserObject instanceof CSGTransformation) {
        CSGTransformation csgTransformation = (CSGTransformation) selectedUserObject;
        csgTransformation.setChild(newCsgNode);
        return true;
    }
    return false;
}
Also used : CSGTransformation(cbit.vcell.geometry.CSGTransformation) CSGObject(cbit.vcell.geometry.CSGObject) BioModelNode(cbit.vcell.desktop.BioModelNode) CSGSetOperator(cbit.vcell.geometry.CSGSetOperator)

Example 34 with BioModelNode

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

the class CSGObjectPropertiesPanel method transformOrApplySetOperator.

private boolean transformOrApplySetOperator(CSGNode newCsgNode) {
    if (newCsgNode == null) {
        return false;
    }
    Object obj = csgObjectTree.getLastSelectedPathComponent();
    if (obj == null || !(obj instanceof BioModelNode)) {
        return false;
    }
    BioModelNode selectedNode = (BioModelNode) obj;
    Object selectedUserObject = selectedNode.getUserObject();
    if (!(selectedUserObject instanceof CSGNode)) {
        return false;
    }
    CSGNode selectedCSGNode = (CSGNode) selectedUserObject;
    TreeNode parentNode = selectedNode.getParent();
    if (parentNode == null || !(parentNode instanceof BioModelNode)) {
        return false;
    }
    Object parentObject = ((BioModelNode) parentNode).getUserObject();
    if (newCsgNode instanceof CSGTransformation) {
        CSGTransformation csgTransformation = (CSGTransformation) newCsgNode;
        csgTransformation.setChild(selectedCSGNode);
    } else if (newCsgNode instanceof CSGSetOperator) {
        CSGSetOperator csgSetOperator = (CSGSetOperator) newCsgNode;
        csgSetOperator.addChild(selectedCSGNode);
    }
    if (parentObject == csgObject) {
        csgObject.setRoot(newCsgNode);
    } else if (parentObject instanceof CSGSetOperator) {
        CSGSetOperator parentCSGSetOperator = (CSGSetOperator) parentObject;
        int index = parentCSGSetOperator.indexOf(selectedCSGNode);
        if (index >= 0) {
            parentCSGSetOperator.setChild(index, newCsgNode);
            return true;
        }
    } else if (parentObject instanceof CSGTransformation) {
        CSGTransformation parentCSGTransformation = (CSGTransformation) parentObject;
        parentCSGTransformation.setChild(newCsgNode);
        return true;
    }
    return false;
}
Also used : TreeNode(javax.swing.tree.TreeNode) CSGTransformation(cbit.vcell.geometry.CSGTransformation) CSGNode(cbit.vcell.geometry.CSGNode) CSGObject(cbit.vcell.geometry.CSGObject) BioModelNode(cbit.vcell.desktop.BioModelNode) CSGSetOperator(cbit.vcell.geometry.CSGSetOperator)

Example 35 with BioModelNode

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

the class CSGObjectPropertiesPanel method deleteNode.

private void deleteNode() {
    Object obj = csgObjectTree.getLastSelectedPathComponent();
    if (obj == null || !(obj instanceof BioModelNode)) {
        return;
    }
    BioModelNode selectedNode = (BioModelNode) obj;
    Object selectedUserObject = selectedNode.getUserObject();
    if (!(selectedUserObject instanceof CSGNode)) {
        return;
    }
    CSGNode selectedCSGNode = (CSGNode) selectedUserObject;
    TreeNode parentNode = selectedNode.getParent();
    if (parentNode == null || !(parentNode instanceof BioModelNode)) {
        return;
    }
    Object parentObject = ((BioModelNode) parentNode).getUserObject();
    if (parentObject == csgObject) {
        csgObject.setRoot(null);
    } else if (parentObject instanceof CSGSetOperator) {
        CSGSetOperator csgSetOperator = (CSGSetOperator) parentObject;
        csgSetOperator.removeChild(selectedCSGNode);
    } else if (parentObject instanceof CSGTransformation) {
        CSGTransformation csgTransformation = (CSGTransformation) parentObject;
        csgTransformation.setChild(null);
    }
    updateCSGObject(parentObject);
}
Also used : TreeNode(javax.swing.tree.TreeNode) CSGTransformation(cbit.vcell.geometry.CSGTransformation) CSGNode(cbit.vcell.geometry.CSGNode) CSGObject(cbit.vcell.geometry.CSGObject) BioModelNode(cbit.vcell.desktop.BioModelNode) CSGSetOperator(cbit.vcell.geometry.CSGSetOperator)

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