dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31450
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16022: PNG maps, using full image width for map titles
------------------------------------------------------------
revno: 16022
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-07-08 17:16:41 +0200
message:
PNG maps, using full image width for map titles
modified:
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/MapUtils.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-07-06 15:43:19 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java 2014-07-08 15:16:41 +0000
@@ -149,7 +149,6 @@
InternalMapLayer dataLayer = internalMap.getFirstDataLayer();
- // Build representation of a map using GeoTools, then render as image
BufferedImage mapImage = MapUtils.render( internalMap, width, height );
if ( dataLayer == null )
@@ -157,15 +156,13 @@
return mapImage;
}
else
- {
- // Build the legend set, then render it to an image
+ {
LegendSet legendSet = new LegendSet( dataLayer );
-
- BufferedImage titleImage = MapUtils.renderTitle( map.getName(), width, height );
-
+
BufferedImage legendImage = legendSet.render( i18nManager.getI18nFormat() );
-
- // Combine the legend image and the map image into one image
+
+ BufferedImage titleImage = MapUtils.renderTitle( map.getName(), getImageWidth( legendImage, mapImage ) );
+
return combineLegendAndMapImages( titleImage, legendImage, mapImage );
}
}
@@ -368,7 +365,7 @@
// Create image, note that image height cannot be less than legend
- int width = legendImage.getWidth() + mapImage.getWidth();
+ int width = getImageWidth( legendImage, mapImage );
int height = Math.max( titleImage.getHeight() + mapImage.getHeight(), ( legendImage.getHeight() + 1 ) );
BufferedImage finalImage = new BufferedImage( width, height, mapImage.getType() );
@@ -382,4 +379,9 @@
return finalImage;
}
+
+ private int getImageWidth( BufferedImage legendImage, BufferedImage mapImage )
+ {
+ return ( legendImage != null ? legendImage.getWidth() : 0 ) + ( mapImage != null ? mapImage.getWidth() : 0 );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/MapUtils.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/MapUtils.java 2014-07-06 15:43:19 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/MapUtils.java 2014-07-08 15:16:41 +0000
@@ -199,11 +199,9 @@
return image;
}
- public static BufferedImage renderTitle( String title, Integer maxWidth, Integer maxHeight )
+ public static BufferedImage renderTitle( String title, Integer width )
{
- int[] widthHeight = getWidthHeight( maxWidth, maxHeight, 0, 0, 1 );
-
- BufferedImage image = new BufferedImage( widthHeight[0], TITLE_HEIGHT, BufferedImage.TYPE_INT_ARGB );
+ BufferedImage image = new BufferedImage( width, TITLE_HEIGHT, BufferedImage.TYPE_INT_ARGB );
Graphics2D g = (Graphics2D) image.getGraphics();
g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );