Supermaniac101 10 anni fa
parent
commit
bd82728b83

+ 39 - 0
src/agenda/Time.java

@@ -0,0 +1,39 @@
+package agenda;
+
+import java.io.Serializable;
+
+/**
+ * Created by gjoosen on 07/02/15.
+ */
+public class Time implements Serializable {
+    
+    private int hours, minutes;
+    
+    public Time(int hours, int minutes){
+        this.hours = hours;
+        this.minutes = minutes;
+    }
+
+    public int getHours() {
+        return hours;
+    }
+
+    public int getMinutes() {
+        return minutes;
+    }
+    
+    @Override
+    public String toString(){
+        return this.numberToTimeDigits(this.hours) + ":" + this.numberToTimeDigits(this.minutes);
+    }
+    
+    private String numberToTimeDigits(int h){
+        String hours;
+        if(h == 0 || h == 1 || h == 2 || h == 3 || h == 4 || h == 5 || h == 6 || h == 7 || h == 8 || h == 9){
+            hours = "0" + h;
+        }else {
+            hours = String.valueOf(h);
+        }
+        return hours;
+    }
+}

+ 35 - 0
src/gui/simulator/AccessPoint.java

@@ -0,0 +1,35 @@
+package gui.simulator;
+
+import java.awt.geom.Rectangle2D;
+import java.io.Serializable;
+
+public class AccessPoint extends DrawEngine implements Serializable {
+	
+	private static Images.ImageType images = Images.ImageType.Entrance;
+	private static String facilityName = "Ingang";
+	private Terrain terrain;
+	
+	
+    //TODO change visilibty
+    public AccessPoint(Terrain terrain, int x, int y) {
+        super(images, x, y, 1, 0, SimulatorPane.Objects.ENTRANCE, terrain, new Rectangle2D.Double(-10, -10, 430, 170), true);
+        this.terrain = terrain;
+    }
+
+    public AccessPoint(Terrain terrain, int x, int y, double scale, double distance) {
+        super(images, x, y, scale, distance, SimulatorPane.Objects.ENTRANCE, terrain, new Rectangle2D.Double(-10, -10, 430, 170), true);
+        this.terrain = terrain;
+    }
+    
+    public AccessPoint(int x, int y, double scale, double distance, Terrain terrain) {
+        super(images, x, y, scale, distance, SimulatorPane.Objects.ENTRANCE, terrain, new Rectangle2D.Double(-10, -10, 430, 170), true);
+        this.terrain = terrain;
+    }
+    
+    public String getFacilityName(){
+    	return facilityName;
+    }
+    
+    
+    
+}

+ 60 - 0
src/gui/simulator/Border.java

@@ -0,0 +1,60 @@
+package gui.simulator;
+
+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 implements Serializable {
+
+	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, Terrain terrain) {
+        super(images, x, y, 1, 0, SimulatorPane.Objects.BORDER, terrain, null, false);
+    }
+    
+    public String getFacilityName(){
+    	return facilityName;
+    }
+    
+    @Override
+    public boolean contains(Point2D point){
+        Shape shape = new Rectangle2D.Double(0, 0, getWidth(), getHeight());
+        return this.getAffineTransform().createTransformedShape(shape).contains(point);
+    }
+    
+    @Override
+    public void draw(Graphics2D g){
+        g.drawRect((int)getX(), (int)getY(), getHeight(),getWidth());
+    }
+    @Override
+    public void setRotation(double rotation) {
+    }
+    @Override
+    public double getScale() {
+    return 0.0;
+    }
+    @Override
+    public void setScale(double scale) {
+    
+    }
+    @Override
+    public int getWidth(){
+    	return width;
+    }
+    @Override
+    public int getHeight(){
+    	return height;
+    }
+    @Override
+    public double getRotation() {
+    	return 0.0;
+    }
+
+}

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

@@ -81,21 +81,6 @@ public abstract class DrawEngine implements Serializable{
         this.terrain.removeWalkingPaths(this);
     }
     
-    public void changeLocation(Location loc){
-		switch(loc){
-		case NORTH:
-			//Visitors spawn north
-		case EAST:
-			//Visitors spawn east
-		case SOUTH:
-			//Visitors spawn south
-		case WEST:
-			//Visitors spawn west
-		default:
-			break;
-		}
-	}
-
     //getters and setters down here
     public double getX() {
         return x;

+ 26 - 0
src/gui/simulator/ExitPoint.java

@@ -0,0 +1,26 @@
+package gui.simulator;
+
+import java.awt.geom.Rectangle2D;
+import java.io.Serializable;
+
+public class ExitPoint extends DrawEngine implements Serializable {
+	
+	private static Images.ImageType images = Images.ImageType.Exit;
+	private static String facilityName = "Uitgang";
+	private Terrain terrain;
+
+    //TODO change visibility
+    public ExitPoint(Terrain terrain, int x, int y, double scale, double distance) {
+        super(images, x, y, scale, distance, SimulatorPane.Objects.EXIT, terrain, new Rectangle2D.Double(-10, -10, 430, 170), true);
+        this.terrain = terrain;
+    }
+    
+    public ExitPoint(int x, int y, double scale, double distance, Terrain terrain) {
+        super(images, x, y, scale, distance, SimulatorPane.Objects.EXIT, terrain, new Rectangle2D.Double(-10, -10, 430, 170), true);
+        this.terrain = terrain;
+    }
+
+    public String getFacilityName(){
+    	return facilityName;
+    }
+}

+ 5 - 0
src/gui/simulator/MarkedArea.java

@@ -0,0 +1,5 @@
+package gui.simulator;
+
+public class MarkedArea {
+
+}

+ 15 - 5
src/gui/simulator/Terrain.java

@@ -58,6 +58,7 @@ public class Terrain extends JPanel {
 	private Topbar topbar;
 	private Agenda agenda;
 	private WalkingPath currentpath;
+	
 
 	private static TextPaint background;
 	private int festivalheight, festivalwidth, pathgenerate, maxvisitors; 
@@ -69,6 +70,7 @@ public class Terrain extends JPanel {
 	transient Cursor rotate, pathpoint;
 	private Point lastMousePosition;
 	public enum Location{NORTH, EAST, SOUTH, WEST};
+	private static Location location;
 
 	public Terrain(int length, int width, SimulatorPane.Terrains terrain, Agenda agenda, SimulatorPane simulator){
 		//get values
@@ -225,7 +227,7 @@ public class Terrain extends JPanel {
 				if(dragObject != null){
 					if(SwingUtilities.isLeftMouseButton(e) && (dragObject instanceof AccessPoint || dragObject instanceof ExitPoint)){    
 						if(clickPoint.getX()<200){
-							dragObject.changeLocation(Location.WEST);
+							location = Location.SOUTH;
 							dragObject.setX(-75);
 							dragObject.setRotation(90);
 							if(dragObject.getY()<80){
@@ -237,7 +239,7 @@ public class Terrain extends JPanel {
 							}   
 						} else if (clickPoint.getX()>200 && clickPoint.getX()< getFestivalWidth()-200){
 							if(clickPoint.getY()<(getFestivalHeight()/2)){
-								dragObject.changeLocation(Location.NORTH);
+								location = Location.NORTH;
 								dragObject.setY(0);
 								dragObject.setRotation(180);
 
@@ -250,7 +252,7 @@ public class Terrain extends JPanel {
 								}   
 
 							} else if(clickPoint.getY()>(getFestivalHeight()/2)){
-								dragObject.changeLocation(Location.SOUTH);
+								location = Location.WEST;
 								dragObject.setY(getFestivalHeight()-75);
 								dragObject.setRotation(180);
 
@@ -263,7 +265,7 @@ public class Terrain extends JPanel {
 								}    
 							}
 						} else if(clickPoint.getX()>getFestivalWidth()-200){
-							dragObject.changeLocation(Location.EAST);
+							location = Location.EAST;
 							dragObject.setX(getFestivalWidth()-125);
 							dragObject.setRotation(90);
 							if(dragObject.getY()<80){
@@ -460,7 +462,15 @@ public class Terrain extends JPanel {
 			if(!entrances.isEmpty())
 				startpoint = entrances.get((int)(Math.random()*entrances.size())).getCenter();
 			if(startpoint != null)  //No entrance found , stop adding people. 
-				visitors.add(new Visitor(new Point2D.Double(-100-Math.random()*200, getFestivalHeight()-Math.random()*getFestivalHeight()), startpoint, this));
+				if(location == Location.NORTH){
+					visitors.add(new Visitor(new Point2D.Double(getFestivalWidth()-Math.random()*getFestivalWidth(), -100-Math.random()*200), startpoint, this));
+				} else if(location == Location.EAST){
+					visitors.add(new Visitor(new Point2D.Double(getFestivalWidth()+Math.random()*200, getFestivalHeight()-Math.random()*getFestivalHeight()), startpoint, this));
+				} else if(location == Location.SOUTH){
+					visitors.add(new Visitor(new Point2D.Double(-100-Math.random()*200, getFestivalHeight()-Math.random()*getFestivalHeight()), startpoint, this));
+				} else if(location == Location.WEST){
+					visitors.add(new Visitor(new Point2D.Double(getFestivalWidth()-Math.random()*getFestivalWidth(), getFestivalHeight()+Math.random()*200), startpoint, this));
+				}
 		}
 		topbar.recalculate();
 		if(topbar.getTime().get(Calendar.HOUR_OF_DAY) > 20 && topbar.getTime().get(Calendar.HOUR_OF_DAY) < 25){

+ 26 - 0
src/gui/simulator/facilities/Stage.java

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