Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. private BoundingBox getBoundsDebug() {
  2. Bounds localBounds = this.getBoundsInLocal();
  3. double minX = localBounds.getMinX() + 200;
  4. double maxX = localBounds.getMaxX() - 200;
  5. double minY = localBounds.getMinY() + 200;
  6. double maxY = localBounds.getMaxY() - 200;
  7.  
  8. //Flip the boundingbox' y-coords, as the rendering is flipped, but the model isn't.
  9. Point2D minPoint = getModelCoords(minX, maxY);
  10. Point2D maxPoint = getModelCoords(maxX, minY);
  11.  
  12. gc.setStroke(Color.RED);
  13. gc.beginPath();
  14. gc.lineTo(minPoint.getX(), minPoint.getY());
  15. gc.lineTo(minPoint.getX(), maxPoint.getY());
  16. gc.lineTo(maxPoint.getX(), maxPoint.getY());
  17. gc.lineTo(maxPoint.getX(), minPoint.getY());
  18. gc.lineTo(minPoint.getX(), minPoint.getY());
  19. gc.stroke();
  20.  
  21. return new BoundingBox(minPoint.getX(), minPoint.getY(),
  22. maxPoint.getX()-minPoint.getX(), maxPoint.getY()-minPoint.getY());
  23. }
  24.  
  25.  
  26. public double getCenterX(){
  27. Bounds localBounds = this.getBoundsInLocal();
  28. double minX = localBounds.getMinX() + 200;
  29. double maxX = localBounds.getMaxX() - 200;
  30. double minY = localBounds.getMinY() + 200;
  31. double maxY = localBounds.getMaxY() - 200;
  32.  
  33. //Flip the boundingbox' y-coords, as the rendering is flipped, but the model isn't.
  34. Point2D minPoint = getModelCoords(minX, maxY);
  35. Point2D maxPoint = getModelCoords(maxX, minY);
  36. return (minPoint.getX() + (maxPoint.getX()-minPoint.getX())/2)/model.getLonfactor();
  37. }
  38.  
  39. public double getCenterY(){
  40. Bounds localBounds = this.getBoundsInLocal();
  41. double minX = localBounds.getMinX() + 200;
  42. double maxX = localBounds.getMaxX() - 200;
  43. double minY = localBounds.getMinY() + 200;
  44. double maxY = localBounds.getMaxY() - 200;
  45.  
  46. //Flip the boundingbox' y-coords, as the rendering is flipped, but the model isn't.
  47. Point2D minPoint = getModelCoords(minX, maxY);
  48. Point2D maxPoint = getModelCoords(maxX, minY);
  49. return (minPoint.getY() + (maxPoint.getY()-minPoint.getY())/2);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement