public static DeviceOrientation from(int degrees){
switch (degrees) {
case (-1):
    return CLOCKWISE_0;
case 0:
  return CLOCKWISE_0;
case 90:
return CLOCKWISE_90;
case 180:
return CLOCKWISE_180;
case 270:
return CLOCKWISE_270;
default :
int normalizedDegrees=(Math.abs(degrees / 360) * 360 + 360 + degrees) % 360;
if (normalizedDegrees > 315 || normalizedDegrees <= 45) {
return CLOCKWISE_0;
}
 else if (normalizedDegrees > 45 && normalizedDegrees <= 135) {
return CLOCKWISE_90;
}
 else if (normalizedDegrees > 135 && normalizedDegrees <= 225) {
return CLOCKWISE_180;
}
 else {
return CLOCKWISE_270;
}
}
}

public static DeviceOrientation from ( int degrees ) { switch ( degrees ) { case ( - 1 ) : return CLOCKWISE_0 ; case 0 : return CLOCKWISE_0 ; case 90 : return CLOCKWISE_90 ; case 180 : return CLOCKWISE_180 ; case 270 : return CLOCKWISE_270 ; default : int normalizedDegrees = ( Math . abs ( degrees / 360 ) * 360 + 360 + degrees ) % 360 ; if ( normalizedDegrees > 315 || normalizedDegrees <= 45 ) { return CLOCKWISE_0 ; } else if ( normalizedDegrees > 45 && normalizedDegrees <= 135 ) { return CLOCKWISE_90 ; } else if ( normalizedDegrees > 135 && normalizedDegrees <= 225 ) { return CLOCKWISE_180 ; } else { return CLOCKWISE_270 ; } } }
turns a degree value ( 0 , 90 , 180 , 270 ) into one of clockwise_0 , clockwise_90 , clockwise_180 or clockwise_270 . if any other degree value is given , the closest orientation of clockwise_0 , clockwise_90 , clockwise_180 , and clockwise_270 to the angular value is returned .
