|
@@ -1,6 +1,6 @@
|
|
|
package gui.simulator;
|
|
package gui.simulator;
|
|
|
|
|
|
|
|
-import gui.simulator.Images.ImageType;
|
|
|
|
|
|
|
+import gui.simulator.Images.TextPaint;
|
|
|
import gui.simulator.SimulatorPane.Objects;
|
|
import gui.simulator.SimulatorPane.Objects;
|
|
|
import gui.simulator.facilities.SimulatorStage;
|
|
import gui.simulator.facilities.SimulatorStage;
|
|
|
|
|
|
|
@@ -40,99 +40,98 @@ import agenda.Agenda;
|
|
|
|
|
|
|
|
public class Terrain extends JPanel {
|
|
public class Terrain extends JPanel {
|
|
|
|
|
|
|
|
- private List<DrawEngine> entities;
|
|
|
|
|
- private Point2D oldPosition;
|
|
|
|
|
|
|
+ private List<DrawEngine> entities;
|
|
|
|
|
+ private Point2D oldPosition;
|
|
|
private double oldRotation, oldScale;
|
|
private double oldRotation, oldScale;
|
|
|
- private DrawEngine dragObject, selectedObject;
|
|
|
|
|
- private ImageType background;
|
|
|
|
|
- private Sidebar sidebar;
|
|
|
|
|
- private Topbar topbar;
|
|
|
|
|
-
|
|
|
|
|
- private int festivalheight, festivalwidth;
|
|
|
|
|
- private int sideBarWidth = 200;
|
|
|
|
|
-
|
|
|
|
|
- private int pathgenerate, maxvisitors;
|
|
|
|
|
- private WalkingPath currentpath;
|
|
|
|
|
-
|
|
|
|
|
- Point2D cameraPoint = new Point2D.Double(festivalwidth/2,festivalheight/2);
|
|
|
|
|
|
|
+ private DrawEngine dragObject, selectedObject;
|
|
|
|
|
+ private static TextPaint background;
|
|
|
|
|
+ private Sidebar sidebar;
|
|
|
|
|
+ private Topbar topbar;
|
|
|
|
|
+
|
|
|
|
|
+ private int festivalheight, festivalwidth;
|
|
|
|
|
+ private int sideBarWidth = 200;
|
|
|
|
|
+
|
|
|
|
|
+ private int pathgenerate, maxvisitors;
|
|
|
|
|
+ private WalkingPath currentpath;
|
|
|
|
|
+
|
|
|
|
|
+ Point2D cameraPoint = new Point2D.Double(festivalwidth/2,festivalheight/2);
|
|
|
float cameraScale = 1;
|
|
float cameraScale = 1;
|
|
|
private boolean grid;
|
|
private boolean grid;
|
|
|
private ArrayList<Visitor> visitors;
|
|
private ArrayList<Visitor> visitors;
|
|
|
private WalkingPathArrayList paths;
|
|
private WalkingPathArrayList paths;
|
|
|
Cursor rotate, pathpoint;
|
|
Cursor rotate, pathpoint;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
Point2D lastClickPosition;
|
|
Point2D lastClickPosition;
|
|
|
Point lastMousePosition;
|
|
Point lastMousePosition;
|
|
|
Point2D lastMovedMousePosition;
|
|
Point2D lastMovedMousePosition;
|
|
|
TexturePaint p;
|
|
TexturePaint p;
|
|
|
|
|
|
|
|
private Agenda agenda;
|
|
private Agenda agenda;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
public enum Location{NORTH, EAST, SOUTH, WEST};
|
|
public enum Location{NORTH, EAST, SOUTH, WEST};
|
|
|
|
|
|
|
|
- public Terrain(int length, int width, SimulatorPane.Terrains terrain, Agenda agenda, SimulatorPane simulator){
|
|
|
|
|
- //get values
|
|
|
|
|
- maxvisitors = 30;
|
|
|
|
|
- setFestivalHeight(length);
|
|
|
|
|
- setFestivalWidth(width);
|
|
|
|
|
- visitors = new ArrayList<Visitor>();
|
|
|
|
|
- paths = new WalkingPathArrayList();
|
|
|
|
|
-
|
|
|
|
|
- createCustomCursors();
|
|
|
|
|
- //initialize sidebar & topbar
|
|
|
|
|
- sidebar = new Sidebar(sideBarWidth, 3000, this);
|
|
|
|
|
- topbar = new Topbar(this, simulator, agenda);
|
|
|
|
|
- addMouseListener(topbar);
|
|
|
|
|
-
|
|
|
|
|
- //set terrainbackground
|
|
|
|
|
- switch(terrain){
|
|
|
|
|
|
|
+ public Terrain(int length, int width, SimulatorPane.Terrains terrain, Agenda agenda, SimulatorPane simulator){
|
|
|
|
|
+ //get values
|
|
|
|
|
+ maxvisitors = 30;
|
|
|
|
|
+ setFestivalHeight(length);
|
|
|
|
|
+ setFestivalWidth(width);
|
|
|
|
|
+ visitors = new ArrayList<Visitor>();
|
|
|
|
|
+ paths = new WalkingPathArrayList();
|
|
|
|
|
+
|
|
|
|
|
+ createCustomCursors();
|
|
|
|
|
+ //initialize sidebar & topbar
|
|
|
|
|
+ sidebar = new Sidebar(sideBarWidth, 3000, this);
|
|
|
|
|
+ topbar = new Topbar(this, simulator, agenda);
|
|
|
|
|
+ addMouseListener(topbar);
|
|
|
|
|
+
|
|
|
|
|
+ //set terrainbackground
|
|
|
|
|
+ switch(terrain){
|
|
|
case BEACH:
|
|
case BEACH:
|
|
|
- background = Images.ImageType.Sand;
|
|
|
|
|
|
|
+ background = Images.TextPaint.TPSand;
|
|
|
break;
|
|
break;
|
|
|
case GRASS:
|
|
case GRASS:
|
|
|
- background = Images.ImageType.Grass;
|
|
|
|
|
|
|
+ background = Images.TextPaint.TPGrass;
|
|
|
break;
|
|
break;
|
|
|
case URBAN:
|
|
case URBAN:
|
|
|
- background = Images.ImageType.Street;
|
|
|
|
|
|
|
+ background = Images.TextPaint.TPStreet;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- p = new TexturePaint(Images.getImage(background), new Rectangle2D.Double(0, 0, 200, 200));
|
|
|
|
|
-
|
|
|
|
|
- this.entities = new LinkedList();
|
|
|
|
|
- this.initEntities();
|
|
|
|
|
- this.listeners();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ this.entities = new LinkedList();
|
|
|
|
|
+ this.initEntities();
|
|
|
|
|
+ this.listeners();
|
|
|
this.agenda = agenda;
|
|
this.agenda = agenda;
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- 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;
|
|
lastClickPosition = clickPoint;
|
|
|
lastMousePosition = e.getPoint();
|
|
lastMousePosition = e.getPoint();
|
|
|
- //if selected in sidebar
|
|
|
|
|
|
|
+ //if selected in sidebar
|
|
|
sidebar.getFacility(e);
|
|
sidebar.getFacility(e);
|
|
|
- //else selected in terrain
|
|
|
|
|
- if(e.getX() > sideBarWidth){
|
|
|
|
|
- for(DrawEngine drawObject: entities){
|
|
|
|
|
- if(drawObject.contains(clickPoint)){
|
|
|
|
|
- if(pathgenerate == 1){
|
|
|
|
|
- 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);
|
|
|
|
|
- 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.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);
|
|
|
|
|
+ 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();
|
|
oldRotation = selectedObject.getScale();
|
|
|
oldScale = selectedObject.getScale();
|
|
oldScale = selectedObject.getScale();
|
|
|
|
|
|
|
@@ -154,163 +153,163 @@ public class Terrain extends JPanel {
|
|
|
dialog.pack();
|
|
dialog.pack();
|
|
|
dialog.setVisible(true);
|
|
dialog.setVisible(true);
|
|
|
}
|
|
}
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if(pathgenerate == 1){
|
|
|
|
|
- if(SwingUtilities.isRightMouseButton(e)){
|
|
|
|
|
- pathgenerate = 0;
|
|
|
|
|
- }
|
|
|
|
|
- }else if(pathgenerate > 1){
|
|
|
|
|
- if(SwingUtilities.isRightMouseButton(e)){
|
|
|
|
|
- currentpath.removeLastPoint();
|
|
|
|
|
- if(currentpath.getPath().size() == 0){
|
|
|
|
|
- pathgenerate = 0;
|
|
|
|
|
- }
|
|
|
|
|
- }else{
|
|
|
|
|
- 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){
|
|
|
|
|
+ if(SwingUtilities.isRightMouseButton(e)){
|
|
|
|
|
+ pathgenerate = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }else if(pathgenerate > 1){
|
|
|
|
|
+ if(SwingUtilities.isRightMouseButton(e)){
|
|
|
|
|
+ currentpath.removeLastPoint();
|
|
|
|
|
+ if(currentpath.getPath().size() == 0){
|
|
|
|
|
+ pathgenerate = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ 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.setRotation(oldRotation);
|
|
|
selectedObject.setScale(oldScale);
|
|
selectedObject.setScale(oldScale);
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- for(WalkingPath p:paths){
|
|
|
|
|
- p.reCalculate();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
|
|
|
|
- selectedObject = null;
|
|
|
|
|
- dragObject = null;
|
|
|
|
|
- repaint();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- addMouseMotionListener(new MouseMotionAdapter() {
|
|
|
|
|
- public void mouseMoved(MouseEvent e){
|
|
|
|
|
- lastMovedMousePosition = getClickPoint(e.getPoint());
|
|
|
|
|
- if(e.getX() < sidebar.getSideBarWidth()){
|
|
|
|
|
- setCursor(new Cursor(Cursor.HAND_CURSOR));
|
|
|
|
|
- }else if(pathgenerate >0){
|
|
|
|
|
- setCursor(pathpoint);
|
|
|
|
|
- }else if(topbar.containsMouse(e.getPoint())){
|
|
|
|
|
- setCursor(new Cursor(Cursor.HAND_CURSOR));
|
|
|
|
|
- }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 instanceof ExitPoint)){
|
|
|
|
|
- if(e.getX()<200){
|
|
|
|
|
- dragObject.changeLocation(Location.WEST);
|
|
|
|
|
- dragObject.setX(-75);
|
|
|
|
|
- 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 (e.getX()>200 && e.getX()< getFestivalWidth()-200){
|
|
|
|
|
- if(e.getY()<(getFestivalHeight()/2)){
|
|
|
|
|
- dragObject.changeLocation(Location.NORTH);
|
|
|
|
|
- dragObject.setY(0);
|
|
|
|
|
- dragObject.setRotation(180);
|
|
|
|
|
-
|
|
|
|
|
- if(dragObject.getX()<100){
|
|
|
|
|
- dragObject.setX(100);
|
|
|
|
|
- } else if(dragObject.getX()>getFestivalWidth()-200){
|
|
|
|
|
- dragObject.setY(getFestivalWidth()-200);
|
|
|
|
|
- } else {
|
|
|
|
|
- dragObject.setX(dragObject.getX() - (lastClickPosition.getX() - clickPoint.getX()));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- } else if(e.getY()>(getFestivalHeight()/2)){
|
|
|
|
|
- dragObject.changeLocation(Location.SOUTH);
|
|
|
|
|
- dragObject.setY(getFestivalHeight()-75);
|
|
|
|
|
- dragObject.setRotation(180);
|
|
|
|
|
-
|
|
|
|
|
- if(dragObject.getX()<100){
|
|
|
|
|
- dragObject.setX(100);
|
|
|
|
|
- } else if(dragObject.getX()>getFestivalWidth()-200){
|
|
|
|
|
- dragObject.setY(getFestivalWidth()-200);
|
|
|
|
|
- } else {
|
|
|
|
|
- dragObject.setX(dragObject.getX() - (lastClickPosition.getX() - clickPoint.getX()));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else if(e.getX()>getFestivalWidth()-200){
|
|
|
|
|
- dragObject.changeLocation(Location.EAST);
|
|
|
|
|
- dragObject.setX(getFestivalWidth()-125);
|
|
|
|
|
- dragObject.setRotation(90);
|
|
|
|
|
- if(dragObject.getY()<80){
|
|
|
|
|
- dragObject.setY(80);
|
|
|
|
|
- } else if(dragObject.getY()>getFestivalHeight()-200){
|
|
|
|
|
- dragObject.setY(getFestivalHeight()-150);
|
|
|
|
|
- dragObject.setRotation(90);
|
|
|
|
|
- } 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()));
|
|
|
|
|
- }
|
|
|
|
|
- for(WalkingPath p:paths){
|
|
|
|
|
- p.reCalculate();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for(WalkingPath p:paths){
|
|
|
|
|
+ p.reCalculate();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
|
|
|
|
+ selectedObject = null;
|
|
|
|
|
+ dragObject = null;
|
|
|
|
|
+ repaint();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ addMouseMotionListener(new MouseMotionAdapter() {
|
|
|
|
|
+ public void mouseMoved(MouseEvent e){
|
|
|
|
|
+ lastMovedMousePosition = getClickPoint(e.getPoint());
|
|
|
|
|
+ if(e.getX() < sidebar.getSideBarWidth()){
|
|
|
|
|
+ setCursor(new Cursor(Cursor.HAND_CURSOR));
|
|
|
|
|
+ }else if(pathgenerate >0){
|
|
|
|
|
+ setCursor(pathpoint);
|
|
|
|
|
+ }else if(topbar.containsMouse(e.getPoint())){
|
|
|
|
|
+ setCursor(new Cursor(Cursor.HAND_CURSOR));
|
|
|
|
|
+ }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 instanceof ExitPoint)){
|
|
|
|
|
+ if(e.getX()<200){
|
|
|
|
|
+ dragObject.changeLocation(Location.WEST);
|
|
|
|
|
+ dragObject.setX(-75);
|
|
|
|
|
+ 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 (e.getX()>200 && e.getX()< getFestivalWidth()-200){
|
|
|
|
|
+ if(e.getY()<(getFestivalHeight()/2)){
|
|
|
|
|
+ dragObject.changeLocation(Location.NORTH);
|
|
|
|
|
+ dragObject.setY(0);
|
|
|
|
|
+ dragObject.setRotation(180);
|
|
|
|
|
+
|
|
|
|
|
+ if(dragObject.getX()<100){
|
|
|
|
|
+ dragObject.setX(100);
|
|
|
|
|
+ } else if(dragObject.getX()>getFestivalWidth()-200){
|
|
|
|
|
+ dragObject.setY(getFestivalWidth()-200);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ dragObject.setX(dragObject.getX() - (lastClickPosition.getX() - clickPoint.getX()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } else if(e.getY()>(getFestivalHeight()/2)){
|
|
|
|
|
+ dragObject.changeLocation(Location.SOUTH);
|
|
|
|
|
+ dragObject.setY(getFestivalHeight()-75);
|
|
|
|
|
+ dragObject.setRotation(180);
|
|
|
|
|
+
|
|
|
|
|
+ if(dragObject.getX()<100){
|
|
|
|
|
+ dragObject.setX(100);
|
|
|
|
|
+ } else if(dragObject.getX()>getFestivalWidth()-200){
|
|
|
|
|
+ dragObject.setY(getFestivalWidth()-200);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ dragObject.setX(dragObject.getX() - (lastClickPosition.getX() - clickPoint.getX()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if(e.getX()>getFestivalWidth()-200){
|
|
|
|
|
+ dragObject.changeLocation(Location.EAST);
|
|
|
|
|
+ dragObject.setX(getFestivalWidth()-125);
|
|
|
|
|
+ dragObject.setRotation(90);
|
|
|
|
|
+ if(dragObject.getY()<80){
|
|
|
|
|
+ dragObject.setY(80);
|
|
|
|
|
+ } else if(dragObject.getY()>getFestivalHeight()-200){
|
|
|
|
|
+ dragObject.setY(getFestivalHeight()-150);
|
|
|
|
|
+ dragObject.setRotation(90);
|
|
|
|
|
+ } 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()));
|
|
|
|
|
+ }
|
|
|
|
|
+ for(WalkingPath p:paths){
|
|
|
|
|
+ p.reCalculate();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
{
|
|
{
|
|
|
- setCursor(new Cursor(Cursor.MOVE_CURSOR));
|
|
|
|
|
|
|
+ setCursor(new Cursor(Cursor.MOVE_CURSOR));
|
|
|
cameraPoint = new Point2D.Double(
|
|
cameraPoint = new Point2D.Double(
|
|
|
cameraPoint.getX() + (lastMousePosition.getX() - e.getX()),
|
|
cameraPoint.getX() + (lastMousePosition.getX() - e.getX()),
|
|
|
cameraPoint.getY() + (lastMousePosition.getY() - e.getY())
|
|
cameraPoint.getY() + (lastMousePosition.getY() - e.getY())
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
- repaint();
|
|
|
|
|
|
|
+ repaint();
|
|
|
lastMousePosition = e.getPoint();
|
|
lastMousePosition = e.getPoint();
|
|
|
lastClickPosition = clickPoint;
|
|
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();
|
|
double oldscale = object.getScale();
|
|
|
if(oldscale < 0.3){
|
|
if(oldscale < 0.3){
|
|
|
if((e.getPreciseWheelRotation()/10.0) > 0){
|
|
if((e.getPreciseWheelRotation()/10.0) > 0){
|
|
@@ -331,46 +330,46 @@ public class Terrain extends JPanel {
|
|
|
|
|
|
|
|
repaint();
|
|
repaint();
|
|
|
return;
|
|
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));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void paintComponent(Graphics g) {
|
|
|
|
|
- super.paintComponent(g);
|
|
|
|
|
- Graphics2D g2 = (Graphics2D) g;
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //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));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void paintComponent(Graphics g) {
|
|
|
|
|
+ super.paintComponent(g);
|
|
|
|
|
+ Graphics2D g2 = (Graphics2D) g;
|
|
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
|
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
|
|
|
topbar.draw(g2, getWidth());
|
|
topbar.draw(g2, getWidth());
|
|
|
- sidebar.draw(g2);
|
|
|
|
|
|
|
+ sidebar.draw(g2);
|
|
|
|
|
|
|
|
//draw simulation field
|
|
//draw simulation field
|
|
|
- Area a1 = new Area(new Rectangle2D.Double(sideBarWidth, 0, getWidth()-sideBarWidth, getHeight()));
|
|
|
|
|
- Area a2 = new Area(topbar.getBackground());
|
|
|
|
|
- a2.transform(new AffineTransform().getTranslateInstance(1, 1.2));
|
|
|
|
|
- a1.subtract(a2);
|
|
|
|
|
-
|
|
|
|
|
- g2.setClip(a1);
|
|
|
|
|
|
|
+ Area a1 = new Area(new Rectangle2D.Double(sideBarWidth, 0, getWidth()-sideBarWidth, getHeight()));
|
|
|
|
|
+ Area a2 = new Area(topbar.getBackground());
|
|
|
|
|
+ a2.transform(new AffineTransform().getTranslateInstance(1, 1.2));
|
|
|
|
|
+ a1.subtract(a2);
|
|
|
|
|
+
|
|
|
|
|
+ g2.setClip(a1);
|
|
|
AffineTransform oldTransform = g2.getTransform();
|
|
AffineTransform oldTransform = g2.getTransform();
|
|
|
g2.translate(sideBarWidth,0);
|
|
g2.translate(sideBarWidth,0);
|
|
|
g2.setTransform(getCamera());
|
|
g2.setTransform(getCamera());
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- g2.setPaint(p);
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ g2.setPaint(Images.getTextPaint(background));
|
|
|
g2.fill(new Rectangle2D.Double(0,0,festivalwidth,festivalheight));
|
|
g2.fill(new Rectangle2D.Double(0,0,festivalwidth,festivalheight));
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if(grid){
|
|
if(grid){
|
|
|
g2.setColor(new Color(160,160,160,120));
|
|
g2.setColor(new Color(160,160,160,120));
|
|
|
g2.setStroke(new BasicStroke(1));
|
|
g2.setStroke(new BasicStroke(1));
|
|
@@ -389,60 +388,60 @@ public class Terrain extends JPanel {
|
|
|
for(WalkingPath path:paths){
|
|
for(WalkingPath path:paths){
|
|
|
path.paint(g2);
|
|
path.paint(g2);
|
|
|
}
|
|
}
|
|
|
- for(Visitor v:visitors){
|
|
|
|
|
- v.paint(g2);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- g2.setStroke(new BasicStroke(4));
|
|
|
|
|
|
|
+ for(Visitor v:visitors){
|
|
|
|
|
+ v.paint(g2);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ g2.setStroke(new BasicStroke(4));
|
|
|
for(DrawEngine drawObject: entities){
|
|
for(DrawEngine drawObject: entities){
|
|
|
- drawObject.draw(g2);
|
|
|
|
|
- if(pathgenerate > 0){
|
|
|
|
|
- g2.setColor(new Color(180,100,100,120));
|
|
|
|
|
- g2.fill(new Rectangle((int)drawObject.getCenter().getX()-20, (int)drawObject.getCenter().getY()-20, 40,40));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ drawObject.draw(g2);
|
|
|
|
|
+ if(pathgenerate > 0){
|
|
|
|
|
+ g2.setColor(new Color(180,100,100,120));
|
|
|
|
|
+ g2.fill(new Rectangle((int)drawObject.getCenter().getX()-20, (int)drawObject.getCenter().getY()-20, 40,40));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
//draw collide boxes
|
|
//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.setTransform(oldTransform);
|
|
|
|
|
- }
|
|
|
|
|
- g2.setClip(null);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- 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.setTransform(oldTransform);
|
|
|
|
|
+ }
|
|
|
|
|
+ g2.setClip(null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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 {
|
|
try {
|
|
|
return getCamera().inverseTransform(point, null);
|
|
return getCamera().inverseTransform(point, null);
|
|
|
} catch (NoninvertibleTransformException e1) {
|
|
} catch (NoninvertibleTransformException e1) {
|
|
@@ -450,8 +449,8 @@ public class Terrain extends JPanel {
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- private AffineTransform getCamera() {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private AffineTransform getCamera() {
|
|
|
AffineTransform tx = new AffineTransform();
|
|
AffineTransform tx = new AffineTransform();
|
|
|
//start field in top left corner, next to sidebar
|
|
//start field in top left corner, next to sidebar
|
|
|
tx.translate(-cameraPoint.getX() + sideBarWidth, -cameraPoint.getY());
|
|
tx.translate(-cameraPoint.getX() + sideBarWidth, -cameraPoint.getY());
|
|
@@ -460,66 +459,66 @@ public class Terrain extends JPanel {
|
|
|
tx.scale(cameraScale, cameraScale);
|
|
tx.scale(cameraScale, cameraScale);
|
|
|
return tx;
|
|
return tx;
|
|
|
}
|
|
}
|
|
|
- public void calculate(){
|
|
|
|
|
- for(Visitor v:visitors){
|
|
|
|
|
- v.update(visitors, entities,paths);
|
|
|
|
|
- }
|
|
|
|
|
- if(Math.random()*500 <100){
|
|
|
|
|
- Point2D startpoint = null;
|
|
|
|
|
- for(DrawEngine e:entities){
|
|
|
|
|
- List<AccessPoint> entrances = new ArrayList<AccessPoint>();
|
|
|
|
|
- if(e.type == Objects.ENTRANCE){
|
|
|
|
|
- entrances.add((AccessPoint)e);
|
|
|
|
|
- }
|
|
|
|
|
- if(!entrances.isEmpty())
|
|
|
|
|
- startpoint = entrances.get((int)(Math.random()*entrances.size())).getCenter();
|
|
|
|
|
- }
|
|
|
|
|
- if(startpoint == null || visitors.size() >= maxvisitors) return; //No entrance found OR to many visitors, stop adding people.
|
|
|
|
|
- visitors.add(new Visitor(new Point2D.Double(-100-Math.random()*200, getFestivalHeight()-Math.random()*getFestivalHeight()), startpoint));
|
|
|
|
|
- }
|
|
|
|
|
- topbar.recalculate();
|
|
|
|
|
- stageloop:
|
|
|
|
|
- for(DrawEngine object:entities){
|
|
|
|
|
- if(object.type == SimulatorPane.Objects.STAGE){
|
|
|
|
|
- SimulatorStage stage = (SimulatorStage)object;
|
|
|
|
|
- for(Act act:agenda.getCurrentActs(topbar.getTime())){
|
|
|
|
|
- if(act.getStage() == stage.getStage()){
|
|
|
|
|
- stage.setPlayingact(act);
|
|
|
|
|
- continue stageloop;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- stage.setPlayingact(null);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- 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(){
|
|
|
|
|
|
|
+ public void calculate(){
|
|
|
|
|
+ for(Visitor v:visitors){
|
|
|
|
|
+ v.update(visitors, entities,paths);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(Math.random()*500 <100){
|
|
|
|
|
+ Point2D startpoint = null;
|
|
|
|
|
+ for(DrawEngine e:entities){
|
|
|
|
|
+ List<AccessPoint> entrances = new ArrayList<AccessPoint>();
|
|
|
|
|
+ if(e.type == Objects.ENTRANCE){
|
|
|
|
|
+ entrances.add((AccessPoint)e);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!entrances.isEmpty())
|
|
|
|
|
+ startpoint = entrances.get((int)(Math.random()*entrances.size())).getCenter();
|
|
|
|
|
+ }
|
|
|
|
|
+ if(startpoint == null || visitors.size() >= maxvisitors) return; //No entrance found OR to many visitors, stop adding people.
|
|
|
|
|
+ visitors.add(new Visitor(new Point2D.Double(-100-Math.random()*200, getFestivalHeight()-Math.random()*getFestivalHeight()), startpoint));
|
|
|
|
|
+ }
|
|
|
|
|
+ topbar.recalculate();
|
|
|
|
|
+ stageloop:
|
|
|
|
|
+ for(DrawEngine object:entities){
|
|
|
|
|
+ if(object.type == SimulatorPane.Objects.STAGE){
|
|
|
|
|
+ SimulatorStage stage = (SimulatorStage)object;
|
|
|
|
|
+ for(Act act:agenda.getCurrentActs(topbar.getTime())){
|
|
|
|
|
+ if(act.getStage() == stage.getStage()){
|
|
|
|
|
+ stage.setPlayingact(act);
|
|
|
|
|
+ continue stageloop;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ stage.setPlayingact(null);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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();
|
|
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
|
|
Images.ImageType image;
|
|
Images.ImageType image;
|
|
|
|
|
|
|
@@ -529,15 +528,15 @@ public class Terrain extends JPanel {
|
|
|
image = Images.ImageType.PathCursor;
|
|
image = Images.ImageType.PathCursor;
|
|
|
pathpoint = toolkit.createCustomCursor(Images.getImage(image), new Point(14,14), "Pathpoint");
|
|
pathpoint = toolkit.createCustomCursor(Images.getImage(image), new Point(14,14), "Pathpoint");
|
|
|
}
|
|
}
|
|
|
- public void toggleGrid(){
|
|
|
|
|
- grid = !grid;
|
|
|
|
|
- }
|
|
|
|
|
- public void newWalkingPath(Images.ImageType imagetype){
|
|
|
|
|
|
|
+ public void toggleGrid(){
|
|
|
|
|
+ grid = !grid;
|
|
|
|
|
+ }
|
|
|
|
|
+ public void newWalkingPath(Images.ImageType imagetype){
|
|
|
if(pathgenerate == 0){
|
|
if(pathgenerate == 0){
|
|
|
currentpath = new WalkingPath(imagetype);
|
|
currentpath = new WalkingPath(imagetype);
|
|
|
pathgenerate = 1;
|
|
pathgenerate = 1;
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
public List<DrawEngine> getEntities() {
|
|
public List<DrawEngine> getEntities() {
|
|
|
return entities;
|
|
return entities;
|
|
|
}
|
|
}
|
|
@@ -555,5 +554,5 @@ public class Terrain extends JPanel {
|
|
|
paths.remove(p);
|
|
paths.remove(p);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|