Mercurial > hg > Applications > TreeVNC
diff src/viewer_swing/java/com/glavsoft/viewer/UiSettings.java @ 309:31d86f0ee977
create fit screen button
author | oc |
---|---|
date | Thu, 22 Jan 2015 11:17:50 +0900 |
parents | 61938de1dd06 |
children | 9b70bfdef8bd |
line wrap: on
line diff
--- a/src/viewer_swing/java/com/glavsoft/viewer/UiSettings.java Thu Jan 22 01:02:19 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/UiSettings.java Thu Jan 22 11:17:50 2015 +0900 @@ -108,10 +108,10 @@ fireListeners(); } - public void adjustHdSize(int width) { + public void adjustHdSize(int singleWidth) { double hdWidth = 1920.0; double defaultScaleFactor = 100.0; - double scaleFactor = (hdWidth / width) * defaultScaleFactor; + double scaleFactor = (hdWidth / singleWidth) * defaultScaleFactor; if (scaleFactor > MAX_SCALE_PERCENT) { scaleFactor = MAX_SCALE_PERCENT; } @@ -197,4 +197,27 @@ '}'; } + public void fitScreen(int thisScreenWidth, int thisScreenHeight, int singleWidth, int singleHeight) { + double doubleThisWidth = (double) thisScreenWidth; + double doubleThisHeight = (double) thisScreenHeight; + + double widthScale = (doubleThisWidth/singleWidth); + double heightScale = (doubleThisHeight/singleHeight); + double defaultScaleFactor = 100.0; + double scaleFactor = 100.0; + + double diff = widthScale - heightScale; + + if(diff == 0) { + scaleFactor = defaultScaleFactor * widthScale; + setScalePercent(scaleFactor); + } else if(diff > 0) { + scaleFactor = defaultScaleFactor * heightScale; + } + if (scaleFactor > MAX_SCALE_PERCENT) { + scaleFactor = MAX_SCALE_PERCENT; + } + setScalePercent(scaleFactor); + fireListeners(); + } }