SimulationTreePanel.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:featurea 作者:
/**
 * 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();
            }
        }

    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号