SimulationTreePanel.java 文件源码

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

项目:featurea 作者:
/**
 * Shows an add new joint dialog using the given joint panel.
 * <p>
 * If the user closes or cancels, nothing is modified.  If the user clicks the add button
 * a new joint is created and added to the world.
 *
 * @param clazz the joint class
 */
private void addJointAction(Class<? extends Joint> clazz) {
    synchronized (Simulation.LOCK) {
        SandboxBody[] bodies = this.getBodies();
        // check the joint class type
        if (bodies == null || bodies.length == 0 || (clazz != PinJoint.class && bodies.length == 1)) {
            JOptionPane.showMessageDialog(ControlUtilities.getParentWindow(this), Messages.getString("menu.resources.joint.add.warning"),
                    Messages.getString("menu.resources.joint.add.warning.title"), JOptionPane.ERROR_MESSAGE);
            return;
        }

        Joint joint = AddJointDialog.show(ControlUtilities.getParentWindow(this), bodies, clazz);
        if (joint != null) {
            // add the joint to the world
            this.simulation.getWorld().addJoint(joint);
            // add the joint to the root node
            DefaultMutableTreeNode jointNode = new DefaultMutableTreeNode(joint);
            // insert into the tree
            this.model.insertNodeInto(jointNode, this.jointFolder, this.jointFolder.getChildCount());
            // expand the path to the new node
            this.tree.expandPath(new TreePath(jointNode.getPath()).getParentPath());
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号