AccessPoint.java 1.6 KB

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