RouteSplitpaneCurrentLocation.java 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package panels;
  2. import java.awt.BorderLayout;
  3. import java.awt.GridLayout;
  4. import java.util.ArrayList;
  5. import javax.swing.JButton;
  6. import javax.swing.JPanel;
  7. import customComponents.Kruispunt;
  8. /**
  9. * Write a description of class BoebotSimGUI here.
  10. *
  11. * @author (your name)
  12. * @version (a version number or a date)
  13. */
  14. public class RouteSplitpaneCurrentLocation extends JPanel
  15. {
  16. private ArrayList<ArrayList<Kruispunt>> map;
  17. private int teller = -1;
  18. private int ox;
  19. private int oy;
  20. private int orotation;
  21. private int y;
  22. private int x;
  23. private int xx;
  24. private int xy;
  25. private int ex;
  26. private int ey;
  27. private JPanel content;
  28. JButton pauze, hervatten;
  29. JPanel menubar;
  30. public RouteSplitpaneCurrentLocation()
  31. {
  32. content = new JPanel(new GridLayout(1,1));
  33. menubar = new JPanel();
  34. map = new ArrayList<ArrayList<Kruispunt>>();
  35. //boeboet
  36. this.ox = 2;
  37. this.oy = 2;
  38. this.orotation = 90;
  39. //object
  40. this.xx = 1;
  41. this.xy = 1;
  42. //finish
  43. this.ex = 4;
  44. this.ey = 4;
  45. menubar.setLayout(new GridLayout(1,4));
  46. menubar.add(pauze = new JButton("Pauze"));
  47. menubar.add(hervatten = new JButton("Hervatten"));
  48. this.setLayout(new BorderLayout());
  49. this.add(content, BorderLayout.CENTER);
  50. this.add(menubar, BorderLayout.SOUTH);
  51. }
  52. public void vorigeStapBoebot()
  53. {
  54. if(teller > 0)
  55. {
  56. teller --;
  57. //ox = boebotSimulator.ax.get(teller);
  58. //oy = boebotSimulator.ay.get(teller);
  59. //orotation = boebotSimulator.arotation.get(teller);
  60. refresh();
  61. }
  62. }
  63. public void volgendeStapBoebot()
  64. {
  65. if(teller < 0)
  66. {
  67. teller ++;
  68. //ox = boebotSimulator.ax.get(teller);
  69. //oy = boebotSimulator.ay.get(teller);
  70. //orotation = boebotSimulator.arotation.get(teller);
  71. refresh();
  72. }
  73. }
  74. public void refresh()
  75. {
  76. content.removeAll();
  77. content.setLayout(new GridLayout(y, x));
  78. map.clear();
  79. for(int row = 0; row < y; row ++)
  80. {
  81. map.add(row, new ArrayList<Kruispunt>());
  82. for(int col = 0; col < x; col ++)
  83. {
  84. map.get(row).add(new Kruispunt());
  85. Kruispunt kruispunt = map.get(row).get(col);
  86. if(row == (y - ey) && col == ex)
  87. {
  88. kruispunt.setFinish();
  89. }
  90. if(row == (y - oy) && col == ox)
  91. {
  92. kruispunt.setBoebot(orotation);
  93. }
  94. if(row == (y - xy) && col == xx)
  95. {
  96. kruispunt.setGat();
  97. }
  98. content.add(kruispunt);
  99. }
  100. }
  101. }
  102. public void setGridsize(int x, int y){
  103. this.x = x;
  104. this.y = y;
  105. refresh();
  106. }
  107. public void setBoebot(int x, int y, int o){
  108. ox = x;
  109. oy = y;
  110. orotation = o;
  111. refresh();
  112. }
  113. }