/**
* Called when the user clicks the Center On Origin menu item on a body.
*/
private void centerOnOriginAction() {
// the current selection should have the body selected
TreePath path = this.tree.getSelectionPath();
// make sure that something is selected
if (path != null) {
// getProperty the currently selected node
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
// make sure the selected node is a body
if (node.getUserObject() instanceof SandboxBody) {
// getProperty the body from the node
SandboxBody body = (SandboxBody) node.getUserObject();
synchronized (Simulation.LOCK) {
// re-center the body
body.translateToOrigin();
}
}
}
}
SimulationTreePanel.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:featurea
作者:
评论列表
文章目录