private static List<Part> layout(Part fp, int w) {
            List<Part> ret = new LinkedList<Part>();
            List<Part> line = new LinkedList<Part>();
            int x = 0, y = 0;
            int mw = 0, lh = 0;
            for (Part p = fp; p != null; p = p.next) {
                boolean lb = p instanceof Newline;
                int pw, ph;
                while (true) {
                    p.x = x;
                    pw = p.width();
                    ph = p.height();
                    if (w > 0) {
                        if (p.x + pw > w) {
                            lb = true;
                            Part tmp = p.split(w - x);
                            if (tmp != null) {
                                p = tmp;
                                continue;
                            } else {
                                break;
                            }
                        }
                    }
                    break;
                }
                ret.add(p);
                line.add(p);
                if (ph > lh) lh = ph;
                x += pw;
                if (x > mw) mw = x;
                if (lb) {
                    aline(line, y);
                    x = 0;
                    y += lh;
                    lh = 0;
                    line = new LinkedList<Part>();
                }
            }
            aline(line, y);
            return (ret);
        }