-
- private static Box[] frontier = new Box[65535];
- /** pack the boxes into rows and columns, compute contentwidth */
- public void pack() {
- if (!test(REPACK)) { constrain(); return; }
- boolean haskid = false;
- for(Box child = getChild(0); child != null; child = child.nextSibling()) { haskid = true; child.pack(); }
- if (!haskid) { clear(REPACK); constrain(); return; }
- int frontier_size = 0;
- //#repeat COLS/ROWS rows/cols cols/rows col/row row/col colspan/rowspan rowspan/colspan \
- // contentheight/contentwidth contentwidth/contentheight
- if (test(FIXED) == COLS) {
- rows = 0;
- for(Box child = getChild(0); child != null; child = child.nextSibling()) {
- if (!child.test(PACKED) || !child.test(VISIBLE)) continue;
- if (cols == 1) { child.row = rows; rows += child.rowspan; child.col = 0; continue; }
- child.col = (short)(frontier_size <= 0 ? 0 : (frontier[frontier_size-1].col + frontier[frontier_size-1].colspan));
- child.row = (short)(frontier_size <= 0 ? 0 : frontier[frontier_size-1].row);
- if (child.col + min(cols,child.colspan) > cols) { child.col = 0; child.row++; }
- for(int i=0; i<frontier_size; i++)
- if (frontier[i].row + frontier[i].rowspan <= child.row) {
- frontier[i--] = frontier[--frontier_size]; frontier[frontier_size] = null;
- } else if (frontier[i].col<child.col+min(cols,child.colspan)&&frontier[i].col+frontier[i].colspan>child.col) {
- child.col = (short)(frontier[i].col + frontier[i].colspan);
- if (child.col + min(cols,child.colspan) > cols) {
- child.row = (short)(frontier[i].row + frontier[i].rowspan);
- for(i--; i>0; i--) child.row = (short)min(row, frontier[i].row + frontier[i].rowspan);
- child.col = (short)0;
- }
- i = -1;
- } else break;
- frontier[frontier_size++] = child;
- }
- for(int i=0; i<frontier_size; i++){ rows=(short)max(rows, frontier[i].row + frontier[i].rowspan); frontier[i] = null; }
+
+ public float minWidth() { return Encode.longToFloat1(transform.rotateBox(minwidth, minheight)); }
+ public float minHeight() { return Encode.longToFloat2(transform.rotateBox(minwidth, minheight)); }
+ public float maxWidth() { return Encode.longToFloat1(transform.rotateBox(maxwidth, maxheight)); }
+ public float maxHeight() { return Encode.longToFloat2(transform.rotateBox(maxwidth, maxheight)); }
+ public float contentWidth() { return Encode.longToFloat1(transform.rotateBox(contentwidth, contentheight)); }
+ public float contentHeight() { return Encode.longToFloat2(transform.rotateBox(contentwidth, contentheight)); }
+
+ /** used (single-threadedly) in constrain() */
+ private static int xmin = 0, ymin = 0, xmax = 0, ymax = 0;
+
+ private static class BoundingBox {
+ public int xmin, ymin, xmax, ymax;
+ public boolean unbounded() {
+ return xmin==Integer.MAX_VALUE||xmax==Integer.MIN_VALUE||ymin==Integer.MAX_VALUE||ymax==Integer.MIN_VALUE; }
+ public void reset() {
+ xmin = Integer.MAX_VALUE; ymin = Integer.MAX_VALUE;
+ xmax = Integer.MIN_VALUE; ymax = Integer.MIN_VALUE;
+ }
+ public void include(Affine a, float cw, float ch) {
+ //#repeat contentwidth/contentheight contentheight/contentwidth minwidth/minheight row/col col/row \
+ // textwidth/textheight maxwidth/maxheight bounds/boundsy x1/y1 x2/y2 z1/q1 z2/q2 z3/q3 z4/q4 \
+ // horizontalBounds/verticalBounds e/f multiply_px/multiply_py xmin/ymin xmax/ymax
+ float z1 = a.multiply_px(0, 0);
+ float z2 = a.multiply_px(cw, ch);
+ float z3 = a.multiply_px(cw, 0);
+ float z4 = a.multiply_px(0, ch);
+ xmin = min(xmin, (int)min(min(z1, z2), min(z3, z4)));
+ xmax = max(xmax, (int)max(max(z1, z2), max(z3, z4)));
+ //#end
+ }
+ public void include(Affine a, Path path) {
+ //#repeat contentwidth/contentheight contentheight/contentwidth minwidth/minheight row/col col/row \
+ // textwidth/textheight maxwidth/maxheight bounds/boundsy x1/y1 x2/y2 z1/q1 z2/q2 z3/q3 z4/q4 \
+ // horizontalBounds/verticalBounds e/f multiply_px/multiply_py xmin/ymin xmax/ymax
+ long bounds = path.horizontalBounds(a);
+ float z1 = Encode.longToFloat2(bounds);
+ float z2 = Encode.longToFloat1(bounds);
+ float z3 = Encode.longToFloat2(bounds);
+ float z4 = Encode.longToFloat1(bounds);
+ xmin = min(xmin, (int)min(min(z1, z2), min(z3, z4)));
+ xmax = max(xmax, (int)max(max(z1, z2), max(z3, z4)));
+ //#end