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);
}
}
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);
}
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;
}
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;
}
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);
}
Aggregations