Exemplo n.º 1
0
 private Cell<T> _insertCellAfter() {
   Cell<T> newCell = new Cell<T>(parent, this, nextCell);
   if (nextCell == null) {
     parent.lastCell = newCell;
   } else {
     nextCell.prevCell = newCell;
   }
   nextCell = newCell;
   return newCell;
 }
Exemplo n.º 2
0
    public boolean tryInterleaveWith(Row<T> other) {
      // System.out.println("Try to interleave " + this);
      // System.out.print("             with " + other);
      if (!isInterleaveableWith(other)) {
        // System.out.println(": failed");
        return false;
      }

      Iterator<Cell<T>> oIt = other.iterator();
      for (Cell<T> c : this) {
        Cell<T> oC = oIt.next();
        if (c.isFilled()) {
          if (oC.prevCell == null) {
            oC.parent.firstCell = c;
          } else {
            oC.prevCell.nextCell = c;
          }
          if (oC.nextCell == null) {
            oC.parent.lastCell = c;
          } else {
            oC.nextCell.prevCell = c;
          }

          c.prevCell = oC.prevCell;
          c.nextCell = oC.nextCell;
          c.parent = oC.parent;
          oC.nextCell = null;
          oC.prevCell = null;
          oC.parent = null;
        } else if (c.isUnpackable()) {
          oC.setPackable(false);
        }
      }
      this._remove();
      // System.out.println(": done");
      return true;
    }