RouteSplitpaneDisplay.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 RouteSplitpaneDisplay 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 xrotation;
  26. private int ex;
  27. private int ey;
  28. private JPanel content;
  29. JButton pauze, hervatten;
  30. JPanel menubar;
  31. public RouteSplitpaneDisplay()
  32. {
  33. content = new JPanel(new GridLayout(1,1));
  34. menubar = new JPanel();
  35. map = new ArrayList<ArrayList<Kruispunt>>();
  36. menubar.setLayout(new GridLayout(1,4));
  37. menubar.add(pauze = new JButton("Pauze"));
  38. menubar.add(hervatten = new JButton("Hervatten"));
  39. this.setLayout(new BorderLayout());
  40. this.add(content, BorderLayout.CENTER);
  41. this.add(menubar, BorderLayout.SOUTH);
  42. }
  43. public void vorigeStapBoebot()
  44. {
  45. if(teller > 0)
  46. {
  47. teller --;
  48. //ox = boebotSimulator.ax.get(teller);
  49. //oy = boebotSimulator.ay.get(teller);
  50. //orotation = boebotSimulator.arotation.get(teller);
  51. refresh();
  52. }
  53. }
  54. public void volgendeStapBoebot()
  55. {
  56. if(teller < 0)
  57. {
  58. teller ++;
  59. //ox = boebotSimulator.ax.get(teller);
  60. //oy = boebotSimulator.ay.get(teller);
  61. //orotation = boebotSimulator.arotation.get(teller);
  62. refresh();
  63. }
  64. }
  65. public void refresh()
  66. {
  67. content.removeAll();
  68. content.setLayout(new GridLayout(y, x));
  69. map.clear();
  70. for(int row = 0; row < y; row ++)
  71. {
  72. map.add(row, new ArrayList<Kruispunt>());
  73. for(int col = 0; col < x; col ++)
  74. {
  75. map.get(row).add(new Kruispunt());
  76. Kruispunt kruispunt = map.get(row).get(col);
  77. if(row == (y - ey -1) && col == ex)
  78. {
  79. kruispunt.setFinish();
  80. }
  81. if(row == (y - oy - 1) && col == ox)
  82. {
  83. kruispunt.setBoebot(orotation);
  84. }
  85. if(row == (y - xy -1) && col == xx)
  86. {
  87. kruispunt.setGat(xrotation);
  88. }
  89. content.add(kruispunt);
  90. }
  91. }
  92. }
  93. public void setGridsize(int x, int y){
  94. this.x = x;
  95. this.y = y;
  96. refresh();
  97. }
  98. public void setBoebot(int x, int y, int o){
  99. ox = x;
  100. oy = y;
  101. orotation = o;
  102. refresh();
  103. }
  104. public void setGat(int x, int y, int o){
  105. xx = x;
  106. xy = y;
  107. xrotation = o;
  108. refresh();
  109. }
  110. public void setFinish(int x, int y){
  111. ex= x;
  112. ey = y;
  113. refresh();
  114. }
  115. }