|
@@ -238,7 +238,29 @@ public class Terrain extends JPanel {
|
|
|
public void mouseDragged(MouseEvent e) {
|
|
public void mouseDragged(MouseEvent e) {
|
|
|
Point2D clickPoint = getClickPoint(e.getPoint());
|
|
Point2D clickPoint = getClickPoint(e.getPoint());
|
|
|
if(dragObject != null){
|
|
if(dragObject != null){
|
|
|
- if(SwingUtilities.isLeftMouseButton(e)){
|
|
|
|
|
|
|
+ if(SwingUtilities.isLeftMouseButton(e) && dragObject instanceof AccessPoint){
|
|
|
|
|
+ dragObject.setX(-25);
|
|
|
|
|
+ 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(SwingUtilities.isLeftMouseButton(e) && dragObject instanceof ExitPoint){
|
|
|
|
|
+ dragObject.setX(getFestivalWidth()-200);
|
|
|
|
|
+ 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(SwingUtilities.isLeftMouseButton(e)){
|
|
|
setCursor(new Cursor(Cursor.MOVE_CURSOR));
|
|
setCursor(new Cursor(Cursor.MOVE_CURSOR));
|
|
|
dragObject.setX(dragObject.getX() - (lastClickPosition.getX() - clickPoint.getX()));
|
|
dragObject.setX(dragObject.getX() - (lastClickPosition.getX() - clickPoint.getX()));
|
|
|
dragObject.setY(dragObject.getY() - (lastClickPosition.getY() - clickPoint.getY()));
|
|
dragObject.setY(dragObject.getY() - (lastClickPosition.getY() - clickPoint.getY()));
|
|
@@ -432,20 +454,6 @@ public class Terrain extends JPanel {
|
|
|
//getters and setters for sidebar
|
|
//getters and setters for sidebar
|
|
|
public void setDragObject(DrawEngine dragObject){
|
|
public void setDragObject(DrawEngine dragObject){
|
|
|
this.dragObject = 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(){
|
|
public DrawEngine getDragObject(){
|