private Snake getSimpleSnake() {
   final Snake snake = new Snake(color, Arrows.asToDown());
   snake.setLabel(textBlock);
   snake.addPoint(p1);
   snake.addPoint(p2);
   return snake;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
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;
 }
  public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
    final Snake snake = new Snake(color, true);
    final Point2D mp1a = translate1.getTranslated(p1);
    final Point2D mp2b = translate2.getTranslated(p2);
    final double middle = (mp1a.getY() + mp2b.getY()) / 2.0;
    snake.addPoint(mp1a);
    snake.addPoint(mp1a.getX(), middle);
    snake.addPoint(mp2b.getX(), middle);
    // snake.addPoint(mp2b);
    ug.draw(snake);

    final Snake small = new Snake(color, Arrows.asToDown());
    small.addPoint(mp2b.getX(), middle);
    small.addPoint(mp2b);
    ug.draw(small);
  }