RouteSplitpane.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package panels;
  2. import java.awt.BorderLayout;
  3. import java.awt.Component;
  4. import java.awt.Cursor;
  5. import java.awt.Dimension;
  6. import java.awt.GridLayout;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import java.util.ArrayList;
  10. import javax.swing.JButton;
  11. import javax.swing.JPanel;
  12. import javax.swing.JSplitPane;
  13. import customComponents.MapLabel;
  14. public class RouteSplitpane extends JPanel {
  15. RouteSplitpaneDisplay rightpanel;
  16. RouteSplitpanePlanner leftpanel;
  17. private int rows, columns;
  18. JButton pauze, hervatten, clear, upload, automatisch;
  19. JPanel menubar;
  20. int currentstep = 0;
  21. public RouteSplitpane(){
  22. //Linker paneel van de splitPane
  23. leftpanel = new RouteSplitpanePlanner();
  24. leftpanel.setMinimumSize(new Dimension(200, 100));
  25. //rechter paneel van de splitPane
  26. rightpanel = new RouteSplitpaneDisplay();
  27. rightpanel.setMinimumSize(new Dimension(200, 100));
  28. //aantal opties voor de splitpane
  29. JSplitPane split = new JSplitPane();
  30. split.setResizeWeight(0.5);
  31. split.setContinuousLayout(true);
  32. Component divider = split.getComponent(2);
  33. divider.setCursor(new Cursor(Cursor.HAND_CURSOR));
  34. //panels toevoegen aan de splitpane
  35. split.setLeftComponent(leftpanel);
  36. split.setRightComponent(rightpanel);
  37. menubar = new JPanel(new BorderLayout());
  38. menubar.setLayout(new GridLayout(1,4));
  39. menubar.add(automatisch = new JButton("Automatische route"));
  40. automatisch.addActionListener(new ActionListener() {
  41. @Override
  42. public void actionPerformed(ActionEvent arg0) {
  43. leftpanel.setAutomatisch(true);
  44. }
  45. });
  46. menubar.add(upload = new JButton("Upload"));
  47. menubar.add(clear = new JButton("Clear"));
  48. clear.addActionListener(new ActionListener() {
  49. @Override
  50. public void actionPerformed(ActionEvent arg0) {
  51. rightpanel.clear();
  52. leftpanel.clear();
  53. currentstep = 0;
  54. }
  55. });
  56. menubar.add(pauze = new JButton("Pauze"));
  57. menubar.add(hervatten = new JButton("Hervatten"));
  58. this.setLayout(new BorderLayout());
  59. this.add(split, BorderLayout.CENTER);
  60. this.add(menubar, BorderLayout.SOUTH);
  61. }
  62. public void setFieldSize(int y, int x, ArrayList<ArrayList<Integer>> cor, ArrayList<Character> steps){
  63. rightpanel.setGridsize(x, y);
  64. leftpanel.drawField(x, y, cor, steps);
  65. setRows(y);
  66. setColumns(x);
  67. }
  68. public void automatischBerekenen(){
  69. //Iconbar.setMessage("Zet eerste coordinaat", 0);
  70. }
  71. public void kruispunt(){
  72. try{
  73. int x =leftpanel.coordinaten.get(currentstep).get(1);
  74. int y = leftpanel.coordinaten.get(currentstep).get(0);
  75. int o = leftpanel.coordinaten.get(currentstep).get(2);
  76. rightpanel.setBoebot(x, y, o);
  77. currentstep++;
  78. }catch(IndexOutOfBoundsException e){
  79. currentstep = 0;
  80. }
  81. }
  82. public void gat(){
  83. int x =leftpanel.coordinaten.get(currentstep).get(0);
  84. int y = leftpanel.coordinaten.get(currentstep).get(1);
  85. int o = leftpanel.coordinaten.get(currentstep).get(2);
  86. rightpanel.setGat(x, y, o);
  87. }
  88. public int getRows() {
  89. return rows;
  90. }
  91. public void setRows(int rows) {
  92. this.rows = rows;
  93. }
  94. public int getColumns() {
  95. return columns;
  96. }
  97. public void setColumns(int columns) {
  98. this.columns = columns;
  99. }
  100. public void setCurrentstep(int step){
  101. this.currentstep = step;
  102. }
  103. }