ExitPoint.java 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package gui.simulator;
  2. public class ExitPoint extends Draw{
  3. private static String imageLocation = "/simulator/uitgang.png";
  4. private static String facilityName = "Uitgang";
  5. private Terrain terrain;
  6. public ExitPoint(Terrain terrain, int x, int y, double scale, double distance) {
  7. super(imageLocation, x, y, scale, distance);
  8. this.terrain = terrain;
  9. }
  10. public String getFacilityName(){
  11. return facilityName;
  12. }
  13. @Override
  14. public void setX(double x){
  15. double oldPosX = this.getX();
  16. double oldPosY = this.getY();
  17. if(x<0){
  18. this.setRotation(90);
  19. this.x = 0;
  20. } else if(x>9*terrain.getWidth()/10){
  21. this.x = 9*terrain.getWidth()/10;
  22. this.setRotation(90);
  23. } else if(x>0 && x<9*terrain.getWidth()/10 && this.y > 50 && this.y < terrain.getFestivalLength()-150){
  24. this.x = oldPosX;
  25. this.y = oldPosY;
  26. } else {
  27. this.x = x;
  28. }
  29. }
  30. @Override
  31. public void setY(double y){
  32. double oldPosY = this.getY();
  33. if(y<50){
  34. this.setRotation(0);
  35. this.y = 50;
  36. } else if(y>11*terrain.getFestivalLength()/12){
  37. this.setRotation(0);
  38. this.y = 11*terrain.getFestivalLength()/12;
  39. } else if(x>terrain.getWidth()/10 && x<9*terrain.getWidth()/10 && this.y > 50 && this.y < terrain.getFestivalLength()-150){
  40. this.y = oldPosY;
  41. } else {
  42. this.y = y;
  43. }
  44. }
  45. }