PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/sigmah/src/test/java/org/sigmah/server/report/generator/map/PieMapMarkerTest.java

http://sigma-h.googlecode.com/
Java | 70 lines | 47 code | 16 blank | 7 comment | 0 complexity | 0ca64a3b946e1adec9231b30e63ac995 MD5 | raw file
 1/*
 2 * All Sigmah code is released under the GNU General Public License v3
 3 * See COPYRIGHT.txt and LICENSE.txt.
 4 */
 5
 6package org.sigmah.server.report.generator.map;
 7
 8import junit.framework.Assert;
 9import org.junit.Test;
10import org.sigmah.shared.dao.SiteTableColumn;
11import org.sigmah.server.domain.SiteData;
12import org.sigmah.shared.report.content.LatLng;
13import org.sigmah.shared.report.content.MapContent;
14import org.sigmah.shared.report.content.PieMapMarker;
15import org.sigmah.shared.report.model.BubbleMapLayer;
16import org.sigmah.shared.report.model.Dimension;
17import org.sigmah.shared.report.model.DimensionType;
18import org.sigmah.shared.report.model.MapElement;
19
20import java.util.ArrayList;
21import java.util.List;
22
23/**
24 * @author Alex Bertram
25 */
26public class PieMapMarkerTest {
27
28
29    @Test
30    public void testPies() {
31
32        Dimension dim = new Dimension(DimensionType.Indicator);
33        dim.setCategoryColor(101, 255);
34        dim.setCategoryColor(102, 0x00FF00);
35        dim.setCategoryColor(103, 0x0000FF);
36
37        SiteData site1 = new SiteData();
38        site1.setValue(SiteTableColumn.id,  1);
39        site1.setValue(SiteTableColumn.x, 0d);
40        site1.setValue(SiteTableColumn.y, 0d);
41        site1.setIndicatorValue(101, 50d);
42        site1.setIndicatorValue(102, 40d);
43        site1.setIndicatorValue(103, 10d);
44
45        List<SiteData> sites = new ArrayList<SiteData>();
46        sites.add(site1);
47
48        BubbleMapLayer layer = new BubbleMapLayer();
49        layer.setPie(true);
50        layer.addIndicator(101);
51        layer.addIndicator(102);
52        layer.addIndicator(103);
53        layer.getColorDimensions().add(dim);
54
55        MapElement mapElement = new MapElement();
56        mapElement.addLayer(layer);
57
58        MapContent content = new MapContent();
59
60        TiledMap map = new TiledMap(640, 480, new LatLng(0, 0), 6);
61
62        BubbleLayerGenerator gtor = new BubbleLayerGenerator(mapElement, layer);
63        gtor.generate(sites, map, content);
64
65        Assert.assertEquals(1, content.getMarkers().size());
66
67        PieMapMarker marker = (PieMapMarker) content.getMarkers().get(0);
68        Assert.assertEquals(3, marker.getSlices().size());
69    }
70}