Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private boolean isWidthSmall() {
- return imageWidth <= DEFAULT_SIZE;
- }
- private boolean isHeightSmall() {
- return imageHeight <= DEFAULT_SIZE;
- }
- private void calcSelectorSide() {
- var wSmall = isWidthSmall();
- var hSmall = isHeightSmall();
- if (wSmall && hSmall) {
- selectSideWidth = imageWidth;
- selectSideHeight = imageHeight;
- return;
- }
- if (wSmall) {
- selectSideHeight = selectSideWidth;
- return;
- }
- if (hSmall) {
- selectSideWidth = selectSideHeight;
- return;
- }
- double widthRatio = DEFAULT_SIZE / (double) imageWidth;
- double heightRatio = DEFAULT_SIZE / (double) imageHeight;
- if (heightRatio < widthRatio) {
- selectSideHeight = (int) (DEFAULT_SIZE * heightRatio);
- } else
- selectSideHeight = (int) (DEFAULT_SIZE * widthRatio);
- selectSideWidth = selectSideHeight;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement