import java.awt.*; import javax.swing.*; import java.util.Vector; import javax.media.j3d.*; import com.sun.j3d.utils.geometry.*; import javax.vecmath.*; import javax.vecmath.Vector4d; import java.util.*; /** * * */ public class DHJoint { public double theta = 0; public double d = 0; public double a = 0; public double alpha = 0; public String type = "Rotational"; public double var = 0; public double min = 0; public double max = 0; // public BranchGroup bg; public TransformGroup tgt = new TransformGroup(); public DHPoint point; /// location public Vector childs; public DHJoint parent; /** * DHJoint * * @param d * @param theta * @param alpha * @param a */ public DHJoint (double d, double theta, double alpha, double a) { this.d = d; this.theta = theta; this.alpha = alpha; this.a = a; this.tgt.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); } public DHJoint(String line) { String[] cols = line.split(" "); for (int i=0;i this.max) { return max; } else if (v < this.min) { return min; } return v; } /// interface public JPanel getPanel() { JTextField f = new JTextField(); f.setText(Double.toString(this.var)); f.setSize(100,20); f.addActionListener( new CommandAdjust("f", f, this) ); JButton bp2 = new JButton("++"); bp2.addActionListener( new CommandAdjust("++", f, this) ); JButton bp = new JButton("+"); bp.addActionListener( new CommandAdjust("+", f, this) ); JButton bm = new JButton("-"); bm.addActionListener( new CommandAdjust("-", f, this) ); JButton bm2 = new JButton("--"); bm2.addActionListener( new CommandAdjust("--", f, this) ); JPanel p = new JPanel(); p.setLayout(new GridLayout(1,9)); p.add(new JLabel(this.type + " ")); p.add(new JLabel("Min: " + this.min)); p.add(new JLabel("Max: " + this.max)); p.add(new JLabel("Var: ")); p.add(f); p.add(bp2); p.add(bp); p.add(bm); p.add(bm2); return p; } public JPanel getPanels() { JPanel p = new JPanel(); p.setLayout(new FlowLayout()); DHJoint c = this; p.add(c.getPanel()); while (c.childs != null) { c = (DHJoint) c.childs.get(0); p.add(c.getPanel()); } return p; } /** * toString() */ public String toString() { String t = ""; t += "theta: " + this.theta + " "; t += "d: " + this.d + " "; t += "a: " + this.a+ " "; t += "alpha: " + this.alpha + " "; t += "type : " + this.type+ " "; t += "min : " + this.min+ " "; t += "max : " + this.max+ " "; t += "var : " + this.var+ " "; return t; } }