Browse Source

Added Images class/ Added "New" function/ added SimIo(not working perfect)

Jeroen 10 years ago
parent
commit
a978f45576

+ 1 - 1
.classpath

@@ -2,7 +2,7 @@
 <classpath>
 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="src" path="res"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
 	<classpathentry kind="lib" path="mysql-connector-java-5.1.32-bin.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

+ 90 - 83
src/gui/frames/MainFrame.java

@@ -19,101 +19,102 @@ import agenda.Agenda;
 
 @SuppressWarnings("serial")
 public class MainFrame extends JFrame{
-	
-    public enum Views{EDITOR, SIMULATOR, AGENDA, TABLE};
-    
-    private Agenda agenda;
-    private JPanel currentPanel, simulatorpanel;
-    
-    private int length;
-    private int terainwidth;
-    private SimulatorPane.Terrains terrain;
-    
-    public MainFrame(){
-        this.agenda = new Agenda();
-        this.currentPanel = new EditPane(this.agenda);
-        this.add(currentPanel);
+
+	public enum Views{EDITOR, SIMULATOR, AGENDA, TABLE};
+
+	private Agenda agenda;
+	private JPanel currentPanel, simulatorpanel;
+
+	private int length;
+	private int terainwidth;
+	private SimulatorPane.Terrains terrain;
+
+
+	public MainFrame(){
+		this.agenda = new Agenda();
+		this.currentPanel = new EditPane(this.agenda);
+		this.add(currentPanel);
 		this.setResizable(true);
 		this.setBounds(100,100,1440,900);
 		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 		this.setUndecorated(false);
 		this.setJMenuBar(new MenuBar(this));
 		this.setVisible(true);
-		
+
 		this.length = 100000;
 		this.terainwidth = 10000;
 		this.terrain = SimulatorPane.Terrains.UNDEFINED;
-		
+
 		this.getContentPane().setBackground( Color.WHITE );
 
-        if(System.getProperties().getProperty("os.name").equals("Mac OS X")) {
-            try {
-                Class c = Class.forName("com.apple.eawt.FullScreenUtilities");
-                Method m = c.getMethod("setWindowCanFullScreen", Window.class, Boolean.TYPE);
-                m.invoke(c, this, true);
-            } catch (ClassNotFoundException e) {
-                e.printStackTrace();
-            } catch (NoSuchMethodException e) {
-                e.printStackTrace();
-            } catch (InvocationTargetException e) {
-                e.printStackTrace();
-            } catch (IllegalAccessException e) {
-                e.printStackTrace();
-            }
-        }
+		if(System.getProperties().getProperty("os.name").equals("Mac OS X")) {
+			try {
+				Class c = Class.forName("com.apple.eawt.FullScreenUtilities");
+				Method m = c.getMethod("setWindowCanFullScreen", Window.class, Boolean.TYPE);
+				m.invoke(c, this, true);
+			} catch (ClassNotFoundException e) {
+				e.printStackTrace();
+			} catch (NoSuchMethodException e) {
+				e.printStackTrace();
+			} catch (InvocationTargetException e) {
+				e.printStackTrace();
+			} catch (IllegalAccessException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	public void changeView(Views view){
+		switch(view){
+		case EDITOR:
+			this.updateView(new EditPane(this.agenda));
+			break;
+		case AGENDA:
+			this.updateView(new AgendaPane(this.agenda));
+			break;
+		case SIMULATOR:
+			if(simulatorpanel == null){
+				simulatorpanel = new SimulatorPane(this.agenda, this.length, this.terainwidth, this.terrain);
+				this.updateView(simulatorpanel);
+			}else{
+				this.updateView(simulatorpanel);
+			}
+			break;
+		case TABLE:
+			this.updateView(new Table(this.agenda));
+			break;
+		}
+	}
+
+	public void setTerrain(SimulatorPane.Terrains terrain){
+		this.terrain = terrain;
+	}
+
+	public void setLength(int length){
+		this.length = length;
+	}
+
+	public void setTerainWidth(int width){
+		this.terainwidth = width;
+	}
+
+	public int getTerainWidth(){
+		return terainwidth;
+	}
+
+	public int getLength(){
+		return length;
+	}
+
+	public SimulatorPane.Terrains getTerrain(){
+		return terrain;
+	}
+
+	private void updateView(JPanel panel){
+		this.currentPanel = panel;
+		this.setContentPane(this.currentPanel);
+		this.revalidate();
 	}
-    
-    public void changeView(Views view){
-        switch(view){
-            case EDITOR:
-                this.updateView(new EditPane(this.agenda));
-                break;
-            case AGENDA:
-                this.updateView(new AgendaPane(this.agenda));
-                break;
-            case SIMULATOR:
-            	if(simulatorpanel == null){
-            		simulatorpanel = new SimulatorPane(this.agenda, this.length, this.terainwidth, this.terrain);
-            		this.updateView(simulatorpanel);
-            	}else{
-            		this.updateView(simulatorpanel);
-            	}
-                break;
-            case TABLE:
-                this.updateView(new Table(this.agenda));
-                break;
-        }
-    }
-    
-    public void setTerrain(SimulatorPane.Terrains terrain){
-    	this.terrain = terrain;
-    }
-
-    public void setLength(int length){
-    	this.length = length;
-    }
-    
-    public void setTerainWidth(int width){
-    	this.terainwidth = width;
-    }
-    
-    public int getTerainWidth(){
-    	return terainwidth;
-    }
-    
-    public int getLength(){
-    	return length;
-    }
-    
-    public SimulatorPane.Terrains getTerrain(){
-    	return terrain;
-    }
-    
-    private void updateView(JPanel panel){
-        this.currentPanel = panel;
-        this.setContentPane(this.currentPanel);
-        this.revalidate();
-    }
 
 	public Agenda getAgenda() {
 		return agenda;
@@ -123,5 +124,11 @@ public class MainFrame extends JFrame{
 		this.agenda = agenda;
 		updateView(currentPanel);
 	}
+	public JPanel getSimulatorpanel() {
+		return simulatorpanel;
+	}
 
+	public void setSimulatorpanel(JPanel simulatorpanel) {
+		this.simulatorpanel = simulatorpanel;
+	}
 }

+ 32 - 0
src/gui/menubar/MenuBar.java

@@ -1,6 +1,7 @@
 package gui.menubar;
 
 import gui.frames.MainFrame;
+import gui.simulator.SimIo;
 import gui.simulator.SimulatorDialogPane;
 import gui.simulator.SimulatorPane;
 
@@ -50,6 +51,8 @@ public class MenuBar extends JMenuBar{
 		JMenuItem saveAction = new JMenuItem("Save");
 		JMenuItem helpAction = new JMenuItem("Help");
 		JMenuItem uploadAction = new JMenuItem("Upload agenda to DB");
+		JMenuItem openSim = new JMenuItem("Open simulator");
+		JMenuItem saveSim = new JMenuItem("Save simulator");
 		//view 
 		JMenuItem editorView = new JMenuItem("Editor");
 		JMenuItem agendaView = new JMenuItem("Agenda");
@@ -69,6 +72,7 @@ public class MenuBar extends JMenuBar{
 		newAction.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent arg0) {
 				System.out.println("You have clicked on the new action");
+				new MainFrame();
 			}
 		});
 		fileMenu.add(openAction);
@@ -109,6 +113,34 @@ public class MenuBar extends JMenuBar{
 			}
 		});
 		fileMenu.addSeparator();
+		fileMenu.add(openSim);
+		openSim.addActionListener(new ActionListener() {
+
+			public void actionPerformed(ActionEvent e) {
+				try {
+					SimulatorPane pane = SimIo.readIo();
+					if(pane != null){
+						mainFrame.setSimulatorpanel(pane);
+						System.out.println("read simulator");
+					}
+				} catch (IOException ee) {
+					ee.printStackTrace();
+				}
+			} 
+		});
+		fileMenu.add(saveSim);
+		saveSim.addActionListener(new ActionListener() {
+
+			@Override
+			public void actionPerformed(ActionEvent arg0) {
+				try {
+					SimIo.writeIo(mainFrame.getSimulatorpanel());
+				} catch (IOException e1) {
+					e1.printStackTrace();
+				}
+			}
+		});
+		fileMenu.addSeparator();
 		fileMenu.add(exitAction);
 		exitAction.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent arg0) {

+ 7 - 5
src/gui/simulator/AccessPoint.java

@@ -1,18 +1,20 @@
 package gui.simulator;
 
-public class AccessPoint extends DrawEngine {
+import java.io.Serializable;
+
+public class AccessPoint extends DrawEngine implements Serializable {
 	
-	private static String imageLocation = "/simulator/ingang.png";
+	private static Images.ImageType images = Images.ImageType.Entrance;
 	private static String facilityName = "Ingang";
-	private Terrain terrain;
+		private Terrain terrain;
 
     public AccessPoint(Terrain terrain, int x, int y) {
-        super(imageLocation, x, y, 1, 0, SimulatorPane.Objects.ENTRANCE);
+        super(images, x, y, 1, 0, SimulatorPane.Objects.ENTRANCE);
         this.terrain = terrain;
     }
 
     public AccessPoint(Terrain terrain, int x, int y, double scale, double distance) {
-        super(imageLocation, x, y, scale, distance, SimulatorPane.Objects.ENTRANCE);
+        super(images, x, y, scale, distance, SimulatorPane.Objects.ENTRANCE);
         this.terrain = terrain;
     }
     

+ 4 - 3
src/gui/simulator/Border.java

@@ -4,18 +4,19 @@ import java.awt.Graphics2D;
 import java.awt.Shape;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
+import java.io.Serializable;
 
 
 
-public class Border extends DrawEngine {
+public class Border extends DrawEngine implements Serializable {
 
-	private static String imageLocation = "/simulator/border.png";
+	private static Images.ImageType images = Images.ImageType.Border;
 	private static String facilityName = "Border";
 	private int width;
 	private int height;
 
     public  Border(int x, int y, int width, int heigth) {
-        super(imageLocation, x, y, 1, 0, SimulatorPane.Objects.BORDER);
+        super(images, x, y, 1, 0, SimulatorPane.Objects.BORDER);
     }
     
     public String getFacilityName(){

+ 18 - 15
src/gui/simulator/DrawEngine.java

@@ -1,5 +1,7 @@
 package gui.simulator;
 
+import gui.simulator.Images.ImageType;
+
 import javax.imageio.ImageIO;
 
 import java.awt.*;
@@ -14,17 +16,18 @@ import java.io.IOException;
  */
 public abstract class DrawEngine {
 
-    private Image image;
+    private ImageType image_;
     private double x, y, rotation, scale;
     private double distanceToOtherObjects;
     public SimulatorPane.Objects type;
 
-    public DrawEngine(String image, int x, int y, double scale, double distanceToOtherObjects, SimulatorPane.Objects objecttype){
-        try{
-            this.image = ImageIO.read(getClass().getResource(image));
-        }catch(IOException ex){
-            ex.printStackTrace();
-        }
+    public DrawEngine(ImageType images, int x, int y, double scale, double distanceToOtherObjects, SimulatorPane.Objects objecttype){
+//        try{
+//            this.image = ImageIO.read(getClass().getResource(images));
+//        }catch(IOException ex){
+//            ex.printStackTrace();
+//        }
+    	this.image_ = images;
         this.type = objecttype;
         this.x = x;
         this.y = y;
@@ -36,25 +39,25 @@ public abstract class DrawEngine {
         AffineTransform transform = new AffineTransform();
         transform.translate(this.x, this.y);
         transform.scale(this.scale, this.scale);
-        transform.rotate(Math.toRadians(this.rotation), this.image.getWidth(null) /2 , this.image.getHeight(null) / 2);
+        transform.rotate(Math.toRadians(this.rotation), Images.getImage(image_).getWidth(null) /2 , Images.getImage(image_).getHeight(null) / 2);
         return transform;
     }
 
     public void draw(Graphics2D g){
-        g.drawImage(this.image, this.getAffineTransform(), null);
+        g.drawImage(Images.getImage(image_), this.getAffineTransform(), null);
     }
 
     public boolean contains(Point2D point){
-        Shape shape = new Rectangle2D.Double(0, 0, image.getWidth(null), image.getHeight(null));
+        Shape shape = new Rectangle2D.Double(0, 0, Images.getImage(image_).getWidth(null), Images.getImage(image_).getHeight(null));
         return this.getAffineTransform().createTransformedShape(shape).contains(point);
     }
     
     public Image getImage(){
-    	return image;
+    	return Images.getImage(image_);
     }
 
     public Point2D.Double getCenter(){
-        Point2D.Double center = new Point2D.Double(x + this.image.getWidth(null)*scale / 2, y + this.image.getHeight(null)*scale/2);
+        Point2D.Double center = new Point2D.Double(x + Images.getImage(image_).getWidth(null)*scale / 2, y + Images.getImage(image_).getHeight(null)*scale/2);
         return center;
     }
 
@@ -88,11 +91,11 @@ public abstract class DrawEngine {
     }
 
     public int getWidth(){
-        return this.image.getWidth(null);
+        return Images.getImage(image_).getWidth(null);
     }
 
     public int getHeight(){
-        return this.image.getHeight(null);
+        return Images.getImage(image_).getHeight(null);
     }
     
     public double getRotation() {
@@ -104,7 +107,7 @@ public abstract class DrawEngine {
     }
 
     public Rectangle2D.Double getRect(){
-        return new Rectangle2D.Double(-distanceToOtherObjects, - distanceToOtherObjects, image.getWidth(null)  + 2* distanceToOtherObjects, image.getHeight(null) + 2*distanceToOtherObjects);
+        return new Rectangle2D.Double(-distanceToOtherObjects, - distanceToOtherObjects, Images.getImage(image_).getWidth(null)  + 2* distanceToOtherObjects, Images.getImage(image_).getHeight(null) + 2*distanceToOtherObjects);
     }
 
 

+ 5 - 3
src/gui/simulator/ExitPoint.java

@@ -1,14 +1,16 @@
 package gui.simulator;
 
-public class ExitPoint extends DrawEngine {
+import java.io.Serializable;
+
+public class ExitPoint extends DrawEngine implements Serializable {
 	
-	private static String imageLocation = "/simulator/uitgang.png";
+	private static Images.ImageType images = Images.ImageType.Exit;
 	private static String facilityName = "Uitgang";
 	private Terrain terrain;
 
 
     public ExitPoint(Terrain terrain, int x, int y, double scale, double distance) {
-        super(imageLocation, x, y, scale, distance, SimulatorPane.Objects.EXIT);
+        super(images, x, y, scale, distance, SimulatorPane.Objects.EXIT);
         this.terrain = terrain;
     }
     

+ 85 - 0
src/gui/simulator/Images.java

@@ -0,0 +1,85 @@
+package gui.simulator;
+
+import gui.main.Main;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.imageio.ImageIO;
+
+public class Images{
+
+	public static ArrayList<BufferedImage> images = new ArrayList<BufferedImage>();
+
+	static{
+		try{
+			images.add(ImageIO.read(Main.class.getResource("/sand.jpg"))); 
+			images.add(ImageIO.read(Main.class.getResource("/grass.jpg")));
+			images.add(ImageIO.read(Main.class.getResource("/street.jpg")));
+			images.add(ImageIO.read(Main.class.getResource("/simulator/ingang.png")));
+			images.add(ImageIO.read(Main.class.getResource("/simulator/toilet.png")));
+			images.add(ImageIO.read(Main.class.getResource("/simulator/tent.png")));
+			images.add(ImageIO.read(Main.class.getResource("/simulator/uitgang.png")));
+			images.add(ImageIO.read(Main.class.getResource("/simulator/snackbar.png")));
+			images.add(ImageIO.read(Main.class.getResource("/simulator/border.png")));
+			images.add(ImageIO.read(Main.class.getResource("/visitor.png")));
+			images.add(ImageIO.read(Main.class.getResource("/add.png")));
+			images.add(ImageIO.read(Main.class.getResource("/ground_stone.jpg")));
+			images.add(ImageIO.read(Main.class.getResource("/rotate.gif")));
+			images.add(ImageIO.read(Main.class.getResource("/path.gif")));
+			
+			//images.add(ImageIO.read(Main.class.getResource("")));
+			
+		}catch(IOException e){
+			e.printStackTrace();
+		}
+	}
+	public static BufferedImage getImage(ImageType img)
+	{
+		return images.get(img.ordinal());
+	}
+
+	public enum ImageType
+	{
+		Sand,
+		Grass,
+		Street,
+		Entrance,
+		Toilet,
+		Tent,
+		Exit,
+		Snackbar,
+		Border,
+		Visitor,
+		Add,
+		Pad,
+		RotateCursor,
+		PathCursor
+	}
+}
+//enum ImageEnum
+//{
+//	Podium1("test.png"),
+//	Podium2("test.png"),
+//	Podium3("test.png"),
+//	Podium4("test.png");
+//
+//	private BufferedImage image;
+//	ImageEnum(String filename)
+//	{
+//		try {
+//			this.image = ImageIO.read(Images.class.getResource(filename));
+//
+//
+//		} catch (IOException e) {
+//			// TODO Auto-generated catch block
+//			e.printStackTrace();
+//		}
+//	}
+//	public Image getImage() {
+//		return image;
+//	}
+
+
+

+ 2 - 1
src/gui/simulator/Sidebar.java

@@ -11,9 +11,10 @@ import java.awt.Graphics2D;
 import java.awt.event.MouseEvent;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
+import java.io.Serializable;
 import java.util.ArrayList;
 
-public class Sidebar {
+public class Sidebar implements Serializable {
 	private int sideBarWidth;
 	private int sideBarHeight;
 	private Terrain terrain;

+ 76 - 0
src/gui/simulator/SimIo.java

@@ -0,0 +1,76 @@
+
+package gui.simulator;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import javax.swing.JFileChooser;
+import javax.swing.JPanel;
+
+
+public class SimIo {
+
+	public static void writeIo(JPanel panel) throws IOException
+	{
+		JFileChooser fileChooser = new JFileChooser(); 
+		if(fileChooser.showSaveDialog(null)
+				== fileChooser.APPROVE_OPTION) {
+			java.io.File file = fileChooser.getSelectedFile();
+
+			ObjectOutputStream output = null;
+			try{
+				output = new ObjectOutputStream(new FileOutputStream(file));
+				
+			}catch(IOException e){ 
+				System.out.println("Could not open file." + e);
+			}
+			try{
+			    
+				output.writeObject(panel);
+				output.close();
+			}catch(IOException e){
+				System.out.println("Writing error.  " + e);
+			}
+		}
+
+	}
+
+	public static SimulatorPane readIo() throws IOException
+	{
+		JFileChooser fileChooser = new JFileChooser();
+		if(fileChooser.showOpenDialog(null)
+				== fileChooser.APPROVE_OPTION) {
+			java.io.File file = fileChooser.getSelectedFile();
+
+			ObjectInputStream input = null;
+
+			try{
+				input = new ObjectInputStream(new FileInputStream(file));
+			}catch(IOException e){
+				System.out.println("There was a problem opening the file. " + e);
+
+			}
+			SimulatorPane pane = null;
+			try{
+				pane = (SimulatorPane)input.readObject();
+				input.close();
+				return pane;
+			}catch(Exception e){
+				System.out.println("There was a issue reading this file: " + e);
+			}
+		}
+		return null;
+
+
+	}
+}
+
+
+
+
+
+
+

+ 312 - 320
src/gui/simulator/Terrain.java

@@ -1,11 +1,21 @@
 package gui.simulator;
 
-import agenda.Agenda;
+import gui.simulator.Images.ImageType;
 import gui.simulator.facilities.RestRoom;
 import gui.simulator.facilities.SimulatorStage;
 import gui.simulator.facilities.SnackBar;
 
-import java.awt.*;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.TexturePaint;
+import java.awt.Toolkit;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseMotionAdapter;
@@ -16,39 +26,39 @@ import java.awt.geom.Area;
 import java.awt.geom.NoninvertibleTransformException;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 
-import javax.imageio.ImageIO;
-import javax.swing.*;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+import agenda.Agenda;
 
 public class Terrain extends JPanel {
 
-    private List<DrawEngine> entities;
-    private Point2D oldPosition;
+	private List<DrawEngine> entities;
+	private Point2D oldPosition;
 	private double oldRotation, oldScale;
-    private DrawEngine dragObject, selectedObject;
-    private BufferedImage background;
-    private Sidebar sidebar;
-    
-    private int festivalheight, festivalwidth;
-    private int sideBarWidth = 200;
-    
-    private int pathgenerate = 1;
-    private WalkingPath currentpath;
-    
-    private SimulatorPane.Terrains terrain;
-    Point2D cameraPoint = new Point2D.Double(festivalwidth/2,festivalheight/2);
+	private DrawEngine dragObject, selectedObject;
+	private ImageType background;
+	private Sidebar sidebar;
+
+	private int festivalheight, festivalwidth;
+	private int sideBarWidth = 200;
+
+	private int pathgenerate = 1;
+	private WalkingPath currentpath;
+
+	private SimulatorPane.Terrains terrain;
+	Point2D cameraPoint = new Point2D.Double(festivalwidth/2,festivalheight/2);
 	float cameraScale = 1;
 	private boolean grid;
 	private ArrayList<Visitor> visitors;
 	private ArrayList<WalkingPath> paths;
 	Cursor rotate, pathpoint;
-	
+
 	Point2D lastClickPosition;
 	Point lastMousePosition;
 	Point2D lastMovedMousePosition;
@@ -56,59 +66,47 @@ public class Terrain extends JPanel {
 
 	private Agenda agenda;
 
-    public Terrain(int length, int width, SimulatorPane.Terrains terrain, Agenda agenda){
-    	//get values
-    	setFestivalHeight(length);
-    	setFestivalWidth(width);
-    	grid = true;
-    	this.terrain = terrain;
-    	visitors = new ArrayList<Visitor>();
-    	paths = new ArrayList<WalkingPath>();
-
-    	createCustomCursors();
-    	//initialize sidebar
-    	sidebar = new Sidebar(sideBarWidth, 3000, this);
-
-    	//set terrainbackground
-    	switch(terrain){
-    	case BEACH: 
-    		try {
-			background = ImageIO.read(new File("res/sand.jpg"));
-		} catch (IOException e) {
-			e.printStackTrace();
+	public Terrain(int length, int width, SimulatorPane.Terrains terrain, Agenda agenda){
+		//get values
+		setFestivalHeight(length);
+		setFestivalWidth(width);
+		grid = true;
+		this.terrain = terrain;
+		visitors = new ArrayList<Visitor>();
+		paths = new ArrayList<WalkingPath>();
+
+		createCustomCursors();
+		//initialize sidebar
+		sidebar = new Sidebar(sideBarWidth, 3000, this);
+
+		//set terrainbackground
+		switch(terrain){
+		case BEACH: 
+			background = Images.ImageType.Sand;
+			break;
+		case GRASS:
+			background = Images.ImageType.Grass;
+			break;
+		case URBAN:
+			background = Images.ImageType.Street;
+			break;
 		}
-    		break;
-    	case GRASS:
-    		try {
-    			background = ImageIO.read(new File("res/grass.jpg"));
-    		} catch (IOException e) {
-    			e.printStackTrace();
-    		}
-    		break;
-    	case URBAN:
-    		try {
-    			background = ImageIO.read(new File("res/street.jpg"));
-    		} catch (IOException e) {
-    			e.printStackTrace();
-    		}
-    		break;
-    	}
-    	
-        this.dragObject = null;
-        this.entities = new LinkedList();
-        this.initEntities();
-        this.listeners();
+
+		this.dragObject = null;
+		this.entities = new LinkedList();
+		this.initEntities();
+		this.listeners();
 
 		//agenda
 		this.agenda = agenda;
-    }
+	}
 
-    private void getFacility(MouseEvent e){
-    	Point2D clickPoint = getClickPoint(e.getPoint());
-    	DrawEngine dragObject = null;
-    	if(e.getX() < sideBarWidth)
+	private void getFacility(MouseEvent e){
+		Point2D clickPoint = getClickPoint(e.getPoint());
+		DrawEngine dragObject = null;
+		if(e.getX() < sideBarWidth)
 		{
-    		if(e.getY() > 100 && e.getY() < 260){
+			if(e.getY() > 100 && e.getY() < 260){
 				dragObject = new SimulatorStage((int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10);
 				setDragObject(dragObject);
 			}else if(e.getY() >= 260 && e.getY() < 425){
@@ -128,42 +126,42 @@ public class Terrain extends JPanel {
 			}
 			entities.add(dragObject);
 		}
-    }
-    private void listeners(){
-        addMouseListener(new MouseAdapter() {
-            @Override
-            public void mousePressed(MouseEvent e) {
-            	Point2D clickPoint = getClickPoint(e.getPoint());
+	}
+	private void listeners(){
+		addMouseListener(new MouseAdapter() {
+			@Override
+			public void mousePressed(MouseEvent e) {
+				Point2D clickPoint = getClickPoint(e.getPoint());
 				lastClickPosition = clickPoint;
 				lastMousePosition = e.getPoint();
-                //if selected in sidebar
+				//if selected in sidebar
 				getFacility(e);
-                //else selected in terrain
-                if(e.getX() > sideBarWidth){
-	                for(DrawEngine drawObject: entities){
-	                    if(drawObject.contains(clickPoint)){
-	                    	if(pathgenerate  == 1){
-	                    		currentpath = new WalkingPath();
-	                    		currentpath.addPoint(new Point((int)drawObject.getCenter().getX(), (int)drawObject.getCenter().getY()));
-	                    		currentpath.setObject1(drawObject);
-	                    		pathgenerate = 2;
-	                    		return;
-	                    	}else if(pathgenerate > 1){
-	                    		
-	                    		currentpath.addPoint(new Point((int)drawObject.getCenter().getX(), (int)drawObject.getCenter().getY()));
-	                    		currentpath.setObject2(drawObject);
-	                    		paths.add(currentpath);
-	                        	for(int i=0; i< 200; i++){
-	                            	visitors.add(new Visitor(new Point(100+(i*15),100)));	
-	                            	visitors.get(i).walkRoute(paths.get(0));
-	                        	}
-	                    		pathgenerate = 0;
-	                    		return; 
-	                    	}else{
-	                    		setCursor(new Cursor(Cursor.MOVE_CURSOR));
-	                    		dragObject = drawObject;
-	                    		selectedObject = dragObject;	
-	                    		oldPosition = new Point2D.Double(selectedObject.getX(), selectedObject.getY());
+				//else selected in terrain
+				if(e.getX() > sideBarWidth){
+					for(DrawEngine drawObject: entities){
+						if(drawObject.contains(clickPoint)){
+							if(pathgenerate  == 1){
+								currentpath = new WalkingPath();
+								currentpath.addPoint(new Point((int)drawObject.getCenter().getX(), (int)drawObject.getCenter().getY()));
+								currentpath.setObject1(drawObject);
+								pathgenerate = 2;
+								return;
+							}else if(pathgenerate > 1){
+
+								currentpath.addPoint(new Point((int)drawObject.getCenter().getX(), (int)drawObject.getCenter().getY()));
+								currentpath.setObject2(drawObject);
+								paths.add(currentpath);
+								for(int i=0; i< 200; i++){
+									visitors.add(new Visitor(new Point(100+(i*15),100)));	
+									visitors.get(i).walkRoute(paths.get(0));
+								}
+								pathgenerate = 0;
+								return; 
+							}else{
+								setCursor(new Cursor(Cursor.MOVE_CURSOR));
+								dragObject = drawObject;
+								selectedObject = dragObject;	
+								oldPosition = new Point2D.Double(selectedObject.getX(), selectedObject.getY());
 								oldRotation = selectedObject.getScale();
 								oldScale = selectedObject.getScale();
 
@@ -185,111 +183,111 @@ public class Terrain extends JPanel {
 									dialog.pack();
 									dialog.setVisible(true);
 								}
-	                    		return;
-	                    	}
-	                    }
-	                }
-	                if(pathgenerate > 1){
-                		currentpath.addPoint(new Point((int)getClickPoint(e.getPoint()).getX(), (int)getClickPoint(e.getPoint()).getY()));
-	                }
-                }
-                repaint();
-            }
-
-            @Override
-            public void mouseReleased(MouseEvent e) {
-                if(selectedObject != null){
-                    for(DrawEngine drawObject: entities){
-                        if(drawObject == selectedObject){
-                            continue;
-                        }
-                        if(intersection(selectedObject, drawObject)){
-                            //move back
-                            selectedObject.setX(oldPosition.getX());
-                            selectedObject.setY(oldPosition.getY());
+								return;
+							}
+						}
+					}
+					if(pathgenerate > 1){
+						currentpath.addPoint(new Point((int)getClickPoint(e.getPoint()).getX(), (int)getClickPoint(e.getPoint()).getY()));
+					}
+				}
+				repaint();
+			}
+
+			@Override
+			public void mouseReleased(MouseEvent e) {
+				if(selectedObject != null){
+					for(DrawEngine drawObject: entities){
+						if(drawObject == selectedObject){
+							continue;
+						}
+						if(intersection(selectedObject, drawObject)){
+							//move back
+							selectedObject.setX(oldPosition.getX());
+							selectedObject.setY(oldPosition.getY());
 							selectedObject.setRotation(oldRotation);
 							selectedObject.setScale(oldScale);
-                        }
-                    }
-                }
-                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
-                selectedObject = null;
-                dragObject = null;
-                repaint();
-            }
-        });
-
-        addMouseMotionListener(new MouseMotionAdapter() {
-        	public void mouseMoved(MouseEvent e){
-        		lastMovedMousePosition = getClickPoint(e.getPoint());
-        		if(pathgenerate >0){
-        			setCursor(pathpoint);
-        		}else{
-        			  for(DrawEngine drawObject: entities){
-  	                    if(drawObject.contains(lastMovedMousePosition)){
-  	                    	setCursor(new Cursor(Cursor.HAND_CURSOR));
-  	                    	return;
-  	                    }
-        			  }
-              		setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
-        		}
-        	}
-            @Override
-            public void mouseDragged(MouseEvent e) {
-            	Point2D clickPoint = getClickPoint(e.getPoint());
-                if(dragObject != null){
-                	if(SwingUtilities.isLeftMouseButton(e) && dragObject instanceof AccessPoint){          		
-                		dragObject.setX(-25);
-                		dragObject.setRotation(90);
-                		if(dragObject.getY()<80){
-                		dragObject.setY(80);
-                		} else if(dragObject.getY()>getFestivalHeight()-150){
-                		dragObject.setY(getFestivalHeight()-150);
-                		} else {
-                		dragObject.setY(dragObject.getY() - (lastClickPosition.getY() - clickPoint.getY()));    
-                		}       		
-                	}else if(SwingUtilities.isLeftMouseButton(e) && dragObject instanceof ExitPoint){
-                		dragObject.setX(getFestivalWidth()-200);
-                		dragObject.setRotation(90);
-                		
-                		if(dragObject.getY()<80){
-                    		dragObject.setY(80);
-                    		} else if(dragObject.getY()>getFestivalHeight()-150){
-                    		dragObject.setY(getFestivalHeight()-150);
-                    		} else {
-                    		dragObject.setY(dragObject.getY() - (lastClickPosition.getY() - clickPoint.getY()));    
-                    		}
-                		
-                	}else if(SwingUtilities.isLeftMouseButton(e)){
-                    		setCursor(new Cursor(Cursor.MOVE_CURSOR));
-                    		dragObject.setX(dragObject.getX() - (lastClickPosition.getX() - clickPoint.getX()));
-                    		dragObject.setY(dragObject.getY() - (lastClickPosition.getY() - clickPoint.getY()));
-                    }else if(SwingUtilities.isRightMouseButton(e)){
-                		setCursor(rotate);
-                    	dragObject.setRotation(dragObject.getRotation() + (lastClickPosition.getX() - clickPoint.getX() + lastClickPosition.getY() - clickPoint.getY()));
-                    }
-                }
-                else
+						}
+					}
+				}
+				setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
+				selectedObject = null;
+				dragObject = null;
+				repaint();
+			}
+		});
+
+		addMouseMotionListener(new MouseMotionAdapter() {
+			public void mouseMoved(MouseEvent e){
+				lastMovedMousePosition = getClickPoint(e.getPoint());
+				if(pathgenerate >0){
+					setCursor(pathpoint);
+				}else{
+					for(DrawEngine drawObject: entities){
+						if(drawObject.contains(lastMovedMousePosition)){
+							setCursor(new Cursor(Cursor.HAND_CURSOR));
+							return;
+						}
+					}
+					setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
+				}
+			}
+			@Override
+			public void mouseDragged(MouseEvent e) {
+				Point2D clickPoint = getClickPoint(e.getPoint());
+				if(dragObject != null){
+					if(SwingUtilities.isLeftMouseButton(e) && dragObject instanceof AccessPoint){          		
+						dragObject.setX(-25);
+						dragObject.setRotation(90);
+						if(dragObject.getY()<80){
+							dragObject.setY(80);
+						} else if(dragObject.getY()>getFestivalHeight()-150){
+							dragObject.setY(getFestivalHeight()-150);
+						} else {
+							dragObject.setY(dragObject.getY() - (lastClickPosition.getY() - clickPoint.getY()));    
+						}       		
+					}else if(SwingUtilities.isLeftMouseButton(e) && dragObject instanceof ExitPoint){
+						dragObject.setX(getFestivalWidth()-200);
+						dragObject.setRotation(90);
+
+						if(dragObject.getY()<80){
+							dragObject.setY(80);
+						} else if(dragObject.getY()>getFestivalHeight()-150){
+							dragObject.setY(getFestivalHeight()-150);
+						} else {
+							dragObject.setY(dragObject.getY() - (lastClickPosition.getY() - clickPoint.getY()));    
+						}
+
+					}else if(SwingUtilities.isLeftMouseButton(e)){
+						setCursor(new Cursor(Cursor.MOVE_CURSOR));
+						dragObject.setX(dragObject.getX() - (lastClickPosition.getX() - clickPoint.getX()));
+						dragObject.setY(dragObject.getY() - (lastClickPosition.getY() - clickPoint.getY()));
+					}else if(SwingUtilities.isRightMouseButton(e)){
+						setCursor(rotate);
+						dragObject.setRotation(dragObject.getRotation() + (lastClickPosition.getX() - clickPoint.getX() + lastClickPosition.getY() - clickPoint.getY()));
+					}
+				}
+				else
 				{
-                	setCursor(new Cursor(Cursor.MOVE_CURSOR));
+					setCursor(new Cursor(Cursor.MOVE_CURSOR));
 					cameraPoint = new Point2D.Double(
 							cameraPoint.getX() + (lastMousePosition.getX() - e.getX()),
 							cameraPoint.getY() + (lastMousePosition.getY() - e.getY())
 							);
 				}
-                repaint();
+				repaint();
 				lastMousePosition = e.getPoint();
 				lastClickPosition = clickPoint;
-            }
-        });
-        
-        addMouseWheelListener(new MouseWheelListener() {
-            @Override
-            public void mouseWheelMoved(MouseWheelEvent e) {
-            	Point2D clickPoint = getClickPoint(e.getPoint());
-                for(DrawEngine object: entities){
-                	//if object selected, scale object
-                    if(object.contains(clickPoint)){
+			}
+		});
+
+		addMouseWheelListener(new MouseWheelListener() {
+			@Override
+			public void mouseWheelMoved(MouseWheelEvent e) {
+				Point2D clickPoint = getClickPoint(e.getPoint());
+				for(DrawEngine object: entities){
+					//if object selected, scale object
+					if(object.contains(clickPoint)){
 						double oldscale  = object.getScale();
 						if(oldscale < 0.3){
 							if((e.getPreciseWheelRotation()/10.0) > 0){
@@ -310,36 +308,36 @@ public class Terrain extends JPanel {
 
 						repaint();
 						return;
-                    }
-                }
-                //scale camera
-            	cameraScale *= 1 - (e.getPreciseWheelRotation()/10.0);
-            	repaint();
-            }
-        });
-    }
-
-    /*
-     * Add facilities on initializing
-     */
-    private void initEntities(){
-        //this.entities.add(new Stage(300, 10, 0.5, 10));
-        //this.entities.add(new Stage(400, 40, 2, 10));
-    }
-
-    @Override
-    public void paint(Graphics g) {
-        super.paint(g);
-        Graphics2D g2 = (Graphics2D) g;
-        sidebar.draw(g2);
-        
+					}
+				}
+				//scale camera
+				cameraScale *= 1 - (e.getPreciseWheelRotation()/10.0);
+				repaint();
+			}
+		});
+	}
+
+	/*
+	 * Add facilities on initializing
+	 */
+	private void initEntities(){
+		//this.entities.add(new Stage(300, 10, 0.5, 10));
+		//this.entities.add(new Stage(400, 40, 2, 10));
+	}
+
+	@Override
+	public void paint(Graphics g) {
+		super.paint(g);
+		Graphics2D g2 = (Graphics2D) g;
+		sidebar.draw(g2);
+
 
 		//draw simulation field
 		g2.setClip(new Rectangle2D.Double(sideBarWidth, 0, getWidth()-sideBarWidth, getHeight()));
 		AffineTransform oldTransform = g2.getTransform();
 		g2.translate(sideBarWidth,0);
 		g2.setTransform(getCamera());
-        TexturePaint p = new TexturePaint(background, new Rectangle2D.Double(0, 0, 200, 200));
+		TexturePaint p = new TexturePaint(Images.getImage(background), new Rectangle2D.Double(0, 0, 200, 200));
 		g2.setPaint(p);
 		g2.fill(new Rectangle2D.Double(0,0,festivalwidth,festivalheight));
 		if(grid){
@@ -361,57 +359,57 @@ public class Terrain extends JPanel {
 				path.paint(g2);
 			}
 		}
-    	for(Visitor v:visitors){
-    		v.paint(g2);
-    	}
+		for(Visitor v:visitors){
+			v.paint(g2);
+		}
 		for(DrawEngine drawObject: entities){
-            drawObject.draw(g2); 
-            if(pathgenerate > 0){
-            	g2.fill(drawObject.getAffineTransform().createTransformedShape(new Rectangle((int)(drawObject.getX()-(drawObject.getWidth()/2)-10),(int)(drawObject.getY()-(drawObject.getHeight()/2)-10), 20, 20)));
-            }
-        }
+			drawObject.draw(g2); 
+			if(pathgenerate > 0){
+				g2.fill(drawObject.getAffineTransform().createTransformedShape(new Rectangle((int)(drawObject.getX()-(drawObject.getWidth()/2)-10),(int)(drawObject.getY()-(drawObject.getHeight()/2)-10), 20, 20)));
+			}
+		}
 
 		//draw collide boxes 
-        if(this.selectedObject != null){
-            Shape shape = this.selectedObject.getRect();
-            g2.setColor(Color.RED);
-            g2.draw(this.selectedObject.getAffineTransform().createTransformedShape(shape));
-
-            boolean collide = false;
-            for(DrawEngine drawEngine : entities){
-                if(!drawEngine.equals(this.selectedObject)){
-                    if(intersection(this.selectedObject, drawEngine)){
-                        collide = true;
-                    }
-                }
-            }
-
-            if(collide){
-                g2.setColor(new Color(254, 0, 0, 128));
-            }else{
-                g2.setColor(new Color(0, 254, 0, 128));
-            }
-            g2.fill(this.selectedObject.getAffineTransform().createTransformedShape(this.selectedObject.getRect()));
-            g2.setClip(null);
-            g2.setTransform(oldTransform);
-        }
-    }
-
-    private Rectangle drawDragRectangle(DrawEngine shape){
-        Rectangle rectangle = null;
-        rectangle = new Rectangle((int) (shape.getX() - shape.getDistanceToOtherObjects()), (int) (shape.getY() - shape.getDistanceToOtherObjects()), (int) (shape.getWidth() * shape.getScale() + (2 * shape.getDistanceToOtherObjects())), (int) (shape.getHeight() * shape.getScale() + (2 * shape.getDistanceToOtherObjects())));
-        return rectangle;
-    }
-
-    private boolean intersection(DrawEngine d1, DrawEngine d2){
-        Area area = new Area(d1.getAffineTransform().createTransformedShape(d1.getRect()));
-        Area area2 = new Area(d2.getAffineTransform().createTransformedShape(d2.getRect()));
-
-        area.intersect(area2);
-        return !area.isEmpty();
-    }
-    
-    public Point2D getClickPoint(Point point) {
+		if(this.selectedObject != null){
+			Shape shape = this.selectedObject.getRect();
+			g2.setColor(Color.RED);
+			g2.draw(this.selectedObject.getAffineTransform().createTransformedShape(shape));
+
+			boolean collide = false;
+			for(DrawEngine drawEngine : entities){
+				if(!drawEngine.equals(this.selectedObject)){
+					if(intersection(this.selectedObject, drawEngine)){
+						collide = true;
+					}
+				}
+			}
+
+			if(collide){
+				g2.setColor(new Color(254, 0, 0, 128));
+			}else{
+				g2.setColor(new Color(0, 254, 0, 128));
+			}
+			g2.fill(this.selectedObject.getAffineTransform().createTransformedShape(this.selectedObject.getRect()));
+			g2.setClip(null);
+			g2.setTransform(oldTransform);
+		}
+	}
+
+	private Rectangle drawDragRectangle(DrawEngine shape){
+		Rectangle rectangle = null;
+		rectangle = new Rectangle((int) (shape.getX() - shape.getDistanceToOtherObjects()), (int) (shape.getY() - shape.getDistanceToOtherObjects()), (int) (shape.getWidth() * shape.getScale() + (2 * shape.getDistanceToOtherObjects())), (int) (shape.getHeight() * shape.getScale() + (2 * shape.getDistanceToOtherObjects())));
+		return rectangle;
+	}
+
+	private boolean intersection(DrawEngine d1, DrawEngine d2){
+		Area area = new Area(d1.getAffineTransform().createTransformedShape(d1.getRect()));
+		Area area2 = new Area(d2.getAffineTransform().createTransformedShape(d2.getRect()));
+
+		area.intersect(area2);
+		return !area.isEmpty();
+	}
+
+	public Point2D getClickPoint(Point point) {
 		try {
 			return getCamera().inverseTransform(point, null);
 		} catch (NoninvertibleTransformException e1) {
@@ -419,8 +417,8 @@ public class Terrain extends JPanel {
 		}
 		return null;
 	}
-    
-    private AffineTransform getCamera() {
+
+	private AffineTransform getCamera() {
 		AffineTransform tx = new AffineTransform();
 		//start field in top left corner, next to sidebar
 		tx.translate(-cameraPoint.getX() + sideBarWidth, -cameraPoint.getY());
@@ -429,55 +427,49 @@ public class Terrain extends JPanel {
 		tx.scale(cameraScale, cameraScale);
 		return tx;
 	}
-    public void calculate(){
-    	for(Visitor v:visitors){
-    		v.update(visitors, entities);
-    	}
-    	for(WalkingPath p:paths){
-    		p.reCalculate();
-    	}
-    }
-
-    public void setFestivalHeight(int height){
-    	this.festivalheight = height;
-    }
-    public void setFestivalWidth(int width){
-    	this.festivalwidth = width;
-    }
-    public int getFestivalHeight(){
-    	return festivalheight;
-    }
-    public int getFestivalWidth(){
-    	return festivalwidth;
-    }
-    
-    //getters and setters for sidebar
-    public void setDragObject(DrawEngine dragObject){
-    	this.dragObject = dragObject;
-    }
-    
-    public DrawEngine getDragObject(){
-    	return dragObject;
-    }
-    
-    public void addEntity(DrawEngine dragObject){
-    	entities.add(dragObject);
-    }
-    
-    public void createCustomCursors(){
-    	Toolkit toolkit = Toolkit.getDefaultToolkit();  
-    	Image image = null;
-		try {
-			image = ImageIO.read(Window.class.getResource("/rotate.gif"));
-		} catch (IOException e) {
-			e.printStackTrace();
+	public void calculate(){
+		for(Visitor v:visitors){
+			v.update(visitors, entities);
 		}
-    	rotate = toolkit.createCustomCursor(image, new Point(14,14), "Rotate");  
-		try {
-			image = ImageIO.read(Window.class.getResource("/path.gif"));
-		} catch (IOException e) {
-			e.printStackTrace();
+		for(WalkingPath p:paths){
+			p.reCalculate();
 		}
-		pathpoint = toolkit.createCustomCursor(image, new Point(14,14), "Pathpoint");  
-    }
+	}
+
+	public void setFestivalHeight(int height){
+		this.festivalheight = height;
+	}
+	public void setFestivalWidth(int width){
+		this.festivalwidth = width;
+	}
+	public int getFestivalHeight(){
+		return festivalheight;
+	}
+	public int getFestivalWidth(){
+		return festivalwidth;
+	}
+
+	//getters and setters for sidebar
+	public void setDragObject(DrawEngine dragObject){
+		this.dragObject = dragObject;
+	}
+
+	public DrawEngine getDragObject(){
+		return dragObject;
+	}
+
+	public void addEntity(DrawEngine dragObject){
+		entities.add(dragObject);
+	}
+
+	public void createCustomCursors(){
+		Toolkit toolkit = Toolkit.getDefaultToolkit();  
+		Images.ImageType image;
+
+		image = Images.ImageType.RotateCursor;
+		rotate = toolkit.createCustomCursor(Images.getImage(image), new Point(14,14), "Rotate");  
+
+		image = Images.ImageType.PathCursor;
+		pathpoint = toolkit.createCustomCursor(Images.getImage(image), new Point(14,14), "Pathpoint");  
+	}
 }

+ 4 - 3
src/gui/simulator/Visitor.java

@@ -5,12 +5,13 @@ import java.awt.Image;
 import java.awt.Point;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
+import java.io.Serializable;
 import java.util.List;
 
 import javax.swing.ImageIcon;
 
 
-public class Visitor {
+public class Visitor implements Serializable {
 	Point2D positie;
 	double rotation;
 	double speed;
@@ -18,7 +19,7 @@ public class Visitor {
 	WalkingPath currentpath;
 	int currentpoint;
 	
-	Image image = new ImageIcon("res/visitor.png").getImage();
+	Images.ImageType image = Images.ImageType.Visitor;
 	
 	public Visitor(Point2D positie) {
 		this.positie = positie;
@@ -84,7 +85,7 @@ public class Visitor {
 		tx.translate(positie.getX()-8, positie.getY()-11);
 		tx.rotate(rotation, 4, 6);
 		
-		g.drawImage(image, tx ,null);
+		g.drawImage(Images.getImage(image), tx ,null);
 		
 	}
 

+ 7 - 13
src/gui/simulator/WalkingPath.java

@@ -1,29 +1,23 @@
 package gui.simulator;
 
+import gui.simulator.Images.ImageType;
+
 import java.awt.BasicStroke;
 import java.awt.Graphics2D;
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.TexturePaint;
-import java.awt.Window;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
+import java.io.Serializable;
 import java.util.ArrayList;
 
-import javax.imageio.ImageIO;
-
-public class WalkingPath {
+public class WalkingPath implements Serializable {
 	private ArrayList<Point> path;
 	private DrawEngine object1,object2;
-	private BufferedImage texture;
+	private ImageType texture;
 	
 	public WalkingPath(){
 		path = new ArrayList<Point>();
-		try {
-			texture = ImageIO.read(Window.class.getResource("/ground_stone.jpg"));
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
+		texture = Images.ImageType.Pad;
 	}
 	public void addPoint(Point p){
 		path.add(p);
@@ -59,7 +53,7 @@ public class WalkingPath {
 		
 		for(int i = 1; i < getPath().size(); i++){
 			g2.setStroke(new BasicStroke(40,BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
-			g2.setPaint(new TexturePaint(texture, new Rectangle(0,0,100,100)));
+			g2.setPaint(new TexturePaint(Images.getImage(texture), new Rectangle(0,0,100,100)));
 			g2.drawLine((int)get(i-1).getX(),(int)get(i-1).getY(), (int)get(i).getX(),(int)get(i).getY());
 		}
 		g2.setStroke(new BasicStroke(10,BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

+ 7 - 4
src/gui/simulator/facilities/RestRoom.java

@@ -1,19 +1,22 @@
 package gui.simulator.facilities;
 
+import java.io.Serializable;
+
 import gui.simulator.DrawEngine;
+import gui.simulator.Images;
 import gui.simulator.SimulatorPane;
 
-public class RestRoom extends DrawEngine {
+public class RestRoom extends DrawEngine implements Serializable {
 
-	private static String imageLocation = "/simulator/toilet.png";
+	private static Images.ImageType images = Images.ImageType.Toilet;
 	private static String facilityName = "Plee";
 
     public RestRoom(int x, int y) {
-        super(imageLocation, x, y, 1, 0, SimulatorPane.Objects.RESTROOM);
+        super(images, x, y, 1, 0, SimulatorPane.Objects.RESTROOM);
     }
 
     public RestRoom(int x, int y, double scale, double distance) {
-        super(imageLocation, x, y, scale, distance, SimulatorPane.Objects.RESTROOM);
+        super(images, x, y, scale, distance, SimulatorPane.Objects.RESTROOM);
     }
     
     public String getFacilityName(){

+ 7 - 4
src/gui/simulator/facilities/SimulatorStage.java

@@ -1,21 +1,24 @@
 package gui.simulator.facilities;
 
+import java.io.Serializable;
+
 import agenda.Stage;
 import gui.simulator.DrawEngine;
+import gui.simulator.Images;
 import gui.simulator.SimulatorPane;
 
-public class SimulatorStage extends DrawEngine {
+public class SimulatorStage extends DrawEngine implements Serializable {
 
-	private static String imageLocation = "/simulator/tent.png";
+	private static Images.ImageType images = Images.ImageType.Tent;
 	private static String facilityName = "Stage";
     private Stage stage;
 
     public SimulatorStage(int x, int y) {
-        super(imageLocation, x, y, 1, 0,SimulatorPane.Objects.STAGE);
+        super(images, x, y, 1, 0,SimulatorPane.Objects.STAGE);
     }
 
     public SimulatorStage(int x, int y, double scale, double distance) {
-        super(imageLocation, x, y, scale, distance,SimulatorPane.Objects.STAGE);
+        super(images, x, y, scale, distance,SimulatorPane.Objects.STAGE);
     }
     
     public String getFacilityName(){

+ 7 - 4
src/gui/simulator/facilities/SnackBar.java

@@ -1,19 +1,22 @@
 package gui.simulator.facilities;
 
+import java.io.Serializable;
+
 import gui.simulator.DrawEngine;
+import gui.simulator.Images;
 import gui.simulator.SimulatorPane;
 
-public class SnackBar extends DrawEngine{
+public class SnackBar extends DrawEngine implements Serializable{
 
-	private static String imageLocation = "/simulator/snackbar.png";
+	private static Images.ImageType images = Images.ImageType.Snackbar;
 	private static String facilityName = "Snackbar";
 
     public SnackBar(int x, int y) {
-        super(imageLocation, x, y, 1, 0, SimulatorPane.Objects.SNACKBAR);
+        super(images, x, y, 1, 0, SimulatorPane.Objects.SNACKBAR);
     }
 
     public SnackBar(int x, int y, double scale, double distance) {
-        super(imageLocation, x, y, scale, distance, SimulatorPane.Objects.SNACKBAR);
+        super(images, x, y, scale, distance, SimulatorPane.Objects.SNACKBAR);
     }
     
     public String getFacilityName(){

+ 7 - 4
src/gui/simulator/facilities/Stage.java

@@ -1,19 +1,22 @@
 package gui.simulator.facilities;
 
+import java.io.Serializable;
+
 import gui.simulator.DrawEngine;
+import gui.simulator.Images;
 import gui.simulator.SimulatorPane;
 
-public class Stage extends DrawEngine {
+public class Stage extends DrawEngine implements Serializable{
 
-	private static String imageLocation = "/simulator/tent.png";
+	private static Images.ImageType images = Images.ImageType.Tent;
 	private static String facilityName = "Stage";
 
     public Stage(int x, int y) {
-        super(imageLocation, x, y, 1, 0,SimulatorPane.Objects.STAGE);
+        super(images, x, y, 1, 0,SimulatorPane.Objects.STAGE);
     }
 
     public Stage(int x, int y, double scale, double distance) {
-        super(imageLocation, x, y, scale, distance,SimulatorPane.Objects.STAGE);
+        super(images, x, y, scale, distance,SimulatorPane.Objects.STAGE);
     }
     
     public String getFacilityName(){