← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16370: Reverted R 16362

 

------------------------------------------------------------
revno: 16370
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-08-10 23:25:00 +0200
message:
  Reverted R 16362
modified:
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java	2014-08-09 15:10:30 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java	2014-08-10 21:25:00 +0000
@@ -161,9 +161,9 @@
 
             BufferedImage legendImage = legendSet.render( i18nManager.getI18nFormat() );
 
-            BufferedImage titleImage = MapUtils.renderTitle( map.getName(), width );
+            BufferedImage titleImage = MapUtils.renderTitle( map.getName(), getImageWidth( legendImage, mapImage ) );
             
-            return combineLegendAndMapImages( titleImage, legendImage, mapImage, width, height );
+            return combineLegendAndMapImages( titleImage, legendImage, mapImage );
         }
     }
 
@@ -346,7 +346,7 @@
         return mapValues;
     }
     
-    private BufferedImage combineLegendAndMapImages( BufferedImage titleImage, BufferedImage legendImage, BufferedImage mapImage, int width, int height )
+    private BufferedImage combineLegendAndMapImages( BufferedImage titleImage, BufferedImage legendImage, BufferedImage mapImage )
     {
         Assert.isTrue( titleImage != null );
         Assert.isTrue( legendImage != null );
@@ -355,6 +355,9 @@
 
         // Create image, note that image height cannot be less than legend
         
+        int width = getImageWidth( legendImage, mapImage );
+        int height = Math.max( titleImage.getHeight() + mapImage.getHeight(), ( legendImage.getHeight() + 1 ) );
+        
         BufferedImage finalImage = new BufferedImage( width, height, mapImage.getType() );
 
         // Draw the two images onto the final image with the legend to the left
@@ -366,4 +369,9 @@
 
         return finalImage;
     }
+    
+    private int getImageWidth( BufferedImage legendImage, BufferedImage mapImage )
+    {
+        return ( legendImage != null ? legendImage.getWidth() : 0 ) + ( mapImage != null ? mapImage.getWidth() : 0 );
+    }
 }