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; }
public Snake move(double dx, double dy) { final Snake result = new Snake(color, endDecoration); for (Point2D pt : worm) { result.addPoint(pt.getX() + dx, pt.getY() + dy); } result.textBlock = this.textBlock; result.mergeable = this.mergeable; result.emphasizeDirection = this.emphasizeDirection; return result; }
public Snake transformX(CompressionTransform compressionTransform) { final Snake result = new Snake(color, endDecoration); result.textBlock = this.textBlock; result.mergeable = this.mergeable; result.emphasizeDirection = this.emphasizeDirection; for (Point2D.Double pt : worm) { final double x = compressionTransform.transform(pt.x); final double y = pt.y; result.addPoint(x, y); } return result; }