Ejemplo n.º 1
0
 public Snake merge(Snake other, StringBounder stringBounder) {
   final MergeStrategy strategy = this.mergeable.max(other.mergeable);
   if (strategy == MergeStrategy.NONE) {
     return null;
   }
   if (TextBlockUtils.isEmpty(other.textBlock, stringBounder) == false) {
     return null;
     // System.err.println("merge other.textBlock="+other.textBlock+"
     // "+other.textBlock.calculateDimension(TextBlockUtils.getDummyStringBounder()));
   }
   // if (other.textBlock != null) {
   // return null;
   // }
   if (same(this.getLast(), other.getFirst())) {
     final UPolygon oneOf = other.endDecoration == null ? endDecoration : other.endDecoration;
     final Snake result = new Snake(color, oneOf);
     result.emphasizeDirection =
         emphasizeDirection == null ? other.emphasizeDirection : emphasizeDirection;
     result.worm.addAll(this.worm.merge(other.worm, strategy));
     result.mergeable = strategy;
     return result;
   }
   if (same(this.getFirst(), other.getLast())) {
     return other.merge(this, stringBounder);
   }
   return null;
 }