private static float getShadowWidth ( @ NonNull final Context context , final int elevation , @ NonNull final Orientation orientation , final boolean parallelLight ) { float referenceElevationWidth = ( float ) elevation / ( float ) REFERENCE_ELEVATION * REFERENCE_SHADOW_WIDTH ; float shadowWidth ; if ( parallelLight ) { shadowWidth = referenceElevationWidth * BOTTOM_SCALE_FACTOR ; } else { switch ( orientation ) { case LEFT : shadowWidth = referenceElevationWidth * LEFT_SCALE_FACTOR ; break ; case TOP : shadowWidth = referenceElevationWidth * TOP_SCALE_FACTOR ; break ; case RIGHT : shadowWidth = referenceElevationWidth * RIGHT_SCALE_FACTOR ; break ; case BOTTOM : shadowWidth = referenceElevationWidth * BOTTOM_SCALE_FACTOR ; break ; default : throw new IllegalArgumentException ( "Invalid orientation: " + orientation ) ; } } return dpToPixels ( context , shadowWidth ) ; }
Returns the width of a shadow which is located besides an edge of an elevated view .