← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13886: PNG maps, using proper period names

 

------------------------------------------------------------
revno: 13886
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-01-28 14:36:54 +0200
message:
  PNG maps, using proper period names
modified:
  dhis-2/dhis-services/dhis-service-mapgeneration/pom.xml
  dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java
  dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/Legend.java
  dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/LegendSet.java
  dhis-2/dhis-services/dhis-service-mapgeneration/src/main/resources/META-INF/dhis/beans.xml


--
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-mapgeneration/pom.xml'
--- dhis-2/dhis-services/dhis-service-mapgeneration/pom.xml	2014-01-09 21:56:49 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/pom.xml	2014-01-28 12:36:54 +0000
@@ -29,6 +29,10 @@
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-service-analytics</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.hisp.dhis</groupId>
+      <artifactId>dhis-service-i18n</artifactId>
+    </dependency>
     
     <!-- Other -->
     

=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java	2013-11-04 18:46:33 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java	2014-01-28 12:36:54 +0000
@@ -42,6 +42,7 @@
 import org.hisp.dhis.analytics.AnalyticsService;
 import org.hisp.dhis.analytics.DataQueryParams;
 import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.i18n.I18nManager;
 import org.hisp.dhis.mapgeneration.IntervalSet.DistributionStrategy;
 import org.hisp.dhis.mapping.Map;
 import org.hisp.dhis.mapping.MapView;
@@ -90,6 +91,13 @@
     {
         this.currentUserService = currentUserService;
     }
+    
+    private I18nManager i18nManager;
+
+    public void setI18nManager( I18nManager i18nManager )
+    {
+        this.i18nManager = i18nManager;
+    }
 
     // -------------------------------------------------------------------------
     // MapGenerationService implementation
@@ -156,7 +164,7 @@
             
             LegendSet legendSet = new LegendSet( mapLayer ); //TODO
             
-            BufferedImage legendImage = legendSet.render();
+            BufferedImage legendImage = legendSet.render( i18nManager.getI18nFormat() );
     
             // Combine the legend image and the map image into one image
             return combineLegendAndMapImages( legendImage, mapImage );

=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/Legend.java'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/Legend.java	2014-01-28 12:20:49 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/Legend.java	2014-01-28 12:36:54 +0000
@@ -34,6 +34,8 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.hisp.dhis.i18n.I18nFormat;
+
 /**
  * A legend is a graphical presentation of data contained in a map layer. This
  * class works as helper for LegendSet when it comes to drawing the actual
@@ -46,7 +48,7 @@
 public class Legend
 {
     public static final Font TITLE_FONT = new Font( "title", Font.BOLD, 12 );
-    public static final Font PLAIN_FONT = new Font( "plain", Font.PLAIN, 10 );
+    public static final Font PLAIN_FONT = new Font( "plain", Font.PLAIN, 11 );
 
     private InternalMapLayer mapLayer;
 
@@ -65,13 +67,13 @@
         }
     }
 
-    public void draw( Graphics2D g )
+    public void draw( Graphics2D g, I18nFormat format )
     {
         g.setColor( Color.BLACK );
         g.setFont( TITLE_FONT );
         g.drawString( mapLayer.getName(), 0, 15 );
         g.setFont( PLAIN_FONT );
-        g.drawString( mapLayer.getPeriod().getStartDateString() + "", 0, 35 );
+        g.drawString( format.formatPeriod( mapLayer.getPeriod() ) + "", 0, 35 );
 
         g.translate( 0, HEADER_HEIGHT );
 

=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/LegendSet.java'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/LegendSet.java	2013-10-16 09:44:07 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/LegendSet.java	2014-01-28 12:36:54 +0000
@@ -35,6 +35,8 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.hisp.dhis.i18n.I18nFormat;
+
 /**
  * This class can be used to render a set of legends onto one image.
  * 
@@ -80,7 +82,7 @@
      * @param imageMaxHeight
      * @return
      */
-    public BufferedImage render()
+    public BufferedImage render( I18nFormat format )
     {
         int imageWidth = LEGEND_TOTAL_WIDTH;
         int imageHeight = calculateImageHeight();
@@ -95,7 +97,7 @@
         // Draw legends
         for ( Legend legend : legends )
         {
-            legend.draw( g );
+            legend.draw( g, format );
             g.translate( 0, LEGEND_MARGIN_BOTTOM );
         }
 

=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/resources/META-INF/dhis/beans.xml	2013-11-04 18:46:33 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/resources/META-INF/dhis/beans.xml	2014-01-28 12:36:54 +0000
@@ -9,6 +9,7 @@
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="analyticsService" ref="org.hisp.dhis.analytics.AnalyticsService" />
     <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+    <property name="i18nManager" ref="org.hisp.dhis.i18n.I18nManager" />
   </bean>
 
 </beans>