=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/MapUtils.java' --- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/MapUtils.java 2013-08-07 14:07:18 +0000 +++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/MapUtils.java 2013-08-07 14:32:02 +0000 @@ -201,36 +201,44 @@ * Calcuates the width and height of an two-dimensional area. If width is set, * the width will be used and the height will be calculated. If the height is * set, the height will be used and the width will be calculated. If both width - * and height are set: If area is higher than wider, the height will be used - * and the width calculated; if the area is wider than higher, the width will - * be used and the height calculated. + * and height are set, the width or height will be adjusted to the greatest + * value possible without exceeding any of max width and max height. * * @param maxWidth the maximum width. * @param maxHeight the maxium height. - * @param widthToHeightFactor the width to height factor. + * @param widthFactor the width to height factor. * @return array where first position holds the width and second the height. * @throws IllegalArgumentException if none of width and height are specified. */ - public static int[] getWidthHeight( Integer maxWidth, Integer maxHeight, double widthToHeightFactor ) + public static int[] getWidthHeight( Integer maxWidth, Integer maxHeight, double widthFactor ) { if ( maxWidth == null && maxHeight == null ) { throw new IllegalArgumentException( "At least one of width and height must be specified" ); } - boolean high = widthToHeightFactor < 1d; - boolean bothSpanSet = maxWidth != null && maxHeight != null; + if ( maxWidth == null ) + { + maxWidth = (int) Math.ceil( maxHeight * widthFactor ); + } + else if ( maxHeight == null ) + { + maxHeight = (int) Math.ceil( maxWidth / widthFactor ); + } + else // Both set + { + double maxWidthFactor = (double) maxWidth / maxHeight; + + if ( maxWidthFactor > widthFactor ) // Canvas wider than area + { + maxWidth = (int) Math.ceil( maxHeight * widthFactor ); + } + else // Area wider than canvas + { + maxHeight = (int) Math.ceil( maxWidth / widthFactor ); + } + } - if ( maxWidth == null || ( bothSpanSet && high ) ) - { - maxWidth = (int) Math.ceil( maxHeight * widthToHeightFactor ); - } - - if ( maxHeight == null || ( bothSpanSet && !high ) ) - { - maxHeight = (int) Math.ceil( maxWidth / widthToHeightFactor ); - } - int[] result = { maxWidth, maxHeight }; return result; === modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/test/java/org/hisp/dhis/mapgenerator/MapUtilsTest.java' --- dhis-2/dhis-services/dhis-service-mapgeneration/src/test/java/org/hisp/dhis/mapgenerator/MapUtilsTest.java 2013-08-07 13:03:17 +0000 +++ dhis-2/dhis-services/dhis-service-mapgeneration/src/test/java/org/hisp/dhis/mapgenerator/MapUtilsTest.java 2013-08-07 14:32:02 +0000 @@ -41,6 +41,8 @@ assertEquals( 300, getWidthHeight( 200, 300, 0.5 )[1] ); assertEquals( 200, getWidthHeight( 200, 300, 2 )[0] ); assertEquals( 100, getWidthHeight( 200, 300, 2 )[1] ); + assertEquals( 300, getWidthHeight( 600, 300, 1d )[0] ); + assertEquals( 300, getWidthHeight( 600, 300, 1d )[1] ); assertEquals( 200, getWidthHeight( 200, null, 0.5 )[0] ); assertEquals( 400, getWidthHeight( 200, null, 0.5 )[1] ); === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css 2013-08-06 14:06:25 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css 2013-08-07 14:32:02 +0000 @@ -84,14 +84,14 @@ margin: 0 19px 19px 0; border-radius: 3px; cursor: pointer; - box-shadow: #ddd 0px 1px 2px 0px; + box-shadow: #ddd 0px 1px 3px 0px; background-color: #fff; } .item:hover { border: 1px solid #bbb; - box-shadow: #ccc 0px 1px 2px 0px; + box-shadow: #ccc 0px 1px 3px 0px; } .dropItem