Jelajahi Sumber

Added grid, again...

jancoow 10 tahun lalu
induk
melakukan
0d038384dd
1 mengubah file dengan 14 tambahan dan 25 penghapusan
  1. 14 25
      src/gui/simulator/Terrain.java

+ 14 - 25
src/gui/simulator/Terrain.java

@@ -40,6 +40,7 @@ public class Terrain extends JPanel {
     private SimulatorPane.Terrains terrain;
     Point2D cameraPoint = new Point2D.Double(festivalwidth/2,festivalheight/2);
 	float cameraScale = 1;
+	private boolean grid;
 	
 	Point2D lastClickPosition;
 	Point lastMousePosition;
@@ -48,6 +49,7 @@ public class Terrain extends JPanel {
     	//get values
     	setFestivalHeight(length);
     	setFestivalWidth(width);
+    	grid = true;
     	this.terrain = terrain;
     	//initialize sidebar
     	sidebar = new Sidebar(200, getFestivalHeight(), this);
@@ -199,27 +201,7 @@ public class Terrain extends JPanel {
         Graphics2D g2 = (Graphics2D) g;
         sidebar.draw(g2);
         
-        //draw sidebar
-//        g2.setClip(new Rectangle2D.Double(0,0, sideBarWidth, getHeight()));
-//        g2.setColor(Color.GRAY);
-//        g2.fill3DRect(0, 0, 200, 50, true);
-//        g2.setColor(Color.WHITE);
-//        g2.setFont(new Font("Serif", Font.BOLD, 20));
-//        g2.drawString("Drag and drop", 30, 25);
-//        g2.setColor(Color.BLACK);
-//        g2.setStroke(new BasicStroke(5));
-//        g2.drawLine(199, 0, 199, getHeight());
-//        //draw objects
-//        Draw object1 = new Stage(0,50);
-//        object1.draw(g2);
-//        g2.drawString("stage", 80, 275);
-//        Draw object2 = new RestRoom(0,300, 0.5, 10);
-//        object2.draw(g2);
-//        g2.drawString("toilettage", 70, 525);
-//        Draw object3 = new AccessPoint(this, 0,550, 0.5, 10);
-//        object3.draw(g2);
-//        g2.drawString("ingang", 70, 675);
-		
+
 		//draw simulation field
 		g2.setClip(new Rectangle2D.Double(200, 0, getWidth()-200, getHeight()));
 		AffineTransform oldTransform = g2.getTransform();
@@ -228,10 +210,17 @@ public class Terrain extends JPanel {
         TexturePaint p = new TexturePaint(background, new Rectangle2D.Double(0, 0, 200, 200));
 		g2.setPaint(p);
 		g2.fill(new Rectangle2D.Double(0,0,festivalwidth,festivalheight));
-		for(int i = 0; i < (festivalwidth/100); i++){
-			
-		};
-        
+		if(grid){
+			g2.setColor(new Color(160,160,160,120));
+			g2.setStroke(new BasicStroke(1));
+			for(int i = 0; i < (getFestivalWidth()/10)+1; i++){
+				g2.drawLine(i*10, 0, i*10, getFestivalHeight());
+			};
+			for(int i = 0; i < (getFestivalHeight()/10)+1; i++){
+				g2.drawLine(0, i*10, getFestivalWidth(), i*10);
+			};
+		}
+		
 		for(Draw drawObject: entities){
             drawObject.draw(g2); 
         }