SimulationTreePanel.java 文件源码

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

项目:featurea 作者:
/**
 * Applies a force to the given body if the user accepts the input.
 */
private void applyForceAction() {
    // 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();
            // show the force input dialog
            Vector2 f = ApplyForceDialog.show(ControlUtilities.getParentWindow(this));
            // make sure the user accepted the input
            if (f != null) {
                synchronized (Simulation.LOCK) {
                    body.applyForce(f);
                }
            }
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号