- public void setPrev(Fragment fragment) {
- prevFrag = fragment;
- }
-
- /**
- * Split this Fragment into two. 'this' Fragment will contain length
- * cells, 'this.next()' will contain (getCellCount() - length) cells.
- *
- * @param length the number of cells to leave in this Fragment
- * @throws IndexOutOfBoundsException if length is negative, or 0, greater
- * than (getCellCount() - 1)
- */
- public void split(final int length) {
- // Create the next node
- Line q = new Line();
- q.nextFrag = nextFrag;
- q.prevFrag = this;
- ((Line) nextFrag).prevFrag = q;
- nextFrag = q;
-
- // Split cells
- q.cells = new ArrayList<Cell>(cells.size() - length);
- q.cells.addAll(cells.subList(length, cells.size()));
- cells = cells.subList(0, length);