public MagneticLine getLocationMagneticLine(int x, int y){
        int offset = 15;
        MagneticLine magneticLine = null;
        for (MagneticLine magnet : this.graph.getMagneticLines()) {
            if(magnet instanceof HorizontalMagneticLine){
                if(magnet.y1 >= (y-offset) && magnet.y1 <= (y+offset)){
                    return magnet;
                }
            }
            else if(magnet instanceof VerticalMagneticLine){
                if(magnet.x1 >= (x-offset) && magnet.x1 <= (x+offset)){
                    return magnet;
                }
            }
        }
        return magneticLine; 
    }