← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16362: PNG maps, respecting width set in query param to allow for maps with long titles

 

------------------------------------------------------------
revno: 16362
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-08-09 17:10:30 +0200
message:
  PNG maps, respecting width set in query param to allow for maps with long titles
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 13:10:21 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java	2014-08-09 15:10:30 +0000
@@ -161,9 +161,9 @@
 
             BufferedImage legendImage = legendSet.render( i18nManager.getI18nFormat() );
 
-            BufferedImage titleImage = MapUtils.renderTitle( map.getName(), getImageWidth( legendImage, mapImage ) );
+            BufferedImage titleImage = MapUtils.renderTitle( map.getName(), width );
             
-            return combineLegendAndMapImages( titleImage, legendImage, mapImage );
+            return combineLegendAndMapImages( titleImage, legendImage, mapImage, width, height );
         }
     }
 
@@ -346,7 +346,7 @@
         return mapValues;
     }
     
-    private BufferedImage combineLegendAndMapImages( BufferedImage titleImage, BufferedImage legendImage, BufferedImage mapImage )
+    private BufferedImage combineLegendAndMapImages( BufferedImage titleImage, BufferedImage legendImage, BufferedImage mapImage, int width, int height )
     {
         Assert.isTrue( titleImage != null );
         Assert.isTrue( legendImage != null );
@@ -355,9 +355,6 @@
 
         // 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
@@ -369,9 +366,4 @@
 
         return finalImage;
     }
-    
-    private int getImageWidth( BufferedImage legendImage, BufferedImage mapImage )
-    {
-        return ( legendImage != null ? legendImage.getWidth() : 0 ) + ( mapImage != null ? mapImage.getWidth() : 0 );
-    }
 }