Quellcode durchsuchen

De verbeterde GUI

jancoow vor 11 Jahren
Ursprung
Commit
5e95ccadb7

+ 18 - 0
gui/BoebotGUI.java

@@ -9,6 +9,8 @@ import gnu.io.UnsupportedCommOperationException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.ArrayList;
+
 // Com1Writer.java 1.1 12/02/22  voor BlueJ omgeving
 // @author Jan Woolderink
 // @author Johan Talboom
@@ -76,4 +78,20 @@ public class ComWriter
             outputStream.write(tekst.getBytes());
         } catch (IOException e) {}        
     }
+	//route verzenden naar de boebot
+	public void sendRoute(ArrayList<Character> route){
+		String routestring = "?";
+		for(Character step:route){
+			routestring = routestring + step;
+		}
+		routestring = routestring + "?";
+		writeString(route.toString());
+	}
+	public void sendSpeed(int snelheid){
+		String st = ""+snelheid;
+		st="f"+(int)((snelheid-1)/10);
+		writeString(st);
+	}
+	
+	
 }

+ 81 - 0
gui/customComponents/Filehandling.java

@@ -0,0 +1,81 @@
+package customComponents;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JOptionPane;
+
+public class Filehandling {
+	final static Charset ENCODING = StandardCharsets.UTF_8;
+	
+	public Filehandling(){
+		
+	}
+    //route uitlezen uit een file en de file controleren
+	public ArrayList<ArrayList<Integer>> readRouteFile(String aFileName){
+		Path path = Paths.get(aFileName);
+		try {
+			List<String> routebestand = Files.readAllLines(path, ENCODING);
+			if(routebestand.size() == 0 || !routebestand.get(0).contains("broboticsrouteplanner")){
+				JOptionPane.showConfirmDialog(null, "Route niet geldig!", "Alert: " + "Fout", JOptionPane.INFORMATION_MESSAGE);
+				System.out.println("Route bestand niet geldig!");	
+			}else{
+				String[] sizesplitarray = routebestand.get(1).split(",");
+				String[] corsplitarray = routebestand.get(2).split(";");
+				
+				ArrayList<ArrayList<Integer>> corarray = new ArrayList<ArrayList<Integer>>();
+				corarray.add(new ArrayList<Integer>());
+				corarray.get(0).add(Integer.parseInt(sizesplitarray[0]));
+				corarray.get(0).add(Integer.parseInt(sizesplitarray[1]));
+				
+				int teller = 1;
+				for(String cor:corsplitarray){
+					String[] temparray = cor.split(",");
+					corarray.add(teller, new ArrayList<Integer>());
+					corarray.get(teller).add(0, Integer.parseInt(temparray[0]));
+					corarray.get(teller).add(1, Integer.parseInt(temparray[1]));
+					teller++;
+				}
+				return corarray;
+			}
+		} catch (IOException e) {
+			JOptionPane.showMessageDialog(null, "Route niet geldig!", "Alert: " + "Fout", JOptionPane.INFORMATION_MESSAGE);
+			System.out.println("Route bestand niet geldig!");
+		}
+		return null;
+	}
+
+	//route file schrijven 
+	public void writeRouteFile(int maxx, int maxy, ArrayList<ArrayList<Integer>> route, String aFileName){
+	    Path path = Paths.get(aFileName);
+	    List<String> file = new ArrayList<String>();
+	    
+	    String routestring = "";
+	    for(ArrayList<Integer> cor:route){
+	    	routestring += cor.get(0) + "," + cor.get(1) + ";" ;
+	    }
+	    
+	    file.add("broboticsrouteplanner");
+	    file.add(maxx+","+maxy);
+	    file.add(routestring + ";");
+	    try {
+			Files.write(path, file, ENCODING);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+		
+	//nieuwe routefile aanmaken
+	public void createRouteFile(String filename, List<String> aLines, String aFileName) throws IOException {
+		File file = new File("example.txt");
+		Path path = Paths.get(aFileName);
+	    Files.write(path, aLines, ENCODING);
+	}
+}

+ 91 - 0
gui/customComponents/Kruispunt.java

@@ -0,0 +1,91 @@
+package customComponents;
+/**
+ * Write a description of class Kruispunt here.
+ * 
+ * @author (your name) 
+ * @version (a version number or a date)
+ */
+import java.awt.BasicStroke;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.Line2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+import javax.swing.JLabel;
+public class Kruispunt extends JLabel
+{       
+    BufferedImage kruispunt;
+    public Kruispunt() 
+    {
+    	kruispunt = null;
+    }
+    public void setBoebot(int rotation)
+    {
+        if(rotation == 90)
+        {
+        try{
+            kruispunt = ImageIO.read(new File("src/pictures/boebot.png"));
+        }catch (IOException e){
+            
+        }
+    }
+        if(rotation == 0)
+        {
+        try{
+            kruispunt = ImageIO.read(new File("src/pictures/boven boebot.png"));
+        }catch (IOException e){
+            
+        }
+    }
+        if(rotation == 180)
+        {
+        try{
+            kruispunt = ImageIO.read(new File("src/pictures/onder boebot.png"));
+        }catch (IOException e){
+            
+        }
+    }
+        if(rotation == 270)
+        {
+        try{
+            kruispunt = ImageIO.read(new File("src/pictures/links boebot.png"));
+        }catch (IOException e){
+            
+        }
+    }
+        this.repaint();
+    }
+    public void setGat()
+    {
+        try{
+            kruispunt = ImageIO.read(new File("src/pictures/gat.png"));
+        }catch (IOException e){
+            
+        }
+        this.repaint();
+    }
+    public void setFinish()
+    {
+        try{
+            kruispunt = ImageIO.read(new File("src/pictures/finish.png"));
+        }catch (IOException e){
+            
+        }
+        this.repaint();
+    }
+    protected void paintComponent(Graphics g){
+      super.paintComponent(g);
+      Graphics2D g2 = (Graphics2D) g;
+      g2.setStroke(new BasicStroke(3));
+      Shape horLine = new Line2D.Double(0,getHeight()/2,getWidth(),getHeight()/2);
+      Shape verLine = new Line2D.Double(getWidth()/2,0,getWidth()/2,getHeight());
+      g2.draw(horLine);
+      g2.draw(verLine);
+      
+      g2.drawImage(kruispunt, 0, 0, getWidth(), getHeight(), null);
+    }
+}

+ 6 - 17
gui/main/Main.java

@@ -9,23 +9,12 @@ import windows.MainFrame;
 public class Main {
 
 	public static void main(String[] args) {
-	    try {
-            // Set System L&F
-        UIManager.setLookAndFeel(
-            UIManager.getSystemLookAndFeelClassName());
-	    } 
-	    catch (UnsupportedLookAndFeelException e) {
-	       // handle exception
-	    }
-	    catch (ClassNotFoundException e) {
-	       // handle exception
-	    }
-	    catch (InstantiationException e) {
-	       // handle exception
-	    }
-	    catch (IllegalAccessException e) {
-	       // handle exception
-	    }
+		 try {
+			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+		} catch (ClassNotFoundException | InstantiationException
+				| IllegalAccessException | UnsupportedLookAndFeelException e) {
+			e.printStackTrace();
+		}
 	
 	    
 		new MainFrame(new MainMenu());

+ 6 - 12
gui/menubar/Menu_file.java

@@ -1,6 +1,7 @@
 package menubar;
 
 import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
@@ -20,21 +21,14 @@ public class Menu_file extends JMenu {
 		opslaanals = new JMenuItem("Opslaan als");
 		
 		afsluiten = new JMenuItem("Afsluiten");
-		afsluiten.addMouseListener(new MouseListener() {
+		afsluiten.addActionListener(new ActionListener() {
 			@Override
-			public void mouseReleased(MouseEvent e) {}
-			@Override
-			public void mousePressed(MouseEvent e) {
-				System.exit(0);				
+			public void actionPerformed(ActionEvent e) {
+				System.exit(0);	
 			}
-			@Override
-			public void mouseClicked(MouseEvent e) {}
-			@Override
-			public void mouseEntered(MouseEvent e) {}
-			@Override
-			public void mouseExited(MouseEvent e) {}
 		});
-		
+			
+	
 		setText("Bestand");
 		addSeparator();
 		

+ 3 - 0
gui/menubar/Menu_help.java

@@ -7,6 +7,9 @@ public class Menu_help extends JMenu{
 	public Menu_help(){
 		setToolTipText("Help menu");
 		setText("Help");
+		
+		
+		
 		add(new JMenuItem("Over brobotRouteplanner"));
 	}
 }

+ 14 - 16
gui/panels/AfstandbedieningPanel.java

@@ -1,4 +1,4 @@
-package panel;
+package panels;
 
 import java.awt.Color;
 import java.awt.FlowLayout;
@@ -26,7 +26,6 @@ public class AfstandbedieningPanel extends JPanel {
 	private ComWriter bluetooth;
 	
 	public AfstandbedieningPanel(ComWriter comwriter){
-		super();	
 		this.bluetooth = comwriter;
 		setLayout(new BoxLayout(this,BoxLayout.PAGE_AXIS));
 		
@@ -47,11 +46,12 @@ public class AfstandbedieningPanel extends JPanel {
 		sliderPanel.setBackground(Color.GRAY);
 		add(sliderPanel);
 		
-		slider = new JSlider(0,100,50);
+		slider = new JSlider(0,100,100);
 		slider.setPaintLabels(true);
 		slider.setPaintTicks(true);
-		slider.setMajorTickSpacing(10);
+		slider.setMajorTickSpacing(20);
 		slider.setBackground(Color.GRAY);
+		slider.setFocusable(false);
 		sliderPanel.add(slider);
 		
 		
@@ -91,23 +91,23 @@ public class AfstandbedieningPanel extends JPanel {
 				
 				if(e.getKeyCode() == KeyEvent.VK_UP){
 					//System.out.println("v");
-					bluetooth.writeString('v');
+					bluetooth.writeString("v");
 				}
 				else if(e.getKeyCode() == KeyEvent.VK_DOWN){
 					//System.out.println("a");
-					bluetooth.writeString('a');
+					bluetooth.writeString("a");
 				}
 				else if(e.getKeyCode() == KeyEvent.VK_LEFT){
 					//System.out.println("l");
-					bluetooth.writeString('l');
+					bluetooth.writeString("l");
 				}
 				else if(e.getKeyCode() == KeyEvent.VK_RIGHT){
 					//System.out.println("r");
-					bluetooth.writeString('r');
+					bluetooth.writeString("r");
 				}
 				else if(e.getKeyCode() == KeyEvent.VK_SPACE){
 					//System.out.println("s");
-					bluetooth.writeString('s');
+					bluetooth.writeString("s");
 				}
 			}
 		});
@@ -127,7 +127,7 @@ public class AfstandbedieningPanel extends JPanel {
 		ImageIcon[]plaatjes = new ImageIcon[naam.length];
 		
 		for(int n = 0; n < plaatjes.length; n++){
-			plaatjes[n] = new ImageIcon("pictures/"+naam[n]+".png");
+			plaatjes[n] = new ImageIcon("src/pictures/"+naam[n]+".png");
 		}
 		
 		return plaatjes;
@@ -142,7 +142,7 @@ public class AfstandbedieningPanel extends JPanel {
 		button.addActionListener(new ActionListener(){
 			@Override
 			public void actionPerformed(ActionEvent e) {
-				//bluetooth.writeString(""+charac);
+				bluetooth.writeString(""+charac);
 				System.out.println(charac);
 			}			
 		});
@@ -173,10 +173,8 @@ public class AfstandbedieningPanel extends JPanel {
 		
 	}
 	
-	public String verzendSnelheid(int snelheid){
-		String st = ""+snelheid;
-		current.setText(st);
-		st="f"+snelheid;
-		return st;
+	public void verzendSnelheid(int snelheid){
+		current.setText(snelheid+"");
+		bluetooth.sendSpeed(snelheid);
 	}
 }

+ 5 - 1
gui/panels/Iconbar.java

@@ -9,14 +9,18 @@ import javax.swing.JPanel;
 public class Iconbar extends JPanel {
 	public JButton irremote;
 	public JLabel currentroute;
-		
+	public JLabel currentGridSize;
+	
 	public Iconbar(){
+		currentGridSize = new JLabel();
 		currentroute = new JLabel();
 		irremote = new JButton("Afstandsbediening");
 		
 		this.setLayout(new GridLayout(0,5,10,10));
+	
 		this.add(irremote);
 		this.add(currentroute);
+		this.add(currentGridSize);
 	}
 	
 }

+ 121 - 165
gui/panels/MainMenu.java

@@ -1,26 +1,24 @@
 package panels;
 
 import java.awt.BorderLayout;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.text.NumberFormat;
+import java.util.ArrayList;
 
-import javax.activation.UnsupportedDataTypeException;
 import javax.swing.JFileChooser;
+import javax.swing.JFormattedTextField;
+import javax.swing.JLabel;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
+import javax.swing.filechooser.FileNameExtensionFilter;
+import javax.swing.text.NumberFormatter;
 
-import windows.Remote;
-import menubar.Menu_file;
 import menubar.Menubar;
+import windows.Remote;
 import customComponents.ComWriter;
+import customComponents.Filehandling;
 
 
 public class MainMenu extends JPanel{
@@ -28,191 +26,149 @@ public class MainMenu extends JPanel{
 	RouteSplitpane routeSplitpane;
 	Iconbar iconbar;
 	ComWriter bluetooth;
-	String currentRouteFile;
 	Remote remote;
-	char[] currentRoute;
-	
-	final static Charset ENCODING = StandardCharsets.UTF_8;
+	Filehandling file;
 	
+	String currentRouteFile;
+	int maxx, maxy;
+	ArrayList<ArrayList<Integer>> currentRouteCoordinates;
+	ArrayList<Character> currentRouteSteps;
 	
-    public MainMenu(){
+	public MainMenu(){
     	menubar = new Menubar();
     	routeSplitpane = new RouteSplitpane();
     	iconbar = new Iconbar();
-    	bluetooth = new ComWriter();
-
+    	file = new Filehandling();
+    	//bluetooth = new ComWriter();
     	remote = new Remote(new AfstandbedieningPanel(bluetooth));
     	remote.dispose();
+    	
+    	
     	setLayout(new BorderLayout(0,0));
     	add(menubar, BorderLayout.NORTH);
     	add(routeSplitpane);
     	add(iconbar, BorderLayout.SOUTH);
-    	currentRouteFile = "Nieuwe route";
-    	iconbar.currentroute.setText("Nieuwe route");
-    	menubarMouseListeners();
-    }
-    
+    	add(iconbar, BorderLayout.SOUTH);
+    	
+    	currentRouteCoordinates = new ArrayList<ArrayList<Integer>>();
+    	currentRouteSteps = new ArrayList<Character>();    	
+    	
+    	
+    	menubarMouseListeners();	
+    	
+    	currentRouteFile = "";
+    	iconbar.currentroute.setText("Geen bestand");  
+    	menubar.menu_file.opslaan.setEnabled(false);
+    	menubar.menu_file.opslaanals.setEnabled(false);
+    	
+    	}
+ 
+
     
     public String getCurrentRouteFile() {
 		return currentRouteFile;
 	}
-	public void setCurrentRouteFile(String route){
-		int c = JOptionPane.showConfirmDialog(null, "Weet u zeker dat u de huidige route wilt afsluiten?", "Alert: " + "Weet u het zeker?", JOptionPane.YES_NO_OPTION);	
-        if (c == JOptionPane.YES_OPTION) {
-    		currentRouteFile = route;
-    		iconbar.currentroute.setText(route);
-          }
-        }
     
-    //route uitlezen uit een file en de file controleren
-	public void readRouteFile(String aFileName){
-		Path path = Paths.get(aFileName);
-		try {
-			List<String> routebestand = Files.readAllLines(path, ENCODING);
-			if(routebestand.size() == 0 || !routebestand.get(0).contains("broboticsrouteplanner")){
-				JOptionPane.showConfirmDialog(null, "Route niet geldig!", "Alert: " + "Fout", JOptionPane.INFORMATION_MESSAGE);
-				System.out.println("Route bestand niet geldig!");	
-			}else{
-				setCurrentRouteFile(path.toString());
-				String[] route = routebestand.get(2).split("|");
-				for(String cor:route){
-					System.out.println(cor);
-				}
-				
-			}
-		} catch (IOException e) {
-			JOptionPane.showMessageDialog(null, "Route niet geldig!", "Alert: " + "Fout", JOptionPane.INFORMATION_MESSAGE);
-			System.out.println("Route bestand niet geldig!");
-		}
-	}
-	
-	 //route file schrijven 
-	public void writeRouteFile(List<String> aLines, String aFileName) throws IOException {
-	    Path path = Paths.get(aFileName);
-	    Files.write(path, aLines, ENCODING);
+    //methode om een route in te laden of om een nieuwe route aan te maken.
+	public void setCurrentRouteFile(String route, ArrayList<ArrayList<Integer>> tempcorarray ){
+		int c = JOptionPane.showConfirmDialog(null, "Weet u zeker dat u de huidige route wilt afsluiten?", "Alert: " + "Weet u het zeker?", JOptionPane.YES_NO_OPTION);  
+    	if (c == JOptionPane.YES_OPTION) {
+	        	if(tempcorarray != null){	
+	        		maxx = tempcorarray.get(0).get(0);
+	        		maxy = tempcorarray.get(0).get(1);
+		        	routeSplitpane.rightpanel.setGridsize(maxx, maxy);
+		    		iconbar.currentGridSize.setText( maxx + " x " + maxy);
+		        	tempcorarray.remove(0);
+		        	currentRouteCoordinates = tempcorarray;
+		        	currentRouteFile = route;
+		    		iconbar.currentroute.setText(currentRouteFile);
+		        	menubar.menu_file.opslaan.setEnabled(true);
+		        	menubar.menu_file.opslaanals.setEnabled(true);
+	  	  	  }else{
+	  	  		int[] tempsize = sizePopup();
+	  	  		if(tempsize != null){
+			  	 	routeSplitpane.rightpanel.setGridsize(tempsize[0], tempsize[1]);
+		    		iconbar.currentGridSize.setText(tempsize[0] + " x " + tempsize[1]);
+		        	currentRouteCoordinates.clear();
+		        	currentRouteFile = "new";
+		    		iconbar.currentroute.setText("Nieuw bestand");
+		        	menubar.menu_file.opslaan.setEnabled(false);
+		        	menubar.menu_file.opslaanals.setEnabled(true);
+	  	  		}
+		  	  }
+	       }
 	}
 	
-	//route verzenden naar de boebot
-	public void sendRoute(char[] route){
-		char[] newroute = new char[route.length + 2];
-		newroute[0] =  '?';
-		for(int i=0; i < route.length; i++){
-			newroute[i+1] = route[i];
-		}
-		newroute[newroute.length] = '?';
-		bluetooth.writeString(route.toString());
-	}
+	//popup om de grootte van het veld in te voeren.
+  public int[] sizePopup(){
+	    NumberFormatter formatter = new NumberFormatter(NumberFormat.getInstance());
+	    formatter.setValueClass(Integer.class);
+	    formatter.setMinimum(0);
+	    formatter.setMaximum(40);
+	    formatter.setCommitsOnValidEdit(true);
 		
-	//nieuwe routefile aanmaken
-	public void createRouteFile(String filename, List<String> aLines, String aFileName) throws IOException {
-		File file = new File("example.txt");
-		Path path = Paths.get(aFileName);
-	    Files.write(path, aLines, ENCODING);
-	}
-    
+		JFormattedTextField field1 = new JFormattedTextField(formatter);
+		JFormattedTextField field2 = new JFormattedTextField(formatter);
+
+		JPanel panel = new JPanel(new GridLayout(0, 1));
+        panel.add(new JLabel("Hoogte:"));
+        panel.add(field1);
+        panel.add(new JLabel("Breedte:"));
+        panel.add(field2);
+        int result = JOptionPane.showConfirmDialog(null, panel, "Veld grootte",   JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
+        if (result == JOptionPane.OK_OPTION) {
+        	if(field1.getValue() == null || field2.getValue() == null){
+        		JOptionPane.showMessageDialog(null, "Ongeldige grootte");
+        		return null;
+        	}else{
+        		return new int[]{(int) field1.getValue(),(int) field2.getValue()} ; 
+        	}
+        } else {
+        	return null;
+        }
+  }
+	
     public void menubarMouseListeners(){
     	//maakt de mouse listners voor de menubar
-		menubar.menu_file.openen.addMouseListener(new MouseListener() {
+		menubar.menu_file.openen.addActionListener(new ActionListener() {			
 			@Override
-			public void mouseReleased(MouseEvent e) {}
-			@Override
-			public void mousePressed(MouseEvent e) {
-		      JFileChooser c = new JFileChooser();
-		      // Demonstrate "Open" dialog:
-		      int rVal = c.showOpenDialog(MainMenu.this);
-		      if (rVal == JFileChooser.APPROVE_OPTION) {
-		        readRouteFile(c.getSelectedFile().getAbsolutePath());
-		      }
-		      if (rVal == JFileChooser.CANCEL_OPTION) {
-		        //filename.setText("You pressed cancel");
-		        //dir.setText("");
-		      }
+			public void actionPerformed(ActionEvent e) {
+			      JFileChooser c = new JFileChooser();
+			      c.setFileFilter(new FileNameExtensionFilter("Route bestanden", "rt"));
+			      int rVal = c.showOpenDialog(MainMenu.this);
+			      if (rVal == JFileChooser.APPROVE_OPTION) {
+			    	  setCurrentRouteFile(c.getSelectedFile().getAbsolutePath(), file.readRouteFile(c.getSelectedFile().getAbsolutePath()));
+			      }			
 			}
-			@Override
-			public void mouseExited(MouseEvent e) {}
-			@Override
-			public void mouseEntered(MouseEvent e) {}
-			@Override
-			public void mouseClicked(MouseEvent e) {}
 		});
-		menubar.menu_file.opslaan.addMouseListener(new MouseListener() {
-			@Override
-			public void mouseReleased(MouseEvent e) {
-				// TODO Auto-generated method stub
-				
-			}
-			
-			@Override
-			public void mousePressed(MouseEvent e) {
-				if(currentRouteFile == "Nieuwe Route"){
-					
-				}
-			}
-			
-			@Override
-			public void mouseExited(MouseEvent e) {
-				// TODO Auto-generated method stub
-				
-			}
-			
-			@Override
-			public void mouseEntered(MouseEvent e) {
-				// TODO Auto-generated method stub
-				
-			}
-			
+		menubar.menu_file.opslaan.addActionListener(new ActionListener() {
 			@Override
-			public void mouseClicked(MouseEvent e) {
-				// TODO Auto-generated method stub
-				
+			public void actionPerformed(ActionEvent arg0) {
+				file.writeRouteFile(maxx, maxy, currentRouteCoordinates, currentRouteFile);				
 			}
 		});
-		menubar.menu_file.nieuw.addMouseListener(new MouseListener() {	
-			@Override
-			public void mouseReleased(MouseEvent e) {
-				
-			}	
-			@Override
-			public void mousePressed(MouseEvent e) {
-				setCurrentRouteFile("Nieuwe route");
-			}
+		menubar.menu_file.opslaanals.addActionListener(new ActionListener() {
 			@Override
-			public void mouseExited(MouseEvent e) {
-				
-			}
-			@Override
-			public void mouseEntered(MouseEvent e) {
-				
-			}
-			@Override
-			public void mouseClicked(MouseEvent e) {
-				
+			public void actionPerformed(ActionEvent arg0) {
+				 JFileChooser c = new JFileChooser();
+			      c.setFileFilter(new FileNameExtensionFilter("Route bestanden", "rt"));
+			      int rVal = c.showOpenDialog(MainMenu.this);
+			      if (rVal == JFileChooser.APPROVE_OPTION) {
+			    	  file.writeRouteFile(maxx, maxy, currentRouteCoordinates, c.getSelectedFile().getAbsolutePath());
+			      }		
 			}
 		});
-		iconbar.irremote.addMouseListener(new MouseListener() {
-			@Override
-			public void mouseReleased(MouseEvent e) {
-				// TODO Auto-generated method stub
-				
-			}
+		menubar.menu_file.nieuw.addActionListener(new ActionListener() {
 			@Override
-			public void mousePressed(MouseEvent e) {
-		    	createRemote();
-			}
-			@Override
-			public void mouseExited(MouseEvent e) {
-				// TODO Auto-generated method stub
-				
-			}
-			@Override
-			public void mouseEntered(MouseEvent e) {
-				// TODO Auto-generated method stub
-				
+			public void actionPerformed(ActionEvent e) {
+				setCurrentRouteFile("Nieuwe route", null);
 			}
+		});
+		
+		iconbar.irremote.addActionListener(new ActionListener() {
 			@Override
-			public void mouseClicked(MouseEvent e) {
-				// TODO Auto-generated method stub
-				
+			public void actionPerformed(ActionEvent e) {
+				createRemote();
 			}
 		});
     }
@@ -221,7 +177,7 @@ public class MainMenu extends JPanel{
     	if(remote.isShowing()){
     		remote.dispose();
     	}else{
-    		remote.show();
+    		remote.show(true);
     	}
     }
 }

+ 5 - 5
gui/panels/RouteSplitpane.java

@@ -3,24 +3,24 @@ package panels;
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Cursor;
+import java.awt.Dimension;
 
 import javax.swing.JPanel;
 import javax.swing.JSplitPane;
 
 public class RouteSplitpane extends JSplitPane {
 	JPanel leftpanel;
-	JPanel rightpanel;
+	RouteSplitpaneCurrentLocation rightpanel;
 	
 	public RouteSplitpane(){
 		//Linker paneel van de splitPane
 		leftpanel = new JPanel();
 		leftpanel.setBackground(Color.red);
+		leftpanel.setMinimumSize(new Dimension(200, 100));
 		
 		//rechter paneel van de splitPane
-		rightpanel = new JPanel();
-		rightpanel.setBackground(Color.yellow);
-		
-		
+		rightpanel = new RouteSplitpaneCurrentLocation();
+		rightpanel.setMinimumSize(new Dimension(200, 100));
 		//aantal opties voor de splitpane
 		this.setResizeWeight(0.5);
 		this.setContinuousLayout(true);

+ 118 - 0
gui/panels/RouteSplitpaneCurrentLocation.java

@@ -0,0 +1,118 @@
+package panels;
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.util.ArrayList;
+
+import javax.swing.JButton;
+import javax.swing.JPanel;
+
+import customComponents.Kruispunt;
+/**
+ * Write a description of class BoebotSimGUI here.
+ * 
+ * @author (your name) 
+ * @version (a version number or a date)
+ */
+public class RouteSplitpaneCurrentLocation extends JPanel
+{
+   private ArrayList<ArrayList<Kruispunt>> map;
+   private int teller = -1;
+   private int ox;
+   private int oy;
+   private int orotation;
+   private int y;
+   private int x;
+   private int xx;
+   private int xy;
+   private int ex;
+   private int ey;
+   private JPanel content;
+   JButton pauze, hervatten;
+   JPanel menubar;
+   
+   public RouteSplitpaneCurrentLocation()
+   {
+       content = new JPanel(new GridLayout(1,1));
+       menubar = new JPanel();
+       map = new ArrayList<ArrayList<Kruispunt>>();
+       //boeboet
+       this.ox = 2;
+       this.oy = 2;
+       this.orotation = 90;
+       //object
+       this.xx = 1;
+       this.xy = 1;
+       //finish
+       this.ex = 4;
+       this.ey = 4;
+
+	   	menubar.setLayout(new GridLayout(1,4));
+		menubar.add(pauze = new JButton("Pauze"));
+		menubar.add(hervatten = new JButton("Hervatten"));
+		
+       this.setLayout(new BorderLayout());
+       this.add(content, BorderLayout.CENTER);
+       this.add(menubar, BorderLayout.SOUTH);
+   }
+   public void vorigeStapBoebot()
+   {
+       if(teller > 0)
+       {
+           teller --;
+           //ox = boebotSimulator.ax.get(teller);
+           //oy = boebotSimulator.ay.get(teller);
+           //orotation = boebotSimulator.arotation.get(teller);
+           refresh();
+       }
+   }
+   public void volgendeStapBoebot()
+   {
+       if(teller < 0)
+       {
+           teller ++;
+           //ox = boebotSimulator.ax.get(teller);
+           //oy = boebotSimulator.ay.get(teller);
+           //orotation = boebotSimulator.arotation.get(teller);
+           refresh();
+       }
+   }
+   public void refresh()
+   {
+       content.removeAll();
+       content.setLayout(new GridLayout(y, x));
+       map.clear();
+       for(int row = 0; row < y; row ++)
+       {
+           map.add(row, new ArrayList<Kruispunt>());
+           for(int col = 0; col < x; col ++)
+           {
+               map.get(row).add(new Kruispunt());
+               Kruispunt kruispunt = map.get(row).get(col);
+               if(row == (y - ey) && col == ex)
+               {
+                   kruispunt.setFinish();
+               }
+               if(row == (y - oy) && col == ox)
+               {
+                   kruispunt.setBoebot(orotation);
+               }
+               if(row == (y - xy) && col == xx)
+               {
+                   kruispunt.setGat();
+               }
+               content.add(kruispunt);
+           }
+       }
+   }
+   public void setGridsize(int x, int y){
+	   this.x = x;
+	   this.y = y;
+	   refresh();
+   }
+   public void setBoebot(int x,  int y, int o){
+	   ox = x;
+	   oy = y;
+	   orotation = o;
+	   refresh();
+   }
+}

BIN
gui/pictures/boebot.png


BIN
gui/pictures/boven boebot.png


BIN
gui/pictures/finish.png


BIN
gui/pictures/gat.png


BIN
gui/pictures/kruispunt.png


BIN
gui/pictures/links boebot.png


BIN
gui/pictures/onder boebot.png


+ 42 - 0
gui/popups/FieldSizePopup.java

@@ -0,0 +1,42 @@
+package popups;
+
+import java.awt.GridLayout;
+import java.text.NumberFormat;
+
+import javax.print.attribute.standard.JobMessageFromOperator;
+import javax.swing.JFormattedTextField;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.text.NumberFormatter;
+
+public class FieldSizePopup extends JPopupMenu {
+	int[] fieldsize;
+	public FieldSizePopup(){
+	    NumberFormatter formatter = new NumberFormatter(NumberFormat.getInstance());
+	    formatter.setValueClass(Integer.class);
+	    formatter.setMinimum(0);
+	    formatter.setMaximum(40);
+	    formatter.setCommitsOnValidEdit(true);
+		
+		JFormattedTextField field1 = new JFormattedTextField(formatter);
+		JFormattedTextField field2 = new JFormattedTextField(formatter);
+
+		JPanel panel = new JPanel(new GridLayout(0, 1));
+        panel.add(new JLabel("Hoogte:"));
+        panel.add(field1);
+        panel.add(new JLabel("Breedte:"));
+        panel.add(field2);
+        int result = JOptionPane.showConfirmDialog(null, panel, "Veld grootte",
+            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
+        if (result == JOptionPane.OK_OPTION) {
+        	if(field1.getValue() == null || field2.getValue() == null){
+        		JOptionPane.showMessageDialog(null, "Ongeldige grootte");
+        	}else{
+
+        	}
+        } else {
+        }
+	}
+}

+ 3 - 2
gui/windows/Remote.java

@@ -22,8 +22,9 @@ public class Remote extends JFrame {
 	
 	private void setup(){
 		setTitle("Afstandsbediening");
-        setMinimumSize(new Dimension(257,345));
-        this.setBounds(0, 0, 550, 400);
+        setMinimumSize(new Dimension(257,400));
+        this.setPreferredSize(new Dimension(257,400));
+        setLocationRelativeTo(null);
         setDefaultCloseOperation(DISPOSE_ON_CLOSE);
 		setVisible(true);
 	}