فهرست منبع

Added snackbar, fixed walkingpath bug, and redid accespoint & exitpoint

Supermaniac101 10 سال پیش
والد
کامیت
d7d4e34890

BIN
res/simulator/border.png


BIN
res/simulator/snackbar.png


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

@@ -19,38 +19,4 @@ public class AccessPoint extends DrawEngine {
     public String getFacilityName(){
     	return facilityName;
     }
-    
-    @Override
-    public void setX(double x){
-    	double oldPosX = this.getX();
-    	double oldPosY = this.getY();
-    	if(x<0){
-    		this.setRotation(90);
-    		this.setX(0);
-    	} else if(x>9*terrain.getWidth()/10){
-    		this.setX(9*terrain.getWidth()/10);
-    		this.setRotation(90);
-    	} else if(x>0 && x<9*terrain.getWidth()/10 && this.getY() > 50 && this.getY() < terrain.getFestivalHeight()-150){
-    		this.setX(oldPosX);
-    		this.setY(oldPosY);
-    	} else {
-    		this.setX(x);
-    	}
-    }
-
-    @Override
-    public void setY(double y){
-    	double oldPosY = this.getY();
-    	if(y<50){
-    		this.setRotation(0);
-    		this.setY(50);
-    	} else if(y>11*terrain.getFestivalHeight()/12){
-    		this.setRotation(0);
-    		this.setY(11*terrain.getFestivalHeight()/12);
-    	} else if(this.getX()>terrain.getWidth()/10 && this.getX() <9*terrain.getWidth()/10 && this.getY()> 50 && this.getY() < terrain.getFestivalHeight()-150){
-    		this.setY(oldPosY);
-    	} else {
-    		this.setY(y);
-    	}
-    }
 }

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

@@ -0,0 +1,59 @@
+package gui.simulator;
+
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+
+
+public class Border extends DrawEngine {
+
+	private static String imageLocation = "/simulator/border.png";
+	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);
+    }
+    
+    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;
+    }
+
+}

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

@@ -94,6 +94,7 @@ public abstract class DrawEngine {
     public int getHeight(){
         return this.image.getHeight(null);
     }
+    
     public double getRotation() {
         return rotation;
     }

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

@@ -15,38 +15,4 @@ public class ExitPoint extends DrawEngine {
     public String getFacilityName(){
     	return facilityName;
     }
-    
-    @Override
-    public void setX(double x){
-    	double oldPosX = this.getX();
-    	double oldPosY = this.getY();
-    	if(x<0){
-    		this.setRotation(90);
-    		this.setX(0);
-    	} else if(x>9*terrain.getWidth()/10){
-    		this.setX(9*terrain.getWidth()/10);
-    		this.setRotation(90);
-    	} else if(x>0 && x<9*terrain.getWidth()/10 && this.getY() > 50 && this.getY() < terrain.getFestivalHeight()-150){
-			this.setX(oldPosX);
-			this.setY(oldPosY);
-    	} else {
-			this.setX(x);
-    	}
-    }
-
-    @Override
-    public void setY(double y){
-    	double oldPosY = this.getY();
-    	if(y<50){
-    		this.setRotation(0);
-    		this.setY(50);
-    	} else if(y>11*terrain.getFestivalHeight()/12){
-    		this.setRotation(0);
-    		this.setY(11*terrain.getFestivalHeight()/12);
-    	} else if(this.getX()>terrain.getWidth()/10 && this.getX()<9*terrain.getWidth()/10 && this.getY() > 50 && this.getY() < terrain.getFestivalHeight()-150){
-    		this.setY(oldPosY);
-    	} else {
-    		this.setY(y);
-    	}
-    }
 }

+ 19 - 11
src/gui/simulator/Sidebar.java

@@ -2,6 +2,7 @@ package gui.simulator;
 
 import gui.simulator.facilities.RestRoom;
 import gui.simulator.facilities.SimulatorStage;
+import gui.simulator.facilities.SnackBar;
 
 import java.awt.BasicStroke;
 import java.awt.Color;
@@ -48,16 +49,19 @@ public class Sidebar {
         //draw objects
         DrawEngine object1 = new SimulatorStage(20,100, 0.4, 10);
         object1.draw(g2);
-        g2.drawString("stage", 80, 275);
-        DrawEngine object2 = new RestRoom(60,350, 1 , 10);
+        g2.drawString("Stage", 80, 250);
+        DrawEngine object2 = new RestRoom(60,275, 1 , 10);
         object2.draw(g2);
-        g2.drawString("toilettage", 70, 500);
-        DrawEngine object3 = new AccessPoint(terrain, 0,550, 0.5, 10);
+        g2.drawString("Toilettage", 65, 400);
+        DrawEngine object3 = new AccessPoint(terrain, 0,425, 0.5, 10);
         object3.draw(g2);
-        g2.drawString("ingang", 70, 675);
-        DrawEngine object4 = new ExitPoint(terrain, 0,700, 0.5, 10);
+        g2.drawString("Ingang", 70, 500);
+        DrawEngine object4 = new ExitPoint(terrain, 0,525, 0.5, 10);
         object4.draw(g2);
-        g2.drawString("uitgang", 70, 800);
+        g2.drawString("Uitgang", 70, 600);
+        DrawEngine object5 = new SnackBar(0,620, 0.5, 10);
+        object5.draw(g2);
+        g2.drawString("Snackbar", 70, 825);
     }
 	
     private void getFacility(MouseEvent e){
@@ -65,20 +69,24 @@ public class Sidebar {
     	DrawEngine dragObject = null;
     	if(e.getX() < sideBarWidth)
 		{
-			if(e.getY() < 300){
+			if(e.getY() > 100 && e.getY() < 260){
 				dragObject = new SimulatorStage((int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10);
 				terrain.setDragObject(dragObject);
-			}else if(e.getY() > 300 && e.getY() < 550){
+			}else if(e.getY() >= 260 && e.getY() < 425){
 				dragObject = new RestRoom((int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10);
 				terrain.setDragObject(dragObject);
-			}else if(e.getY() > 550 && e.getY() < 800){
+			}else if(e.getY() >= 430 && e.getY() < 510){
 				dragObject = new AccessPoint(terrain, (int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10);
 				terrain.setDragObject(dragObject);
 			}
-			else if(e.getY() > 800){
+			else if(e.getY() >= 510 && e.getY() < 610){
 				dragObject = new ExitPoint(terrain, (int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10);
 				terrain.setDragObject(dragObject);
 			}
+			else if(e.getY() > 610 && e.getY() < terrain.getFestivalHeight()){
+				dragObject = new SnackBar((int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10);
+				terrain.setDragObject(dragObject);
+			}
 			if(dragObject != null)
 				terrain.addEntity(dragObject);
 		}

+ 1 - 1
src/gui/simulator/SimulatorPane.java

@@ -21,7 +21,7 @@ public class SimulatorPane extends JPanel{
 	//terrain type enums
 	public enum Terrains{BEACH, GRASS, URBAN, UNDEFINED};
 	//object type enums
-	public enum Objects{STAGE, DRINK, FOOD, RESTROOM, SUNGLAS, WAYPOINT, ENTRANCE, EXIT};
+	public enum Objects{STAGE, DRINK, SNACKBAR, RESTROOM, SUNGLAS, WAYPOINT, ENTRANCE, EXIT, BORDER};
 	
 	public SimulatorPane(Agenda agenda, int length, int width, Terrains terrains){
         super.setLayout(new BorderLayout());

+ 28 - 4
src/gui/simulator/Terrain.java

@@ -3,6 +3,7 @@ package gui.simulator;
 import agenda.Agenda;
 import gui.simulator.facilities.RestRoom;
 import gui.simulator.facilities.SimulatorStage;
+import gui.simulator.facilities.SnackBar;
 
 import java.awt.*;
 import java.awt.event.MouseAdapter;
@@ -104,17 +105,26 @@ public class Terrain extends JPanel {
 
     private void getFacility(MouseEvent e){
     	Point2D clickPoint = getClickPoint(e.getPoint());
+    	DrawEngine dragObject = null;
     	if(e.getX() < sideBarWidth)
 		{
-			if(e.getY() < 300){
+    		if(e.getY() > 100 && e.getY() < 260){
 				dragObject = new SimulatorStage((int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10);
-			}else if(e.getY() > 300 && e.getY() < 550){
+				setDragObject(dragObject);
+			}else if(e.getY() >= 260 && e.getY() < 425){
 				dragObject = new RestRoom((int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10);
-			}else if(e.getY() > 550 && e.getY() < 800){
+				setDragObject(dragObject);
+			}else if(e.getY() >= 430 && e.getY() < 510){
 				dragObject = new AccessPoint(this, (int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10);
+				setDragObject(dragObject);
 			}
-			else if(e.getY() > 800){
+			else if(e.getY() >= 510 && e.getY() < 610){
 				dragObject = new ExitPoint(this, (int)clickPoint.getX(),(int)clickPoint.getY(), 0.5, 10);
+				setDragObject(dragObject);
+			}
+			else if(e.getY() > 610 && e.getY() < getFestivalHeight()){
+				dragObject = new SnackBar((int)clickPoint.getX(),(int)clickPoint.getY(), 0.3, 10);
+				setDragObject(dragObject);
 			}
 			entities.add(dragObject);
 		}
@@ -402,6 +412,20 @@ public class Terrain extends JPanel {
     //getters and setters for sidebar
     public void setDragObject(DrawEngine dragObject){
     	this.dragObject = dragObject;
+
+//    	if(this.dragObject instanceof AccessPoint || this.dragObject instanceof ExitPoint){
+//    		this.entities.add(new Border(-1000, -1000, getFestivalWidth()+2000, 999));
+//    		this.entities.add(new Border(-1000, 0, 999, getFestivalHeight()));
+//    		this.entities.add(new Border(-1000, getFestivalHeight(), getFestivalWidth()+2000, getFestivalHeight()+1000));
+//    		this.entities.add(new Border(getFestivalWidth(), -1000, 1000, getFestivalHeight()+2000));
+//    		this.entities.add(new Border(150, 150, getFestivalWidth()-150, getFestivalHeight()-150));
+//    	} else {
+//    		for(DrawEngine object: entities){
+//    			if(object instanceof Border){
+//    				entities.remove(object);
+//    			}
+//    		}
+//    	}
     }
     
     public DrawEngine getDragObject(){

+ 3 - 1
src/gui/simulator/WalkingPath.java

@@ -56,11 +56,13 @@ public class WalkingPath {
 		}
 	}
 	public void paint(Graphics2D g2){
-		g2.setStroke(new BasicStroke(40,BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
+		
 		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.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));
 	}
 	
 	

+ 0 - 5
src/gui/simulator/facilities/BuildingObject.java

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

+ 18 - 1
src/gui/simulator/facilities/SnackBar.java

@@ -1,5 +1,22 @@
 package gui.simulator.facilities;
 
-public class SnackBar {
+import gui.simulator.DrawEngine;
+import gui.simulator.SimulatorPane;
 
+public class SnackBar extends DrawEngine{
+
+	private static String imageLocation = "/simulator/snackbar.png";
+	private static String facilityName = "Snackbar";
+
+    public SnackBar(int x, int y) {
+        super(imageLocation, 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);
+    }
+    
+    public String getFacilityName(){
+    	return facilityName;
+    }
 }

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

@@ -0,0 +1,22 @@
+package gui.simulator.facilities;
+
+import gui.simulator.DrawEngine;
+import gui.simulator.SimulatorPane;
+
+public class Stage extends DrawEngine {
+
+	private static String imageLocation = "/simulator/tent.png";
+	private static String facilityName = "Stage";
+
+    public Stage(int x, int y) {
+        super(imageLocation, 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);
+    }
+    
+    public String getFacilityName(){
+    	return facilityName;
+    }
+}