public JUMIBone findDescendantByName(String inName) { for (JUMIBone a : children) { if (a.getName().equals(inName)) { return a; } a.findDescendantByName(inName); } return null; }
public JUMIBone[] getFullSkeleton() { ArrayList<JUMIBone> allBones = new ArrayList(); JUMIBone root = getRoot(); allBones.add(root); root.addDescendantsToList(allBones); JUMIBone[] result = new JUMIBone[allBones.size()]; allBones.toArray(result); return result; }
public JUMIBone getRoot() { if (parent == null) { return this; } else { return parent.getRoot(); } }
public void addChild(JUMIBone newChild) { children.add(newChild); newChild.setParent(this); }
private void addDescendantsToList(ArrayList<JUMIBone> boneList) { for (JUMIBone a : children) { boneList.add(a); a.addDescendantsToList(boneList); } }
public void removeChild(JUMIBone childToRemove) { children.remove(childToRemove); childToRemove.setParent(null); }