← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16358: PNG maps, reduced boundary layer stroke width

 

------------------------------------------------------------
revno: 16358
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-08-09 15:10:21 +0200
message:
  PNG maps, reduced boundary layer stroke width
added:
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/MapLayerType.java
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/InternalMapLayer.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/InternalMapObject.java
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/mapgeneration/GeoToolsMapObjectTest.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-08 15:16:41 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java	2014-08-09 13:10:21 +0000
@@ -175,9 +175,7 @@
     private static final String DEFAULT_COLOR_LOW = "#ffff00";
 
     private static final float DEFAULT_OPACITY = 0.75f;
-    private static final String DEFAULT_STROKE_COLOR = "#ffffff";
 
-    private static final int DEFAULT_STROKE_WIDTH = 1;
     private static final Integer DEFAULT_RADIUS_HIGH = 35;
     private static final Integer DEFAULT_RADIUS_LOW = 15;
 
@@ -240,12 +238,6 @@
 
         Float opacity = mapView.getOpacity() != null ? mapView.getOpacity().floatValue() : DEFAULT_OPACITY;
 
-        // TODO MapView should be extended to feature stroke color
-        Color strokeColor = MapUtils.createColorFromString( DEFAULT_STROKE_COLOR );
-
-        // TODO MapView might be extended to feature stroke width
-        int strokeWidth = DEFAULT_STROKE_WIDTH;
-        
         boolean hasLegendSet = mapView.hasLegendSet();
 
         // Create and setup an internal layer
@@ -260,8 +252,6 @@
         mapLayer.setColorHigh( colorHigh );
         mapLayer.setOpacity( opacity );
         mapLayer.setClasses( mapView.getClasses() );
-        mapLayer.setStrokeColor( strokeColor );
-        mapLayer.setStrokeWidth( strokeWidth );
 
         if ( !mapView.isDataLayer() ) // Boundary (and facility) layer
         {

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/InternalMapLayer.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/InternalMapLayer.java	2014-07-06 15:43:19 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/InternalMapLayer.java	2014-08-09 13:10:21 +0000
@@ -78,10 +78,6 @@
     protected float opacity;
     
     protected Integer classes;
-
-    protected Color strokeColor;
-
-    protected int strokeWidth;
     
     protected IntervalSet intervalSet;
 
@@ -183,8 +179,8 @@
         mapObject.setName( unit.getName() );
         mapObject.setValue( mapValue );
         mapObject.setFillOpacity( opacity );
-        mapObject.setStrokeColor( strokeColor );
-        mapObject.setStrokeWidth( strokeWidth );
+        mapObject.setStrokeColor( Color.WHITE );
+        mapObject.setMapLayerType( MapLayerType.THEMATIC );
 
         // Build and set the geometric primitive that outlines org unit on the map
         mapObject.buildGeometryForOrganisationUnit( unit );
@@ -208,7 +204,7 @@
         mapObject.setName( unit.getName() );
         mapObject.setFillOpacity( opacity );
         mapObject.setStrokeColor( Color.BLACK );
-        mapObject.setStrokeWidth( 1 );
+        mapObject.setMapLayerType( MapLayerType.BOUNDARY );
 
         mapObject.buildGeometryForOrganisationUnit( unit );
         addMapObject( mapObject );
@@ -516,26 +512,6 @@
         this.classes = classes;
     }
 
-    public Color getStrokeColor()
-    {
-        return strokeColor;
-    }
-
-    public void setStrokeColor( Color strokeColor )
-    {
-        this.strokeColor = strokeColor;
-    }
-
-    public int getStrokeWidth()
-    {
-        return strokeWidth;
-    }
-
-    public void setStrokeWidth( int strokeWidth )
-    {
-        this.strokeWidth = strokeWidth;
-    }
-
     public IntervalSet getIntervalSet()
     {
         return intervalSet;

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/InternalMapObject.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/InternalMapObject.java	2014-07-06 15:43:19 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/InternalMapObject.java	2014-08-09 13:10:21 +0000
@@ -63,12 +63,17 @@
  */
 public class InternalMapObject
 {
+    private static final float LINE_STROKE_WIDTH = 0.1f;
+    
     private static final String CIRCLE = "Circle";
     private static final String POINT = "Point";
     private static final String POLYGON = "Polygon";
     private static final String MULTI_POLYGON = "MultiPolygon";
     private static final String GEOMETRIES = "geometries";
     
+    public static final String TYPE_THEMATIC = "thematic";
+    public static final String TYPE_BOUNDARY = "boundary";
+        
     protected String name;
 
     protected double value;
@@ -81,13 +86,13 @@
 
     protected Color strokeColor;
 
-    protected int strokeWidth;
-
     protected InternalMapLayer mapLayer;
 
     protected Interval interval;
     
     private Geometry geometry;
+    
+    private MapLayerType mapLayerType;
 
     // -------------------------------------------------------------------------
     // Constructors
@@ -193,8 +198,14 @@
         }
         else if ( geometry instanceof Polygon || geometry instanceof MultiPolygon )
         {
-            style = SLD.createPolygonStyle( strokeColor, fillColor,
-                fillOpacity );
+            if ( MapLayerType.BOUNDARY.equals( mapLayerType ) )
+            {
+                style = SLD.createLineStyle( strokeColor, LINE_STROKE_WIDTH );
+            }
+            else
+            {
+                style = SLD.createPolygonStyle( strokeColor, fillColor, fillOpacity );
+            }
         }
         else
         {
@@ -302,17 +313,7 @@
     {
         this.strokeColor = strokeColor;
     }
-
-    public int getStrokeWidth()
-    {
-        return this.strokeWidth;
-    }
-
-    public void setStrokeWidth( int strokeWidth )
-    {
-        this.strokeWidth = strokeWidth;
-    }
-
+    
     public InternalMapLayer getMapLayer()
     {
         return this.mapLayer;
@@ -343,17 +344,22 @@
     {
         this.geometry = geometry;
     }
-
-    /**
-     * Returns a string representing this object, e.g. "InternalMapObject {
-     * name: "Khambia", value: 34.22, radius: 1.00, fillColor:
-     * java.awt.Color(255, 255, 255), fillOpacity: 0.75, strokeColor:
-     * java.awt.Color(0, 0, 0), strokeWidth: 2 }".
-     */
+    
+    public MapLayerType getMapLayerType()
+    {
+        return mapLayerType;
+    }
+    
+    public void setMapLayerType( MapLayerType mapLayerType )
+    {
+        this.mapLayerType = mapLayerType;
+    }
+    
+    @Override
     public String toString()
     {
         return String.format( "InternalMapObject {" + " name: \"%s\"," + " value: %.2f," + " radius: %d,"
             + " fillColor: %s," + " fillOpacity: %.2f" + " strokeColor: %s," + " strokeWidth: %d" + " }", name, value,
-            radius, fillColor, fillOpacity, strokeColor, strokeWidth );
+            radius, fillColor, fillOpacity, strokeColor );
     }
 }

=== added file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/MapLayerType.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/MapLayerType.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/mapgeneration/MapLayerType.java	2014-08-09 13:10:21 +0000
@@ -0,0 +1,34 @@
+package org.hisp.dhis.mapgeneration;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+public enum MapLayerType
+{
+    THEMATIC, BOUNDARY, SYMBOL
+}

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/mapgeneration/GeoToolsMapObjectTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/mapgeneration/GeoToolsMapObjectTest.java	2014-07-06 15:43:19 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/mapgeneration/GeoToolsMapObjectTest.java	2014-08-09 13:10:21 +0000
@@ -105,31 +105,4 @@
         geoToolsMapObject.setStrokeColor( Color.WHITE );
         assertEquals( Color.WHITE, geoToolsMapObject.getStrokeColor() );
     }
-
-    @Test
-    public void testSetGetStrokeWidth()
-    {
-        geoToolsMapObject.setStrokeWidth( 32 );
-        assertEquals( 32, geoToolsMapObject.getStrokeWidth() );
-        geoToolsMapObject.setStrokeWidth( 364114 );
-        assertEquals( 364114, geoToolsMapObject.getStrokeWidth() );
-    }
-
-    @Test
-    public void testSetGetMapLayer()
-    {
-        //TODO
-    }
-
-    @Test
-    public void testSetGetInterval()
-    {
-        //TODO
-    }
-
-    @Test
-    public void testToString()
-    {
-        //TODO
-    }
 }