/* * (non-Javadoc) * * @see org.jense.swing.jtreemap.SplitStrategy#calculatePositionsRec(int, int, * int, int, double, java.util.Vector) */ protected override void calculatePositionsRec(double x0, double y0, double w0, double h0, double weight0, ArrayList v) { SplitBySlice.splitInSlice(x0, y0, w0, h0, v, weight0); foreach (TreeMapNode node in v) { if (node.IsLeaf) { node.setX(node.getX() + getBorder()); node.setY(node.getY() + getBorder()); node.setHeight(node.getHeight() - getBorder()); node.setWidth(node.getWidth() - getBorder()); } else { //if this is not a leaf, calculation for the children if (getBorder() > 1) { setBorder(getBorder() - 2); calculatePositionsRec(node.getX() + 2, node.getY() + 2, node.getWidth() - 2, node.getHeight() - 2, node.getWeight(), node.getChildren()); setBorder(getBorder() + 2); } else if (getBorder() == 1) { setBorder(0); calculatePositionsRec(node.getX() + 1, node.getY() + 1, node.getWidth() - 1, node.getHeight() - 1, node.getWeight(), node.getChildren()); setBorder(1); } else { calculatePositionsRec(node.getX(), node.getY(), node.getWidth(), node.getHeight(), node.getWeight(), node.getChildren()); } } } }
/* * (non-Javadoc) * * @see org.jense.swing.jtreemap.SplitStrategy#calculatePositionsRec(int, int, * int, int, double, java.util.Vector) */ protected override void calculatePositionsRec(double x0, double y0, double w0, double h0, double weight0, ArrayList v) { ArrayList vClone = new ArrayList(); vClone.AddRange(v); //foreach (object n in v) { // vClone.Add(n); //} vClone.Sort(); //sortVector(vClone); if (vClone.Count <= 2) { SplitBySlice.splitInSlice(x0, y0, w0, h0, vClone, sumWeight(vClone)); calculateChildren(vClone); } else { ArrayList v1 = new ArrayList(); ArrayList v2 = new ArrayList(); this.x = x0; this.y = y0; this.w = w0; this.h = h0; splitElements(vClone, v1, v2); //before the recurence, we have to "save" the values for the 2nd Vector double x2 = this.x2; double y2 = this.y2; double w2 = this.w2; double h2 = this.h2; SplitBySlice.splitInSlice(x0, y0, this.w1, this.h1, v1, sumWeight(v1)); calculateChildren(v1); calculatePositionsRec(x2, y2, w2, h2, sumWeight(v2), v2); } }