|
|
@@ -34,10 +34,10 @@ public class Terrain extends JPanel {
|
|
|
private Draw dragObject, selectedObject;
|
|
|
private BufferedImage background;
|
|
|
|
|
|
- private int festivallength, festivalwidth;
|
|
|
- private int sideBarWidth = 200;
|
|
|
+ private int festivalheight, festivalwidth;
|
|
|
private SimulatorPane.Terrains terrain;
|
|
|
- Point2D cameraPoint = new Point2D.Double(festivalwidth/2,festivallength/2);
|
|
|
+ private Sidebar sidebar;
|
|
|
+ Point2D cameraPoint = new Point2D.Double(festivalwidth/2,festivalheight/2);
|
|
|
float cameraScale = 1;
|
|
|
|
|
|
Point2D lastClickPosition;
|
|
|
@@ -45,8 +45,9 @@ public class Terrain extends JPanel {
|
|
|
|
|
|
public Terrain(int length, int width, SimulatorPane.Terrains terrain){
|
|
|
//get values
|
|
|
- setFestivalLength(length);
|
|
|
+ setFestivalHeight(length);
|
|
|
setFestivalWidth(width);
|
|
|
+ sidebar = new Sidebar(200, getFestivalHeight(), this);
|
|
|
this.terrain = terrain;
|
|
|
//set terrainbackground
|
|
|
switch(terrain){
|
|
|
@@ -106,7 +107,7 @@ public class Terrain extends JPanel {
|
|
|
//if selected in sidebar
|
|
|
getFacility(e);
|
|
|
//else selected in terrain
|
|
|
- if(e.getX() > sideBarWidth){
|
|
|
+ if(e.getX() > sidebar.getSideBarWidth()){
|
|
|
for(Draw drawObject: entities){
|
|
|
if(drawObject.contains(clickPoint)){
|
|
|
dragObject = drawObject;
|
|
|
@@ -196,28 +197,30 @@ public class Terrain extends JPanel {
|
|
|
Graphics2D g2 = (Graphics2D) g;
|
|
|
|
|
|
//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 object4 = new ExitPoint(this, 0,700, 0.5, 10);
|
|
|
- object4.draw(g2);
|
|
|
- g2.drawString("uitgang", 70, 800);
|
|
|
+ sidebar.draw(g2);
|
|
|
+
|
|
|
+// g2.setClip(new Rectangle2D.Double(0,0, 200, 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 object4 = new ExitPoint(this, 0,700, 0.5, 10);
|
|
|
+// object4.draw(g2);
|
|
|
+// g2.drawString("uitgang", 70, 800);
|
|
|
|
|
|
//draw simulation field
|
|
|
g2.setClip(new Rectangle2D.Double(200, 0, getWidth()-200, getHeight()));
|
|
|
@@ -226,7 +229,7 @@ public class Terrain extends JPanel {
|
|
|
g2.setTransform(getCamera());
|
|
|
TexturePaint p = new TexturePaint(background, new Rectangle2D.Double(0, 0, 200, 200));
|
|
|
g2.setPaint(p);
|
|
|
- g2.fill(new Rectangle2D.Double(0,0,festivalwidth,festivallength));
|
|
|
+ g2.fill(new Rectangle2D.Double(0,0,festivalwidth,festivalheight));
|
|
|
for(int i = 0; i < (festivalwidth/100); i++){
|
|
|
|
|
|
};
|
|
|
@@ -291,16 +294,16 @@ public class Terrain extends JPanel {
|
|
|
return tx;
|
|
|
}
|
|
|
|
|
|
- public void setFestivalLength(int length){
|
|
|
- this.festivallength = length;
|
|
|
+ public void setFestivalHeight(int height){
|
|
|
+ this.festivalheight = height;
|
|
|
}
|
|
|
|
|
|
public void setFestivalWidth(int width){
|
|
|
this.festivalwidth = width;
|
|
|
}
|
|
|
|
|
|
- public int getFestivalLength(){
|
|
|
- return festivallength;
|
|
|
+ public int getFestivalHeight(){
|
|
|
+ return festivalheight;
|
|
|
}
|
|
|
public int getFestivalWidth(){
|
|
|
return festivalwidth;
|