// Path: src/main/java/model/WalkDirection.java
// public enum WalkDirection implements Serializable {
//     NORTH, WEST, EAST, SOUTH, NORTH_WEST, NORTH_EAST, SOUTH_WEST, SOUTH_EAST, NONE
// }
// 
// Path: src/main/java/model/WalkDirectionUtils.java
// public class WalkDirectionUtils {
//     public static WalkDirection invert(WalkDirection in) {
//         if (in == WalkDirection.NORTH) {
//             return WalkDirection.SOUTH;
//         } else if (in == WalkDirection.NORTH_EAST) {
//             return WalkDirection.SOUTH_WEST;
//         } else if (in == WalkDirection.EAST) {
//             return WalkDirection.WEST;
//         } else if (in == WalkDirection.SOUTH_EAST) {
//             return WalkDirection.NORTH_WEST;
//         } else if (in == WalkDirection.SOUTH) {
//             return WalkDirection.NORTH;
//         } else if (in == WalkDirection.SOUTH_WEST) {
//             return WalkDirection.NORTH_EAST;
//         } else if (in == WalkDirection.WEST) {
//             return WalkDirection.EAST;
//         } else if (in == WalkDirection.NORTH_WEST) {
//             return WalkDirection.SOUTH_EAST;
//         } else {
//             // in is WalkDirection.NONE, but for the compiler, it needs to be else and not else if
//             return WalkDirection.NONE;
//         }
//     }
// 
//     public static WalkDirection getFromLineAngle(double lineAngle) {
//         if (lineAngle <= (Math.PI / 8.0) && lineAngle >= (-Math.PI / 8.0)) {
//             // north
//             return WalkDirection.NORTH;
//         } else if (lineAngle < (Math.PI * 3.0 / 8.0) && lineAngle > (Math.PI / 8.0)) {
//             // ne
//             return WalkDirection.NORTH_EAST;
//         } else if (lineAngle <= (Math.PI * 5.0 / 8.0) && lineAngle >= (Math.PI * 3.0 / 8.0)) {
//             // e
//             return WalkDirection.EAST;
//         } else if (lineAngle < (Math.PI * 7.0 / 8.0) && lineAngle > (Math.PI * 5.0 / 8.0)) {
//             // se
//             return WalkDirection.SOUTH_EAST;
//         } else if ((lineAngle <= (-Math.PI * 7.0 / 8.0) && lineAngle >= (-Math.PI)) || (lineAngle <= (Math.PI) && lineAngle >= (Math.PI * 7.0 / 8.0))) {
//             // s
//             return WalkDirection.SOUTH;
//         } else if (lineAngle < (-Math.PI * 5.0 / 8.0) && lineAngle > (-Math.PI * 7.0 / 8.0)) {
//             // sw
//             return WalkDirection.SOUTH_WEST;
//         } else if (lineAngle <= (-Math.PI * 3.0 / 8.0) && lineAngle >= (-Math.PI * 5.0 / 8.0)) {
//             // w
//             return WalkDirection.WEST;
//         } else {
//             // ... if (lineAngle < (-Math.PI * 1.0 / 8.0) && lineAngle > (-Math.PI * 3.0 / 8.0))
//             // but the compiler requires else...
//             // nw
//             return WalkDirection.NORTH_WEST;
//         }
//     }
// 
//     public static WalkDirection getFromLine(Line line) {
//         double lineAngle = Math.atan2(line.getEndX() - line.getStartX(), line.getStartY() - line.getEndY());
//         return getFromLineAngle(lineAngle);
//     }
// }


import java.io.Serializable;
import java.util.Map;
import java.util.logging.Level;
import com.github.vatbub.common.core.logging.FOKLogger;
import com.github.vatbub.common.view.core.CustomGroup;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import model.WalkDirection;
import model.WalkDirectionUtils;
    public RoomRectangle getStartRoom() {
        return startRoom;
    }

    public void setStartRoom(RoomRectangle startRoom) {
        this.startRoom = startRoom;
        updateLocation();
    }

    /**
     * Invalidates this line
     */
    public void invalidate() {
        if (invalidationRunnable != null) {
            invalidationRunnable.run(this);
        }
    }

    /**
     * Updates the location of this line
     */
    public void updateLocation() {
        if (getStartRoom() != null && getEndRoom() != null) {
            if (!getStartRoom().getRoom().isDirectlyConnectedTo(getEndRoom().getRoom())) {
                // rooms not connected, detach this line
                invalidate();
                return;
            }

            // get the connection direction
// Path: src/main/java/model/WalkDirection.java
// public enum WalkDirection implements Serializable {
//     NORTH, WEST, EAST, SOUTH, NORTH_WEST, NORTH_EAST, SOUTH_WEST, SOUTH_EAST, NONE
// }
// 
// Path: src/main/java/model/WalkDirectionUtils.java
// public class WalkDirectionUtils {
//     public static WalkDirection invert(WalkDirection in) {
//         if (in == WalkDirection.NORTH) {
//             return WalkDirection.SOUTH;
//         } else if (in == WalkDirection.NORTH_EAST) {
//             return WalkDirection.SOUTH_WEST;
//         } else if (in == WalkDirection.EAST) {
//             return WalkDirection.WEST;
//         } else if (in == WalkDirection.SOUTH_EAST) {
//             return WalkDirection.NORTH_WEST;
//         } else if (in == WalkDirection.SOUTH) {
//             return WalkDirection.NORTH;
//         } else if (in == WalkDirection.SOUTH_WEST) {
//             return WalkDirection.NORTH_EAST;
//         } else if (in == WalkDirection.WEST) {
//             return WalkDirection.EAST;
//         } else if (in == WalkDirection.NORTH_WEST) {
//             return WalkDirection.SOUTH_EAST;
//         } else {
//             // in is WalkDirection.NONE, but for the compiler, it needs to be else and not else if
//             return WalkDirection.NONE;
//         }
//     }
// 
//     public static WalkDirection getFromLineAngle(double lineAngle) {
//         if (lineAngle <= (Math.PI / 8.0) && lineAngle >= (-Math.PI / 8.0)) {
//             // north
//             return WalkDirection.NORTH;
//         } else if (lineAngle < (Math.PI * 3.0 / 8.0) && lineAngle > (Math.PI / 8.0)) {
//             // ne
//             return WalkDirection.NORTH_EAST;
//         } else if (lineAngle <= (Math.PI * 5.0 / 8.0) && lineAngle >= (Math.PI * 3.0 / 8.0)) {
//             // e
//             return WalkDirection.EAST;
//         } else if (lineAngle < (Math.PI * 7.0 / 8.0) && lineAngle > (Math.PI * 5.0 / 8.0)) {
//             // se
//             return WalkDirection.SOUTH_EAST;
//         } else if ((lineAngle <= (-Math.PI * 7.0 / 8.0) && lineAngle >= (-Math.PI)) || (lineAngle <= (Math.PI) && lineAngle >= (Math.PI * 7.0 / 8.0))) {
//             // s
//             return WalkDirection.SOUTH;
//         } else if (lineAngle < (-Math.PI * 5.0 / 8.0) && lineAngle > (-Math.PI * 7.0 / 8.0)) {
//             // sw
//             return WalkDirection.SOUTH_WEST;
//         } else if (lineAngle <= (-Math.PI * 3.0 / 8.0) && lineAngle >= (-Math.PI * 5.0 / 8.0)) {
//             // w
//             return WalkDirection.WEST;
//         } else {
//             // ... if (lineAngle < (-Math.PI * 1.0 / 8.0) && lineAngle > (-Math.PI * 3.0 / 8.0))
//             // but the compiler requires else...
//             // nw
//             return WalkDirection.NORTH_WEST;
//         }
//     }
// 
//     public static WalkDirection getFromLine(Line line) {
//         double lineAngle = Math.atan2(line.getEndX() - line.getStartX(), line.getStartY() - line.getEndY());
//         return getFromLineAngle(lineAngle);
//     }
// }


// Path: src/main/java/view/ConnectionLine.java
import java.io.Serializable;
import java.util.Map;
import java.util.logging.Level;
import com.github.vatbub.common.core.logging.FOKLogger;
import com.github.vatbub.common.view.core.CustomGroup;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import model.WalkDirection;
import model.WalkDirectionUtils;

    public RoomRectangle getStartRoom() {
        return startRoom;
    }

    public void setStartRoom(RoomRectangle startRoom) {
        this.startRoom = startRoom;
        updateLocation();
    }

    /**
     * Invalidates this line
     */
    public void invalidate() {
        if (invalidationRunnable != null) {
            invalidationRunnable.run(this);
        }
    }

    /**
     * Updates the location of this line
     */
    public void updateLocation() {
        if (getStartRoom() != null && getEndRoom() != null) {
            if (!getStartRoom().getRoom().isDirectlyConnectedTo(getEndRoom().getRoom())) {
                // rooms not connected, detach this line
                invalidate();
                return;
            }

            // get the connection direction
            WalkDirection dir = null;