public int selectLayer() {
        int layer_size = Math.min(getHeight(), getWidth() / layerCount);
        if (currentMousePosn != null) {
            int s = currentMousePosn.x / layer_size;
            if (s >= layerCount) {
                return -1;
            } else {
                return s;
            }
        } else {
            return -1;
        }
    }