Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. this.x = x;
  2. this.y = y;
  3. this.x1 = x1;
  4. this.y1 = y1;
  5.  
  6. line.setStartX(x);
  7. line.setStartY(y);
  8. line.setEndX(x1);
  9. line.setEndY(y1);
  10. line.getStrokeDashArray().addAll(4d, 8d);
  11.  
  12.  
  13. double sx = line.getStartX();
  14. double sy = line.getStartY();
  15. double ex = line.getEndX();
  16. double ey = line.getEndY();
  17.  
  18. arrow1.setEndX(ex);
  19. arrow1.setEndY(ey);
  20. arrow2.setEndX(ex);
  21. arrow2.setEndY(ey);
  22.  
  23. double factor = arrowLength / Math.hypot(sx-ex, sy-ey);
  24. double factorO = arrowWidth / Math.hypot(sx-ex, sy-ey);
  25.  
  26. // part in direction of main line
  27. double dx = (sx - ex) * factor;
  28. double dy = (sy - ey) * factor;
  29.  
  30. // part ortogonal to main line
  31. double ox = (sx - ex) * factorO;
  32. double oy = (sy - ey) * factorO;
  33.  
  34.  
  35.  
  36.  
  37.  
  38. arrow1.setStartX(ex + dx - oy);
  39. arrow1.setStartY(ey + dy + ox);
  40. arrow2.setStartX(ex + dx + oy);
  41. arrow2.setStartY(ey + dy - ox);
  42.  
  43. setColor();
  44.  
  45.  
  46.  
  47. this.getChildren().addAll(arrow1,arrow2, line);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement