/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author nbriere */ public class GroupLeaf extends Composite { static final long serialVersionUID = // for wader: -6036608125951558970L; -1647706059469889079L; GroupLeaf() { this("Loop"); } GroupLeaf(String name) { super(name); addChild(new cGroup(name + "Leaf")); } Object3D deepCopy() { Composite comp = new GroupLeaf(); deepCopySelf(comp); return comp; } public int Size() { return size(); } public int size() { ////GraphreeD.trace("SIZE " + count + this + " = ", super.size() - 1); if (count == 2) return 2; if (true) return super.size() - 1; // ??? //System.err.println("COUNT = " + count); //assert (count >= 0); if (count <= 1) { //System.err.println("SIZE = " + 1); return 1; // Math.min(Size(),1); } else { //System.err.println("SIZE = " + (Size() - 1)); return Size() - 1; } } public Object3D get(int i) { //GraphreeD.trace("GET " + this + " = ", i); if (count <= 1) { //assert (i==0); if (i != 0) { new Exception().printStackTrace(); //return null; } return super.get(0); } else { if (i+1 >= Size()+1) return new Object3D("BUG"); return super.get(i+1); } } public Object3D reserve(int i) { Object3D child; //GraphreeD.tracein("RESERVE2 " + this + " = ", i); if (count <= 1) { if (super.size() == 0) assert (i==0); child = super.get(0); //Applet3D.tracein("RESERVE ", child); child.count--; //assert (child.count >= 0); } else { if (i+1 >= Size()+1) return new Object3D("BUG"); child = super.get(i+1); //Applet3D.tracein("RESERVE ", child); child.count--; //assert (child.count >= 0); } //Applet3D.trace("CHILD = ", child); return child; } public void release(int i) { //GraphreeD.traceout("RELEASE " + this + " = ", i); if (count <= 1) { // assert (i==0); //Applet3D.traceout("RELEASE " + this + " = ", i); //Applet3D.trace("CHILD = ", super.get(0)); super.get(0).count++; } else { //Applet3D.traceout("RELEASE " + this + " = ", i); //Applet3D.trace("CHILD = ", super.get(i+1)); super.get(i+1).count++; } } }