Example usage for android.view Surface ROTATION_270

List of usage examples for android.view Surface ROTATION_270

Introduction

In this page you can find the example usage for android.view Surface ROTATION_270.

Prototype

int ROTATION_270

To view the source code for android.view Surface ROTATION_270.

Click Source Link

Document

Rotation constant: 270 degree rotation.

Usage

From source file:Main.java

private static float getDegreesForRotation(int value) {
    switch (value) {
    case Surface.ROTATION_90:
        return 360f - 90f;
    case Surface.ROTATION_180:
        return 360f - 180f;
    case Surface.ROTATION_270:
        return 360f - 270f;
    }/*w  w w  . j a va2s  .co  m*/
    return 0f;
}

From source file:Main.java

/**
 * @return the current display rotation in degrees
 *///from w ww. j a  v  a2s  .co  m
public static float getDegreesForRotation(int value) {
    switch (value) {
    case Surface.ROTATION_90:
        return 90f;
    case Surface.ROTATION_180:
        return 180f;
    case Surface.ROTATION_270:
        return 270f;
    }
    return 0f;
}

From source file:Main.java

public static int getScreenRotation(Activity activity) {
    switch (activity.getWindowManager().getDefaultDisplay().getRotation()) {
    default://  ww  w  .  ja v  a 2s.  co m
    case Surface.ROTATION_0:
        return 0;
    case Surface.ROTATION_90:
        return 90;
    case Surface.ROTATION_180:
        return 180;
    case Surface.ROTATION_270:
        return 270;
    }
}

From source file:Main.java

public static int getOrientation(int rotation, boolean upsideDown) {
    if (upsideDown) {
        switch (rotation) {
        case Surface.ROTATION_0:
            return 270;
        case Surface.ROTATION_90:
            return 180;
        case Surface.ROTATION_180:
            return 90;
        case Surface.ROTATION_270:
            return 0;
        }//from   w  ww  . j  av a 2s  .c  om
    } else {
        switch (rotation) {
        case Surface.ROTATION_0:
            return 90;
        case Surface.ROTATION_90:
            return 0;
        case Surface.ROTATION_180:
            return 270;
        case Surface.ROTATION_270:
            return 180;
        }
    }

    return 0;
}

From source file:Main.java

@SuppressLint("SwitchIntDef")
public static int getRotationOffset(@NonNull WindowManager windowManager) {
    switch (windowManager.getDefaultDisplay().getRotation()) {
    case Surface.ROTATION_90:
        return 90;
    case Surface.ROTATION_180:
        return 180;
    case Surface.ROTATION_270:
        return 270;
    default:/*from   w w  w .  j a va 2s.  c o m*/
        return 0;
    }
}

From source file:Main.java

public static int getRotationAdjustment(int screenRotation) {
    int degrees = 0;
    switch (screenRotation) {
    case Surface.ROTATION_0:
        degrees = 0;/* w ww .j  a  v  a2  s  .  c  o m*/
        break;
    case Surface.ROTATION_90:
        degrees = 90;
        break;
    case Surface.ROTATION_180:
        degrees = 180;
        break;
    case Surface.ROTATION_270:
        degrees = 270;
        break;
    }

    int cameraOrientation = getCameraOrientation();
    return (cameraOrientation - degrees + 360) % 360;
}

From source file:Main.java

/**
 * Returns the rotation of the screen from its "natural" orientation.
 * Notice: ANTICLOCKWISE/*  w w  w. jav a  2  s  .c om*/
 * @param rotation "getRotation()"
 */
public static String getRotationStr(int rotation) {
    switch (rotation) {
    //Natural orientation
    case Surface.ROTATION_0://0
        return "ROTATION_0";
    case Surface.ROTATION_90://1
        return "ROTATION_90";
    case Surface.ROTATION_180://2
        return "ROTATION_180";
    case Surface.ROTATION_270://3
        return "ROTATION_270";
    default:
        return UNKNOWN;
    }
}

From source file:Main.java

public static int setCameraDisplayOrientation(int cameraId, Camera camera, int displayRotation) {
    CameraInfo info = new CameraInfo();
    Camera.getCameraInfo(cameraId, info);
    int degrees = 0;
    switch (displayRotation) {
    case Surface.ROTATION_0:
        degrees = 0;/*from   ww w.  jav  a2 s .c o m*/
        break;
    case Surface.ROTATION_90:
        degrees = 90;
        break;
    case Surface.ROTATION_180:
        degrees = 180;
        break;
    case Surface.ROTATION_270:
        degrees = 270;
        break;
    }

    int camRotationDegree = 0;
    if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
        camRotationDegree = (info.orientation + degrees) % 360;
        camRotationDegree = (360 - camRotationDegree) % 360; // compensate the mirror
    } else {
        camRotationDegree = (info.orientation - degrees + 360) % 360;
    }

    if (camera != null) {
        camera.setDisplayOrientation(camRotationDegree);
    }
    return camRotationDegree;
}

From source file:Main.java

public static void setCameraDisplayOrientation(int rotation, int cameraId, Camera camera) {
    Camera.CameraInfo info = new Camera.CameraInfo();
    Camera.getCameraInfo(cameraId, info);
    // int rotation = activity.getWindowManager ().getDefaultDisplay
    // ().getRotation ();
    int degrees = 0;
    switch (rotation) {
    case Surface.ROTATION_0:
        degrees = 0;/*w  ww.ja  v a 2 s  . com*/
        break;
    case Surface.ROTATION_90:
        degrees = 90;
        break;
    case Surface.ROTATION_180:
        degrees = 180;
        break;
    case Surface.ROTATION_270:
        degrees = 270;
        break;
    }
    int result;
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        result = (info.orientation + degrees) % 360;
        result = (360 - result) % 360; // compensate the mirror
    } else {
        // back-facing
        result = (info.orientation - degrees + 360) % 360;
    }
    camera.setDisplayOrientation(result);
}

From source file:Main.java

public static int getOrientationHint(Activity activity, int cameraId, android.hardware.Camera camera) {
    android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
    android.hardware.Camera.getCameraInfo(cameraId, info);
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    int degrees = 0;
    switch (rotation) {
    case Surface.ROTATION_0:
        degrees = 0;//w  ww .  j av  a  2  s.c  o  m
        break;
    case Surface.ROTATION_90:
        degrees = 90;
        break;
    case Surface.ROTATION_180:
        degrees = 180;
        break;
    case Surface.ROTATION_270:
        degrees = 270;
        break;
    }

    int result;
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        result = (info.orientation + degrees) % 360;
    } else { // back-facing
        result = (info.orientation - degrees + 360) % 360;
    }
    return result;
}